Framing object in orbit camera [SOLVED]

Good afternoon guys,

I have an orbit-camera Script retrieve from the Playcanvas itself. Now how can i set the zoom of the camera so that the model focused dont overflow the screen nor be too small?

Which orbit camera script are you using? The one from the Model Viewer template?

Do you want the zoom level to be set on start or to stop the user from zooming too far in/out?

I’m using the script of model viewer and i want the zoom on start

There’s a tick box that attempts to frame it on start which uses the AABB bounding box of the mesh(s).

image

You can also choose to have it focused/framed on a specific entity rather than the whole scene by using the attribute above it (Focus Entity).

If that’s not working well for you, then you can untick the “Frame on Start” box and it will use the distance from the camera to the entity(s) as the initial distance so you can frame it manually.

Thank you for your help. I’ve put the entity directly into the focus method of the script and worked, because my application dynamically loads the 3D model.

Ah, I see. In which case, there is a function that you can call to frame the camera on an entity (I can’t remember what it is offhand but you should be able to find it in the script easily) after the model has loaded.