-
-
Notifications
You must be signed in to change notification settings - Fork 491
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
MR41: Add option to persist camera state to three.js viewer. #29192
Comments
This comment has been minimized.
This comment has been minimized.
Changed keywords from none to threejs camera persist |
comment:3
I wonder if it would be better to actually change default behaviour to be persistent. If there is an easy to discover way to reset the camera, I don't see any drawbacks. |
Dependencies: #28672 |
comment:4
Joshua, while I certainly appreciate all of the effort you put into this feature, there is a much simpler approach. #28672 already makes the camera viewpoint available on the clipboard. This can simply be passed into the plot through a new keyword named While this approach requires a manual step, it avoids the overhead of local storage and the dependence you note on the future structure of Jupyter notebooks. As soon as #28672 is merged, then either you or I can add the new keyword. Please be aware that I handle aspect multipliers a bit differently in my library. I left them more explicit in this viewer so that they don't get forgotten. |
comment:5
Hi Paul! Yes, a Another reason I implemented this feature is because I've been experimenting with adding support for three.js-based animation to Sage: discrete keyframes like the existing Laying the foundation with a persistent camera first seemed the way to go. With the animation state changing on its own every frame, a manual approach similar to I'm open to scrapping persistence for the camera and re-introducing it for the animation. Of course, that presumes that the animation stuff gets accepted later on; there may be better alternatives that I'm unaware of. Or perhaps a hybrid approach: if a Thanks for taking a look at this. :) |
comment:6
Replying to @novoselt:
I don't speed a lot of time in the Jupyter notebook, preferring the console, except recently in order to use |
comment:7
Joshua, just took a look at your animation branch on GitLab. Looks like you're deep into it! Are there any active examples online? And don't forget that Three.js has an animation system already, which you don't appear to be using. Although keyframes are one way to approach the topic, keep in mind that we can manipulate data directly using JavaScript. We haven't yet added a basic spin animation, but that's easily done by updating the rotation parameters of the object. If the object is to be moved along a trajectory, we could pass in a line or function describing the location of its center over time. For more complex alterations, we could pass in a function describing the locations of all vertices over time. Lots of possibilities without thinking in terms of saving a movie frame by frame. Please also try not to add anything to the viewer that will be dependent on a given environment, in this case a Jupyter notebook. I'd rather the viewer be as portable as possible. |
comment:8
Paul, I gathered the examples I've put in my documentation so far and thrown them up on GitHub pages: https://jcamp0x2a.github.io/threejs-animation-example/ I opted not to use Three.js's animation system since I wanted to support multiple "times", one per variable being animated. Three.js would allow me to use multiple mixers to blend linearly between several sets of keyframes, but that wouldn't be appropriate for plotting a function f(x,y,...) that's not some linear combination c1f1(x)+c2f2(y)+... Agreed that keyframes aren't necessarily the best approach, but it has two enourmous benefits:
Perhaps I should create a new ticket for the animation to continue the conversation there? I'll hold off on the persistence stuff then if it's not desired. Thanks! |
comment:9
Joshua, the animations are great! Definitely new ticket for that. Will study the code more in the near future. Rather than inspecting the notebook for a unique ID, why not generate a random large number? That's what I've done in my library and haven't had any problems yet, even with pages with lots of embedded content. |
comment:11
Batch modifying tickets that will likely not be ready for 9.1, based on a review of the ticket title, branch/review status, and last modification date. |
Changed branch from u/galois/mrs/41/threejs-persist-camera to u/paulmasson/mrs/41/threejs-persist-camera |
Changed author from Joshua Campbell to Paul Masson |
comment:13
Joshua, here at long last is the New commits:
|
comment:14
Hi Paul, I've verified that setting the I'm wary of passing structured data like this as a string parameter, though. It works fine for the Get Viewpoint use case, but one may imagine wanting to set the viewpoint to a specific axis-angle or have the axis-angle computed in some way. In the former case a typo (like forgetting a comma) would produce a blank plot instead of a syntax error, and in the latter case you'd have to take the extra step of building up a string. As Get Viewpoint is currently implemented, we have to surround its output with something to avoid a syntax error, but why not parentheses instead of quotes? While testing, I forgot to surround the output with quotes a... non-zero... number of times. Ideally, and I apologize for not thinking of this when reviewing the code that introduced it, Get Viewpoint would do the surrounding for us to avoid this perhaps not uncommon occurrence among some subset of users ;) Also, do we want the zoom / camera distance to be included as well? Perhaps by letting the length of the axis vector represent the zoom/distance? Many thanks! |
comment:15
The Get Viewpoint feature was added to support how TikZ interfaces with Sage: see this tutorial for more information. See also the general rotate command in the base class for 3D objects. Adding anything else to the string here might require changes to other interfaces, so I don't think we should do that. I agree that requiring a structured string for input is not ideal, and I like the idea of using parentheses or square brackets. That is a better way to structure the input for later handling and either can be used in Python. I'll put together a version for testing. |
Branch pushed to git repo; I updated commit sha1. New commits:
|
comment:17
Here's a more stable version, where
|
Branch pushed to git repo; I updated commit sha1. New commits:
|
comment:19
Added support for tuples and clarified angle variable in documentation. Let's add the zoom feature once we get some feedback from users. |
comment:20
I checked that the viewpoint is still set correctly, that lists/tuples are both supported, and that a helpful warning message is displayed if the One very minor note: the documentation still states "string of the form...". Otherwise looks good and can give positive review. Thank you for adding this option. Will make using |
Branch pushed to git repo; I updated commit sha1. New commits:
|
Branch pushed to git repo; I updated commit sha1. New commits:
|
comment:23
Replying to @jcamp0x2a:
Done! |
comment:24
Thanks! |
Reviewer: Joshua Campbell |
comment:26
These have been merged into 9.2.beta4 |
Joshua Campbell (@jcamp0x2a) opened a merge request at https://gitlab.com/sagemath/sage/-/merge_requests/41:
Depends on #28672
Depends on #29250
CC: @paulmasson
Component: graphics
Keywords: threejs camera persist
Author: Paul Masson
Branch/Commit: u/paulmasson/mrs/41/threejs-persist-camera @
3b7fc0c
Reviewer: Joshua Campbell
Issue created by migration from https://trac.sagemath.org/ticket/29192
The text was updated successfully, but these errors were encountered: