NavMesh
Defined in: ai/nav/NavMesh.ts:77
The active navigable world, however it was built.
Implements
Section titled “Implements”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new NavMesh(
data):NavMesh
Defined in: ai/nav/NavMesh.ts:107
Parameters
Section titled “Parameters”Returns
Section titled “Returns”NavMesh
Properties
Section titled “Properties”agentRadius
Section titled “agentRadius”
readonlyagentRadius:number
Defined in: ai/nav/NavMesh.ts:86
readonlyareas:Uint8Array
Defined in: ai/nav/NavMesh.ts:89
maxVertsPerPoly
Section titled “maxVertsPerPoly”
readonlymaxVertsPerPoly:number
Defined in: ai/nav/NavMesh.ts:85
readonlyneis:Int32Array
Defined in: ai/nav/NavMesh.ts:83
polyCount
Section titled “polyCount”
readonlypolyCount:number
Defined in: ai/nav/NavMesh.ts:84
readonlypolys:Int32Array
Defined in: ai/nav/NavMesh.ts:82
snapDistance
Section titled “snapDistance”
readonlysnapDistance:number
Defined in: ai/nav/NavMesh.ts:87
readonlyup:Vec3
Defined in: ai/nav/NavMesh.ts:79
The mesh follows the ground, so off it is straight up.
Implementation of
Section titled “Implementation of”verticalReach
Section titled “verticalReach”
readonlyverticalReach:number
Defined in: ai/nav/NavMesh.ts:88
readonlyverts:Float32Array
Defined in: ai/nav/NavMesh.ts:81
Accessors
Section titled “Accessors”linkCount
Section titled “linkCount”Get Signature
Section titled “Get Signature”get linkCount():
number
Defined in: ai/nav/NavMesh.ts:203
How many links this mesh carries, counting each direction of a two-way one.
Returns
Section titled “Returns”number
Methods
Section titled “Methods”connect()
Section titled “connect()”connect(
segments):void
Defined in: ai/nav/NavMesh.ts:186
Join places the ground does not. Each segment is resolved to the polygons under its two ends; one that reaches no ground at either end joins nothing and is dropped, because a link to nowhere is a route that ends in the air.
Parameters
Section titled “Parameters”segments
Section titled “segments”readonly NavLinkSegment[]
Returns
Section titled “Returns”void
contains()
Section titled “contains()”contains(
p,x,z):boolean
Defined in: ai/nav/NavMesh.ts:233
Whether (x, z) is inside polygon p, seen from above.
Parameters
Section titled “Parameters”number
number
number
Returns
Section titled “Returns”boolean
corner()
Section titled “corner()”corner(
p,i,out):Vec3
Defined in: ai/nav/NavMesh.ts:224
World position of polygon p’s corner i, written into out.
Parameters
Section titled “Parameters”number
number
Returns
Section titled “Returns”costOf()
Section titled “costOf()”costOf(
p):number
Defined in: ai/nav/NavMesh.ts:177
What crossing polygon p costs a unit of distance.
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”number
describe()
Section titled “describe()”describe(
sink):void
Defined in: ai/nav/NavMesh.ts:584
Hand the shape of the walkable world to a drawer.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”findPoly()
Section titled “findPoly()”findPoly(
p,out?,snap?):number
Defined in: ai/nav/NavMesh.ts:284
The polygon a world point stands on, or -1. A point over more than one —
under a bridge, on a balcony — belongs to the floor nearest its own height,
which is the whole reason this mesh exists. snap overrides how far off the
mesh the point may be, for a caller that has its own idea of near.
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”number
findWorldPath()
Section titled “findWorldPath()”findWorldPath(
from,to,opts?):Vec3[] |null
Defined in: ai/nav/NavMesh.ts:354
Plan a world-space route between two world points, or null when there is no way. The waypoints carry all three axes: on a flat surface the third is the plane the scene is drawn on, on a spatial one it is the ground the route walks over.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”Vec3[] | null
Implementation of
Section titled “Implementation of”heightAt()
Section titled “heightAt()”heightAt(
p,x,z):number
Defined in: ai/nav/NavMesh.ts:256
Height of polygon p at (x, z). A convex polygon is not flat — its
corners came off a voxel grid — so the answer comes from the triangle of
the fan that covers the point, and from the nearest corner when the point
is outside every one of them.
Parameters
Section titled “Parameters”number
number
number
Returns
Section titled “Returns”number
isNavigable()
Section titled “isNavigable()”isNavigable(
p):boolean
Defined in: ai/nav/NavMesh.ts:580
Whether an agent may stand at a world point. Asked of a place the agent has not been routed to — a step sideways to get round another body — which is why it is not the same question as “is there a route here”.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”boolean
Implementation of
Section titled “Implementation of”setAreaCost()
Section titled “setAreaCost()”setAreaCost(
area,cost):void
Defined in: ai/nav/NavMesh.ts:171
Say what an area costs to cross, against 1 for open ground. Cheap makes a route prefer it and dear makes it go round; nothing here BLOCKS, because a price an agent will not pay when there is another way is still a price it pays when there is not.
Parameters
Section titled “Parameters”number
number
Returns
Section titled “Returns”void
vertexCount()
Section titled “vertexCount()”vertexCount(
p):number
Defined in: ai/nav/NavMesh.ts:215
How many corners polygon p actually has.
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”number