Answer the question
In order to leave comments, you need to log in
How to position the camera to fit the entire mesh into it?
There is a sphere in the center of the scene. And there is a camera (for example FreeCamera in babylon.js). It is necessary that the camera (it is on the z axis) is positioned so that the sphere fits entirely into the screen (it can be either landscape or portrait, of different proportions). It is desirable that this also work when resizing the window.
Those. we need some analogue of background-size: contain from css for the camera/scene.
Answer the question
In order to leave comments, you need to log in
Terminology:
FOV - field of view (field of view of the camera)
BB - bounding box (bounding box)
BB-size - the largest size of the bounding box (if the width is greater, then the width, if the height, then the height)
Dist - the distance from the BB at which stay camera
Formula:
Dist = (BB-size / 2) / tan(FOV)
Copyright & further reading
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question