跳转到内容

NavGrid

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

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

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:51

NavGridOptions

NavGrid

readonly cellSize: number

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


readonly height: number

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


readonly originX: number

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


readonly originY: number

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


readonly walkable: Uint8Array

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

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


readonly width: number

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

cellToWorld(gx, gy): Vec2

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

Center of cell (gx, gy) in world pixels.

number

number

Vec2


inBounds(gx, gy): boolean

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

number

number

boolean


index(gx, gy): number

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

number

number

number


isWalkable(gx, gy): boolean

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

number

number

boolean


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

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

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

Cell | null


setWalkable(gx, gy, walkable): void

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

number

number

boolean

void


worldToCell(wx, wy): Cell

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

Cell containing world point (wx, wy). May be out of bounds — caller checks.

number

number

Cell