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

GridEditorBase

The writes every grid editor takes, 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]

ReadonlyGridBase.cellAt


copyFrom(values): void

Takes every value whole, one per cell in index order.

Parameter Type
values ArrayLike<number>

void


fillAt(value, fromIndex, toIndex): void

Fills the inclusive box between the cells at two indices.

Parameter Type
value number
fromIndex number
toIndex number

void


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

ReadonlyGridBase.forEachChange


readAt(index): number

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

Parameter Type
index number

number

ReadonlyGridBase.readAt


setAt(index, value): void

Sets the value at index.

Parameter Type
index number
value number

void