XRReferenceSpaceEvent: XRReferenceSpaceEvent() constructor

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

The XRReferenceSpaceEvent() constructor is used to create a new XRReferenceSpaceEvent object, which represents an event regarding the state of a WebXR reference space object, XRReferenceSpace.

Syntax

js
new XRReferenceSpaceEvent(type, options)

Parameters

type

A string with the name of the event. It is case-sensitive and browsers always set it to reset.

options

An object that, in addition of the properties defined in Event(), can have the following properties:

referenceSpace

The XRReferenceSpace from which the event originates.

transform

An XRRigidTransform which maps the old coordinate system (from before the changes indicated by this event) to the new coordinate system.

Return value

A new XRReferenceSpaceEvent object, initialized as defined by the input parameters.

Examples

This simple snippet calls the constructor to create a new reference space event of type reset.

js
let refSpaceEvent = new XRReferenceSpaceEvent("reset", {
  referenceSpace: myRefSpace,
  transform: myTransform,
});

Specifications

Specification
WebXR Device API
# dom-xrreferencespaceevent-xrreferencespaceevent

Browser compatibility

BCD tables only load in the browser