XRFrame.getViewerPose()

Draft
This page is not complete.

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.

Syntax

var xrViewerPose = xrFrame.getViewerPose(referenceSpace);

Parameters

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

Return value

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

Exceptions

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

Examples

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.

Specifications

Specification Status Comment
WebXR Device API
The definition of 'XRFrame.getViewerPose()' in that specification.
Working Draft Initial definition.

Browser compatibility

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
getViewerPose()
Experimental
Chrome Full support 79Edge Full support 79Firefox No support NoIE No support NoOpera No support NoSafari No support NoWebView Android No support NoChrome Android Full support 79Firefox Android No support NoOpera Android No support NoSafari iOS No support NoSamsung Internet Android Full support 11.2

Legend

Full support  
Full support
No support  
No support
Experimental. Expect behavior to change in the future.
Experimental. Expect behavior to change in the future.