The game frame is granted the xr-spatial-tracking permission, so the WebXR Device API works with no setup.
Starting a session
Browsers only start an immersive session from a user gesture, so call requestSession() from a click handler in your game:
if (await navigator.xr?.isSessionSupported("immersive-vr")) {
enterButton.hidden = false;
enterButton.addEventListener("click", async () => {
const session = await navigator.xr.requestSession("immersive-vr"); // or "immersive-ar"
// Hand the session to your engine, e.g. renderer.xr.setSession(session) in three.js
});
}Your game doesn't receive input while a Wavedash purchase overlay is open, so players can't start a session until it closes.
Browser support
- Meta Quest Browser supports
immersive-vrandimmersive-ar. It's the main target. - Chrome on Android supports
immersive-aron ARCore devices. - Safari on visionOS supports
immersive-vrbut notimmersive-ar. - Safari on iOS has no WebXR. Keep a flat-screen mode.
Engines
- three.js, Babylon.js, and Godot 4 web exports support WebXR natively.
- Unity doesn't support WebXR in WebGL builds. Community packages such as WebXR Export add it.
Assets loaded from other servers still need the cross-origin isolation headers.