files/en-us/web/api/xrframe/getviewerpose/index.md
{{APIRef("WebXR Device API")}}{{SeeCompatTable}}{{SecureContext_Header}}
The getViewerPose() method, a member of the {{domxref("XRFrame")}} interface, returns a {{domxref("XRViewerPose")}} object which describes the viewer's pose (position and orientation) relative to the specified reference space.
See the {{domxref("XRFrame.getPose", "getPose()")}} method for a way to calculate a pose that represents the difference between two spaces.
getViewerPose(referenceSpace)
referenceSpace
A {{domxref("XRViewerPose")}} describing the viewer's position and orientation relative to the specified reference space.
InvalidStateError {{domxref("DOMException")}}
getViewerPose() was not
called within the context of a callback to a
session's {{domxref("XRSession.requestAnimationFrame", "XRSession.requestAnimationFrame()")}}.In this callback function for {{domxref("XRSession.requestAnimationFrame", "requestAnimationFrame()")}}, the {{domxref("XRViewerPose")}} describing the viewer's viewpoint on the world is obtained by calling getViewerPose() on the {{domxref("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}}
{{Compat}}