VRPose:angularAcceleration 屬性
已棄用:此特性不再推薦。雖然某些瀏覽器可能仍然支援它,但它可能已經從相關的網路標準中刪除,可能正在刪除過程中,或者可能僅為相容性目的而保留。請避免使用它,如果可能,請更新現有程式碼;請參閱本頁底部的相容性表格以指導您的決策。請注意,此特性可能隨時停止工作。
非標準:此特性未標準化。我們不建議在生產環境中使用非標準特性,因為它們瀏覽器支援有限,並且可能會更改或被移除。但是,在沒有標準選項的特定情況下,它們可以是合適的替代方案。
angularAcceleration 是 VRPose 介面的一個只讀屬性,它返回一個數組,表示在當前時間戳下 VRDisplay 的角加速度向量,單位為每秒每秒米。
注意:此屬性是舊的 WebVR API 的一部分。它已被 WebXR Device API 取代。
換句話說,它表示感測器繞 x、y 和 z 軸旋轉的當前加速度。
值
返回一個 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-Frame、Babylon.js 或 Three.js 等框架,或 polyfill 來開發可在所有瀏覽器上執行的 WebXR 應用程式。有關更多資訊,請閱讀 Meta 的從 WebVR 移植到 WebXR 指南。
瀏覽器相容性
載入中…