Skip to content

five-on-it / packages/world/src/nav-grid

packages/world/src/nav-grid ​

The navigation grid: a level's ground as cells someone can stand on or not, derived from the geometry with no authoring. Every cell knows the height of its ground (surfaceHeight: the plane, a terrace, a slope). A cell is blocked by every triangle that is a wall for someone standing on its ground (rising more than a step above it where it comes nearest, starting below head height over it, within a clearance: half a metre for a person, more for a car), sampled at the cell's centre and around it so a wall thinner than a cell cannot slip between two centres; a slope (a ramp, the hidden wedge under a flight of stairs, a hillside) is walkable, dearer; a cliff (two neighbouring cells more than a metre apart in height, neither a slope: a terrace's edge) blocks both its cells; ground under water deeper than a wade or under lava is blocked (people swim it, nobody plans through it); a road is tarmac; a cell next to a blocked one is near a wall. The AI plans on it with its own cost per flag. The grid is two-dimensional: a deck and the ground under it share their cells. Pure and deterministic. Isomorphic: no DOM, no Node.

Interfaces ​

Variables ​

Functions ​