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.
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new NavGrid(
opts):NavGrid
Defined in: ai/nav/NavGrid.ts:51
Parameters
Section titled “Parameters”Returns
Section titled “Returns”NavGrid
Properties
Section titled “Properties”cellSize
Section titled “cellSize”
readonlycellSize:number
Defined in: ai/nav/NavGrid.ts:45
height
Section titled “height”
readonlyheight:number
Defined in: ai/nav/NavGrid.ts:44
originX
Section titled “originX”
readonlyoriginX:number
Defined in: ai/nav/NavGrid.ts:46
originY
Section titled “originY”
readonlyoriginY:number
Defined in: ai/nav/NavGrid.ts:47
walkable
Section titled “walkable”
readonlywalkable:Uint8Array
Defined in: ai/nav/NavGrid.ts:49
Row-major walkability, 1 = walkable. Mutable via setWalkable.
readonlywidth:number
Defined in: ai/nav/NavGrid.ts:43
Methods
Section titled “Methods”cellToWorld()
Section titled “cellToWorld()”cellToWorld(
gx,gy):Vec2
Defined in: ai/nav/NavGrid.ts:84
Center of cell (gx, gy) in world pixels.
Parameters
Section titled “Parameters”number
number
Returns
Section titled “Returns”inBounds()
Section titled “inBounds()”inBounds(
gx,gy):boolean
Defined in: ai/nav/NavGrid.ts:71
Parameters
Section titled “Parameters”number
number
Returns
Section titled “Returns”boolean
index()
Section titled “index()”index(
gx,gy):number
Defined in: ai/nav/NavGrid.ts:67
Parameters
Section titled “Parameters”number
number
Returns
Section titled “Returns”number
isWalkable()
Section titled “isWalkable()”isWalkable(
gx,gy):boolean
Defined in: ai/nav/NavGrid.ts:75
Parameters
Section titled “Parameters”number
number
Returns
Section titled “Returns”boolean
nearestWalkable()
Section titled “nearestWalkable()”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.
Parameters
Section titled “Parameters”number
number
maxRadius?
Section titled “maxRadius?”number = 8
Returns
Section titled “Returns”Cell | null
setWalkable()
Section titled “setWalkable()”setWalkable(
gx,gy,walkable):void
Defined in: ai/nav/NavGrid.ts:79
Parameters
Section titled “Parameters”number
number
walkable
Section titled “walkable”boolean
Returns
Section titled “Returns”void
worldToCell()
Section titled “worldToCell()”worldToCell(
wx,wy):Cell
Defined in: ai/nav/NavGrid.ts:89
Cell containing world point (wx, wy). May be out of bounds — caller checks.
Parameters
Section titled “Parameters”number
number