BabylonJS/Babylon.js · error

Anchors are not enabled in your browser

Error message

Anchors are not enabled in your browser

What it means

_createAnchorAtTransformationAsync requires XRFrame.createAnchor; when the browser does not implement it, the method first detaches the anchor feature and throws this Error. It indicates the current browser/session cannot create frame-based XR anchors at all.

Source

Thrown at packages/dev/core/src/XR/features/WebXRAnchorSystem.pure.ts:589

                // Logger.Warn("Please provide a world parent node to apply world transformation");
            } else {
                mat.multiplyToRef(this._options.worldParentNode.getWorldMatrix(), mat);
            }
        }

        return <IWebXRAnchor>anchor;
    }

    private async _createAnchorAtTransformationAsync(xrTransformation: XRRigidTransform, xrFrame: XRFrame) {
        if (xrFrame.createAnchor) {
            try {
                return await xrFrame.createAnchor(xrTransformation, this._referenceSpaceForFrameAnchors ?? this._xrSessionManager.referenceSpace);
            } catch (error) {
                throw new Error(String(error), { cause: error });
            }
        } else {
            this.detach();
            throw new Error("Anchors are not enabled in your browser");
        }
    }
}

let _Registered = false;
/**
 * Register side effects for webXRAnchorSystem.
 * Safe to call multiple times; only the first call has an effect.
 */
export function RegisterWebXRAnchorSystem(): void {
    if (_Registered) {
        return;
    }
    _Registered = true;

    // register the plugin
    WebXRFeaturesManager.AddWebXRFeature(
        WebXRAnchorSystem.Name,

View on GitHub (pinned to 0592b347b8)

Solutions

  1. Check support before enabling: `if (!xrFrame.createAnchor)` or check WebXR 'anchors' feature availability, and provide a non-anchor fallback.
  2. Request the 'anchors' feature in the session (WebXRAnchorSystem name/requiredFeatures) with a browser that implements it.
  3. Use a device/browser that supports WebXR anchors (recent Quest browser, ChromeOS/Android Chrome with ARCore, etc.).
  4. Catch the error and disable anchor-dependent functionality gracefully (the feature is detached automatically).

Example fix

// before
const anchor = await anchors.addAnchorAtTransformationAsync(matrix);
// after
const session = xrSessionManager.session;
const supportsAnchors = typeof XRFrame !== "undefined" && XRFrame.prototype?.createAnchor;
if (!supportsAnchors) {
    console.warn("WebXR anchors unsupported; using local tracking only");
} else {
    const anchor = await anchors.addAnchorAtTransformationAsync(matrix);
}
Defensive patterns

Strategy: fallback

Validate before calling

const anchorsSupported = typeof XRFrame !== "undefined" && typeof (XRFrame.prototype as any)?.createAnchor === "function";
if (!anchorsSupported) { /* use non-anchor fallback */ }

Type guard

function supportsXRFrameAnchors(): boolean {
    return typeof XRFrame !== "undefined" && typeof (XRFrame.prototype as any).createAnchor === "function";
}

Try / catch

try {
    return await anchors.addAnchorAtTransformationAsync(matrix);
} catch (e) {
    if (String((e as Error).message).includes("Anchors are not enabled")) {
    return fallbackLocalTracking(matrix);
    }
    throw e;
}

Prevention

When it happens

Trigger: Requesting an anchor (via xrAnchor() or the anchor system's frame loop) on a browser or XR runtime without XRFrame.createAnchor support (no WebXR anchors module).

Common situations: Desktop browsers or older headsets lacking the WebXR anchors API; entering an immersive session where 'anchors' was not requested/granted so createAnchor is never exposed; using a polyfill that omits anchors.

Related errors


AI-assisted analysis of BabylonJS/Babylon.js@0592b347b8 (2026-08-30). Data as JSON: /api/errors/b5aff0ae475931cb. Report an issue: GitHub.