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

浏览器兼容性

另见