@@ -246,6 +246,7 @@ proto.initializeGLPlot = function() {
246246 y : s * o . y ,
247247 z : s * o . z
248248 } ) ;
249+ scene . fullSceneLayout . aspectmode = layout [ scene . id ] . aspectmode = 'manual' ;
249250 }
250251
251252 relayoutCallback ( scene ) ;
@@ -470,12 +471,12 @@ proto.recoverContext = function() {
470471var axisProperties = [ 'xaxis' , 'yaxis' , 'zaxis' ] ;
471472
472473function computeTraceBounds ( scene , trace , bounds ) {
473- var sceneLayout = scene . fullSceneLayout ;
474+ var fullSceneLayout = scene . fullSceneLayout ;
474475
475476 for ( var d = 0 ; d < 3 ; d ++ ) {
476477 var axisName = axisProperties [ d ] ;
477478 var axLetter = axisName . charAt ( 0 ) ;
478- var ax = sceneLayout [ axisName ] ;
479+ var ax = fullSceneLayout [ axisName ] ;
479480 var coords = trace [ axLetter ] ;
480481 var calendar = trace [ axLetter + 'calendar' ] ;
481482 var len = trace [ '_' + axLetter + 'length' ] ;
@@ -508,13 +509,13 @@ function computeTraceBounds(scene, trace, bounds) {
508509}
509510
510511function computeAnnotationBounds ( scene , bounds ) {
511- var sceneLayout = scene . fullSceneLayout ;
512- var annotations = sceneLayout . annotations || [ ] ;
512+ var fullSceneLayout = scene . fullSceneLayout ;
513+ var annotations = fullSceneLayout . annotations || [ ] ;
513514
514515 for ( var d = 0 ; d < 3 ; d ++ ) {
515516 var axisName = axisProperties [ d ] ;
516517 var axLetter = axisName . charAt ( 0 ) ;
517- var ax = sceneLayout [ axisName ] ;
518+ var ax = fullSceneLayout [ axisName ] ;
518519
519520 for ( var j = 0 ; j < annotations . length ; j ++ ) {
520521 var ann = annotations [ j ] ;
@@ -725,42 +726,40 @@ proto.plot = function(sceneData, fullLayout, layout) {
725726 } ) ;
726727 }
727728
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-
738729 /*
739730 * Dynamically set the aspect ratio depending on the users aspect settings
740731 */
741- var axisAutoScaleFactor = 4 ;
742732 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' ) {
758735 aspectRatio = [ 1 , 1 , 1 ] ;
759- } else if ( fullSceneLayout . aspectmode === 'data' ) {
760- aspectRatio = axesScaleRatio ;
761- } else if ( fullSceneLayout . aspectmode === 'manual' ) {
736+ } else if ( aspectmode === 'manual' ) {
762737 var userRatio = fullSceneLayout . aspectratio ;
763738 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+ }
764763 } else {
765764 throw new Error ( 'scene.js aspectRatio was not one of the enumerated types' ) ;
766765 }
0 commit comments