XRFrame: phương thức getJointPose()

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

Phương thức getJointPose() của giao diện XRFrame trả về một đối tượng XRJointPose cung cấp tư thế của một khớp tay (xem XRHand) tương đối với không gian cơ sở cho trước.

Cú pháp

js
getJointPose(joint, baseSpace)

Tham số

joint

Một XRJointSpace chỉ định không gian khớp tay để lấy XRJointPose mô tả vị trí và hướng của mục.

baseSpace

Một XRSpace được dùng làm cơ sở hoặc gốc tọa độ cho vị trí và hướng tương đối.

Giá trị trả về

Một đối tượng XRJointPose chỉ định vị trí và hướng của khớp tay, tương đối với XRSpace được chỉ định bởi baseSpace.

Ví dụ

Sử dụng getJointPose()

Gọi getJointPose() với một XRJointSpace và một XRReferenceSpace để nhận đối tượng 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");
      frame.getJointPose(indexFingerTipJoint, referenceSpace); // XRJointPose
    }
  }
}

Thông số kỹ thuật

Specification
WebXR Hand Input Module - Level 1
# dom-xrframe-getjointpose

Tương thích trình duyệt

Xem thêm