How to setup camera from a view matrix

I am working on a project where we are using OpenCV to compute a pose. From the pose we get in OpenCV have I created the view matrix. I would now like to use add some 3D model(s) in BabylonJS but are a bit lost on how I can setup a camera from a view matrix.

I would also like to dynamic update the camera when a new pose arrive.

your view matrix contains position and rotation which you can use directly on your camera.
What you can do (instead of forcing the camera’s view matrix) is construct a babylon matrix from the view matrix and decompose (Matrix | Babylon.js Documentation) it to the camera’s position and rotation(Quaternion). this will update the camera’s transformation according to the matrix provided

5 Likes

Thanks for the quick answer!
It was what I was looking for.

I forgot to do a cast from the base Camera to FreeCamera, so poor Typescript wasn’t to much help.