ArcRotateCamera and setTarget with TransformNode

Hi everyone! :slight_smile:

Again a short question about camera functionality… I recently cleaned up my complex character that I imported, so the root is actually a TransformNode. I tried to set the main camera (ArcRotateCamera) to target this, with camera.setTarget(transformNode), but got the same error as in this playground (added line 81):
https://playground.babylonjs.com/#2JKA91#149

Am I doing something naughty? :sweat_smile:

As you can see in the doc, the param need to be AbstractMesh or Vector3, so you may change it like camera.setTarget(transformNode.position).

2 Likes

You can also set the target to the center of the transformnode.

const bb = transformnode.getHierarchyBoundingVectors()
camera.setTarget(bb.max.add(bb.min).divide(new Vector3(2, 2, 2)))