Hi everyone,
I have a piece of code that calculate the bounding box of a 3D object that has multiple child meshes, and use camera framing behaviour to fit the 3D object in camera viewport.
Most time it works perfectly. However I noticed if the 3D object is very tall, on a landscape viewport the top/bottom will be cut off.
I have setup this playground so you can check the issue by changing preview screen size.
I also have following screenshots for reference:
Landscape viewport
You can see the top/bottom is slightly cut off.
Portrait viewport
You can see the whole object fits into viewport with padding around, which is the ideal result I want.
At first I thought it’s line 116: camera.upperRadiusLimit = bbBoxLongestSide * 5
that sets a small upperRadiusLimit that prevent camera from zooming out. However even I changed the upperRadiusLimit to a huge number, it still can’t fit the whole object into landscape viewport .
I wonder if anyone knows how to resolve this issue?
Updates
Thanks for the help! Here’s working playground:
I used zoomOnMeshHierarchy
as suggested, it’s working great now