Accurate device orientation tracking

Hi,
I am trying use the phone’s sensor to rotate an object in a simple scene. As far as I understand the older class DeviceOrientationControls is no longer supported, but I managed to put something together using the sensor-JS example on how to use the deviceorientation event.

It kinda works, but not great and it gets into a gimbal lock when pointing the phone vertically. I assume it’s not trivial to use the rest of the data to correct and improve the tracking.

I then came across some webVR examples, where the tracking of phone’s orientation works great. I am still trying to wrap my head about all these, but I wonder if it would be possible to get just the orientation from the webVR (or webXR) library to rotate my object, without having to render in stereo or any of the other VR functionality.

thank you