TypologySienna Chen
ToolsLightweight

WebXR runtime

VR and AR sessions from a web page.

The browser feature that opens a VR or AR session on a headset or a phone. The same 3D scene gets drawn once per eye and follows the head. You need a device to test it, and iPhone support is limited.

Breaks when
needs HTTPS and a device to testiOS Safari support is limited
Also called
WebXR, immersive-vr, immersive-ar

Prompts

Add VR to an existing scene
Take this Three.js scene and add WebXR: VRButton, renderer.xr.enabled = true, setAnimationLoop instead of requestAnimationFrame, a 1.6 m default eye height, and a teleport ray from the right controller against a floor plane. Desktop behaviour stays unchanged when XR is unavailable.
AR placement on a table
WebXR immersive-ar with hit-test: show a reticle on detected surfaces, place the glTF on tap, and use light-estimation for the scene light. When hit-test is unsupported, fall back to placing the object at a fixed 1 m distance.
Why post-processing breaks in XR
Explain and implement why the scene renders twice per frame from the XR camera array, why an EffectComposer breaks inside a session, and provide a fallback that bypasses the composer while a session is active and restores it on exit.

Related

Resources · 2