Skip to content

Commit 66da760

Browse files
committed
fixed camera init to avoid multiple calls to create camera and resuse the identical camera object in creating gl3d scene
1 parent c759396 commit 66da760

File tree

3 files changed

+11
-14
lines changed

3 files changed

+11
-14
lines changed

package-lock.json

+2-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
"gl-mat4": "^1.2.0",
8181
"gl-mesh3d": "^2.0.8",
8282
"gl-plot2d": "^1.4.2",
83-
"gl-plot3d": "^2.1.1",
83+
"gl-plot3d": "git://github.com/gl-vis/gl-plot3d.git#8974522a2b56120766d34d4e509f292a718b7f3e",
8484
"gl-pointcloud2d": "^1.0.2",
8585
"gl-scatter3d": "^1.2.0",
8686
"gl-select-box": "^1.0.3",

src/plots/gl3d/scene.js

+8-10
Original file line numberDiff line numberDiff line change
@@ -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
this.enableGLCameraMouseListener();
359357
}
@@ -808,7 +806,7 @@ proto.setCamera = function setCamera(cameraData) {
808806

809807
this.glplot.dispose();
810808

811-
initializeGLPlot(this, cameraData, pixelRatio);
809+
initializeGLPlot(this, pixelRatio);
812810
this.glplot.camera._ortho = newOrtho;
813811
}
814812
};

0 commit comments

Comments
 (0)