当前位置: 动力学知识库 > 问答 > 编程问答 >

web applications - 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 gather 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);
  }
} 
分享给朋友:
您可能感兴趣的文章:
随机阅读: