Move camera based on accelerometer data

Is there any example where camera is changing its position based on accelerometer data?

Actually the DeviceOrientationCamera is exactly that:
Babylon.js/deviceOrientationCamera.ts at master · BabylonJS/Babylon.js (

DeviceOrientationCamera just can rotate, i can’t move when i walk like six-axis vr device

This might work with XR ? @RaananW ?

reviving a 2 years old topic :slight_smile:

WebXR is the way to go. otherwise - it is not recommended to use accelerometer to detect movement. You can find the direction (usually), but not the new position.

This is far as I got myself in like 1 year with a friend… opencv, accelerometer, magnetometer and GPS :joy:

…yeah, then WebXR came out :running_man:

1 Like

Yeah! :slight_smile:

1 Like

here im moving the mesh, not the camera - but should be same/same (with external accelerometer). as raanan says, can’t detect new position in space.



Could you give me more information about how you did this? I need to display real-time movement of an object in a web page based on accelerometer/gyroscope data. It’s for an academic project. I don’t really know anything about 3D modeling and manipulation and I was just checking if babylonjs could help me achieve that. What you show in your video is exactly what I need to do, so I would really appreciate if you could share the code and details with me.

1 Like

hi @maldaurore
i dug through some archives and found something that looks like what i remember using to do this: GitHub - bigrig2212/arduino-tests.

the basic concept was:

  • pull data from accelerometer (i used johnny-five library to do it - dunno if that’s still viable)
  • I wired up the accelerometer at first and then went wireless via bluetooth (which was much more complicated)
  • then sent the xyz data into babylon via a socket connection
  • then mirrored those xyz positions on a loaded GLB

hope that helps.

Thank you very much! :smiley: