Skip to content

Commit

Permalink
write camera.up back to layout only when necessary
Browse files Browse the repository at this point in the history
interaction between previous changes in this PR and #3256
  • Loading branch information
alexcjohnson committed Nov 29, 2018
1 parent 6cfe7c5 commit 8d11985
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/plots/gl3d/scene.js
Original file line number Diff line number Diff line change
Expand Up @@ -754,15 +754,22 @@ proto.updateFx = function(dragmode, hovermode) {
// but only if we *don't* explicitly set z-up earlier via the
// relayout. So push `up` back to layout & fullLayout manually now.
var gd = this.graphDiv;
var layout = gd.layout;
var fullLayout = gd._fullLayout;
var fullCamera = this.fullSceneLayout.camera;
var x = fullCamera.up.x;
var y = fullCamera.up.y;
var z = fullCamera.up.z;
// only push `up` back to (full)layout if it's going to change
if(z / Math.sqrt(x * x + y * y + z * z) > 0.999) return;

var attr = this.id + '.camera.up';
var edits = {};
var zUp = {x: 0, y: 0, z: 1};
var edits = {};
edits[attr] = zUp;
var layout = gd.layout;
Registry.call('_storeDirectGUIEdit', layout, fullLayout._preGUI, edits);
this.fullSceneLayout.camera.up = zUp;
Lib.nestedProperty(gd.layout, attr).set(zUp);
fullCamera.up = zUp;
Lib.nestedProperty(layout, attr).set(zUp);
} else {

// none rotation modes [pan or zoom]
Expand Down

0 comments on commit 8d11985

Please sign in to comment.