Getting WebXR camera position/rotation

In a normal non-XR scenario, I can get the camera’s current look direction like this:

I’m trying to do this in VR mode like this:
But this just returns (0, 0, 1) every frame.

Similarly, getting the position from this camera just gives (0, 0, 0) every frame, even though I’m moving the headset around.

Does anyone know how to get the VR camera’s current world space position/rotation? Is this a bug? Or am I missing something?



the quick answer is - the camera is just a container for two more cameras (both eyes), which have in their position/rotation the eye position and rotation. combined with the container (which is their parent), they can deliver the global position of the camera.

This is, IMO, not very intuitive, that’s why I created this issue - WebXR camera positioning API · Issue #7239 · BabylonJS/Babylon.js · GitHub and will work on that very soon.

1 Like

@adammit! Welcome to the Babylon forum! So happy to see you here! Can’t wait to see what you create!