{"record":{"id":"51402890c0939fbc","repo":"BabylonJS/Babylon.js","slug":"there-is-no-navmesh-generated-514028","errorCode":null,"errorMessage":"There is no NavMesh generated.","messagePattern":"There is no NavMesh generated\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/dev/addons/src/navigation/plugin/RecastNavigationJSPlugin.ts","lineNumber":501,"sourceCode":"    }\n\n    /**\n     * build the navmesh from a previously saved state using getNavmeshData\n     * @param data the Uint8Array returned by getNavmeshData\n     */\n    public buildFromNavmeshData(data: Uint8Array): void {\n        const result = this.bjsRECAST.importNavMesh(data);\n        this.navMesh = result.navMesh;\n        this._navMeshQuery = new this.bjsRECAST.NavMeshQuery(this.navMesh);\n    }\n\n    /**\n     * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data\n     * @returns data the Uint8Array that can be saved and reused\n     */\n    public getNavmeshData(): Uint8Array {\n        if (!this.navMesh) {\n            throw new Error(\"There is no NavMesh generated.\");\n        }\n        return this.bjsRECAST.exportNavMesh(this.navMesh);\n    }\n\n    /**\n     * build the tile cache from a previously saved state using getTileCacheData\n     * @param tileCacheData the data returned by getTileCacheData\n     * @param tileCacheMeshProcess optional process to apply to each tile created\n     */\n    public buildFromTileCacheData(tileCacheData: Uint8Array, tileCacheMeshProcess?: TileCacheMeshProcess): void {\n        const result = this.bjsRECAST.importTileCache(tileCacheData, tileCacheMeshProcess ?? CreateDefaultTileCacheMeshProcess([]));\n        this.navMesh = result.navMesh;\n        this._tileCache = result.tileCache;\n        this._navMeshQuery = new this.bjsRECAST.NavMeshQuery(this.navMesh);\n    }\n\n    /**\n     * returns the tile cache data that can be used later. The tile cache must be built before retrieving the data","sourceCodeStart":483,"sourceCodeEnd":519,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/addons/src/navigation/plugin/RecastNavigationJSPlugin.ts#L483-L519","documentation":"RecastNavigationJSPlugin.getNavmeshData() exports the built navmesh as a Uint8Array for persistence, but requires that a navmesh has actually been built first (this.navMesh set by createNavMesh). If this.navMesh is null/undefined, the plugin throws this error instead of returning garbage.","triggerScenarios":"Calling getNavmeshData() before ever calling createNavMesh/createNavMeshAsync, or after createNavMesh threw 'Unable to create navmesh', or after dispose() cleared the plugin state.","commonSituations":"Trying to save a navmesh at app startup before the build step runs; saving after a failed creation due to bad parameters or geometry; ordering bugs in async code where the save runs before the awaited build finishes.","solutions":["Call createNavMesh (or createNavMeshAsync) successfully before calling getNavmeshData","Check this.navMesh / plugin.isSupported state before exporting","If building asynchronously, await the creation promise before exporting","If the plugin was disposed, recreate the plugin and rebuild the navmesh"],"exampleFix":"// before\nconst data = plugin.getNavmeshData();\n// after\nif (!plugin.navMesh) {\n    await plugin.createNavMeshAsync(meshes, parameters);\n}\nconst data = plugin.getNavmeshData();","handlingStrategy":"validation","validationCode":"if (!plugin.navMesh) {\n    throw new Error(\"Build the navmesh before exporting\");\n}\nconst data = plugin.getNavmeshData();","typeGuard":"const hasNavmesh = (p: { navMesh?: unknown }): p is { navMesh: object } => p.navMesh != null;","tryCatchPattern":"try {\n    const data = plugin.getNavmeshData();\n} catch (e) {\n    if (e.message.includes(\"no NavMesh generated\")) {\n        await plugin.createNavMeshAsync(meshes, params);\n    }\n}","preventionTips":["Always build (and await) createNavMeshAsync before any export/save call","Centralize navmesh save/load behind a helper that builds on demand","Check plugin state after dispose and rebuild before reuse"],"tags":["navigation","recast","navmesh","lifecycle"],"backgroundTag":"navmesh-not-built","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}