安全上下文
此特征只可用于 安全上下文 (HTTPS),在某些或所有 支持浏览器 .

transform read-only attribute of the XRPose 接口是 XRRigidTransform object providing the position and orientation of the pose relative to the base XRSpace as specified when the pose was obtained by calling XRFrame.getPose() .

句法

let poseTransform = xrPose.transform;
					

XRRigidTransform which provides the position and orientation of the XRPose relative to the XRFrame to which this XRPose is aligned. This is the same pose that's returned by the frame's getPose() 方法。

范例

This handler for the XRSession event select handles events for tracked pointers. It determines the targeted object by passing the event frame's pose into a function called findTargetUsingRay() , then dispatches the event differently depending on the user's handedness; this is done by comparing the value of the XRInputSource property handedness to a value in the variable user.handedness . If the source is a controller in the user's primary hand, a function is called on the targeted object called primaryAction() ; otherwise, it calls the targeted object's offHandAction() 函数。

xrSession.addEventListener("select", event => {
  let source = event.inputSource;
  let frame = event.frame;
  let targetRayPose = frame.getPose(source.targetRaySpace, myRefSpace);
  let targetObject = findTargetUsingRay(targetRay.transform.matrix);
  if (source.targetRayMode == "tracked-pointer") {
    if (source.handedness == user.handedness) {
      targetObject.primaryAction();
    } else {
      targetObject.offHandAction();
    }
  }
});
					

规范

规范 状态 注释
WebXR 设备 API
The definition of 'XRPose.transform' in that specification.
工作草案 初始定义。

浏览器兼容性

更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
transform Chrome 79 Edge 79 Firefox 不支持 No IE 不支持 No Opera 不支持 No Safari 不支持 No WebView Android 不支持 No Chrome Android 79 Firefox Android 不支持 No Opera Android 不支持 No Safari iOS 不支持 No Samsung Internet Android 11.2

图例

完整支持

完整支持

不支持

不支持

元数据

  • 最后修改: