Skip to content

Commit 1aa6c85

Browse files
authored
Merge pull request #3465 from plotly/fix3425-camera-change
Do not set camera mode to turntable when up.z is zero
2 parents a956a22 + f9698f3 commit 1aa6c85

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

src/plots/gl3d/layout/defaults.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,12 @@ function handleGl3dDefaults(sceneLayoutIn, sceneLayoutOut, coerce, opts) {
128128
var y = sceneLayoutIn.camera.up.y;
129129
var z = sceneLayoutIn.camera.up.z;
130130

131-
if(!x || !y || !z) {
132-
dragmode = 'turntable';
133-
} else if(z / Math.sqrt(x * x + y * y + z * z) > 0.999) {
134-
dragmode = 'turntable';
131+
if(z !== 0) {
132+
if(!x || !y || !z) {
133+
dragmode = 'turntable';
134+
} else if(z / Math.sqrt(x * x + y * y + z * z) > 0.999) {
135+
dragmode = 'turntable';
136+
}
135137
}
136138
} else {
137139
dragmode = 'turntable';
3.2 KB
Loading

test/jasmine/tests/gl3d_plot_interact_test.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,8 @@ describe('Test gl3d plots', function() {
511511
camera: {
512512
up: {
513513
x: null,
514-
z: 0
514+
y: 0.5,
515+
z: 0.5
515516
}
516517
}
517518
}
@@ -524,7 +525,7 @@ describe('Test gl3d plots', function() {
524525
.then(done);
525526
});
526527

527-
it('@gl should set the camera dragmode to turntable if all camera.up.[x|y|z] are zero or missing', function(done) {
528+
it('@gl should not set the camera dragmode to turntable if camera.up.z is zero.', function(done) {
528529
Plotly.plot(gd, {
529530
data: [{
530531
type: 'scatter3d',
@@ -536,7 +537,7 @@ describe('Test gl3d plots', function() {
536537
scene: {
537538
camera: {
538539
up: {
539-
x: 0,
540+
x: 1,
540541
y: 0,
541542
z: 0
542543
}
@@ -546,7 +547,7 @@ describe('Test gl3d plots', function() {
546547
})
547548
.then(delay(20))
548549
.then(function() {
549-
expect(gd._fullLayout.scene.dragmode === 'turntable').toBe(true);
550+
expect(gd._fullLayout.scene.dragmode === 'turntable').not.toBe(true);
550551
})
551552
.then(done);
552553
});

0 commit comments

Comments
 (0)