Skip to content

Latest commit

 

History

History
43 lines (33 loc) · 1.46 KB

File metadata and controls

43 lines (33 loc) · 1.46 KB

XRSystem

Namespace: SpawnDev.SpawnJS.JSObjects.WebXR
Inheritance: SpawnJSObject -> EventTarget -> XRSystem
MDN Reference: XRSystem - MDN

The XRSystem interface is the entry point for the WebXR Device API. Access via Navigator.XR. It provides methods to check for XR support and to create XR sessions.

Constructors

Signature Description
XRSystem(SpawnJSObjectReference _ref) Deserialization constructor. Access via navigator.XR.

Methods

Method Return Type Description
IsSessionSupported(string mode) Task<bool> Checks if the given session mode is supported. Modes: "inline", "immersive-vr", "immersive-ar".
RequestSession(string mode) Task<XRSession> Requests an XR session of the given mode.
RequestSession(string mode, XRSessionInit options) Task<XRSession> Requests a session with options (required/optional features).

Events

Event Type Description
OnDeviceChange ActionEvent<Event> Fired when the set of available XR devices changes.

Example

using var navigator = new Navigator();
var xr = navigator.XR;
if (xr != null)
{
    bool vrSupported = await xr.IsSessionSupported("immersive-vr");
    if (vrSupported)
    {
        using var session = await xr.RequestSession("immersive-vr");
        Console.WriteLine($"XR session started");
    }
}