I recently created a PR for this feature because it’s been really helpful while I’ve been working on my code. The zoomOnBoundingsInfo function is great for framing a mesh, but I noticed it relies on the bounding sphere to calculate the camera distance, which can cause issues with meshes that are particularly deep.
To fix this, I added an option to choose how the distance is calculated — either using the bounding sphere or the bounding box. I also needed it to work with orthographic cameras, so I implemented a similar setup for that as well. On top of that, I added a way to set an offset on the radius so the mesh doesn’t align exactly with the window edges when displayed.
This is a tool we use internally, but I thought it might be useful to share it with the community too. I opened this topic to make communication easier instead of going through GitHub. I’ve closed my PR for now, so I’ll just refer to #17329, which was reviewed by @georgie from the Babylon.js team.
hey @PietroFurlan would you mind creating a playground that displays the issue you mention with a deep mesh + using bounding sphere for zoomto? that way i can test the new boundingbox logic again in the current draft PR with your changes and understand the usecase of the new feature? thank you!
also is the orthographic framing logic in your most recent commit the correct logic, or should we go with the original (where sphere/boundingbox use different logic)
I’ve been testing a new ArcRotateCamera control that zooms fov instead of radius.
Here’s a work in progress that shows a zoom in to a sphere. Instead of “zooming into” the sphere and past its surface, it continues to zoom to show the surface in more detail. Demo zoom is visually limited by texture size. What is drawn is symbolic of dynamic loading of “tiles” (though I’m not actually loading images yet).
Hi, this is a playground on your PR, you can play with the box dimentions to verify any scenario.
I left the rasiusScale parameter to 1.2 to show the error when switching to orthografic camera.
The right logic is the one i posted on your PR in git