Camera target should zoom

This app has dynamic models being loaded in from a server, because none of the models have pivot points that are centered(object is slighty to the right, and pivot point is world center etc), I have to set the pivot point at runtime.

Anyhow when i set target on my object, the camera looks really zoomed out on certain models but not others, especially tiny ones

I used this code to center the pivot point and then i set target:

I have demo for you. :slight_smile:

camera.useFramingBehavior = true;
you can also set target to be the mesh itself.

If you look in some of our camera behaviors you have lots of other options

1 Like

unfortunately does not work for me, no framing occurs, and the camera is just standing still, same as the screenshot

and i also set target to the mesh

This is how the models look in blender, the pivot is off center so i center it at runtime and then try to set target but the camera appears too far away for SOME models that are smaller than others

This is a comparison of a small model and a big model, usually i only load one

How about something like this

You will need to have an ArcRotateCamera instead of the default camera you were using. (line 5)

Also important to note. You can have the framing behavior be around the node itself or the sphere. I’m assuming the sphere is your center point? If I set target to the sphere however it will zoom too far in. So either need to calculate some kind of offset or just use the set target to the larger model.

1 Like

Thanks this was what I needed. FramingBehaviour.

I ended up using camera.framingBehavior.zoomOnMeshesHierarchy(meshes) after the above code