XRJointSpace

可用性有限

此特性不是基線特性,因為它在一些最廣泛使用的瀏覽器中不起作用。

XRJointSpace 介面是一個 XRSpace,代表 XRHand 關節的位置和方向。

EventTarget XRSpace XRJointSpace

例項屬性

XRJointSpace.jointName 只讀

被跟蹤關節的名稱。有關可能的的雙手關節名稱,請參閱 XRHand

示例

使用 XRJointSpace 物件

您可以透過呼叫 XRFrame.getJointPose(),使用 XRJointSpace 物件和 XRReferenceSpace 來獲取 XRJointPose

js
navigator.xr
  .requestSession({ optionalFeatures: ["hand-tracking"] })
  .then(/** … */);

function renderFrame(session, frame) {
  // …

  for (const inputSource of session.inputSources) {
    if (inputSource.hand) {
      const indexFingerTipJoint = inputSource.hand.get("index-finger-tip"); // XRJointSpace
      indexFingerTipJoint.jointName; // "index-finger-tip"
      frame.getJointPose(indexFingerTipJoint, referenceSpace); // XRJointPose
    }
  }
}

規範

規範
WebXR Hand Input 模組 - Level 1
# xrhand-interface

瀏覽器相容性

另見