跳转到内容

NavGrid

此内容尚不支持你的语言。

Defined in: ai/nav/NavGrid.ts:52

A uniform-cost square grid with a walkability mask. gy increases with world +Y; a Y-down source (e.g. a tilemap) flips rows when it builds the grid, so NavGrid itself stays direction-agnostic.

new NavGrid(opts): NavGrid

Defined in: ai/nav/NavGrid.ts:71

NavGridOptions

NavGrid

readonly cellSize: number

Defined in: ai/nav/NavGrid.ts:57


readonly height: number

Defined in: ai/nav/NavGrid.ts:56


readonly originX: number

Defined in: ai/nav/NavGrid.ts:59

Cell (0,0)’s centre.


readonly originY: number

Defined in: ai/nav/NavGrid.ts:60


readonly originZ: number

Defined in: ai/nav/NavGrid.ts:62

The depth the grid lies at — carried onto every waypoint it hands back.


readonly up: Vec3

Defined in: ai/nav/NavGrid.ts:54

The grid lies in x/y, so off it is toward whoever is looking at the scene.

NavSurface.up


readonly walkable: Uint8Array

Defined in: ai/nav/NavGrid.ts:64

Row-major walkability, 1 = walkable. Mutable via setWalkable.


readonly width: number

Defined in: ai/nav/NavGrid.ts:55

cellToWorld(gx, gy): Vec3

Defined in: ai/nav/NavGrid.ts:170

Centre of cell (gx, gy) in world space.

number

number

Vec3


clearanceAt(gx, gy): number

Defined in: ai/nav/NavGrid.ts:161

Cells from here to the nearest thing that blocks — off the grid counts as blocked. An agent is a body: a path hugging a wall is walkable for the cell it was planned through and a wall for the half hanging over the next. Computed on first ask, dropped when walkability changes.

number

number

number


clearCosts(): void

Defined in: ai/nav/NavGrid.ts:151

Put every cell back to open-ground price, before the areas are re-marked.

void


clearObstructions(): void

Defined in: ai/nav/NavGrid.ts:124

Lift everything off the ground at once, before the obstacles are re-marked.

void


costAt(gx, gy): number

Defined in: ai/nav/NavGrid.ts:136

What crossing a cell costs, against 1 for open ground. Cheap makes a route prefer it and dear makes it go round; it never blocks, because a price an agent will not pay when there is another way is still one it pays when there is not.

number

number

number


describe(sink): void

Defined in: ai/nav/NavGrid.ts:223

Every walkable cell as a quad, and every edge where the walkable world stops. The corner array is reused between calls — see NavSurfaceSink.

NavSurfaceSink

void

NavSurface.describe


findWorldPath(from, to, opts?): Vec3[] | null

Defined in: ai/nav/NavGrid.ts:207

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.

NavPoint

NavPoint

NavQueryOptions

Vec3[] | null

NavSurface.findWorldPath


inBounds(gx, gy): boolean

Defined in: ai/nav/NavGrid.ts:92

number

number

boolean


index(gx, gy): number

Defined in: ai/nav/NavGrid.ts:88

number

number

number


isNavigable(p): boolean

Defined in: ai/nav/NavGrid.ts:214

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”.

NavPoint

boolean

NavSurface.isNavigable


isWalkable(gx, gy): boolean

Defined in: ai/nav/NavGrid.ts:96

number

number

boolean


nearestWalkable(gx, gy, maxRadius?, clearance?): Cell | null

Defined in: ai/nav/NavGrid.ts:191

Nearest walkable cell to (gx, gy) by outward ring search, or null if the whole grid is blocked. Used to snap a start/goal that lands on a wall onto a usable cell before searching.

number

number

number = 8

number = 0

Cell | null


setCost(gx, gy, cost): void

Defined in: ai/nav/NavGrid.ts:141

number

number

number

void


setObstructed(gx, gy, obstructed): void

Defined in: ai/nav/NavGrid.ts:113

Put something in the way of a cell, or take it out again. The map’s own walkability is untouched: an obstacle is a thing standing ON the ground, and lifting it has to give back exactly the ground that was there.

number

number

boolean

void


setWalkable(gx, gy, walkable): void

Defined in: ai/nav/NavGrid.ts:102

number

number

boolean

void


worldToCell(p): Cell

Defined in: ai/nav/NavGrid.ts:179

Cell containing a world point. May be out of bounds — caller checks.

NavPoint

Cell