I’m implementing a three.js webxr web app and trying to get the real-world compass orientation relative to the three.js scene so that I can place objects oriented to north in the AR. e.g. Place an arrow on the floor pointing north.
Webxr sets y rotation to zero relative to the initial launch orientation of the device. i.e. 0 rotation is forwards when you start the app rather than, say, north.
I can get the webxr camera rotation with:
var XRCameraDirectionVector = new THREE.Vector3(); xrCamera.getWorldDirection(XRCameraDirectionVector); let XRCameraDirectionDegrees = THREE.MathUtils.radToDeg(XRCameraDirectionVector.x);
I can get the compass per this article.
I know that I could take the compass bearing at the time that the zero is first set and use that as an offset, but I want to keep taking readings from the compass to improve the accuracy as the user moves around, so that would be fiddly.
I’m sure I’m missing something obvious, but how do I find where north is within the scene, please? Thanks.