<XrScene>
Turns a <TresCanvas> into an XR-capable scene. Place it directly inside <TresCanvas>; every vue-xr-ui component must live below it. It owns the XR session store, controllers and hands, and a frame loop that keeps running inside the headset.
Every live demo on this site is a <TresCanvas> with an <XrScene> inside. On a Quest, Enter VR in the demo's corner takes it into the headset.
Usage
<TresCanvas window-size>
<TresPerspectiveCamera :position="[0, 1.5, 0.1]" :look-at="[0, 1.4, -1]" />
<XrScene :options="{ handTracking: true }" @session-start="onStart">
<!-- panels, windows, your 3D content -->
</XrScene>
</TresCanvas>Sharpness
By default a session renders at the headset's native resolution (frameBufferScaling: 'high') with no fixed foveation (foveation: 0). The browser's own defaults are softer: Quest Browser's framebuffer is smaller than the display, and three.js turns foveation all the way up, which blurs everything away from the centre of each lens. For a scene that is mostly UI the GPU has room for it. A heavy 3D scene can trade some sharpness back:
<XrScene :options="{ frameBufferScaling: 'mid', foveation: 0.5 }">Mixed reality
In a passthrough (immersive-ar) session it clears to transparent so the room shows through, and it emits recenter when the user recentres the view. See Mixed reality.
API
Props
| Prop | Type | Default | Description |
|---|---|---|---|
options | Omit<XRStoreOptions<any>, "emulate"> | {} | Options for the @pmndrs/xr store: session features (handTracking, planeDetection, hitTest, anchors...) and input config. Defaults to the device's native resolution (frameBufferScaling: 'high') and no fixed foveation (foveation: 0), for sharp text; lower them to trade sharpness for GPU time. |
passthrough | boolean | true | In a passthrough (immersive-ar) session, clear to transparent and hide scene.background, so the room shows through behind the UI. Both come back when the session ends. false keeps the canvas colour. |
emulator | false | XrEmulator | A WebXR emulator (a virtual Quest 3 with controllers, hands and a synthetic room) from createXrEmulator() in vue-xr-ui/emulator. Injected on localhost when no headset is found. None by default (false also means none). |
Events
| Event | Payload | Description |
|---|---|---|
sessionStart | session: XRSession | A session started (VR or passthrough). |
sessionEnd | The session ended. | |
recenter | The user recentred the view (held the Meta button): the floor origin moved to where they stand now. Content placed in front of the user can be placed again; anchored content stays where it is in the room. |