VRPose:angularAcceleration 属性

已弃用:此特性不再推荐。虽然某些浏览器可能仍然支持它,但它可能已经从相关的网络标准中删除,可能正在删除过程中,或者可能仅为兼容性目的而保留。请避免使用它,如果可能,请更新现有代码;请参阅本页底部的兼容性表格以指导您的决策。请注意,此特性可能随时停止工作。

非标准:此特性未标准化。我们不建议在生产环境中使用非标准特性,因为它们浏览器支持有限,并且可能会更改或被移除。但是,在没有标准选项的特定情况下,它们可以是合适的替代方案。

angularAccelerationVRPose 接口的一个只读属性,它返回一个数组,表示在当前时间戳下 VRDisplay 的角加速度向量,单位为每秒每秒米。

注意:此属性是旧的 WebVR API 的一部分。它已被 WebXR Device API 取代。

换句话说,它表示传感器绕 xyz 轴旋转的当前加速度。

返回一个 Float32Array,如果 VR 传感器无法提供角加速度信息,则返回 null

示例

js
// rendering loop for a VR scene
function drawVRScene() {
  // WebVR: Request the next frame of the animation
  vrSceneFrame = vrDisplay.requestAnimationFrame(drawVRScene);

  // Populate frameData with the data of the next frame to display
  vrDisplay.getFrameData(frameData);

  // Retrieve the angular acceleration values for use in rendering
  // curFramePose is a VRPose object
  const curFramePose = frameData.pose;
  const angAcc = curFramePose.angularAcceleration;
  const aax = angAcc[0];
  const aay = angAcc[1];
  const aaz = angAcc[2];

  // render the scene
  // …

  // WebVR: submit the rendered frame to the VR display
  vrDisplay.submitFrame();
}

规范

此属性是旧的 WebVR API 的一部分,已被 WebXR Device API 取代。它已不再是标准的开发方向。

在所有浏览器都实现新的 WebXR API 之前,建议依靠 A-FrameBabylon.jsThree.js 等框架,或 polyfill 来开发可在所有浏览器上运行的 WebXR 应用程序。有关更多信息,请阅读 Meta 的从 WebVR 移植到 WebXR 指南。

浏览器兼容性

另见