ArcRotateCamera.zoomOn is not working as expected.
If I have a large viewport, I see that there is still a bit more to be zoomed there.
If I reduce the viewport, and call the function again, nothing updates and the object doesn’t fit.
I want to use this to automatically zoom the camera in the initial load to fit the viewport.
zoomOn function places the cameras so the distance to the bounding box center of the mesh is large enough to not have the camera in the bounding box.
to make it short, it places the camera, so it’s far enough of the bounding box.
It doesn’t take into account the projected bounding box, the camera fov or the viewport size.
Thanks for letting me know about that.
In that case, if I want to zoom in/out automatically the camera to fit the current viewing bounding box, what could I do?
Do I have to manually calculate the ArcRotateCamera’s alpha, beta, radius?
alpha/beta can be updated just by setting the target (center of bounding box).
The real deal is to set the distance to the center that will give the projected bounding box to be entierly framed by the viewport.
as usual depending on the quality, this will need some work.
if you assume the bounding sphere is enough, then you can compute the distance so the projected disk is framed by the viewport.
for the viewport, you only need the ratio width/height I think. the closer to 1, the more you can zoom.
and use the fov value from the camera aswell.
And calculated the hfov and vfov from dfov and based on that, I calculated the radius.
Is this the right choice?
It seems working but still shows some paddings.