Taos API Reference
    Preparing search index...

    Class XrSession

    Thin wrapper over a WebGPU-backed immersive WebXR session: owns the XRSession, the XRGPUBinding, the projection layer and the reference space, and turns each XRFrame into a list of XrEyeViews the engine can render. This is the single place that touches the (draft) WebGPU-XR API; everything downstream is plain Taos Mat4 / GPUTexture.

    Lifecycle:

    1. await XrSession.isSupported() — gate a UI "Enter VR" button.
    2. const xr = await XrSession.create(engine.ctx) — inside a user gesture.
    3. engine.enterXR(xr) — the engine swaps its rAF loop to this session.
    4. await xr.end() (or the user removes the headset) → onEnd fires.
    Index

    Properties

    session: XRSession
    binding: XRGPUBinding
    layer: XRProjectionLayer
    referenceSpace: XRReferenceSpace
    colorFormat: GPUTextureFormat
    mode: XRSessionMode

    The mode this session was created with ('immersive-vr' | 'immersive-ar' | 'inline').

    onEnd: (() => void) | null = null

    Fired when the session ends (user exits, headset removed, end()).

    Accessors

    • get isImmersiveAr(): boolean

      True for an 'immersive-ar' session — the caller should render a transparent background so the camera passthrough shows through.

      Returns boolean

    • get blendMode(): XREnvironmentBlendMode

      How the runtime composites this session over the real world. 'opaque' for VR (and the safe default on UAs that don't expose the field); 'alpha-blend' / 'additive' for AR passthrough.

      Returns XREnvironmentBlendMode

    • get isPassthrough(): boolean

      True when the composited output blends over a real-world view, i.e. the engine must produce a transparent (alpha < 1) background. Covers both 'alpha-blend' (video passthrough) and 'additive' (optical see-through).

      Returns boolean

    Methods

    • Whether the browser exposes WebXR and the WebGPU-XR binding for the given mode. Returns false (never throws) when navigator.xr or XRGPUBinding is absent, so callers can use it to decide whether to show an "Enter VR" UI.

      Parameters

      • mode: XRSessionMode = 'immersive-vr'

      Returns Promise<boolean>

    • Schedule the next XR frame. Mirrors window.requestAnimationFrame but is driven by the headset's compositor and supplies an XRFrame.

      Parameters

      • callback: XRFrameRequestCallback

      Returns number

    • Resolve the per-eye views for this frame. Returns an empty array when the pose is unavailable (tracking lost) — the caller should skip rendering that frame. Each returned matrix is already in Taos/WebGPU conventions.

      Parameters

      • frame: XRFrame

      Returns XrEyeView[]