-
-
Notifications
You must be signed in to change notification settings - Fork 36.1k
OrbitControl: Allow camera.up to be modified at any time.
#18829
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
Conversation
| // so camera.up is the orbit axis | ||
| var quat = new Quaternion().setFromUnitVectors( object.up, new Vector3( 0, 1, 0 ) ); | ||
| var quatInverse = quat.clone().inverse(); | ||
| var originalUp = new Vector3( 0, 1, 0 ); |
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.
Does this value need to be the current default up (static property) of Object3D, whatever it is at any time? Or just the default up that THREE ships with by default?
|
Relevant #17857 (comment) My original PR for merging trackball and orbit controls also supported this featured. Perhaps we could consider using that implementation when or if we decide to merge the controls into a single file. /ping @mrdoob Is the process of stopping support for |
|
I could benefit from this change. If someone can resolve the conflicts and merge it, that would be awesome!! For my use case, see: https://stackoverflow.com/questions/68061129/how-to-change-the-up-direction-on-the-fly-when-using-orbitcontrols-in-three-js I actually tried this out locally, and found that there were changes such as switching from "var" to "const" and "invert" versus "inverse" that probably resulted in the merge conflicts. I ended up implementing something slightly different, and maybe better... |
camera.up to be modified at any time.
Fix `invert()` usage.
|
To clarify this is the issue the PR tries to fix: https://jsfiddle.net/268unfyj/ The fiddle changes the camera's up vector to Here is a version of the fiddle that uses an embedded version of This version indeed retains the interaction. The following should be mentioned though: When the up vector is updated, the camera is transformed in the next update step to accommodate the new convention. This sudden "jump" could be considered as a bug but there is no way around it when the up vector changes and the controls rely on |
|
@WestLangley Do you see any fundamental issues with this PR? |
Actually, this PR falls well-short of his specification:
This PR is not going to do that. @Mugen87 wrote:
I agree completely. The behavior is also disconcerting IMO, especially when damping is enabled. I do not see a compelling use case or demand for this PR as implemented. I expect a more natural implementation can be handled at the application level -- via two cameras, for example. And, of course, the developer can always hack his own copy of |
|
I fixed this in my own branch of OrbitControls a long time ago. The change I made works quite well. You can see the code I'm using here. I did this around two years ago so it might be easier to diff it against an older version of the Orbit Controls code. I think that I added an "upDirection" parameter and only a few lines of code were needed. I haven't seen any negative side effects from this change. If you want to see it in action, there is an old version released here if you just want a quick preview. You can also sync up the whole project. There's a video on how to do that here. Or, you can just follow the directions in the Readme, and then read the directions in the "help" section of the GUI. Search for |
|
The link back to my original StackOverflow question. |
The allows us to do
camera.up = new Vector3(...)any time. Before, it could only be done one time before creating OrbitControls.I'm not sure if there are any functional side-effects, or if it even works. I haven't tested it yet, but the main idea is that I wanted to try to set
camera.upat some point after OrbitControls already exist, and found that it didn't do anything.Also, if this does work, do I need to edit both OrbitControls files? Or does one get generated from the other?