XRFrame

Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

A WebXR Device API XRFrame object is passed into the requestAnimationFrame() callback function and provides access to the information needed in order to render a single frame of animation for an XRSession describing a VR or AR scene. Events which communicate the tracking state of objects also provide an XRFrame reference as part of their structure.

In addition to providing a reference to the XRSession for which this frame is to be rendered, the getViewerPose() method is provided to obtain the XRViewerPose describing the viewer's position and orientation in space, and getPose() can be used to create an XRPose describing the relative position of one XRSpace relative to another.

Properties

session Read only

The XRSession that for which this XRFrame describes the tracking details for all objects. The information about a specific object can be obtained by calling one of the methods on the object.

trackedAnchors Read only

An XRAnchorSet containing all anchors still tracked in the frame.

Methods

createAnchor()

Returns a Promise which resolves to a free-floating XRAnchor object.

fillJointRadii()

Populates a Float32Array with radii for a list of hand joint spaces. Returns true if successful for all spaces.

fillPoses()

Populates a Float32Array with the matrices of the poses, relative to a given base space. Returns true if all spaces have a valid pose.

getDepthInformation()

Returns an XRCPUDepthInformation object containing CPU depth information for the frame.

getHitTestResults()

Returns an array of XRHitTestResult objects containing hit test results for a given XRHitTestSource.

getHitTestResultsForTransientInput()

Returns an array of XRTransientInputHitTestResult objects containing hit test results for a given XRTransientInputHitTestSource.

getJointPose()

Returns an XRJointPose object providing the pose of a hand joint (see XRHand) relative to a given base space.

getLightEstimate()

Returns an XRLightEstimate object containing estimated lighting values for an XRLightProbe.

getPose()

Returns an XRPose object representing the spatial relationship between the two specified XRSpace objects.

getViewerPose()

Returns an XRViewerPose describing the viewer's position and orientation in a given XRReferenceSpace.

Specifications

Specification
WebXR Device API
# xrframe-interface

Browser compatibility

BCD tables only load in the browser

See also