API reference

Every public class, method, and event in @codexo/exojs. Generated from source.

I

interfaceNavigationSpace

@codexo/exojs-pathfinding / pathfinding / stable

The search core's view of a world: integer node ids, a neighbour relation and a heuristic. GridSpace and WaypointGraph implement it, and so can application code - a space needs no scene node, no renderer and no asset. Implementations must be deterministic: the same query on an unmutated space has to produce the same neighbours in the same order, or paths stop being reproducible across runs and machines.

3
props
8
methods
0
events
Import
import { NavigationSpace } from '@codexo/exojs-pathfinding'

The search core's view of a world: integer node ids, a neighbour relation and a heuristic. GridSpace and WaypointGraph implement it, and so can application code - a space needs no scene node, no renderer and no asset.

Implementations must be deterministic: the same query on an unmutated space has to produce the same neighbours in the same order, or paths stop being reproducible across runs and machines.

Methods8
Describes the traversal from from to to, if the space models one.
heuristic(node: number, goal: number): number
Estimated remaining cost from node to goal. Must never overestimate, or the result stops being cost-optimal; returning 0 degrades the search to Dijkstra, which is the correct answer for a space without positions.
nearestNode?(x: number, y: number): number
The node closest to a point, whether or not it is traversable and whether or not the point lies inside the space. Backs snapToNearest for coordinate queries; without it such a query reports unreachable.
neighbors(node: number, agentSize: number, outNodes: Int32Array, outCosts: Float64Array): number
Writes the neighbours of node and the cost of stepping to each into the buffers, and returns how many were written. The buffers belong to the pathfinder and are reused across nodes and searches, so an implementation must not retain them. Costs must be positive and finite. agentSize is the requested clearance; spaces that do not model clearance ignore it.
pointToNode(x: number, y: number): number
The node at a point, or -1 when the point lies outside the space.
Returns a pruned expansion valid for a search at this agentSize, or null when the space cannot prune under those conditions. Called once per search, so an implementation may build state here - but not per node.
smoothPath?(nodes: readonly number[], agentSize: number): number[]
Returns a shortened node sequence with the same start and goal that is still traversable for an agent of agentSize. Backs smooth.
Properties3
maxDegree: number
Upper bound on how many neighbours one node can have.
nodeCapacity: number
One past the largest node id. Sizes the pathfinder's search buffers.
revision: number
Increments on every mutation that can invalidate a path. Carried into PathResult.revision so callers can detect stale paths.
Source