通过在
Android上使用event.accelerationIncludingGravity,它返回值
x: -0.2
y: +0.1
z: +9.1
在平坦的表面上休息时.但是,我希望在没有重力的情况下获得加速,但不支持event.acceleration.有没有办法通过数学转换它?在HTML5Rocks中有一个删除重力因子的例子,但它似乎不起作用.
// Convert the value from acceleration to degrees acceleration.x|y is the
// acceleration according to gravity, we'll assume we're on Earth and divide
// by 9.81 (earth gravity) to get a percentage value, and then multiply that
// by 90 to convert to degrees.
var tiltLR = Math.round(((acceleration.x) / 9.81) * -90);
var tiltFB = Math.round(((acceleration.y + 9.81) / 9.81) * 90 * facingUp);