-
Tag walkable meshes in your GLTF with
userData.navigable = true. -
At load, the engine builds a 2.5D heightfield grid over the scene bounds:
- Downward raycasts over the tagged meshes determine per‑cell ground height.
- Cells are marked walkable if they meet slope and step‑height constraints.
- Optional per‑object cost: set
userData.navigableCost(ornavCost/cost) on a mesh to scale movement cost.
-
No baking step is required; just set userData on your GLTF meshes.
cellSize(m): grid resolution (default 0.5)maxSlopeDeg(deg): maximum walkable surface slope (default 45)stepHeight(m): maximum vertical delta between neighbor cells (default 0.4)agentRadius(m): used for future clearance logic (default 0.3)smooth(bool): simple waypoint smoothing (default true)
- Add
NavLinkcomponent to any node to connect two points:targetName: name of the target objectbidirectional(default true)cost(default 1.0)
- At load, each link snaps to the nearest grid nodes and adds edges into the graph.
NavMesh.findPath(start: Vector3, end: Vector3, { smooth?: boolean }) => Vector3[]- Returns an array of world positions (Y from sampled ground).
- Use
Agent(src/runtime/agent.js) withuseNavMesh: trueto follow paths.
- On walkable geometry:
userData.navigable = true - Optional:
userData.navigableCost = number - Add
NavMeshanywhere in the scene (e.g., root component mapping) to enable navigation.
- For large worlds, consider tiling cell generation; current implementation builds a single grid over scene bounds.