BabylonJS/Babylon.js · error · Error

There is no TileCache generated.

Error message

There is no TileCache generated.

What it means

getTileCacheData() exports the tile cache built with buildTileCache so it can be saved and later restored via buildFromTileCacheData. It requires both a navmesh (this.navMesh) and a tile cache (this._tileCache) to exist; otherwise it throws this error.

Source

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

     * @param tileCacheData the data returned by getTileCacheData
     * @param tileCacheMeshProcess optional process to apply to each tile created
     */
    public buildFromTileCacheData(tileCacheData: Uint8Array, tileCacheMeshProcess?: TileCacheMeshProcess): void {
        const result = this.bjsRECAST.importTileCache(tileCacheData, tileCacheMeshProcess ?? CreateDefaultTileCacheMeshProcess([]));
        this.navMesh = result.navMesh;
        this._tileCache = result.tileCache;
        this._navMeshQuery = new this.bjsRECAST.NavMeshQuery(this.navMesh);
    }

    /**
     * returns the tile cache data that can be used later. The tile cache must be built before retrieving the data
     * @returns the tile cache data that can be used later. The tile cache must be built before retrieving the data
     * @throws Error if there is no TileCache generated
     * @remarks The returned data can be used to rebuild the tile cache later using buildFromTileCacheData
     */
    public getTileCacheData(): Uint8Array {
        if (!this.navMesh || !this._tileCache) {
            throw new Error("There is no TileCache generated.");
        }
        return this.bjsRECAST.exportTileCache(this.navMesh, this._tileCache);
    }

    /**
     * Disposes
     */
    public dispose() {
        this._crowd?.dispose();
        this.navMesh?.destroy();
        this._navMeshQuery?.destroy();
        this._tileCache?.destroy();
    }

    /**
     * Creates a cylinder obstacle and add it to the navigation
     * @param position world position
     * @param radius cylinder radius

View on GitHub (pinned to 0592b347b8)

Solutions

  1. Build a tiled navmesh and call buildTileCache before exporting
  2. Verify this.navMesh exists before calling getTileCacheData
  3. Await navmesh/tile cache creation before exporting
  4. Use getNavmeshData instead if the workflow is non-tiled

Example fix

// before
const tileCacheData = plugin.getTileCacheData();
// after
if (plugin.navMesh && plugin._tileCache) {
    const tileCacheData = plugin.getTileCacheData();
} else {
    await plugin.createNavMeshAsync(meshes, tileParameters);
}
Defensive patterns

Strategy: validation

Validate before calling

if (!plugin.navMesh || !(plugin as any)._tileCache) {
    throw new Error("Tiled navmesh and tile cache required before export");
}
const data = plugin.getTileCacheData();

Type guard

const hasTileCache = (p: { navMesh?: unknown; _tileCache?: unknown }): boolean => p.navMesh != null && p._tileCache != null;

Try / catch

try {
    const data = plugin.getTileCacheData();
} catch (e) {
    if (e.message.includes("no TileCache")) {
        // fall back to non-tiled export or rebuild tiled navmesh
        const data = plugin.getNavmeshData();
    }
}

Prevention

When it happens

Trigger: Calling getTileCacheData() when buildTileCache was never called, when tile-based navmesh creation was not requested (no tileCache produced), or when the navMesh itself is null (never created or disposed).

Common situations: Saving tile cache data in a non-tiled navmesh workflow; calling the export before the navmesh build completes; exporting after dispose(); mixing tileCache APIs with a navmesh built without tile caching.

Related errors


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