Skip to content

Commit 67ea429

Browse files
committed
improved logic
1 parent cb6dab7 commit 67ea429

File tree

3 files changed

+15
-12
lines changed

3 files changed

+15
-12
lines changed

src/plots/gl3d/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ exports.plot = function plotGl3d(gd) {
6969
if(!scene.cameraInitial) {
7070
scene.cameraInitial = Lib.extendDeep({}, sceneLayout.camera);
7171
}
72+
/*
73+
if(!sceneLayout._scene.cameraInitial) {
74+
sceneLayout._scene.cameraInitial = Lib.extendDeep({}, gd._fullLayout[sceneId].camera);
75+
}
76+
*/
7277

7378
scene.plot(fullSceneData, fullLayout, gd.layout);
7479
}

src/plots/gl3d/layout/defaults.js

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -97,23 +97,15 @@ function handleGl3dDefaults(sceneLayoutIn, sceneLayoutOut, coerce, opts) {
9797
sceneLayoutIn.aspectmode = sceneLayoutOut.aspectmode;
9898
}
9999

100-
var overwrite = false;
100+
var overwriteIn = false;
101101
if(sceneLayoutIn.camera &&
102102
sceneLayoutIn.camera.up &&
103103
sceneLayoutIn.camera.up.z !== 1) {
104-
overwrite = true;
104+
overwriteIn = (sceneLayoutIn.dragmode !== 'turntable') ? true : false;
105105
}
106106

107-
if(sceneLayoutIn.dragmode === 'turntable') {
108-
overwrite = false;
109-
}
110-
111-
if(overwrite === true) {
107+
if(overwriteIn === true) {
112108
sceneLayoutIn.dragmode = 'orbit';
113-
} else {
114-
if(sceneLayoutIn.dragmode === 'turntable') {
115-
sceneLayoutIn.camera.up = [0, 0, 1];
116-
}
117109
}
118110

119111
supplyGl3dAxisLayoutDefaults(sceneLayoutIn, sceneLayoutOut, {
@@ -125,6 +117,10 @@ function handleGl3dDefaults(sceneLayoutIn, sceneLayoutOut, coerce, opts) {
125117
fullLayout: opts.fullLayout
126118
});
127119

120+
if(sceneLayoutOut.dragmode === 'turntable') {
121+
sceneLayoutOut.camera.up = [0, 0, 1];
122+
}
123+
128124
Registry.getComponentMethod('annotations3d', 'handleDefaults')(
129125
sceneLayoutIn, sceneLayoutOut, opts
130126
);

test/jasmine/tests/gl3d_plot_interact_test.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -769,7 +769,7 @@ describe('Test gl3d modebar handlers', function() {
769769
buttonDefault.click();
770770
});
771771

772-
it('@gl button resetCameraLastSave3d should reset camera to default', function(done) {
772+
fit('@gl button resetCameraLastSave3d should reset camera to default', function(done) {
773773
var buttonDefault = selectButton(modeBar, 'resetCameraDefault3d');
774774
var buttonLastSave = selectButton(modeBar, 'resetCameraLastSave3d');
775775

@@ -808,6 +808,8 @@ describe('Test gl3d modebar handlers', function() {
808808
assertCameraEye(gd._fullLayout.scene, 0.1, 0.1, 1);
809809
assertCameraEye(gd._fullLayout.scene2, 2.5, 2.5, 2.5);
810810

811+
console.log("gd._fullLayout.scene._scene.cameraInitial=", gd._fullLayout.scene._scene.cameraInitial);
812+
811813
delete gd._fullLayout.scene._scene.cameraInitial;
812814
delete gd._fullLayout.scene2._scene.cameraInitial;
813815

0 commit comments

Comments
 (0)