WebXR mixed reality: passthrough, planes and anchors

By the Turbl team · · 11 min read

WebXR mixed reality starts with one change: you request an immersive-ar session instead of immersive-vr. The headset then shows its camera view of the room, called passthrough, and draws your 3D scene on top. Five optional modules add knowledge of the room: hit test, anchors, plane detection, mesh detection and depth sensing. As of November 2026, the Meta Quest Browser runs all five. Google lists hit test, anchors and depth sensing for Chrome on Android XR. Safari on Apple Vision Pro has no immersive-ar mode.

How a mixed reality session starts

WebXR is the browser API that connects a web page to a headset. If it is new to you, read what WebXR is first.

A WebXR session has a mode. immersive-vr replaces the real world with your scene. immersive-ar blends your scene with the real world.

const supported = await navigator.xr.isSessionSupported('immersive-ar');

const session = await navigator.xr.requestSession('immersive-ar', {
  requiredFeatures: ['hit-test'],
  optionalFeatures: ['anchors', 'plane-detection'],
});

Call requestSession from a click or tap handler. Browsers reject the request otherwise.

A feature in requiredFeatures must be available, or the session fails. A feature in optionalFeatures is dropped quietly if the device lacks it. Put a feature in the required list only when the app is useless without it.

Two rules catch most beginners:

  • Draw on a transparent background. Meta's documentation says the passthrough view is not visible otherwise. Do not paint a sky or a floor, and do not clear the canvas with an opaque color.
  • You cannot read the camera pixels. The browser puts passthrough behind your canvas. Meta's documentation for the Quest Browser says: "There is no way to get to the pixels of the passthrough content."

The session also reports environmentBlendMode. On a passthrough headset it is alpha-blend: your pixels cover the camera image. On glasses with transparent lenses it is additive: your pixels only add light, so black is invisible.

What each WebXR mixed reality module does

Passthrough alone gives you a floating scene. The modules below let content react to the room. Each one is a separate specification, and each has its own feature string.

ModuleFeature stringWhat you getSpec status (W3C)
AR modulenone, it is the immersive-ar modePassthrough and blendingCandidate Recommendation Draft, April 2025
Hit testhit-testThe point where a ray meets a real surfaceWorking Draft, December 2025
AnchorsanchorsA pose that stays fixed to a real placeEditor's Draft, April 2026
Plane detectionplane-detectionFlat surfaces as polygons: floor, walls, tablesEditor's Draft, March 2026
Mesh detectionmesh-detectionTriangle meshes of the room and its objectsDraft Community Group Report, February 2026
Depth sensingdepth-sensingA per-frame distance image from the headsetWorking Draft, August 2026

None of these is a finished W3C Recommendation, so details can still change between browser versions.

Hit test

A hit test casts a ray and returns where it meets real-world geometry. You use it to place things: point at the table, get a pose on the table. The result's Y axis points along the surface normal, the direction straight out of the surface. An object placed with it stands upright on a table and sticks out from a wall.

A hit test only sees the real world. It ignores your own virtual objects.

Anchors

The headset keeps refining its map of the room, so a fixed coordinate can end up a few centimeters from the real spot it once marked. An anchor is a pose the system keeps tied to a real location while that map changes. You create one, then read its pose every frame and move your object to it.

The Quest Browser adds persistent anchors. You call requestPersistentHandle() on an anchor and store the string it returns. After a reload, restorePersistentAnchor() on the session gives the anchor back. Meta documents three limits. A site can hold 8 persistent anchors at a time. They do not survive private mode. Clearing the site's history deletes them.

Plane detection

Plane detection hands you the flat surfaces of the room. Each XRPlane has a polygon and an orientation (horizontal or vertical). It can also carry a semantic label such as "table" or "wall". You read them from frame.detectedPlanes.

On Quest, planes come from the room scan the user made during space setup. Meta says the polygons are always horizontal or vertical rectangles on its headsets. If the user has no scan, the list is empty. Your page can then call session.initiateRoomCapture() to start the scan from inside the session. The list does not fill at once, so Meta advises waiting 2 to 3 seconds after the session starts before you decide it is empty. The call works only once per session.

Mesh detection

Mesh detection returns triangle meshes instead of flat rectangles. Each XRMesh has vertices, indices and an optional semantic label. Meta's Immersive Web SDK guide describes two kinds: a global mesh of the scene, and bounded meshes for single objects with labels such as "table" or "chair". Use meshes for physics and for hiding virtual objects behind furniture. On Quest, the guide says room setup must be finished first.

Depth sensing

Depth sensing gives you a distance value for each pixel of the view, updated live. Its main use is occlusion: a virtual object goes behind your hand or a chair that was never scanned. Besides the depth-sensing feature string, requestSession needs a depthSensing object with two required lists: usagePreference and dataFormatPreference. The usage is cpu-optimized or gpu-optimized. With CPU data you call getDepthInMeters(x, y). With GPU data you get a texture to sample in a shader, which is the route to use for occlusion.

Which devices and browsers support what

This is what each vendor documents as of November 2026. "Not listed" means the vendor's page does not name the module. It is not proof that the module is missing, so test on the device.

FeatureMeta Quest BrowserChrome on Android XRSafari on Apple Vision Pro
immersive-ar passthroughYesYesNo
Hit testYesYesNo
AnchorsYes, plus persistent anchorsYesNo
Plane detectionYesNot listedNo
Mesh detectionYes, headset models not listedNot listedNo
Depth sensingYes, on Quest 3 and 3SYesNo

Notes on each column:

  • Meta Quest. Meta's mixed reality page documents passthrough, plane detection and anchors. It lists passthrough as color on Quest Pro and grayscale on Quest 2. The page predates Quest 3 and 3S, which also have color passthrough cameras. Mesh detection is documented in Meta's Immersive Web SDK guide, which names no headset models. The browser's release history mentions depth sensing in version 33.3 (June 2024), and UploadVR reports that the underlying Depth API runs on Quest 3 and 3S. Since Browser 40.4 in October 2025, hit testing on Quest 3 and 3S uses that live depth, so it works without a room scan, according to the same UploadVR report.
  • Android XR. Google lists the AR module, hit test, anchors, depth sensing, light estimation and hand input for Chrome on Android XR. Depth is stereo there: one depth map per eye, where a phone delivers one. Plane and mesh detection are not on the list. There is more in the Android XR and Galaxy XR guide.
  • Apple Vision Pro. An Apple engineer wrote on the developer forums in June 2026 that immersive-ar "isn't currently supported in visionOS". We found no later statement from Apple. Safari runs immersive-vr sessions. See WebXR on Apple Vision Pro for what does work.
  • Pico. Pico's developer page for the Pico 4 Ultra says its Chromium-based browser supports the "WebXR MR API". The page has no per-module list, so test on the device.
  • Android phones. WebXR AR runs on phones that support ARCore, Google's AR service, with Google Play Services for AR installed. The scene shows on the phone screen instead of in a headset.

The full picture across all browsers, VR included, is in the WebXR browser support table.

Example: place an object on a real table

The flow has four steps:

  1. Start an immersive-ar session with hit-test.
  2. Each frame, cast a ray and show a ring (a reticle) where it hits.
  3. On trigger press or pinch, create an object at the reticle.
  4. Create an anchor there and keep the object glued to it.

This version uses three.js, a JavaScript 3D library. It follows the official webxr_ar_hittest example, with anchors added. The API calls were checked against the three.js r187 source and MDN in November 2026.

import * as THREE from 'three';
import { ARButton } from 'three/addons/webxr/ARButton.js';

const renderer = new THREE.WebGLRenderer({ antialias: true, alpha: true });
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.xr.enabled = true;
document.body.appendChild(renderer.domElement);
document.body.appendChild(ARButton.createButton(renderer, {
  requiredFeatures: ['hit-test'],
  optionalFeatures: ['anchors'],
}));

const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(70, window.innerWidth / window.innerHeight, 0.01, 20);
scene.add(new THREE.HemisphereLight(0xffffff, 0xbbbbff, 3));

const reticle = new THREE.Mesh(
  new THREE.RingGeometry(0.08, 0.1, 32).rotateX(-Math.PI / 2),
  new THREE.MeshBasicMaterial()
);
reticle.matrixAutoUpdate = false;
reticle.visible = false;
scene.add(reticle);

const boxGeometry = new THREE.BoxGeometry(0.1, 0.1, 0.1).translate(0, 0.05, 0);
const placed = [];
let hitTestSource = null;
let placeRequested = false;

for (const index of [0, 1]) {
  const controller = renderer.xr.getController(index);
  controller.addEventListener('select', () => { placeRequested = true; });
  scene.add(controller);
}

renderer.xr.addEventListener('sessionstart', async () => {
  const session = renderer.xr.getSession();
  const viewerSpace = await session.requestReferenceSpace('viewer');
  hitTestSource = await session.requestHitTestSource({ space: viewerSpace });
});
renderer.xr.addEventListener('sessionend', () => { hitTestSource = null; });

renderer.setAnimationLoop((time, frame) => {
  if (frame && hitTestSource) {
    const refSpace = renderer.xr.getReferenceSpace();
    const hits = frame.getHitTestResults(hitTestSource);
    const pose = hits.length > 0 ? hits[0].getPose(refSpace) : null;
    reticle.visible = pose !== null;

    if (pose) {
      reticle.matrix.fromArray(pose.transform.matrix);

      if (placeRequested) {
        const box = new THREE.Mesh(boxGeometry, new THREE.MeshStandardMaterial({ color: 0xff5533 }));
        box.matrixAutoUpdate = false;
        box.matrix.fromArray(pose.transform.matrix);
        scene.add(box);

        if (frame.createAnchor) {
          frame.createAnchor(pose.transform, refSpace)
            .then((anchor) => placed.push({ anchor, box }))
            .catch(() => {});
        }
      }
    }
    placeRequested = false;

    for (const { anchor, box } of placed) {
      const anchorPose = frame.getPose(anchor.anchorSpace, refSpace);
      if (anchorPose) box.matrix.fromArray(anchorPose.transform.matrix);
    }
  }
  renderer.render(scene, camera);
});

What the code does:

  • alpha: true keeps the canvas transparent, so passthrough shows.
  • The hit test ray starts at the viewer space. That is the user's head, so the reticle follows the gaze.
  • select is WebXR's primary action event. It fires on a controller trigger press. With hand tracking on Quest, it fires on a pinch.
  • The box geometry is shifted up by half its height. It sits on the table instead of sinking into it.
  • If the browser has no anchors, the box still appears. Its position is then not corrected when the headset updates its map of the room.

You do not need a headset to try it. Meta's Immersive Web Emulator, a desktop browser extension, emulates hit test, plane detection, mesh detection and anchors. The steps are in how to test WebXR without a headset.

Design tips for room-scale mixed reality

Every user's room is different, and your app cannot know its size or furniture in advance. These points come from Meta's mixed reality design guidelines and from how the APIs behave.

  • Define a minimum room. Decide the smallest space and the fewest surfaces your app needs. Meta calls this designing "for a minimally viable environment". No table found? Offer the floor.
  • Ask for the least. Hit test needs no room scan on Quest 3 and 3S. Plane and mesh detection do. Use hit test when you only place a few objects that stay put. UploadVR notes that objects that move across surfaces still need the scanned room.
  • Start content about 1 meter away. Meta recommends placing objects roughly 1 meter away and slightly below the user's line of sight.
  • Anchor to the room, not the head. Meta's guideline: "Avoid locking HUD style content to the user's head movements." Put menus on a surface or at a fixed spot in the room.
  • Do not put objects behind real walls. Meta's guideline covers walls and other physical objects. Without occlusion, a virtual object that should be hidden is drawn on top of the wall. Keep content inside the room, or use depth sensing for occlusion.
  • Add a shadow. Meta's guideline is to "use shadows for more realistic object placement". A shadow under an object shows that it rests on the table and does not float above it.
  • Do not hide real objects. Meta's example is a virtual object that overlaps a real lamp or vase and hides it from the user.
  • Fade between passthrough and full VR. Meta's passthrough guideline says an abrupt switch "can be an overwhelming and uncomfortable experience". It recommends transitions such as fade animations.

Where Turbl fits

Turbl builds WebXR projects from a text description, and its games can use mixed reality that puts the game in your own room. You do not write the session or placement code. It is optimized for Meta Quest first and is single player only. If you need exact control over each module, write the code yourself with three.js or Babylon.js.

FAQ

Does WebXR support passthrough on Meta Quest?

Yes. Request an immersive-ar session in the Meta Quest Browser and draw on a transparent background. Meta's documentation lists color passthrough on Quest Pro and grayscale on Quest 2. Quest 3 and 3S also have color passthrough cameras.

Can a WebXR page access the passthrough camera image?

Not on Meta Quest. The browser places passthrough behind your canvas, and Meta's documentation says there is no way to get to the passthrough pixels. You get planes, meshes and depth instead of the picture.

Does Apple Vision Pro support WebXR mixed reality?

No, according to Apple's latest statement that we found. An Apple engineer wrote in June 2026 that immersive-ar is not supported in visionOS. Safari on Vision Pro runs immersive-vr sessions.

What is the difference between plane detection and mesh detection?

Plane detection gives flat polygons, such as a tabletop or a wall. Mesh detection gives triangle meshes that follow the real shape of the room and its objects. Planes are simpler and enough for placing things. Meshes suit physics and occlusion.

Do users need to scan their room first?

It depends on the feature. On Quest 3 and 3S, hit testing has used live depth since Browser 40.4 and needs no scan. Plane and mesh detection on Quest rely on the room setup. If it is missing, your page can call initiateRoomCapture() once per session to start it.

Sources

Keep reading