Skip to content
Work in progress. These docs describe Spawnite at launch, and some parts are still being built.

ReadonlyGridBase

What every grid reads, whatever its dimensions.

Type Parameter Default type
Values extends GridArray GridArray
Property Modifier Type Description
values readonly ReadonlyTypedArray<Values> Each value, by its index, x fastest, then y, then z.
version readonly number Counts the grid’s changes, for a reader’s memo: a reader keeps the grid it read beside it, since a grid made again counts from 0.

cellAt(index, out): [number, number, number]

Writes the coordinates of the cell at index into out, a dimension the grid lacks as 0, and returns out.

Parameter Type
index number
out [number, number, number]

[number, number, number]


forEachChange(since, visit): boolean

Visits each change after version since, oldest first, and returns true; returns false, visiting nothing, when the grid no longer keeps the changes since since, so the reader reads values whole. The change handed is the same object for each visit.

Parameter Type
since number
visit (change) => void

boolean


readAt(index): number

The value at index. Throws for an index outside the grid.

Parameter Type
index number

number