#Cool Community how to calculate the zoom to fit object into the screen in Orthographic Camera

2 messages · Page 1 of 1 (latest)

uneven siren
#

Hello Coolest Community, how to calculate the zoom to fit my object into the screen height in Orthographic Camera. Dose anyone have any Idea could not fined anything

median crown
#

stackoverflow has some bits https://stackoverflow.com/questions/31978368/three-js-fit-orthographic-camera-to-scene but it's never generic, i've searched weeks through discourse, stackoverflow, there is no one suits all solution, none of these even anticipate that you may have controls, they don't animate, etc

the only exception is react, if that's an option this will work with any camera, as well as your controls: https://github.com/pmndrs/drei#bounds

you can see it working here: https://codesandbox.io/s/rz2g0

Combining TransformControls, OrbitControls and Valtio.

GitHub

🥉 useful helpers for react-three-fiber. Contribute to pmndrs/drei development by creating an account on GitHub.