Mobile orientation and accelerometer

Is BabylonJS compatible with any possibility of detecting the mobile phone’s orientation and accelerometer to control, let’s say, a box? Tilting the phone to the left makes the box goes left, etc…?

Hi FBa,

Sure! Babylon already provides a DeviceOrientationCamera, which uses IMU data from the browser data to control the camera. Here’s the code that listens to that input; you should just be able to listen to the same input and repurpose it to control anything you want. Good luck!

Thanks. I am trying to copy one from the demo and see if it works.
Does it work?

The device I’m on right now doesn’t have an IMU, so I wouldn’t be able to evaluate it at the moment. You should just be able to try it on your phone or tablet, though. However, I think you might need to make the file an HTML file so that the browser knows what to do with it; right now, it just opens as plaintext. :slight_smile:

It’s now on my github page as an index.html

My phone hasn’t responded to the movement. Please let me know if you have a chance to test it out. Thank you so much!