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 (github.com)
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
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
…yeah, then WebXR came out
Yeah!
SLAM FTW!
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.
Hello.
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.
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.
ben
Thank you very much!
I was having this same problem - or thought I was. Turns out the lack of position tracking is an optical illusion. Like driving down the highway, and the far distance background appears to follow along with you. Mountains, cities, etc. But you expect this - they are enormous and distant.
https://doc.babylonjs.com/features/featuresDeepDive/webXR/webXRSessionManagers
An arbitrary value, but position tracking as I move around my model, now makes sense visually. So position tracking was always working. But in AR, without any depth data on the passthru background, position tracking may appear broken at the wrong world scale.