ArcRotate camera won't change targets

Can someone please tell me how to change the target on an ArcRotateCamera because what I am doing has zero effect.

Here I create a camera pointed at the center of a mesh I have created:
var camera = new BABYLON.ArcRotateCamera(“camera1”, 0, 0.8, 10, new BABYLON.Vector3(0, 4.5, -10), scene);
camera.zoomToMouseLocation = true;
camera.setTarget(new BABYLON.Vector3(0, 4.5, 10));
camera.attachControl(true);

When the mesh changes, defined by variables width, height and length, I want to change the target to the new center of the mesh.

So I do this:
camera.setTarget(new BABYLON.Vector3(0, height/2, length/2));

Nothing changes.

Am I missing something?

after 2 seconds the target of the camera is changed to the next sphere

camera.setTarget(mesh.getAbsolutePosition())

Thanks but that’s not what I need. That’s is for a target camera that is locked on a mesh. I need to target an ArcRotateCamera to a point. My mesh doesn’t move. It just changes size. I want to target the point at the center of the mesh, not the mesh itself.

Use the bounding sphere world center of the mesh like in this example :

435435 | Babylon.js Playground (babylonjs.com)

1 Like

Thank you @Cedric that works perfectly!

1 Like