@@ -246,6 +246,7 @@ proto.initializeGLPlot = function() {
246
246
y : s * o . y ,
247
247
z : s * o . z
248
248
} ) ;
249
+ scene . fullSceneLayout . aspectmode = layout [ scene . id ] . aspectmode = 'manual' ;
249
250
}
250
251
251
252
relayoutCallback ( scene ) ;
@@ -470,12 +471,12 @@ proto.recoverContext = function() {
470
471
var axisProperties = [ 'xaxis' , 'yaxis' , 'zaxis' ] ;
471
472
472
473
function computeTraceBounds ( scene , trace , bounds ) {
473
- var sceneLayout = scene . fullSceneLayout ;
474
+ var fullSceneLayout = scene . fullSceneLayout ;
474
475
475
476
for ( var d = 0 ; d < 3 ; d ++ ) {
476
477
var axisName = axisProperties [ d ] ;
477
478
var axLetter = axisName . charAt ( 0 ) ;
478
- var ax = sceneLayout [ axisName ] ;
479
+ var ax = fullSceneLayout [ axisName ] ;
479
480
var coords = trace [ axLetter ] ;
480
481
var calendar = trace [ axLetter + 'calendar' ] ;
481
482
var len = trace [ '_' + axLetter + 'length' ] ;
@@ -508,13 +509,13 @@ function computeTraceBounds(scene, trace, bounds) {
508
509
}
509
510
510
511
function computeAnnotationBounds ( scene , bounds ) {
511
- var sceneLayout = scene . fullSceneLayout ;
512
- var annotations = sceneLayout . annotations || [ ] ;
512
+ var fullSceneLayout = scene . fullSceneLayout ;
513
+ var annotations = fullSceneLayout . annotations || [ ] ;
513
514
514
515
for ( var d = 0 ; d < 3 ; d ++ ) {
515
516
var axisName = axisProperties [ d ] ;
516
517
var axLetter = axisName . charAt ( 0 ) ;
517
- var ax = sceneLayout [ axisName ] ;
518
+ var ax = fullSceneLayout [ axisName ] ;
518
519
519
520
for ( var j = 0 ; j < annotations . length ; j ++ ) {
520
521
var ann = annotations [ j ] ;
@@ -725,42 +726,40 @@ proto.plot = function(sceneData, fullLayout, layout) {
725
726
} ) ;
726
727
}
727
728
728
- var axesScaleRatio = [ 1 , 1 , 1 ] ;
729
-
730
- // Compute axis scale per category
731
- for ( i = 0 ; i < 3 ; ++ i ) {
732
- axis = fullSceneLayout [ axisProperties [ i ] ] ;
733
- axisType = axis . type ;
734
- var axisRatio = axisTypeRatios [ axisType ] ;
735
- axesScaleRatio [ i ] = Math . pow ( axisRatio . acc , 1.0 / axisRatio . count ) / dataScale [ i ] ;
736
- }
737
-
738
729
/*
739
730
* Dynamically set the aspect ratio depending on the users aspect settings
740
731
*/
741
- var axisAutoScaleFactor = 4 ;
742
732
var aspectRatio ;
743
-
744
- if ( fullSceneLayout . aspectmode === 'auto' ) {
745
- if ( Math . max . apply ( null , axesScaleRatio ) / Math . min . apply ( null , axesScaleRatio ) <= axisAutoScaleFactor ) {
746
- /*
747
- * USE DATA MODE WHEN AXIS RANGE DIMENSIONS ARE RELATIVELY EQUAL
748
- */
749
-
750
- aspectRatio = axesScaleRatio ;
751
- } else {
752
- /*
753
- * USE EQUAL MODE WHEN AXIS RANGE DIMENSIONS ARE HIGHLY UNEQUAL
754
- */
755
- aspectRatio = [ 1 , 1 , 1 ] ;
756
- }
757
- } else if ( fullSceneLayout . aspectmode === 'cube' ) {
733
+ var aspectmode = fullSceneLayout . aspectmode ;
734
+ if ( aspectmode === 'cube' ) {
758
735
aspectRatio = [ 1 , 1 , 1 ] ;
759
- } else if ( fullSceneLayout . aspectmode === 'data' ) {
760
- aspectRatio = axesScaleRatio ;
761
- } else if ( fullSceneLayout . aspectmode === 'manual' ) {
736
+ } else if ( aspectmode === 'manual' ) {
762
737
var userRatio = fullSceneLayout . aspectratio ;
763
738
aspectRatio = [ userRatio . x , userRatio . y , userRatio . z ] ;
739
+ } else if ( aspectmode === 'auto' || aspectmode === 'data' ) {
740
+ var axesScaleRatio = [ 1 , 1 , 1 ] ;
741
+ // Compute axis scale per category
742
+ for ( i = 0 ; i < 3 ; ++ i ) {
743
+ axis = fullSceneLayout [ axisProperties [ i ] ] ;
744
+ axisType = axis . type ;
745
+ var axisRatio = axisTypeRatios [ axisType ] ;
746
+ axesScaleRatio [ i ] = Math . pow ( axisRatio . acc , 1.0 / axisRatio . count ) / dataScale [ i ] ;
747
+ }
748
+
749
+ if ( aspectmode === 'data' ) {
750
+ aspectRatio = axesScaleRatio ;
751
+ } else { // i.e. 'auto' option
752
+ if (
753
+ Math . max . apply ( null , axesScaleRatio ) /
754
+ Math . min . apply ( null , axesScaleRatio ) <= 4
755
+ ) {
756
+ // USE DATA MODE WHEN AXIS RANGE DIMENSIONS ARE RELATIVELY EQUAL
757
+ aspectRatio = axesScaleRatio ;
758
+ } else {
759
+ // USE EQUAL MODE WHEN AXIS RANGE DIMENSIONS ARE HIGHLY UNEQUAL
760
+ aspectRatio = [ 1 , 1 , 1 ] ;
761
+ }
762
+ }
764
763
} else {
765
764
throw new Error ( 'scene.js aspectRatio was not one of the enumerated types' ) ;
766
765
}
0 commit comments