@@ -192,7 +192,7 @@ function render(scene) {
192192 scene . drawAnnotations ( scene ) ;
193193}
194194
195- function tryCreatePlot ( scene , camera , pixelRatio , canvas , gl ) {
195+ function tryCreatePlot ( scene , cameraObject , pixelRatio , canvas , gl ) {
196196
197197 var glplotOptions = {
198198 canvas : canvas ,
@@ -204,7 +204,7 @@ function tryCreatePlot(scene, camera, pixelRatio, canvas, gl) {
204204 snapToData : true ,
205205 autoScale : true ,
206206 autoBounds : false ,
207- camera : camera ,
207+ cameraObject : cameraObject ,
208208 pixelRatio : pixelRatio
209209 } ;
210210
@@ -238,9 +238,11 @@ function tryCreatePlot(scene, camera, pixelRatio, canvas, gl) {
238238 return true ;
239239}
240240
241- function initializeGLPlot ( scene , camera , pixelRatio , canvas , gl ) {
241+ function initializeGLPlot ( scene , pixelRatio , canvas , gl ) {
242242
243- var success = tryCreatePlot ( scene , camera , pixelRatio , canvas , gl ) ;
243+ scene . initializeGLCamera ( ) ;
244+
245+ var success = tryCreatePlot ( scene , scene . camera , pixelRatio , canvas , gl ) ;
244246 /*
245247 * createPlot will throw when webgl is not enabled in the client.
246248 * Lets return an instance of the module with all functions noop'd.
@@ -281,8 +283,6 @@ function initializeGLPlot(scene, camera, pixelRatio, canvas, gl) {
281283 } , false ) ;
282284 }
283285
284- if ( ! scene . camera ) scene . initializeGLCamera ( ) ;
285-
286286 scene . glplot . camera = scene . camera ;
287287
288288 scene . glplot . oncontextloss = function ( ) {
@@ -351,9 +351,7 @@ function Scene(options, fullLayout) {
351351 this . convertAnnotations = Registry . getComponentMethod ( 'annotations3d' , 'convert' ) ;
352352 this . drawAnnotations = Registry . getComponentMethod ( 'annotations3d' , 'draw' ) ;
353353
354- var camera = fullLayout . scene . camera ;
355-
356- initializeGLPlot ( this , camera , this . pixelRatio ) ;
354+ initializeGLPlot ( this , this . pixelRatio ) ;
357355}
358356
359357var proto = Scene . prototype ;
@@ -796,7 +794,7 @@ proto.setCamera = function setCamera(cameraData) {
796794
797795 this . glplot . dispose ( ) ;
798796
799- initializeGLPlot ( this , cameraData , pixelRatio ) ;
797+ initializeGLPlot ( this , pixelRatio ) ;
800798 this . glplot . camera . _ortho = newOrtho ;
801799 }
802800} ;
@@ -851,7 +849,6 @@ proto.saveCamera = function saveCamera(layout) {
851849
852850proto . updateFx = function ( dragmode , hovermode ) {
853851 var camera = this . camera ;
854-
855852 if ( camera ) {
856853 // rotate and orbital are synonymous
857854 if ( dragmode === 'orbit' ) {
@@ -873,16 +870,16 @@ proto.updateFx = function(dragmode, hovermode) {
873870 var y = fullCamera . up . y ;
874871 var z = fullCamera . up . z ;
875872 // only push `up` back to (full)layout if it's going to change
876- if ( z / Math . sqrt ( x * x + y * y + z * z ) > 0.999 ) return ;
877-
878- var attr = this . id + '.camera.up' ;
879- var zUp = { x : 0 , y : 0 , z : 1 } ;
880- var edits = { } ;
881- edits [ attr ] = zUp ;
882- var layout = gd . layout ;
883- Registry . call ( '_storeDirectGUIEdit' , layout , fullLayout . _preGUI , edits ) ;
884- fullCamera . up = zUp ;
885- Lib . nestedProperty ( layout , attr ) . set ( zUp ) ;
873+ if ( z / Math . sqrt ( x * x + y * y + z * z ) < 0.999 ) {
874+ var attr = this . id + '.camera.up' ;
875+ var zUp = { x : 0 , y : 0 , z : 1 } ;
876+ var edits = { } ;
877+ edits [ attr ] = zUp ;
878+ var layout = gd . layout ;
879+ Registry . call ( '_storeDirectGUIEdit' , layout , fullLayout . _preGUI , edits ) ;
880+ fullCamera . up = zUp ;
881+ Lib . nestedProperty ( layout , attr ) . set ( zUp ) ;
882+ }
886883 } else {
887884 // none rotation modes [pan or zoom]
888885 camera . keyBindingMode = dragmode ;
0 commit comments