Skip to content

five-on-it / packages/world/src/pavements

packages/world/src/pavements ​

The pavements of a level: where people walk. Built from the roads alone, so any level with streets has them: beside every paved road, on both sides, a line of nodes a little beyond its edge (PAVEMENT's offset, every step metres), kept where a person could stand (open ground at the road's height, flat enough, off every carriageway); consecutive nodes along a side are linked when the way between them is clear. Around a junction the pavement ends are joined two ways: a corner (a link off every road, round the kerb to the next street) and a crossing over each arm, a couple of metres back from the junction's box (a zebra; people may wait at it). A door is a place in front of a building: the middle of its front (the side its model faces), out on the pavement, linked to the nearest node. Nodes that touch become one, so the pavements of streets meeting at a corner join up; the connected parts are numbered.

Walking the network: pavementDistances gives every node's walking distance to a goal (Dijkstra over the links, cached per goal) and nextPavementNode the next node on a shortest way there; nearestPavementNode finds the node nearest a point. Pure and deterministic, built once per level object (pavementsOf). Isomorphic: no DOM, no Node.

Interfaces ​

Variables ​

Functions ​