Skip to content

Commit 8d11985

Browse files
committed
write camera.up back to layout only when necessary
interaction between previous changes in this PR and #3256
1 parent 6cfe7c5 commit 8d11985

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/plots/gl3d/scene.js

+11-4
Original file line numberDiff line numberDiff line change
@@ -754,15 +754,22 @@ proto.updateFx = function(dragmode, hovermode) {
754754
// but only if we *don't* explicitly set z-up earlier via the
755755
// relayout. So push `up` back to layout & fullLayout manually now.
756756
var gd = this.graphDiv;
757-
var layout = gd.layout;
758757
var fullLayout = gd._fullLayout;
758+
var fullCamera = this.fullSceneLayout.camera;
759+
var x = fullCamera.up.x;
760+
var y = fullCamera.up.y;
761+
var z = fullCamera.up.z;
762+
// only push `up` back to (full)layout if it's going to change
763+
if(z / Math.sqrt(x * x + y * y + z * z) > 0.999) return;
764+
759765
var attr = this.id + '.camera.up';
760-
var edits = {};
761766
var zUp = {x: 0, y: 0, z: 1};
767+
var edits = {};
762768
edits[attr] = zUp;
769+
var layout = gd.layout;
763770
Registry.call('_storeDirectGUIEdit', layout, fullLayout._preGUI, edits);
764-
this.fullSceneLayout.camera.up = zUp;
765-
Lib.nestedProperty(gd.layout, attr).set(zUp);
771+
fullCamera.up = zUp;
772+
Lib.nestedProperty(layout, attr).set(zUp);
766773
} else {
767774

768775
// none rotation modes [pan or zoom]

0 commit comments

Comments
 (0)