navigation
Navigation with navcat
navcat builds a navmesh (the interconnected walkable polygons of your level) from raw geometry and answers pathfinding queries over it. Reach for it when something needs to move intelligently through the world — enemies routing around obstacles, NPCs patrolling, units ordered to a point, agents that must avoid walls and gaps. It is rendering-agnostic; navcat/three adapts it to Three.js.
Do you even need a navmesh? For "walk straight at the target on open, flat ground," a navmesh is overkill — steer directly. A navmesh earns its place once agents must route around obstacles, across uneven or multi-level terrain, or as a coordinated crowd. If your case is simpler, implementing your own steering is the right call.
Versions move — read the installed types
This skill routes you to the right capability and decision; it does not pin exact signatures, because navcat's API (export names, option fields, return shapes) shifts between versions. Before calling into it, read the installed package's exports/types (navcat, navcat/blocks, navcat/three) to confirm current names and fields. Treat the code below as shape, not contract.
The pipeline at a glance
- Extract geometry — turn your walkable Three.js meshes (floor, terrain, obstacles) into
positions/indiceswithgetPositionsAndIndices(meshes)fromnavcat/three. - Generate the navmesh — one call:
generateSoloNavMesh(input, options)fromnavcat/blocksfor a single area (the default), orgenerateTiledNavMeshfor large worlds and partial rebuilds. - Query — paths, nearest walkable point, random points, line-of-sight, over the generated navmesh.
- Move agents — follow the path yourself each frame, or hand many agents to the
crowdblock.