Skip to content

Commit 1081e6a

Browse files
committed
no need to duplicate camera on gl-plot3d scene
1 parent 0f86036 commit 1081e6a

File tree

2 files changed

+16
-18
lines changed

2 files changed

+16
-18
lines changed

src/plots/gl3d/scene.js

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ function initializeGLPlot(scene, canvas, gl) {
293293

294294
scene.glplot.canvas.addEventListener('wheel', function(e) {
295295
if(gd._context._scrollZoom.gl3d) {
296-
if(scene.glplot.camera._ortho) {
296+
if(scene.camera._ortho) {
297297
var s = (e.deltaX > e.deltaY) ? 1.1 : 1.0 / 1.1;
298298
var o = scene.glplot.getAspectratio();
299299
scene.glplot.setAspectratio({
@@ -326,8 +326,6 @@ function initializeGLPlot(scene, canvas, gl) {
326326
}, false);
327327
}
328328

329-
scene.glplot.camera = scene.camera;
330-
331329
scene.glplot.oncontextloss = function() {
332330
scene.recoverContext();
333331
};
@@ -779,7 +777,7 @@ proto.destroy = function() {
779777

780778
this.camera.mouseListener.enabled = false;
781779
this.container.removeEventListener('wheel', this.camera.wheelListener);
782-
this.camera = this.glplot.camera = null;
780+
this.camera = null;
783781
this.glplot.dispose();
784782
this.container.parentNode.removeChild(this.container);
785783
this.glplot = null;
@@ -808,19 +806,19 @@ function getLayoutCamera(camera) {
808806

809807
// get camera position in plotly coords from 'gl-plot3d' coords
810808
proto.getCamera = function() {
811-
this.glplot.camera.view.recalcMatrix(this.camera.view.lastT());
812-
return getLayoutCamera(this.glplot.camera);
809+
this.camera.view.recalcMatrix(this.camera.view.lastT());
810+
return getLayoutCamera(this.camera);
813811
};
814812

815813
// set gl-plot3d camera position and scene aspects with a set of plotly coords
816814
proto.setViewport = function(sceneLayout) {
817815
var cameraData = sceneLayout.camera;
818816

819-
this.glplot.camera.lookAt.apply(this, getCameraArrays(cameraData));
817+
this.camera.lookAt.apply(this, getCameraArrays(cameraData));
820818
this.glplot.setAspectratio(sceneLayout.aspectratio);
821819

822820
var newOrtho = (cameraData.projection.type === 'orthographic');
823-
var oldOrtho = this.glplot.camera._ortho;
821+
var oldOrtho = this.camera._ortho;
824822

825823
if(newOrtho !== oldOrtho) {
826824
this.glplot.redraw();
@@ -837,7 +835,7 @@ proto.setViewport = function(sceneLayout) {
837835
this.glplot.dispose();
838836

839837
initializeGLPlot(this);
840-
this.glplot.camera._ortho = newOrtho;
838+
this.camera._ortho = newOrtho;
841839
}
842840
};
843841

test/jasmine/tests/gl3d_plot_interact_test.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ describe('Test gl3d before/after plot', function() {
9393
})
9494
.then(delay(20))
9595
.then(function() {
96-
var cameraBefore = gd._fullLayout.scene._scene.glplot.camera;
96+
var cameraBefore = gd._fullLayout.scene._scene.camera;
9797
expect(cameraBefore.up[0]).toBeCloseTo(0, 2, 'cameraBefore.up[0]');
9898
expect(cameraBefore.up[1]).toBeCloseTo(0, 2, 'cameraBefore.up[1]');
9999
expect(cameraBefore.up[2]).toBeCloseTo(1, 2, 'cameraBefore.up[2]');
@@ -108,7 +108,7 @@ describe('Test gl3d before/after plot', function() {
108108
.then(_clickThere)
109109
.then(delay(20))
110110
.then(function() {
111-
var cameraAfter = gd._fullLayout.scene._scene.glplot.camera;
111+
var cameraAfter = gd._fullLayout.scene._scene.camera;
112112
expect(cameraAfter.up[0]).toBeCloseTo(0, 2, 'cameraAfter.up[0]');
113113
expect(cameraAfter.up[1]).toBeCloseTo(0, 2, 'cameraAfter.up[1]');
114114
expect(cameraAfter.up[2]).toBeCloseTo(1, 2, 'cameraAfter.up[2]');
@@ -123,7 +123,7 @@ describe('Test gl3d before/after plot', function() {
123123
.then(_clickOtherplace)
124124
.then(delay(20))
125125
.then(function() {
126-
var cameraFinal = gd._fullLayout.scene._scene.glplot.camera;
126+
var cameraFinal = gd._fullLayout.scene._scene.camera;
127127
expect(cameraFinal.up[0]).toBeCloseTo(0, 2, 'cameraFinal.up[0]');
128128
expect(cameraFinal.up[1]).toBeCloseTo(0, 2, 'cameraFinal.up[1]');
129129
expect(cameraFinal.up[2]).toBeCloseTo(1, 2, 'cameraFinal.up[2]');
@@ -300,7 +300,7 @@ describe('Test gl3d plots', function() {
300300
.then(delay(20))
301301
.then(function() {
302302
expect(gd._fullLayout.scene.camera.projection.type === 'perspective').toBe(true);
303-
expect(gd._fullLayout.scene._scene.glplot.camera._ortho === false).toBe(true);
303+
expect(gd._fullLayout.scene._scene.camera._ortho === false).toBe(true);
304304
})
305305
.then(done);
306306
});
@@ -326,7 +326,7 @@ describe('Test gl3d plots', function() {
326326
.then(delay(20))
327327
.then(function() {
328328
expect(gd._fullLayout.scene.camera.projection.type === 'orthographic').toBe(true);
329-
expect(gd._fullLayout.scene._scene.glplot.camera._ortho === true).toBe(true);
329+
expect(gd._fullLayout.scene._scene.camera._ortho === true).toBe(true);
330330
})
331331
.then(done);
332332
});
@@ -355,28 +355,28 @@ describe('Test gl3d plots', function() {
355355
})
356356
.then(function() {
357357
expect(gd._fullLayout.scene.camera.projection.type === 'orthographic').toBe(true);
358-
expect(gd._fullLayout.scene._scene.glplot.camera._ortho === true).toBe(true);
358+
expect(gd._fullLayout.scene._scene.camera._ortho === true).toBe(true);
359359
})
360360
.then(function() {
361361
return Plotly.relayout(gd, 'scene.camera.eye.z', 2);
362362
})
363363
.then(function() {
364364
expect(gd._fullLayout.scene.camera.projection.type === 'orthographic').toBe(true);
365-
expect(gd._fullLayout.scene._scene.glplot.camera._ortho === true).toBe(true);
365+
expect(gd._fullLayout.scene._scene.camera._ortho === true).toBe(true);
366366
})
367367
.then(function() {
368368
return Plotly.relayout(gd, 'scene.camera.projection.type', 'perspective');
369369
})
370370
.then(function() {
371371
expect(gd._fullLayout.scene.camera.projection.type === 'perspective').toBe(true);
372-
expect(gd._fullLayout.scene._scene.glplot.camera._ortho === false).toBe(true);
372+
expect(gd._fullLayout.scene._scene.camera._ortho === false).toBe(true);
373373
})
374374
.then(function() {
375375
return Plotly.relayout(gd, 'scene.camera.eye.z', 3);
376376
})
377377
.then(function() {
378378
expect(gd._fullLayout.scene.camera.projection.type === 'perspective').toBe(true);
379-
expect(gd._fullLayout.scene._scene.glplot.camera._ortho === false).toBe(true);
379+
expect(gd._fullLayout.scene._scene.camera._ortho === false).toBe(true);
380380
})
381381
.then(done);
382382
});

0 commit comments

Comments
 (0)