API

Interface XrSessionOptions

Options for enterXr. All fields optional; sensible immersive-VR defaults.

interface XrSessionOptions {
    colorFormat?: GPUTextureFormat;
    depthFar?: number;
    depthNear?: number;
    depthStencilFormat?: GPUTextureFormat | null;
    features?: readonly XrFeatureSpec[];
    input?: false | XrInputCallbacks;
    mode?: XrSessionMode;
    onEnd?: () => void;
    onFrame?: (ctx: XrSessionContext, frame: XRFrame, time: number) => void;
    optionalFeatures?: string[];
    referenceSpaceType?: XrReferenceSpaceType;
    requiredFeatures?: string[];
}
Index
colorFormat?: GPUTextureFormat

Projection-layer color format. Defaults to binding.getPreferredColorFormat().

depthFar?: number

XR projection far-clip distance in metres. Defaults to the UA value when omitted (typically 1000).

depthNear?: number

XR projection near-clip distance in metres. Smaller lets objects (e.g. a controller or a grabbed cube) come right up to the eyes without clipping. Defaults to 0.02.

depthStencilFormat?: GPUTextureFormat | null

Projection-layer depth/stencil format handed to the compositor for reprojection. Defaults to "depth24plus". Pass null to render without a compositor depth attachment (Babylon Lite then renders color-only — supply your own depth if needed).

features?: readonly XrFeatureSpec[]

Opt-in XR features (e.g. pointerSelection()). Their native session-feature descriptors are merged into optionalFeatures, and each is instantiated, driven per frame, and disposed automatically by the session.

input?: false | XrInputCallbacks

Input-source callbacks, or false to disable input tracking entirely. Defaults to {} (sources tracked, no callbacks).

"immersive-vr" (default) or "immersive-ar".

onEnd?: () => void

Called when the session ends (user exit, exitXr, or device-driven).

onFrame?: (ctx: XrSessionContext, frame: XRFrame, time: number) => void

Called once per XRFrame after poses are updated and before rendering.

optionalFeatures?: string[]

Optional feature descriptors.

referenceSpaceType?: XrReferenceSpaceType

Reference space to render against. Defaults to "local-floor", falling back to "local" if the device does not offer it.

requiredFeatures?: string[]

Extra required feature descriptors (merged with the mandatory "webgpu").