@@ -192,7 +192,7 @@ function render(scene) {
192
192
scene . drawAnnotations ( scene ) ;
193
193
}
194
194
195
- function tryCreatePlot ( scene , camera , pixelRatio , canvas , gl ) {
195
+ function tryCreatePlot ( scene , cameraObject , pixelRatio , canvas , gl ) {
196
196
197
197
var glplotOptions = {
198
198
canvas : canvas ,
@@ -204,7 +204,7 @@ function tryCreatePlot(scene, camera, pixelRatio, canvas, gl) {
204
204
snapToData : true ,
205
205
autoScale : true ,
206
206
autoBounds : false ,
207
- camera : camera ,
207
+ cameraObject : cameraObject ,
208
208
pixelRatio : pixelRatio
209
209
} ;
210
210
@@ -238,9 +238,11 @@ function tryCreatePlot(scene, camera, pixelRatio, canvas, gl) {
238
238
return true ;
239
239
}
240
240
241
- function initializeGLPlot ( scene , camera , pixelRatio , canvas , gl ) {
241
+ function initializeGLPlot ( scene , pixelRatio , canvas , gl ) {
242
242
243
- var success = tryCreatePlot ( scene , camera , pixelRatio , canvas , gl ) ;
243
+ scene . initializeGLCamera ( ) ;
244
+
245
+ var success = tryCreatePlot ( scene , scene . camera , pixelRatio , canvas , gl ) ;
244
246
/*
245
247
* createPlot will throw when webgl is not enabled in the client.
246
248
* Lets return an instance of the module with all functions noop'd.
@@ -281,8 +283,6 @@ function initializeGLPlot(scene, camera, pixelRatio, canvas, gl) {
281
283
} , false ) ;
282
284
}
283
285
284
- if ( ! scene . camera ) scene . initializeGLCamera ( ) ;
285
-
286
286
scene . glplot . camera = scene . camera ;
287
287
288
288
scene . glplot . oncontextloss = function ( ) {
@@ -351,9 +351,7 @@ function Scene(options, fullLayout) {
351
351
this . convertAnnotations = Registry . getComponentMethod ( 'annotations3d' , 'convert' ) ;
352
352
this . drawAnnotations = Registry . getComponentMethod ( 'annotations3d' , 'draw' ) ;
353
353
354
- var camera = fullLayout . scene . camera ;
355
-
356
- initializeGLPlot ( this , camera , this . pixelRatio ) ;
354
+ initializeGLPlot ( this , this . pixelRatio ) ;
357
355
}
358
356
359
357
var proto = Scene . prototype ;
@@ -796,7 +794,7 @@ proto.setCamera = function setCamera(cameraData) {
796
794
797
795
this . glplot . dispose ( ) ;
798
796
799
- initializeGLPlot ( this , cameraData , pixelRatio ) ;
797
+ initializeGLPlot ( this , pixelRatio ) ;
800
798
this . glplot . camera . _ortho = newOrtho ;
801
799
}
802
800
} ;
@@ -851,7 +849,6 @@ proto.saveCamera = function saveCamera(layout) {
851
849
852
850
proto . updateFx = function ( dragmode , hovermode ) {
853
851
var camera = this . camera ;
854
-
855
852
if ( camera ) {
856
853
// rotate and orbital are synonymous
857
854
if ( dragmode === 'orbit' ) {
@@ -873,16 +870,16 @@ proto.updateFx = function(dragmode, hovermode) {
873
870
var y = fullCamera . up . y ;
874
871
var z = fullCamera . up . z ;
875
872
// 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
+ }
886
883
} else {
887
884
// none rotation modes [pan or zoom]
888
885
camera . keyBindingMode = dragmode ;
0 commit comments