Interface XRSession
depthDataFormat?: XRDepthDataFormat;
depthUsage?: XRDepthUsage;
domOverlayState?: XRDOMOverlayState;
enabledFeatures?: string[];
environmentBlendMode: XREnvironmentBlendMode;
frameRate?: number;
inputSources: XRInputSourceArray;
isSystemKeyboardSupported: boolean;
onend: XRSessionEventHandler;
onframeratechange: XRSessionEventHandler;
oninputsourceschange: XRInputSourcesChangeEventHandler;
onselect: XRInputSourceEventHandler;
onselectend: XRInputSourceEventHandler;
onselectstart: XRInputSourceEventHandler;
onsqueeze: XRInputSourceEventHandler;
onsqueezeend: XRInputSourceEventHandler;
onsqueezestart: XRInputSourceEventHandler;
onvisibilitychange: XRSessionEventHandler;
renderState: XRRenderState;
requestHitTest?: ((ray: XRRay, referenceSpace: XRReferenceSpace) => Promise<XRHitResult[]>);
requestHitTestSource?: ((options: XRHitTestOptionsInit) => Promise<XRHitTestSource>);
requestHitTestSourceForTransientInput?: ((options: XRTransientInputHitTestOptionsInit) => Promise<XRTransientInputHitTestSource>);
supportedFrameRates?: Float32Array;
visibilityState: XRVisibilityState;
addEventListener<K>(type: K, listener: ((this: XRSession, ev: XRSessionEventMap[K]) => any), options?: boolean | AddEventListenerOptions): void;
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
cancelAnimationFrame(id: number): void;
dispatchEvent(event: Event): boolean;
end(): Promise<void>;
initiateRoomCapture?(): Promise<undefined>;
removeEventListener<K>(type: K, listener: ((this: XRSession, ev: XRSessionEventMap[K]) => any), options?: boolean | EventListenerOptions): void;
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
requestAnimationFrame(callback: XRFrameRequestCallback): number;
requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRBoundedReferenceSpace | XRReferenceSpace>;
updateRenderState(renderStateInit?: XRRenderStateInit): Promise<void>;
updateTargetFrameRate(rate: number): Promise<void>;
}
Hierarchy
- EventTarget
- XRSession (view full)
Index
Properties
Methods
Properties
Optional
Readonly
depthDataFormat
Optional
Readonly
depthUsage
Optional
Readonly
domOverlayState
Optional
Readonly
enabledFeatures
Readonly
environmentBlendMode
Optional
Readonly
frameRate
Readonly
inputSources
Returns a list of this session's XRInputSources, each representing an input device used to control the camera and/or scene.
Readonly
isSystemKeyboardSupported
onend
onframeratechange
oninputsourceschange
onselect
onselectend
onselectstart
onsqueeze
onsqueezeend
onsqueezestart
onvisibilitychange
Readonly
renderState
object which contains options affecting how the imagery is rendered. This includes things such as the near and far clipping planes
Optional
requestHitTest
Optional
requestHitTestSource
Optional
requestHitTestSourceForTransientInput
Optional
Readonly
supportedFrameRates
Readonly
visibilityState
Methods
addEventListener
- add
Event <K>(type, listener, options?): voidListener Appends an event listener for events whose type attribute value is type. The callback argument sets the callback that will be invoked when the event is dispatched.
The options argument sets listener-specific options. For compatibility this can be a boolean, in which case the method behaves exactly as if the value was specified as options's capture.
When set to true, options's capture prevents callback from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE. When false (or not present), callback will not be invoked when event's eventPhase attribute value is CAPTURING_PHASE. Either way, callback will be invoked if event's eventPhase attribute value is AT_TARGET.
When set to true, options's passive indicates that the callback will not cancel the event by invoking preventDefault(). This is used to enable performance optimizations described in § 2.8 Observing event listeners.
When set to true, options's once indicates that the callback will only be invoked once after which the event listener will be removed.
If an AbortSignal is passed for options's signal, then the event listener will be removed when signal is aborted.
The event listener is appended to target's event listener list and is not appended if it has the same type, callback, and capture.
Type Parameters
- K extends keyof XRSessionEventMap
Parameters
- type: K
- listener: ((this: XRSession, ev: XRSessionEventMap[K]) => any)
- (this, ev): any
Parameters
- this: XRSession
- ev: XRSessionEventMap[K]
Returns any
Optional
options: boolean | AddEventListenerOptions
Returns void
- add
Event (type, listener, options?): voidListener Appends an event listener for events whose type attribute value is type. The callback argument sets the callback that will be invoked when the event is dispatched.
The options argument sets listener-specific options. For compatibility this can be a boolean, in which case the method behaves exactly as if the value was specified as options's capture.
When set to true, options's capture prevents callback from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE. When false (or not present), callback will not be invoked when event's eventPhase attribute value is CAPTURING_PHASE. Either way, callback will be invoked if event's eventPhase attribute value is AT_TARGET.
When set to true, options's passive indicates that the callback will not cancel the event by invoking preventDefault(). This is used to enable performance optimizations described in § 2.8 Observing event listeners.
When set to true, options's once indicates that the callback will only be invoked once after which the event listener will be removed.
If an AbortSignal is passed for options's signal, then the event listener will be removed when signal is aborted.
The event listener is appended to target's event listener list and is not appended if it has the same type, callback, and capture.
Parameters
- type: string
- listener: EventListenerOrEventListenerObject
Optional
options: boolean | AddEventListenerOptions
Returns void
cancelAnimationFrame
dispatchEvent
- dispatch
Event (event): boolean Dispatches a synthetic event event to target and returns true if either event's cancelable attribute value is false or its preventDefault() method was not invoked, and false otherwise.
Parameters
- event: Event
Returns boolean
end
Optional
initiateRoomCapture
- initiate
Room (): Promise<undefined>Capture XRSession is extended to contain the initiateRoomCapture method which, if supported, will ask the XR Compositor to capture the current room layout. It is up to the XRCompositor if this will replace or augment the set of tracked planes. The user agent MAY also ignore this call, for instance if it doesn’t support a manual room capture more or if it determines that the room is already set up. The initiateRoomCapture method MUST only be able to be called once per XRSession.
Returns Promise<undefined>
removeEventListener
- remove
Event <K>(type, listener, options?): voidListener Removes the event listener in target's event listener list with the same type, callback, and options.
Type Parameters
- K extends keyof XRSessionEventMap
Parameters
- type: K
- listener: ((this: XRSession, ev: XRSessionEventMap[K]) => any)
- (this, ev): any
Parameters
- this: XRSession
- ev: XRSessionEventMap[K]
Returns any
Optional
options: boolean | EventListenerOptions
Returns void
- remove
Event (type, listener, options?): voidListener Removes the event listener in target's event listener list with the same type, callback, and options.
Parameters
- type: string
- listener: EventListenerOrEventListenerObject
Optional
options: boolean | EventListenerOptions
Returns void
requestAnimationFrame
- request
Animation (callback): numberFrame Schedules the specified method to be called the next time the user agent is working on rendering an animation frame for the WebXR device. Returns an integer value which can be used to identify the request for the purposes of canceling the callback using cancelAnimationFrame(). This method is comparable to the Window.requestAnimationFrame() method.
Parameters
- callback: XRFrameRequestCallback
Returns number
requestReferenceSpace
- request
Reference (type): Promise<XRBoundedReferenceSpace | XRReferenceSpace>Space Requests that a new XRReferenceSpace of the specified type be created. Returns a promise which resolves with the XRReferenceSpace or XRBoundedReferenceSpace which was requested, or throws a NotSupportedError if the requested space type isn't supported by the device.
Parameters
- type: XRReferenceSpaceType
Returns Promise<XRBoundedReferenceSpace | XRReferenceSpace>
updateRenderState
- update
Render (renderStateInit?): Promise<void>State Parameters
Optional
renderStateInit: XRRenderStateInit
Returns Promise<void>
EventTarget is a DOM interface implemented by objects that can receive events and may have listeners for them.
MDN Reference