dorukeker / gyronorm.js

JavaScript project for accessing and normalizing the accelerometer and gyroscope data on mobile devices
MIT License
641 stars 65 forks source link

Parameter orientationBase: GyroNorm.WORLD chrome/android #24

Open firewolf opened 8 years ago

firewolf commented 8 years ago

I have problem with orientation sensor and its respect (or better - leak of respect) to GyroNorm.WORLD on android (6.0.1)/chrome (52.0.2743.98). The problem is - it is not working for me, values are relative to device, not to real orientation with respect of NORTH pole.

dorukeker commented 7 years ago

I've just tested this, and can confirm I had the same thing on newer Android+Chrome. (iPhone behaves as expected).

Also normally if you don't define the orientationBase in the settings, it should show GAME for iPhone and WORLD for Android by default. This also does not work as expected for Android.

Gyronorm is using an underlying library (Full Tilt) to get the orientation values from the browser. The WORLD vs GAME setting is handled at that level. The same issue is mentioned here for FullTilt https://github.com/adtile/Full-Tilt/issues/22

Seems like this happens because Chrome has changed how they handle the device orientation by default. That breaks if you want world-based values. If you use game-based values both devices work like before. I will keep an eye on if/how FullTilt will address this.

For now I don't have a quick solution. I will keep this thread open for further updates. Please add any updates on your side here; so other following can benefit from that.

Cheers, Doruk

janrg commented 7 years ago

I have the same problem, with Chrome on both android and iOS.

jasan-s commented 7 years ago

could this account for the change? https://developer.mozilla.org/en-US/docs/Web/API/Window/ondeviceorientationabsolute

dorukeker commented 7 years ago

I have not tested this. My experience is that similar events are not implemented (or implemented differently) across device+browsers. Also at the top of that page it warns it is not a standard and should not be used for production.

Having said that I have not used tried it myself. I will keep it in mind when/if I dive deeper into this issue.

jasan-s commented 7 years ago

Im on android 5.1 using chrome 54.0.x and I'm still getting absolute orientation alpha from the deviceOreination event. I thought this was affecting all chrome 50 and above? or is this affecting when the condition is android 6 and chrome ver > 50

dorukeker commented 7 years ago

In the earlier versions of Chrome the default orientation base was WORLD. Meaning you get absolute values. If you want relative values, you need to set the orientation base explicitly to GAME. See the parameters you can pass when you first initialize GyroNorm object.

angularsen commented 6 years ago

Full Tilt project seems stagnant, there are a couple of forks that added the absolute API for google. https://github.com/adtile/Full-Tilt/network