Hi~
I want to add a function to switch camera between perspective and orthographic, I need to correctly set orthoLRTB to keep camera looks like in same position and distance. I have tried this pg (https://playground.babylonjs.com/#QN0D08#1), I am not sure if it’s right.
The current switch is instantaneous. Is there a gradual way to transition from perspective to ortho?
Orthographic mode is basically just fov = 0
so what you want is to transition fov from whatever it is right now to 0
but changing fov causes a zooming effect so you also have to move the camera back to keep the frame constant.
But if you actually transition to fov = 0, your camera will need to be at inifinity distance.
so what we actually do is.
- transition fov to near 0 (say 0.001)
- then change to ortho view
I asked chatgpt to implement this and it did a pretty good job, here’s the PG
Press “t” to transition
(you’ll prolly need to save some of your initial camera params to do the reverse transition)
Thank you! It is pretty good job! ![]()