Navigation · interface

PortalGraph

Explained in Navigation.

interface PortalGraph
import type { PortalGraph } from '@driftengine/nav';

Properties

NameTypeDescription
graphreadonlyNavGraphNodes: one per portal, then the start, then the goal.
portalCountreadonlynumber
sidesreadonlyInt32ArrayThe two polygons each portal joins, near first: 2 per portal.
endsreadonlyInt32ArrayThe portal's two vertices as each of its polygons stores them: 4 per portal, near's pair then far's.
More

Both, rather than one pair flipped when the path crosses the other way. The funnel needs the left end and the right end for the direction of travel, and which vertex is which depends on the winding of the polygon being left — a mesh whose two polygons do not store a shared edge in opposite orders would silently get the funnel's two sides swapped, which is a legal path and a visibly worse one. Read at build time from both sides, so nothing assumes.

polyStartreadonlyUint32ArrayWhich portals a polygon has: polyStart[p] to polyStart[p + 1] into polyPortals.
polyPortalsreadonlyUint32Array
startNodereadonlynumber
goalNodereadonlynumber
goalSlotreadonlyUint32ArrayThe edge slot each portal keeps for the goal, and the range the start node's slots occupy.
startSlotsreadonlyUint32Array
attachedGoalnumberThe polygon whose portals currently point at the goal, or −1.