Navigation · class

NavMeshQuery

A query, holding everything a search needs so that running one allocates nothing.

Explained in Navigation.

class NavMeshQuery
import { NavMeshQuery } from '@driftengine/nav';

In depth

One per agent, or one shared by a caller that queries serially. The scratch is sized by the mesh because a polygon path cannot be longer than the mesh has polygons.

Constructor

new

constructor(mesh: PolyMesh)
ParameterTypeDescription
meshPolyMesh

Properties

NameTypeDescription
meshreadonlyPolyMesh
portalsreadonlyPortalGraph

Methods

findPolyPath

findPolyPath(from: number, to: number, out: Uint32Array): number

The polygons from from to to, written into out. Zero where there is no route.

ParameterTypeDescription
fromnumber
tonumber
outUint32Array
More

Asked between the two polygons' centres, because a polygon is a region and a search over portals needs a point. What comes back is the corridor a path between those two points would be funnelled through, which is what a caller asking this question wants.

findPath

findPath(fromX: number, fromZ: number, toX: number, toZ: number, extent: number, out: Float64Array): number

A path from one point to another, as world positions in out, x and z per step.

ParameterTypeDescription
fromXnumber
fromZnumber
toXnumber
toZnumber
extentnumber
outFloat64Array
More

Returns how many points were written, or zero for no route — which is a real answer, not an error: a mesh with two components is a world with a gap in it, and an agent that asks for the other side has to be told rather than thrown at inside a frame.