Zooming into mesh question

Hi, how can I get the camera to always zoom as close as possible to the mesh without the mesh being clipped off. Is there an algorithm or a function that does this?

You can set a very low value for camera.minZ, like 0.1, that’s probably your issue here.

If you use an ArcRotateCamera there a convenient camera.lowerRadiusLimit that can help you too.

1 Like

In this case, I actually want the camera to zoom in as much as possible. Right now, the camera is far away from my mesh when it loads. I want the mesh to take up as much canvas space as possible without it being clipped.

If you use arcRotateCamera, there is a zoomOn-function:

Example Code:

var myMeshes = [meshOne] // array of your meshes to fill camera view
camera.zoomOn(myMeshes, true)
3 Likes