-
Notifications
You must be signed in to change notification settings - Fork 181
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
Allow three degrees of freedom in viewing a 3D object #615
Comments
Thank you very much for suggesting this feature. Actually, it is already implemented and just has to be integrated into the code. My plan is to do it this week, before releasing the next version. However, for comparison, I encourage you to send a pull request, too. In the 1990s, the site of David Joyce was the inspiration for me to start working on displaying math in the web browser. |
Well, we had not yet really gotten into the code; we are just looking for a starting point where we could begin to contribute and to get to know the code, and wanted to make sure our efforts would be welcome. We hadn't really started on implementing a third degree of freedom in orientation. If you are close on this feature, perhaps we should begin with an independent item where we can contribute without duplicating effort. I will open a new issue for the next item on our list of features needed to re-enable Joyce's constructions, to get your feedback. (We already have a development browser extension that uses GeoGebra to revive all of Joyce's pages; you can send me a personal communication if you are interested in trying it. But GeoGebra is impossible to package into a published extension, because of how it's delivered, which is why we need to switch to your much lighter-weight package. Thanks for creating JSXGraph.) |
It is good that we waste efforts to simultaeously do the same thing. Let's go for the Sphere3D! |
Done with v1.8.0 |
Ooh, I was all excited to see it in action, but as you likely know even though the API reference now says v1.8.0, the examples are still running off of https://jsxgraph.org/docs/static/jsxgraphcore.js which is still v1.7.0. |
I'm pretty sure that this is a browser cache issue. |
Ah, right, because the file name of the javascript file isn't changing when you update versions. |
However, I am pretty sure there are still only two degrees of freedom in manipulating the view: as far as I can tell, when the x-axis is pointing straight at you, the z-axis must be pointing straight up; there doesn't seem to be any way to "roll" the view so that the z-axis is horizontal to the left and the y-axis is straight up, for example (with the x-axis still straight at you). We would be happy to investigate adding the third degree of freedom into the manipulation of the view. If that's of interest to you, please do feel free to reopen this issue. |
You are completely right. So long we only addressed the part related to "free" dragging. However, I don't understand your suggestion above to include the missing rotation in the
|
The reason that there are only two degrees of freedom available with the current drag interface is that the current interpretation of a drag is always vertical motion <-> elevation and horizontal motion <-> azimuth. If on the other hand you interpret any drag "naturally" as rotating an imaginary marble that you have grabbed at your down click point so that the corresponding point on the marble moves as close to your drag destination as possible, you now have access to all the rotations you need to achieve any orientation (although not in a single drag, since any one drag only has two degrees of freedom; we are implicitly using the noncommutativity of It might be wisest to go in two steps: first add a "roll" slider on the right in addition to the existing elevation and azimuth sliders, which would work independently of the existing sliders and current dragging behavior; then in a second PR change (or add an option to change) the dragging behavior. Let us know what makes sense to you. Thanks! |
Now I understand! I browsed through the literature and found essentially these algorithms:
Nowadays, this handling of 3D scenes is mostly called virtual trackball. What algorithm do you suggest Hanson, Shoemake or Bell? Should I add it or do you want to do it? One more question: In v1.8.0 we quietly added central projection as an option (We did not announce it because 3D point dragging is not yet implemented for this option). What kind of 3 degree of freedom handling do you suggest for central projection? |
Since the view3D event handling needs some refactoring to implement the 3 degrees of freedom, I will do it this week. |
The one I'll recommend in the next comment isn't one of the four you mentioned. I see it as a descendant of Shoemake's ARCBALL. For anyone following along, here are references for the rotation interfaces that @alfredwassermann mentioned, and some quick descriptive notes. I found the references in:
Method references and notesHanson's rolling-ball method"The Rolling Ball" (in Graphics Gems III)
Chen's Virtual Sphere controller"A study in interactive 3-D rotation using 2-D control devices", with a correction in "Virtual trackballs revisited"
Shoemake's ARCBALL"ARCBALL: A User Interface for Specifying Three-Dimensional Orientation Using a Mouse"
Bell's trackballDescribed second-hand in "Virtual trackballs revisited"
|
I'm pretty happy with the rotation interface I used in these slides. It's used with central projection there, but it should work with parallel projection too. Here's how it works.
I think of this as an infinitesimal version of Shoemake's ARCBALL. Every time a "mouse moved" event fires, you use ARCBALL to move the grabbed point from the last cursor position to the current one. |
Thanks a lot! However, in the above example sometimes the object (sculpture) is rotated, sometimes the viewport is rotated. Meanwhile, I made some progress with Bell's virtual trackball. Here is an example. Please, tell me your opinion! So far it only works for parallel projection, but this is just a matter of code organization. For people coming here later: that test site might be unavailable in a few weeks from now. |
Do you mean that the sculpture sometimes rotates in the opposite direction from what you expect? In this implementation, the only thing you can grab is the pink cubical cage that bounds the sculpture (which should become visible when you mouse over). If you grab a cage edge on the far side of the sculpture, the rotation could be confusing if you think you're grabbing the visible face of the sculpture. This behavior could be changed with some work. I just didn't have time to change it, and I wasn't confident that any of the alternatives I had in mind would actually be better.
Whoa, this is really cool! The model doesn't rotate the way I expect, but I can't tell whether the problem is in my expectations or in the way the code runs on my browser. If I load the page, click with my cursor over the center of the sphere, and drag toward the bottom of the screen, what rotation should I see? I expect the model to rotate along a great circle perpendicular to the screen, but it instead seems to rotate along the 0 meridian (drawn in blue stroke color). |
You are right, it does not yet do exactly what the user expects. Here is an example which I would like to have... |
I agree, that example of mouse rotation interface is quite intuitive and allows all three degrees of freedom. Another tiny issue with the demo you put up (https://jsxgraph.uni-bayreuth.de/~alfred/jsxdev/3D/drag.html) is that if my click happens to lie directly atop the displayed axes, then the drag does nothing; the orientation of the display remains fixed. I understand that it this gesture may be interpreted as my trying to change the position of something that is fixed, but still it feels inconsistent with the fact that if I drag starting just a tiny bit off the axis, then the display does rotate. Just my two cents and please let us know if you would like any other concrete support from me and @Vectornaut on this subproject. Thanks! |
I also impulsively dragged over the displayed axis, and was momentarily confused when it didn't work. One way to avoid this might be to give the View3D box specific handles (draggable points or lines), like other objects have. Dragging the handles could rotate the View3D around its center. This could be combined with any virtual trackball method; the handles would just control where you can initially grab the trackball. I like the idea of making the corners of the box draggable. Since the view box clips most objects, this should ensure that there are always one or two handles visible, away from other objects. |
Now, dragging over the axis works. It is a good suggestion to add 3D handles. This is a job for our student's project in this summer term. |
Indeed. Now really the only hitch is that the direction the visualization rotates does not visually match the direction the mouse pointer is moving on screen, making it a bit challenging to navigate to a desired orientation... |
Would it be useful for me to work on the virtual trackball next week? I'm in a good position to do this, because I've been studying the View3D internals for an upcoming pull request. I don't want to duplicate the summer student's effort, though. |
Yes. This would be very helpful! |
Awesome—I'll put the virtual trackball on my to-do list. |
Currently, a View3D allows the view azimuth and elevation to be controlled, but there does not appear to be a way to "roll" the view. We are considering using JSXGraph to revive the interactive diagrams in David Joyce's online Euclid's Elements (see https://mathcs.clarku.edu/~djoyce/java/elements/elements.html). In some of the 3D constructions, it is very useful to have full freedom in orienting the diagram, to help understand what is going one. Therefore, we would propose to allow all degrees of freedom in orienting the view of a View3D object, and would like to know if that enhancement would be a change that the maintainers of JSXGraph would perceive favorably.
If so, we are certainly willing to propose pull requests to implement such a feature. One approach would be to address #573 simultaneously: one natural interpretation of arbitrary drag events (on the "background" of a View3D object) would often include a "roll" component in the implied transformation to the 3D coordinates. So by allowing arbitrary background drags and interpreting them in this way, it would be possible to rotate the 3D view into an arbitrary orientation (possibly needing multiple drags to achieve an exact desired orientation).
The text was updated successfully, but these errors were encountered: