Skip to content

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

packages/world/src/nav-layers ​

The layered navigation: the navigation grid (NavGrid) with what stands over its ground. A cell of the grid has its ground (node i is cell i, exactly as the grid makes it) and, above it, every other surface someone can stand on there: the floor of an upper storey, a deck, a bridge, the roof of a building or of a tunnel, a landing. Each such upper node is the top of something that collides (a structure or a building), up-facing enough to stand on, more than a step above the ground, with a person's headroom over it and not inside a solid; like the ground, it is blocked by every wall within the clearance of someone standing on it, and it is near a wall where it touches a blocked node or the edge of its floor.

Every node also knows the height of its surface just inside each of its cell's four edges (its edge heights): what carries someone there at the ground's height (the ground, or a deck a ramp ends on), or its floor there (none where the floor stops short of the edge). Two nodes of neighbouring cells are linked (forEachLink) when both are free and their surfaces meet where the cells do, within a step (LAYER_STEP): so a flight of stairs leads up its length onto the floor it reaches but is never climbed onto from its side, the street under a bridge stays apart from the road on it, and a table or a crate is no floor anyone gets onto. Pure and deterministic. Isomorphic: no DOM, no Node.

Interfaces ​

Variables ​

Functions ​