Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. XRFrame
  4. getViewerPose()

XRFrame: getViewerPose() method

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

Experimental:This is anexperimental technology
Check theBrowser compatibility table carefully before using this in production.

Secure context: This feature is available only insecure contexts (HTTPS), in some or allsupporting browsers.

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

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

Syntax

js
getViewerPose(referenceSpace)

Parameters

referenceSpace

AnXRReferenceSpace object specifying the space to use as thereference point or base for the computation of the viewer's current pose.

Return value

AXRViewerPose describing the viewer's position and orientation relativeto the specified reference space.

Exceptions

InvalidStateErrorDOMException

Thrown ifgetViewerPose() was notcalled within the context of a callback to asession'sXRSession.requestAnimationFrame().

Examples

In this callback function forrequestAnimationFrame(), theXRViewerPose describing the viewer's viewpoint on the world is obtained by callinggetViewerPose() on theXRFrame passed into the callback.

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

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

Specifications

Specification
WebXR Device API
# dom-xrframe-getviewerpose

Browser compatibility

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp