开发者

Is it possible for a web app to gather an iPhone's accelerometer data? If so, how?

Is it possible for a web app to ga开发者_高级运维ther an iPhone's accelerometer data? If so, how? I would think they might have in the Safari Web browser an API with such functionality.

If it is possible could someone send me a link to pages with specific coding information.


Found this snippet from here with a bit of Googling.

window.ondevicemotion = function(event) {
  ax = event.accelerationIncludingGravity.x
  ay = event.accelerationIncludingGravity.y
  az = event.accelerationIncludingGravity.z
  rotation = event.rotationRate;
  if (rotation != null) {
    arAlpha = Math.round(rotation.alpha);
    arBeta = Math.round(rotation.beta);
    arGamma = Math.round(rotation.gamma);
  }
} 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜