yomotsu / camera-controls

A camera control for three.js, similar to THREE.OrbitControls yet supports smooth transitions and more features.
https://yomotsu.github.io/camera-controls/
MIT License
2.02k stars 255 forks source link

moveTo moves to an incorrect position after dolly #540

Open jcheese1 opened 1 month ago

jcheese1 commented 1 month ago

Describe the bug

moveTo moves to an incorrect position after dolly. please see the attached video.

To Reproduce

Steps to reproduce the behavior:

  1. Go to https://yomotsu.github.io/camera-controls/examples/basic.html
  2. Click on moveTo (3,5,2). Correctly moves to the right position.
  3. Now click on Reset and click on dolly -1 a few times, and click on moveTo (3,5,2) again. the z position is not correct.

Code

No response

Live example

No response

Expected behavior

Properly moves to the vector defined in moveTo regardless of dolly position.

Screenshots or Video

https://github.com/user-attachments/assets/6b7ca49c-d12b-4c6c-9eed-bc952e76aa96

Device

Desktop

OS

MacOS

Browser

Chrome

yomotsu commented 1 month ago

Thank you for your report. I have checked it, and everything seems correct. The moveTo() function adjusts the center position, while the dolly() function changes the distance to the center.

Please try using console.log(cameraControls.getTarget()) after calling moveTo(). It should return the correct position.

jcheese1 commented 1 month ago

@yomotsu thank you for checking!

The moveTo() function adjusts the center position, while the dolly() function changes the distance to the center.

did not know this, thank you. Is there a way to make it move to moveTo (3,5,2) no matter where you dolly?

yomotsu commented 1 month ago

I think you can simply call dollyTo( 0 ) at the same time

jcheese1 commented 1 month ago

@yomotsu I can, but the transition is not smooth. I want a smooth transition from the current dolly position to moveTo (3,5,2) if that is possible?