BabylonJS/Babylon.js · error

feature not found

Error message

feature not found

What it means

WebXRFeaturesManager.ConstructFeature looks up a constructor in _AvailableFeatures[featureName][version] and returns a factory function. If no constructor is registered for that exact name+version pair, it throws this generic "feature not found" Error. It means the requested feature/version combination was never registered (or not imported/registered yet).

Source

Thrown at packages/dev/core/src/XR/webXRFeaturesManager.ts:428

            this._AvailableFeatures[featureName].stable = version;
        }
        this._AvailableFeatures[featureName][version] = constructorFunction;
    }

    /**
     * Returns a constructor of a specific feature.
     *
     * @param featureName the name of the feature to construct
     * @param version the version of the feature to load
     * @param xrSessionManager the xrSessionManager. Used to construct the module
     * @param options optional options provided to the module.
     * @returns a function that, when called, will return a new instance of this feature
     */
    public static ConstructFeature(featureName: string, version: number = 1, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature {
        const constructorFunction = this._AvailableFeatures[featureName][version];
        if (!constructorFunction) {
            // throw an error? return nothing?
            throw new Error("feature not found");
        }

        return constructorFunction(xrSessionManager, options);
    }

    /**
     * Can be used to return the list of features currently registered
     *
     * @returns an Array of available features
     */
    public static GetAvailableFeatures() {
        return Object.keys(this._AvailableFeatures);
    }

    /**
     * Gets the versions available for a specific feature
     * @param featureName the name of the feature
     * @returns an array with the available versions

View on GitHub (pinned to 0592b347b8)

Solutions

  1. Verify the feature name matches a registered WebXR feature constant (e.g. WebXRFeatureName.ANCHOR_SYSTEM) exactly.
  2. Check WebXRFeaturesManager.AvailableFeatures (or the feature's exported versions) for the versions actually registered and pass one of those.
  3. Import the module that registers the feature (side-effect imports in the Babylon XR entrypoint) so it appears in the registry.
  4. Use version "stable" or "latest" instead of a hardcoded number when unsure.
  5. Wrap in try/catch and fall back to a default feature set if the feature is optional.

Example fix

// before
WebXRFeaturesManager.ConstructFeature("hit-test", 2, sessionManager);
// after
const version = WebXRFeaturesManager.GetStableVersionOfFeature(WebXRFeatureName.HIT_TEST);
WebXRFeaturesManager.ConstructFeature(WebXRFeatureName.HIT_TEST, version, sessionManager);
Defensive patterns

Strategy: validation

Validate before calling

const name = WebXRFeatureName.HIT_TEST;
const version = WebXRFeaturesManager.GetStableVersionOfFeature(name);
if (version === -1) throw new Error(`Feature ${name} not registered`);

Type guard

function isFeatureAvailable(name: string, version: number): boolean {
    return !!WebXRFeaturesManager._AvailableFeatures?.[name]?.[version];
}

Try / catch

try {
    xr.enableFeature(WebXRFeatureName.HIT_TEST, "stable");
} catch (e) {
    if (String((e as Error).message) === "feature not found") {
    console.warn("Feature/version not registered; skipping");
    } else { throw e; }
}

Prevention

When it happens

Trigger: Calling WebXRFeaturesManager.ConstructFeature(name, version) (or enableFeature, which calls it) with a featureName absent from the registry, or a version number for which no constructor was registered for that feature.

Common situations: Misspelled feature name; requesting version 2 of a feature that only has version 1; tree-shaken builds where the feature module was never imported/registered; calling ConstructFeature directly with a stale version after a library upgrade.

Related errors


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