camera-controls icon indicating copy to clipboard operation
camera-controls copied to clipboard

Strange behavior of dolly to cursor zoom out

Open fukuken1968 opened this issue 3 years ago • 4 comments

Describe the bug

see the attached screenshot

To Reproduce

Steps to reproduce the behavior:

  1. check 'dolly to cursor'
  2. rotate the mouse wheel (repeat increasing and decreasing)
  3. 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]

fukuken1968 avatar Jan 23 '22 07:01 fukuken1968

Thanks for your report. Reproduced. It seems only happens if the camera is facing every 90deg (front, side, and so on)

yomotsu avatar Jan 23 '22 13:01 yomotsu

I have the same problem.

blksky avatar Jul 22 '22 08:07 blksky

I assume that the camera position is moving and the camera far frustum is clipping the scene.

msemtd avatar Jul 22 '22 08:07 msemtd

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...

yomotsu avatar Jul 23 '22 00:07 yomotsu

Is there a solution?

blksky avatar Oct 24 '22 11:10 blksky

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.

yomotsu avatar Oct 28 '22 15:10 yomotsu

I think this problem has finally been fixed at https://github.com/yomotsu/camera-controls/pull/322

yomotsu avatar Nov 20 '22 04:11 yomotsu