Arc Rotate Camera - Focus on Select Mesh

Hi,
I am trying to focus my camera on the selected mesh. I want to achieve this by animating the camera from its current position to the position of the selected mesh. After the animation, the mesh should be facing the camera such that it becomes the point of pivot. Not only should the camera move longitudinally and latitudinally but also zoom in / out based on the position of the mesh. I tried a bunch of functions but was unable to achieve this effect. If anyone has worked on something similar to this or have an idea as to how to do it, please share. Thanks in advance.

The basis is setTarget to selected mesh for the camera in question? And you want to set/preserve the radius of the camera and adjust it’s rotation based on the mesh’s facing?

1 Like

The camera should be facing the picked mesh. The radius and the rotation may change as per the positioning of the mesh. For example, in case of a car if I pick the tyre then the camera should move towards the tyre such that the tyre appears to be at the center of the screen (becoming the point of pivot).

Would it not be what lockedTarget is for ?

Thank you, everyone, for giving valuable suggestions and answers. I found this example and it is somewhat close to what I want to achieve. I am sharing the example so that others who are facing a similar problem can get an idea of how to tackle their problem.

https://www.babylonjs-playground.com/#7B4S6A#1

3 Likes