BabylonJS/Babylon.js · error · Error
At least one mesh is needed to create the nav mesh.
Error message
At least one mesh is needed to create the nav mesh.
What it means
GenerateNavMeshWithWorker() is the worker-based async path of nav mesh generation (generator.worker.ts:41). Like the single-threaded path, it requires at least one Babylon.js Mesh because the worker needs geometry to rasterize. An empty meshes array is rejected immediately with this error before any worker message is sent.
Source
Thrown at packages/dev/addons/src/navigation/generator/generator.worker.ts:41
export function GenerateNavMeshWithWorker(
meshes: Array<Mesh>,
parameters: INavMeshParametersV2,
workerOptions: {
/**
* Completion callback that is called when the NavMesh generation is complete.
* @param navMesh The generated NavMesh.
* @param navMeshQuery The NavMeshQuery associated with the generated NavMesh.
* @param tileCache Optional TileCache if tile cache generation was used.
*/
completion: (navMesh: NavMesh, navMeshQuery: NavMeshQuery, tileCache?: TileCache) => void;
/**
* Worker instance used for asynchronous NavMesh generation.
*/
worker: Worker;
}
) {
if (meshes.length === 0) {
throw new Error("At least one mesh is needed to create the nav mesh.");
}
// callback function to process the message from the worker
workerOptions.worker.onmessage = (e) => {
if ((e as any).data?.success === false) {
throw new Error(`Unable to generate navMesh: ${e}`);
} else {
const { navMesh, tileCache } = e.data;
if (tileCache) {
// if tileCache is present, the binary data contains the navmesh and the tilecache as well
const tileCacheArray = new Uint8Array(tileCache);
const navMeshData = BuildFromTileCacheData(tileCacheArray, CreateDefaultTileCacheMeshProcess());
workerOptions.completion(navMeshData.navMesh, navMeshData.navMeshQuery, navMeshData.tileCache);
return;
} else {
if (navMesh) {
// deserialize the navmesh only (no tilecache present)
const navMeshArray = new Uint8Array(navMesh);View on GitHub (pinned to 0592b347b8)
Solutions
- Pass at least one mesh with geometry: plugin.createNavMesh([ground, ...obstacles], parameters)
- Guard the call site: if (meshes.length === 0) { /* fix collection or skip generation */ }
- Verify the mesh collection query (tags/predicates/enabled state) actually returns meshes and that async loads completed first
Example fix
// before
const meshes = scene.meshes.filter(m => m.metadata?.nav); // empty
await plugin.createNavMeshAsync(meshes, parameters);
// after
const meshes = scene.meshes.filter(m => m.metadata?.nav);
if (meshes.length === 0) {
meshes.push(groundMesh); // ensure there is a base nav surface
}
await plugin.createNavMeshAsync(meshes, parameters); Defensive patterns
Strategy: validation
Validate before calling
const meshes = scene.meshes.filter(m => m.isEnabled() && m.geometry);
if (meshes.length === 0) {
return; // or push a fallback ground mesh before creating the plugin
}
await CreateNavigationPluginWorkerAsync(meshes, parameters, workerOptions); Type guard
function hasMeshes(meshes: unknown): meshes is Array<Mesh> {
return Array.isArray(meshes) && meshes.length > 0;
} Try / catch
try {
await plugin.createNavMeshAsync(meshes, parameters);
} catch (e) {
if (e instanceof Error && e.message.includes("At least one mesh is needed")) {
// fix mesh collection before retrying
}
} Prevention
- Guard worker-based generation behind a meshes.length > 0 check
- Collect meshes only after scene.whenReadyAsync() so async loads are complete
- Keep a known-good base mesh (e.g. ground) always in the nav mesh list
When it happens
Trigger: Calling GenerateNavMeshWithWorker([], parameters, workerOptions) — typically indirectly through CreateNavigationPluginWorkerAsync with an empty mesh array; same root causes as error 10: filtering/tag selection matching nothing, async loads not finished, or conditionally built arrays that end up empty.
Common situations: Same as error 10 but in apps using the worker plugin for off-thread generation: game startup calling createNavMesh before level meshes load; tag-based filters returning zero; refactors that pass a subset array that is empty.
Related errors
- At least one mesh is needed to create the nav mesh.
- Unable to generate navMesh: ${e}
- Unable to create navmesh. No navMesh or navMeshQuery returne
- Unable to get nav mesh. No vertices or indices.
- Unable to generateSoloNavMesh: ${result.error}
AI-assisted analysis of BabylonJS/Babylon.js@0592b347b8 (2026-08-30).
Data as JSON: /api/errors/e47f1dc7e5d32489.
Report an issue: GitHub.