Rotate Camera around Mesh without moving Camera Position

Hi,

I am currently looking for a solution to rotate a camera around a mesh without moving the camera position. I found a similar question but without a solution. What I am looking for is like in this post: How do I make the camera rotate around the clicked model? - Questions - Babylon.js.

I am selecting a mesh on click and set it as lockedTarget because I want the rotation point of the camera to be around the mesh. After that Babylon moves the lockedTarget to the center of the camera. How is it possible to stop Babylon from moving the camera?
This is my current playground I am working on. https://playground.babylonjs.com/#G2F8LN#116

You can frame the object without moving the camera by calling setTarget.

https://playground.babylonjs.com/#G2F8LN#119

Thank you for your response. In your example, the camera (or the mesh) is still jumping around on pick event. My goal is to stop it from doing that.

The camera is panned when setting a new target in order to keep alpha/beta angles. But it’s possible to compute that pan vector and change the camera position accordingly.

https://playground.babylonjs.com/#G2F8LN#121

Or simpler, copy the camera position, set the target and reset the camera position

https://playground.babylonjs.com/#G2F8LN#122

I understand how it should work, also setting the camera position to the old position is giving me the right results in console. But the camera is still moving. In both examples the camera is still moving around.

Not sure to understand. you want the camera to ‘look at’ another mesh without changing target ?

something like this? https://www.babylonjs-playground.com/#BBMK96#4
press control and then double click on one of the spheres

My goal is to change the target on click. Now when I click i dont want the mesh or camera to move. Everything should stay exactly the same (angle, rotation etc.).

I have added an example video below.

ok, then you need a pivot.

I came across it before, but I thought that you cant rotate the meshes on camera input. Do I need to create my own click and drag events? Or how can I set a pivot and then rotate with click input (like normal camera rotation).