PaulHax / spin-controls

Arcball style controls for three.js Object3Ds and Cameras. Featuring pointer to trackball accuracy and unlimited rotation.
https://paulhax.github.io/spin-controls/
MIT License
78 stars 12 forks source link

Lock a rotation axis #14

Closed cederache closed 3 years ago

cederache commented 3 years ago

Hi, I'm using your script (CameraSpinControls) and I wonder if this could be possible to lock an axis of the camera rotation.

To explain the use I have, I'm trying to rotate around a 3D model like that :

Capture d’écran 2021-05-27 à 16 27 41

But, I can't figure how to lock the camera front vector (kinda like the OrbitControls from three.js) and when I'm rotating around my model, the camera is a bit messed up :

Capture d’écran 2021-05-27 à 16 29 22

What I'm trying to have is an OrbitControls behavior with the ability to set a different pivot point than the center (target).

Thanks in advance.

PaulHax commented 3 years ago

Hello there,

The messed up camera orientation is a feature of the "trackball" control style implemented by Spin Controls. Trackball controls are handy when we need to roll the camera/object. But yeah, most applications should use the more constrained, orbit style controls.

Perhaps stick with three.js' OrbitControls and modify it a little? Put a rotation between orbitControls.object and the actual camera: target -> object -> { rotation captured when target/pivot set } -> camera

cederache commented 3 years ago

Thanks for your response. I found another threeJS controller that allow me to set a pivot point with an OrbitControls style : https://github.com/yomotsu/camera-controls

I'm closing this issue since the non lock is a feature of the "trackball" control style.

maronin commented 3 years ago

Thanks for your response. I found another threeJS controller that allow me to set a pivot point with an OrbitControls style : https://github.com/yomotsu/camera-controls

I'm closing this issue since the non lock is a feature of the "trackball" control style.

Thank you for linking this repo, this is exactly what I was looking for. However, I can't figure out how to set the pivot point with this controller when using the mouse to rotate. How did you end up doing this?

PaulHax commented 3 years ago

@maronin camera-controls https://yomotsu.github.io/camera-controls/examples/focal-offset.html example seems to be what your after.

maronin commented 3 years ago

@maronin camera-controls https://yomotsu.github.io/camera-controls/examples/focal-offset.html example seems to be what your after.

Yeah I actually stumbled upon that and found this discussion: https://github.com/yomotsu/camera-controls/issues/130

I am basically looking for exactly what nikhilxb described with the skeleton example in that issue.

Seems like there is currently no complete solution to this and the last activity was on June 8th 2021...

I've searched the internet for a while and this is as close as I got to what I am looking for in terms of camera controls.

cederache commented 3 years ago

Thanks for your response. I found another threeJS controller that allow me to set a pivot point with an OrbitControls style : https://github.com/yomotsu/camera-controls I'm closing this issue since the non lock is a feature of the "trackball" control style.

Thank you for linking this repo, this is exactly what I was looking for. However, I can't figure out how to set the pivot point with this controller when using the mouse to rotate. How did you end up doing this?

I ended up changing the UX of my 3D viewer. We will not use the focal offset and we will keep the pivot point in the center of the viewer. Instead, we will add the possibility to double clic to zoom and center on the intersect point of the click (like potree : http://potree.org/potree/examples/viewer.html)