ArcRotate camera zoomOn not working as expected

I’m still seeing an issue with zoomOn using the ArcRotateCamera with multiple meshes. The meshes I’m using have a wider aspect ratio than the viewport and zoomOn clips them outside the viewport.

Here is a repro with two meshes (using 5.51.0):

So I did see that part of it was clipped on the left side though I haven’t had a chance to fully figure out why, I’ll update when I have something.

This would be nice I also have the issue when the camera is not exact in front/left/right of the scene the zoom is too close: https://playground.babylonjs.com/#W3D1GK#10

Thanks for looking at this so quickly. The other important part that I didn’t call out is (as with the comment from @Pe443) this only happens when the position camera is not a normal to one of the bounding box planes. I haven’t looked at the zoomOn code but it seems like maybe it is not taking into account the projection of the bounding box when the camera is at an angle. In my repro playground the camera alpha is BABYLON.Tools.ToRadians(235) and beta is BABYLON.Tools.ToRadians(55).

Just wondering if there has been any work on this bug? Thanks!

@PolygonalSun can you have a quick look ?

Yeah, I’ll take a look as soon as I can.

1 Like

So all calculations for the zoomOn function are done with respect to where all meshes’ bounding box points are, in world space. In some scenarios, or at least from some angles, the farthest points chosen may be the same distance from the center as other points but won’t end up being considered. The solution for this is a bit tricky because what would need to be done is to check if there are any points, for all provided meshes, that reside outside of the camera’s frustum. Right now, I’m trying to implement a performant way to find if any of these points exist and adjust how the zoomOn function calculates things.

I’ve merged a fix for it that should make it behavior more like FramingBehavior: github.com/BabylonJS/Babylon.js/pull/14387

3 Likes