Skip to content

Commit

Permalink
cameraInitial > viewInitial
Browse files Browse the repository at this point in the history
  • Loading branch information
archmoj committed Mar 4, 2019
1 parent 4d7c1b4 commit 9e1aa7a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/components/modebar/buttons.js
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ function handleCamera3d(gd, ev) {
var scene = fullLayout[sceneId]._scene;

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

aobj[key].projection = {
type: (scene.camera._ortho) ? 'orthographic' : 'perspective'
Expand Down
22 changes: 19 additions & 3 deletions src/plots/gl3d/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,25 @@ exports.plot = function plotGl3d(gd) {
sceneLayout._scene = scene;
}

// save 'initial' camera settings for modebar button
if(!scene.cameraInitial) {
scene.cameraInitial = Lib.extendDeep({}, sceneLayout.camera);
// save 'initial' camera view settings for modebar button
if(!scene.viewInitial) {
scene.viewInitial = {
up: {
x: sceneLayout.camera.up.x,
y: sceneLayout.camera.up.y,
z: sceneLayout.camera.up.z
},
eye: {
x: sceneLayout.camera.eye.x,
y: sceneLayout.camera.eye.y,
z: sceneLayout.camera.eye.z
},
center: {
x: sceneLayout.camera.center.x,
y: sceneLayout.camera.center.y,
z: sceneLayout.camera.center.z
}
};
}

scene.plot(fullSceneData, fullLayout, gd.layout);
Expand Down
8 changes: 4 additions & 4 deletions test/jasmine/tests/gl3d_plot_interact_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1043,8 +1043,8 @@ describe('Test gl3d modebar handlers', function() {
it('@gl button resetCameraDefault3d should reset camera to default', function(done) {
var buttonDefault = selectButton(modeBar, 'resetCameraDefault3d');

expect(gd._fullLayout.scene._scene.cameraInitial.eye).toEqual({ x: 0.1, y: 0.1, z: 1 });
expect(gd._fullLayout.scene2._scene.cameraInitial.eye).toEqual({ x: 2.5, y: 2.5, z: 2.5 });
expect(gd._fullLayout.scene._scene.viewInitial.eye).toEqual({ x: 0.1, y: 0.1, z: 1 });
expect(gd._fullLayout.scene2._scene.viewInitial.eye).toEqual({ x: 2.5, y: 2.5, z: 2.5 });

gd.once('plotly_relayout', function() {
assertScenes(gd._fullLayout, 'camera.eye.x', 1.25);
Expand Down Expand Up @@ -1099,8 +1099,8 @@ describe('Test gl3d modebar handlers', function() {
assertCameraEye(gd._fullLayout.scene, 0.1, 0.1, 1);
assertCameraEye(gd._fullLayout.scene2, 2.5, 2.5, 2.5);

delete gd._fullLayout.scene._scene.cameraInitial;
delete gd._fullLayout.scene2._scene.cameraInitial;
delete gd._fullLayout.scene._scene.viewInitial;
delete gd._fullLayout.scene2._scene.viewInitial;

Plotly.relayout(gd, {
'scene.bgcolor': '#d3d3d3',
Expand Down

0 comments on commit 9e1aa7a

Please sign in to comment.