yomotsu / camera-controls

A camera control for three.js, similar to THREE.OrbitControls yet supports smooth transitions and more features.

Home Page:https://yomotsu.github.io/camera-controls/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Give `setLookAt` a linear option

jamesnakagawa opened this issue · comments

Is your feature request related to a problem? Please describe.

Setting dollyToCursor=true enables an alternate mode of zooming where the camera travels in a straight line towards/away from the target. However, there is no way to do this outside of a user input event. Since I am working on an application where host and participant machines are trying to stay in sync, the participant machine cannot replicate the camera transition seen by the host.

Describe the solution you'd like

A boolean option on setLookAt or an alternative method setLookAtLinear which would move the camera in a straight line by manipulating protected members _changedDolly and _dollyControlCoord.

Describe alternatives you've considered

I've tried subclassing camera-controls and setting these myself, but since I only have the parameters given to setLookAt (the camera position and target object), it is very difficult or impossible to calculate _dollyControlCoord. It could be that the solution involves changing the update function.

Additional context

Thank you very much for this excellent library!

Thanks for using camera-controls.

the participant machine cannot replicate the camera transition seen by the host.

If you would like to do this, I think "setLookAtLinear" is not really necessary.
You can just use setLookAt with the host's cameraControls state to sync, like this example:
https://yomotsu.github.io/camera-controls/examples/path-animation.html

Also, we already have a setLookAtLinear-ish method, called "lerpLookAt".
Although you need to find the line and alpha between two points of the line start and end by yourself...

Thanks for your reply!

I will try the approach you suggested using gsap.