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.
The 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.
See the getPose() method for a way to calculate a pose that represents the difference between two spaces.
getViewerPose(referenceSpace)
referenceSpaceAn 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
Thrown if getViewerPose() was not called within the context of a callback to a session's XRSession.requestAnimationFrame().
In this callback function for requestAnimationFrame(), the XRViewerPose describing the viewer's viewpoint on the world is obtained by calling getViewerPose() on the 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.
| Specification |
|---|
| WebXR Device API> # dom-xrframe-getviewerpose> |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
getViewerPose |
79 | 79 | No | 66 | No | 79 | No | 57 | No | 11.2 | No | No |
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/XRFrame/getViewerPose