Rotating a FreeCamera around a point in space programatically

Hi again! :slight_smile:

I’d very much like to rotate my FreeCamera (not ArcRotateCamera) around a point in space programatically, so in scene.beforeRender, not using an animation.

Let’s say the point is 0, 0, 0 and the camera is at position 0, 50, -55.

Anybody willing to help me out with the math please?

camera.setTarget(Vector3.Zero());
scene.onBeforeRenderObservable.add(() => {
    // pls mr.camera rotate around the target >:(
});

Thanks and much love!

Genius, a literal god, magnificent.

Thanks a lot! Works perfectly :slight_smile:

1 Like

Hmmmm, what if I wanted to rotate the camera around a different point other than 0, 0, 0?

Thanks! Now it all works :slight_smile:

Was this ever solved?

Here’s a simple example rotating around zero: Camera rotating around target | Babylon.js Playground (babylonjs.com)