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
1.99k stars 253 forks source link

Dolly behavior in first person mode is different when scrolling up and down #465

Open mrok-gmx-de opened 11 months ago

mrok-gmx-de commented 11 months ago

Describe the bug

The behavior of the mouse wheel in the first person perspective is not as the user expects, as the camera moves away from the object faster when scrolling down than it approaches when scrolling up.

To Reproduce

  1. In the Fist person example, if you set the infinity dolly propertiety checked and the wheel to DOLLY, you may notice a difference between the distance to the cube after scrolling up and down.
  2. You can test this by bringing the bottom edge of the cube to the bottom border of the window and turning the wheel up and down one or more times.

Code

No response

Live example

https://yomotsu.github.io/camera-controls/examples/first-person.html

Expected behavior

I would expect the edge to be at in the same place after turning the wheel up and down an equal number of times. The same goes to the behavior when pressing the wheel for a speed dolly.

Screenshots or Video

  1. Bevor scrolling up image
  2. After scrolling up two times image
  3. After scrolling down two times image

Device

Desktop

OS

Windows

Browser

Chrome

yomotsu commented 10 months ago

Thanks for your report. I guess I need to prepare a mouse device for reproduction.

Aside from that, the below code seems to work as expected. _zoomInternal() is used in the wheel event internally.

cameraControls._zoomInternal(10,.5,.5);
// then...
cameraControls._zoomInternal(-10,.5,.5);