Navigation · class
NavMeshQuery
A query, holding everything a search needs so that running one allocates nothing.
Explained in Navigation.
class NavMeshQueryimport { 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)| Parameter | Type | Description |
|---|---|---|
mesh | PolyMesh |
Properties
| Name | Type | Description |
|---|---|---|
meshreadonly | PolyMesh | |
portalsreadonly | PortalGraph |
Methods
findPolyPath
findPolyPath(from: number, to: number, out: Uint32Array): numberThe polygons from from to to, written into out. Zero where there is no route.
| Parameter | Type | Description |
|---|---|---|
from | number | |
to | number | |
out | Uint32Array |
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): numberA path from one point to another, as world positions in out, x and z per step.
| Parameter | Type | Description |
|---|---|---|
fromX | number | |
fromZ | number | |
toX | number | |
toZ | number | |
extent | number | |
out | Float64Array |
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.