Skip to content

Commit 54b1ca1

Browse files
committed
fix issue 3576 disable camera mouse listener before scene is complete
1 parent 4b21575 commit 54b1ca1

File tree

2 files changed

+71
-0
lines changed

2 files changed

+71
-0
lines changed

src/plots/gl3d/scene.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,9 @@ proto.initializeGLCamera = function() {
372372
zoomMax: 100,
373373
mode: 'orbit'
374374
});
375+
376+
// Note: we shoule disable camera interactions until the scene is complete
377+
this.camera.mouseListener.enabled = false;
375378
};
376379

377380
proto.recoverContext = function() {

test/jasmine/tests/gl3d_plot_interact_test.js

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,74 @@ describe('Test gl3d plots', function() {
7575
destroyGraphDiv();
7676
});
7777

78+
it('@gl should not rotate camera on the very first click before scene is complete and modebar setup', function(done) {
79+
var _mock = Lib.extendDeep(
80+
{
81+
layout: {
82+
scene: {
83+
camera: {
84+
up: {
85+
x: 0,
86+
y: 0,
87+
z: 1
88+
},
89+
eye: {
90+
x: 1.2,
91+
y: 1.2,
92+
z: 1.2
93+
},
94+
center: {
95+
x: 0,
96+
y: 0,
97+
z: 0
98+
}
99+
}
100+
}
101+
}
102+
},
103+
mock2
104+
);
105+
106+
// N.B. gl3d click events are 'mouseover' events
107+
// with button 1 pressed
108+
function _click() {
109+
mouseEvent('mouseover', 605, 271, {buttons: 1});
110+
return delay(20)();
111+
}
112+
113+
Plotly.plot(gd, _mock)
114+
.then(delay(20))
115+
.then(function() {
116+
gd.on('plotly_click', function(eventData) {
117+
ptData = eventData.points[0];
118+
});
119+
})
120+
.then(_click)
121+
.then(delay(20))
122+
.then(function() {
123+
expect(gd._fullLayout.scene.camera.up.x).toEqual(0, 'camera.up.x');
124+
expect(gd._fullLayout.scene.camera.up.y).toEqual(0, 'camera.up.y');
125+
expect(gd._fullLayout.scene.camera.up.z).toEqual(1, 'camera.up.z');
126+
expect(gd._fullLayout.scene.camera.eye.x).toEqual(1.2, 'camera.eye.x');
127+
expect(gd._fullLayout.scene.camera.eye.y).toEqual(1.2, 'camera.eye.y');
128+
expect(gd._fullLayout.scene.camera.eye.z).toEqual(1.2, 'camera.eye.z');
129+
expect(gd._fullLayout.scene.camera.center.x).toEqual(0, 'camera.center.x');
130+
expect(gd._fullLayout.scene.camera.center.y).toEqual(0, 'camera.center.y');
131+
expect(gd._fullLayout.scene.camera.center.z).toEqual(0, 'camera.center.z');
132+
133+
expect(gd._fullLayout.scene._scene.glplot.camera.up[0]).toEqual(0, 'camera.up[0]');
134+
expect(gd._fullLayout.scene._scene.glplot.camera.up[1]).toEqual(0, 'camera.up[1]');
135+
expect(gd._fullLayout.scene._scene.glplot.camera.up[2]).toEqual(1, 'camera.up[2]');
136+
expect(gd._fullLayout.scene._scene.glplot.camera.eye[0]).toBeCloseTo(1.2, 6, 'camera.eye[0]');
137+
expect(gd._fullLayout.scene._scene.glplot.camera.eye[1]).toBeCloseTo(1.2, 6, 'camera.eye[1]');
138+
expect(gd._fullLayout.scene._scene.glplot.camera.eye[2]).toBeCloseTo(1.2, 6, 'camera.eye[2]');
139+
expect(gd._fullLayout.scene._scene.glplot.camera.center[0]).toEqual(0, 'camera.center[0]');
140+
expect(gd._fullLayout.scene._scene.glplot.camera.center[1]).toEqual(0, 'camera.center[1]');
141+
expect(gd._fullLayout.scene._scene.glplot.camera.center[2]).toEqual(0, 'camera.center[2]');
142+
})
143+
.then(done);
144+
});
145+
78146
it('@noCI @gl should display correct hover labels of the second point of the very first scatter3d trace', function(done) {
79147
var _mock = Lib.extendDeep({}, multipleScatter3dMock);
80148

0 commit comments

Comments
 (0)