O
O
Oleg Ulyanov2017-01-10 17:19:39
3D
Oleg Ulyanov, 2017-01-10 17:19:39

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

1 answer(s)
G
GreatRash, 2017-01-10
@gelosoft

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 question

Ask a Question

731 491 924 answers to any question