camera-controls
camera-controls copied to clipboard
Strange behavior of dolly to cursor zoom out
Describe the bug
see the attached screenshot
To Reproduce
Steps to reproduce the behavior:
- check 'dolly to cursor'
- rotate the mouse wheel (repeat increasing and decreasing)
- drawing disappears at a certain timing
Code
Live example
https://yomotsu.github.io/camera-controls/examples/orthographic.html
Expected behavior
Do not disappear even if zoom out in dolly to cursor mode.
Screenshots or Video
Platform:
- Device: [Desktop]
- OS: [Windows]
- Browser: [Chrome]
Thanks for your report. Reproduced. It seems only happens if the camera is facing every 90deg (front, side, and so on)
I have the same problem.
I assume that the camera position is moving and the camera far frustum is clipping the scene.
I guess the cause of the problem is here: https://github.com/yomotsu/camera-controls/blob/c35908d208fe0d695ec7d9aa5de8ee247dc3b611/src/CameraControls.ts#L2240-L2241
If the camera is facing the front (or every 90degs), then the divisor
above will be 0
, then causes unexpected behavior.
We should re-consider zoom-to-cursor (not dolly) in orthographic calculation...
Is there a solution?
Unfortunately, this is quite complex. Actually, zoom-to-cursor in orthographic behaves as dolly, as a result, the camera moves out of the clipping plane. Users should not use zoom-to-cursor in orthographic😢 OrthographicCamera must not dolly and should use zoom instead correctly.
I think this problem has finally been fixed at https://github.com/yomotsu/camera-controls/pull/322