草案
此页面不完整。

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

getViewerPose() method, a member of the XRFrame interface, returns a XRViewerPose object which describes the viewer's pose (position and orientation) relative to the specified reference space.

getPose() method for a way to calculate a pose that represents the difference between two spaces.

句法

var xrViewerPose = xrFrame.getViewerPose(referenceSpace);
					

参数

referenceSpace
XRReferenceSpace object specifying the space to use as the reference point or base for the computation of the viewer's current pose.

返回值

A XRViewerPose describing the viewer's position and orientation relative to the specified reference space.

异常

InvalidStateError
DOMException indicating that getViewerPose() was not called within the context of a callback to a session's XRSession.requestAnimationFrame() .

范例

In this callback function for requestAnimationFrame() XRViewerPose describing the viewer's viewpoint on the world is obtained by calling getViewerPose() XRFrame passed into the callback.

viewerPose = xrFrame.getViewerPose(xrReferenceSpace);
if (viewerPose) {
  /* render the pose's views */
}
					

To see a complete example, take a look at Movement, orientation, and motion .

规范

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

浏览器兼容性

The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
getViewerPose() 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

图例

完整支持

完整支持

不支持

不支持

实验。期望将来行为有所改变。

实验。期望将来行为有所改变。

元数据

  • 最后修改: