Skip to content

fix reset camera buttons to work after switching projection between perspective and orthographic #3597

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Mar 5, 2019
Merged
12 changes: 8 additions & 4 deletions src/components/modebar/buttons.js
Original file line number Diff line number Diff line change
Expand Up @@ -348,10 +348,14 @@ function handleCamera3d(gd, ev) {
var scene = fullLayout[sceneId]._scene;

if(attr === 'resetDefault' || attr === 'resetLastSave') {
aobj[key] = Lib.extendDeep({}, scene.viewInitial);

aobj[key].projection = {
type: (scene.camera._ortho) ? 'orthographic' : 'perspective'
aobj[key] = {
'up': scene.viewInitial.up,
'eye': scene.viewInitial.eye,
'center': scene.viewInitial.center,
'projection': {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't need to update projection at all, am I right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right. But in order to that we need to explicitly pass the current projection here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, that's a bug then. Calling

Plotly.relayout('graph', 'scene.camera.up', {/**/})

should not change the projection type.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't we just need to flatten it to aobj[key + '.up'] = ... etc?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @alexcjohnson & @etpinard.
Flattening was really helpful.

type: (scene.camera._ortho) ?
'orthographic' : 'perspective'
}
};
}

Expand Down
18 changes: 9 additions & 9 deletions src/plots/gl3d/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,19 +71,19 @@ exports.plot = function plotGl3d(gd) {
if(!scene.viewInitial) {
scene.viewInitial = {
up: {
x: sceneLayout.camera.up.x,
y: sceneLayout.camera.up.y,
z: sceneLayout.camera.up.z
x: camera.up.x,
y: camera.up.y,
z: camera.up.z
},
eye: {
x: sceneLayout.camera.eye.x,
y: sceneLayout.camera.eye.y,
z: sceneLayout.camera.eye.z
x: camera.eye.x,
y: camera.eye.y,
z: camera.eye.z
},
center: {
x: sceneLayout.camera.center.x,
y: sceneLayout.camera.center.y,
z: sceneLayout.camera.center.z
x: camera.center.x,
y: camera.center.y,
z: camera.center.z
}
};
}
Expand Down