How to get DeviceOrientationCamera in Babylon Native?

I want the camera in the scene to rotate based on the device rotation, orientation (IMU). The Device orientation camera works fine from browser BabylonJS. How to replicate the same in Babylon Native ?

So do I need to be doing all this (Babylon.js/freeCameraDeviceOrientationInput.ts at 7cee15e89e995cd466e18e5a1b78e0b6432f85da · BabylonJS/Babylon.js · GitHub) logic in React Native by passing in the IMU value ?

ping @BabylonNative

@Krishnan_R Can you send a playground of what you have working with Babylon.js on a browser?

1 Like

I am using this sensor value from Android IMU SensorEvent  |  Android Developers
and setting it for the virtual camera using

 let imuQuaternion = new Quaternion(parseFloat(array[0]),parseFloat(array[1]), parseFloat(array[2]), parseFloat(array[3])); // Please note the order has been changed
camera.rotationQuaternion = imuQuaternion;

the array contains x,y,z,w. Though the camera moves with device moving, its is not in proper sync with axis.

Sorry for the delay. Ideally, what should happen to support this is to polyfill device orientation event. Otherwise, it should be possible to do it manually like you are trying but I don’t know the correct math for it.