BabylonJS/Babylon.js · error · Error

Unable to create navmesh. No navMesh or navMeshQuery returne

Error message

Unable to create navmesh. No navMesh or navMeshQuery returned.

What it means

_processNavMeshResult validates the result of Recast navmesh creation in createNavMesh/createNavMeshAsync. If the native/JS Recast call returns a partial result missing navMesh or navMeshQuery, the plugin throws instead of storing an unusable state.

Source

Thrown at packages/dev/addons/src/navigation/plugin/RecastNavigationJSPlugin.ts:714

            options
        );
        const polyHeightResult = this._navMeshQuery.getPolyHeight(polyRef, resultPosition);

        return {
            position: { x: resultPosition.x, y: polyHeightResult.success ? polyHeightResult.height : resultPosition.y, z: resultPosition.z },
            polyRef: polyRef,
            height: polyHeightResult.height,
        };
    }

    /**
     * Handles common post-processing and validation of navmesh creation results
     * @param result The partial result from navmesh creation
     * @returns The validated and complete CreateNavMeshresult
     */
    private _processNavMeshResult(result: Nullable<Partial<CreateNavMeshResult>>): CreateNavMeshResult {
        if (!result?.navMesh || !result?.navMeshQuery) {
            throw new Error("Unable to create navmesh. No navMesh or navMeshQuery returned.");
        }

        this.navMesh = result.navMesh;
        this._navMeshQuery = result.navMeshQuery;
        this._intermediates = result.intermediates;
        this._tileCache = result.tileCache;

        return {
            navMesh: result.navMesh,
            navMeshQuery: result.navMeshQuery,
            intermediates: result.intermediates,
            tileCache: result.tileCache, // tileCache is optional
        };
    }

    private _preprocessParameters(parameters: INavMeshParametersV2) {
        // if maxObstacles is not defined, set it to a default value and set a default tile size if not defined
        if (parameters.maxObstacles === undefined) {

View on GitHub (pinned to 0592b347b8)

Solutions

  1. Verify the meshes passed to createNavMesh are non-empty and visible/static
  2. Review navmesh creation parameters (cellSize, cellHeight, agentRadius, tileSize) for valid values
  3. Check the Recast library loaded correctly (plugin.isSupported / wasm initialized)
  4. Wrap creation in try/catch and log parameters; reduce scene to a simple box to isolate the failing input

Example fix

// before
const result = await plugin.createNavMeshAsync([], params); // throws
// after
if (meshes.length === 0) {
    throw new Error("No meshes provided for navmesh creation");
}
const result = await plugin.createNavMeshAsync(meshes, params);
Defensive patterns

Strategy: validation

Validate before calling

if (meshes.length === 0) {
    throw new Error("createNavMesh requires at least one mesh");
}
// validate parameters
if (!params.cellSize || params.cellSize <= 0) {
    throw new Error("Invalid cellSize");
}
const result = await plugin.createNavMeshAsync(meshes, params);

Type guard

const isValidResult = (r: unknown): r is { navMesh: object; navMeshQuery: object } =>
    !!r && typeof r === 'object' && 'navMesh' in r && 'navMeshQuery' in r &&
    (r as any).navMesh != null && (r as any).navMeshQuery != null;

Try / catch

try {
    const result = await plugin.createNavMeshAsync(meshes, params);
} catch (e) {
    if (e.message.includes("Unable to create navmesh")) {
        console.error("Navmesh params:", params, "meshes:", meshes.length);
        // retry with simplified geometry / default params
        await plugin.createNavMeshAsync(meshes, defaultParams);
    }
}

Prevention

When it happens

Trigger: createNavMesh/createNavMeshAsync invoked with parameters or geometry from which Recast cannot build a navmesh (empty meshes, degenerate cell sizes, bad bmax/bmin), or a Recast library failure/limit returning null results.

Common situations: Passing an empty mesh array; navmesh parameters (cellSize, agentHeight, tile size) out of valid ranges; unsupported/incompatible recast wasm build returning null; geometry outside the computed bounds.

Related errors


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