XRInputSource: hand 屬性

可用性有限

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

安全上下文: 此功能僅在安全上下文(HTTPS)中可用,且支援此功能的瀏覽器數量有限。

XRInputSource 介面的只讀 hand 屬性是一個 XRHand 物件,用於訪問手部跟蹤裝置。

如果 XRSession 沒有使用 hand-tracking 功能描述符 請求,則返回一個 XRHand 物件或 null

示例

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

function renderFrame(session, frame) {
  // …

  for (const inputSource of session.inputSources) {
    if (inputSource.hand) {
      // render a hand model, perform gesture detection, etc.
    }
  }
}

規範

規範
WebXR Hand Input 模組 - Level 1
# dom-xrinputsource-hand

瀏覽器相容性

另見