Skip to content

Commit 2034941

Browse files
committed
partial preGUI fix for 3D camera
1 parent 5a27c00 commit 2034941

File tree

1 file changed

+25
-6
lines changed

1 file changed

+25
-6
lines changed

src/plots/gl3d/scene.js

+25-6
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,6 @@ function initializeGLPlot(scene, fullLayout, canvas, gl) {
222222

223223
var update = {};
224224
update[scene.id + '.camera'] = getLayoutCamera(scene.camera);
225-
Registry.call('_storeDirectGUIEdit', gd.layout, gd._fullLayout._preGUI, update);
226225
scene.saveCamera(gd.layout);
227226
scene.graphDiv.emit('plotly_relayout', update);
228227
};
@@ -702,10 +701,10 @@ proto.setCamera = function setCamera(cameraData) {
702701

703702
// save camera to user layout (i.e. gd.layout)
704703
proto.saveCamera = function saveCamera(layout) {
705-
var cameraData = this.getCamera(),
706-
cameraNestedProp = Lib.nestedProperty(layout, this.id + '.camera'),
707-
cameraDataLastSave = cameraNestedProp.get(),
708-
hasChanged = false;
704+
var cameraData = this.getCamera();
705+
var cameraNestedProp = Lib.nestedProperty(layout, this.id + '.camera');
706+
var cameraDataLastSave = cameraNestedProp.get();
707+
var hasChanged = false;
709708

710709
function same(x, y, i, j) {
711710
var vectors = ['up', 'center', 'eye'],
@@ -725,7 +724,14 @@ proto.saveCamera = function saveCamera(layout) {
725724
}
726725
}
727726

728-
if(hasChanged) cameraNestedProp.set(cameraData);
727+
if(hasChanged) {
728+
cameraNestedProp.set(cameraData);
729+
730+
var fullLayout = this.fullLayout;
731+
var cameraFullNP = Lib.nestedProperty(fullLayout, this.id + '.camera');
732+
cameraFullNP.set(cameraData);
733+
Registry.call('_storeDirectGUIEdit', layout, fullLayout._preGUI, cameraData);
734+
}
729735

730736
return hasChanged;
731737
};
@@ -744,6 +750,19 @@ proto.updateFx = function(dragmode, hovermode) {
744750
camera.mode = 'turntable';
745751
camera.keyBindingMode = 'rotate';
746752

753+
// The setter for camera.mode animates the transition to z-up,
754+
// but only if we *don't* explicitly set z-up earlier via the
755+
// relayout. So push `up` back to layout & fullLayout manually now.
756+
var gd = this.graphDiv;
757+
var layout = gd.layout;
758+
var fullLayout = gd._fullLayout;
759+
var attr = this.id + '.camera.up';
760+
var edits = {};
761+
var zUp = {x: 0, y: 0, z: 1};
762+
edits[attr] = zUp;
763+
Registry.call('_storeDirectGUIEdit', layout, fullLayout._preGUI, edits);
764+
this.fullSceneLayout.camera.up = zUp;
765+
Lib.nestedProperty(gd.layout, attr).set(zUp);
747766
} else {
748767

749768
// none rotation modes [pan or zoom]

0 commit comments

Comments
 (0)