-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Trigger plotly_relayout event when camera is reset to default or saved (Solves #FI29) #458
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
etpinard
merged 4 commits into
plotly:master
from
monfera:29-emit-relayout-events-on-3d-camera-reset
Apr 21, 2016
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
d6037c0
#29 add plotly_relayout event emission when camera is reset to defaul…
monfera 8dedb6e
#29 add test cases (they're in the CI excluded file but they pass fin…
monfera ff1d418
#29 different camera format, and ensuing code unification
monfera 57b2650
#29 ensure one call per scene, checking against correct callback argu…
monfera File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -559,11 +559,13 @@ proto.destroy = function() { | |
// for reset camera button in mode bar | ||
proto.setCameraToDefault = function setCameraToDefault() { | ||
// as in Gl3d.layoutAttributes | ||
this.glplot.camera.lookAt( | ||
var lookAtInput = [ | ||
[1.25, 1.25, 1.25], | ||
[0, 0, 0], | ||
[0, 0, 1] | ||
); | ||
]; | ||
this.glplot.camera.lookAt.apply(this, lookAtInput); | ||
this.graphDiv.emit('plotly_relayout', lookAtInput); | ||
}; | ||
|
||
// get camera position in plotly coords from 'orbit-camera' coords | ||
|
@@ -586,11 +588,13 @@ proto.setCamera = function setCamera(cameraData) { | |
var up = cameraData.up; | ||
var center = cameraData.center; | ||
var eye = cameraData.eye; | ||
this.glplot.camera.lookAt( | ||
var lookAtInput = [ | ||
|
||
[eye.x, eye.y, eye.z], | ||
[center.x, center.y, center.z], | ||
[up.x, up.y, up.z] | ||
); | ||
]; | ||
this.glplot.camera.lookAt.apply(this, lookAtInput); | ||
this.graphDiv.emit('plotly_relayout', lookAtInput); | ||
}; | ||
|
||
// save camera to user layout (i.e. gd.layout) | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could do even better passing the corresponding camera attribute update object e.g:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@etpinard I'm glad to refactor for it; I'll extract the object-to-array logic into a separate function so we can be DRY among these two
emit
places.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh. To handle the mulit-scene case ⏫ should in fact be:
where
this.id
can bescene
,scene2
,scene3
, etc.