-
-
Notifications
You must be signed in to change notification settings - Fork 35.3k
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
Ability to set OrbitControls different camera.lookAt vs controls.target #18476
Comments
To keep
Have you considered to use |
@kmturley Do you mean something like this target/pivot OrbitControls Example ? The main difference in this version is that I've decoupled I agree with @Mugen87, that perhaps this doesn't fit in the default /js/controls/OrbitControls - non-module |
@Mugen87 I tried using Transform controls, but couldn't get a good working version. Although I found out I could fake the effect need by moving the sphere to the scene 0,0,0, it doesn't stop the Y axis rotation issue where the camera goes inside an object, I could lock the Y axis to prevent this. @sciecode That's exactly the functionality needed. I created a demo here showing the camera pointing at the north pole of a globe (but the camera rotates around the globe normally): I exposed the pan() function so pan could also be set programmatically:
Then setting the pan after the controls init using:
Ideally it would inherit the camera.lookAt setting like this:
Is that possible? |
No need for it. You may set
As we said previously, it's unlikely this feature will get implemented in the default But if we choose to do it, my implementation definitely won't make to the final PR, as I modified some core mechanics to account for your use-case. However, given that enough support is given for adding the feature, I'll gladly adapt it to work correctly with our current implementation. |
@sciecode after testing side-by-side your version doesn't exactly function how I expected. The horizontal orbit is correct, but the vertical rotation is off: If you rotate your version vertically the globe still pivots around the control target: In my manual object spinning implementation the globe pivots around it's center: I created a third version using TransformControls: This is the previous functionality: When you moved the pan/target you get this: Your version does this (which is better): But when rotating the vertical rotation it looks like this: I guess this could be accomplished by moving the target as the object is rotated |
I managed to replicate the functionality (another way) by modifying the TransformControls library to include:
TransformControls.js line 69
line 128:
line 255:
line 523: line 724:
line 644:
line 1178:
Demo here: |
Your suggested workaround using TransformControls works, Thankyou!
|
hello,it doesn't work , |
@liangyuqi These examples are one year old. Three.js source code has since changed. |
Feature request
OrbitControls allows us to quickly implement a rotating camera around a scene. But many people actually use it for rotating an object. There are use cases where you don't always want your camera viewport to look directly at the controls rotation target.
Consider the SketchFab object viewer for example:
https://sketchfab.com/3d-models/the-whole-world-712c2de7426f4eb59aa101d21cd72492
When you rotate an object with the camera zoomed out, all functions well:
You can zoom and pan to focus the camera on the poles using Shift-Mouse-drag:
But now when you continue to rotate around the globe, you suddenly start seeing inside the object and strange angles (because the rotation target is not the center of the globe anymore):
1) Allow camera.lookAt to be offset from controls.target
Now I understand it's intended functionality for OrbitControls to keep the camera looking at the target as it's primarily for orbiting a scene not an object, but wondering if it's possible to support more customization of the controls target vs camera lookAt functionality? currently when using OrbitControls the camera.lookAt function is effectively disabled.
2) Create ObjectControls for exploring/panning individual objects
Or if you would consider a new ObjectControls template which rotates the object smoothly instead of the camera? allowing for movement of the camera independently from the object rotation? since many people are using OrbitControls to imitate rotating an object rather than a scene anyway? There is an example someone has created here:
http://benchung.com/smooth-mouse-rotation-three-js/
Your default jsfiddle actually shows this problem very well (Try panning using Shift-Mouse-drag):
https://jsfiddle.net/hyok6tvj/
Other people have asked for a solution to this use case here:
https://stackoverflow.com/questions/34526500/threejs-orbitcontrol-with-different-rotate-center-and-lookat-point
Three.js version
Browser
OS
Hardware Requirements (graphics card, VR Device, ...)
None
The text was updated successfully, but these errors were encountered: