Does threejs implement a way to use the device’s acceleration to move in a scene? Using the acceleration web api. The same question is asked here. So the idea is that I have a virtual environment. I use the groscope to look around, and the accelerometer to move. So besides being able to look around, which I can already do using the gyroscope(deviceorientation), I want to be able to walk in the scene by walking the real world with the phone.
No, Three.js does not have this implementation. You’d have to find a library that does this (if it exists), or maybe use some sort of AR solution, as discussed in this thread: What are the best free libraries for WebAR? - #2 by karanganesan
I want to be able to walk in the scene by walking the real world with the phone.
Welcome to the club!
You just asked the most difficult thing ever, that is, to add 2-3 more axes on a phone, without external help from expensive (hundreds of dollars/euros) sensors, that are used in all dedicated VR hardware!
I thought about acceleration sensors too, but whatever I tried, failed, although I didn’t do exhaustive experiments. What stopped me is that even if I succeeded, I had the feeling that they are completely unreliable uncalibrated cheapo-cheap chips, intended just to roughly sense the user’s steps, that might vary considerably from phone to phone -and not even all phones have them.
So, what’s left? For outdoors, ar.js claims in its documentation that something similar can be done via GPS -but I doubt that GPS has the required precision for this task (unless you find a large field, and start walking …long distances for a vast virtual environment! Then it might work! (idea for a viral video)
For indoors (which I’m interested in), I haven’t found anything.
So I think the only option left is a custom solution, -I’m already experimenting with some ideas (the hard way as usually), although chances are slim…
Just being able to walk on a single axis would be enough at this point. Not even that I’m managing, I keep going backward and forward all the time by barely moving the phone, because the accelerometer values change from negative to positive and vice versa all the time with the slightest movement, and sometimes I swear I didn’t move at all. There doesn’t seem to be any consistency, it’s utterly useless. Any math magician knows how I can do some black magic math to normalize the accelerometer values or whatever to get useful input?
I just want to walk on a straight line now. I hope this is manageable at least, somehow lol, without going back and forward all the time, because this is not a drunk simulator.
the accelerometer values change from negative to positive and vice versa all the time with the slightest movement, and sometimes I swear I didn’t move at all.
Yes, I had the same problem, I think that the fundamental problem is that the accelerator sensors don’t take into account the mass, so when a large mass (a human being) make a move and a tiny vibrarion happens, the dumb sensors will consider the tiny vibration as a much higher acceleration than your body.
A possible solution to that would be a low-pass filter, - I haven’t tried it, but there comes the polarity problem too that seems arbitrary -or it might change with noise… which is why I quit trying.