Toggle between Perspective and Orthographic camera #598
-
I created a toggle function that sets controls.camera to my perspectiveCamera or to my orthographicCamera. I start with my perspectiveCamera (which works fine) and switch to my orthographicCamera. I have some logic to match the position and rotation. My code works perfectly, execpt the zooming part. I know, that the perspective camera uses dolly zoom, meaning the fov stays constant while the camera distance from the target is adjusted. Zooming out means moving the camera away. For the orthographic camera, zooming is just a number that is multiplied to the frustum. Hence, when I do PS: Using two camera-controls instances will not work for me, because I need to be able to switch the camera, while the user has already started dragging inside the viewport. Replacing the camera-controls instance will lead to loosing this drag. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Just want to share the fix that I figured out :D At the end of my switchToOrthographicCamera function I do this:
At the end of my switchToPerspectiveCamera function I do this:
|
Beta Was this translation helpful? Give feedback.
Just want to share the fix that I figured out :D
At the end of my switchToOrthographicCamera function I do this:
At the end of my switchToPerspectiveCamera function I do this: