Why is WebXR camera rotation property zero when rotationQuaternion has a value

I wanted to get the current rotation of the WebXR camera so I could mirror the rotation to a head and body of an avatar in immersive VR mode.

I eventually found that I can get the rotation values by calling


and the I can pass those rotation values into the call to rotate my mesh’s transformNode around the Y axis

myMesh.rotation = new B.Vector3(0, player.ry, 0)

Can someone explain why is it I have to get the value via the rotationQuaternion function and then convert back to euler values? Why aren’t the they simply available from:


Which seems to always be zeros.

If there is a more elegant way of doing this I’m keen to learn.

Thanks in advance for any explanation.

You basically are either using one mode or another so if quaternions, as they are the favorite way (preventing gimbal lock, simpler maths and such) they are directly used. if not euler can still be used as they are still here to manage back compat and a simpler way to learn,

Hi @sebavan.

Thanks for responding. Are you suggesting that I’ve somehow put it into quaternion ‘mode’ resulting in .rotation reading (0,0,0) from that point in time?

I expect both options to be active at the same time and simply a matter of preference as to which to mode to use?


This could be in a lot of scenari a potential perf hit we prefer to be fully none transparent. I do agree it might not be the prettiest but adding automatic conversion code everywhere could potentially lead to hidden perf drain we prefer to avoid and also the conversion will not always work creating potential issues hard to trouble shoot.

Nope I would think the XR camera by default is in quaternion mode :slight_smile: as the underlying XR transforms are also relying on quaternions: XRRigidTransform.orientation - Web APIs | MDN and no conversion means more perfs

Thanks for explaining @sebavan.

no problem I totally understand the confusion this can cause.