Skip to content

FoliageChunks beta ​

Class of @v12-engine/client

ts
export declare class FoliageChunks

A map's cells cut into chunks of size cells (FOLIAGE_CHUNK), by key (z * across + x in chunks): which wait to be laid, whole or where their cells changed, laid nearest a point first within the frame's budget; where what is laid in each stands (its bounds), and the level each is drawn at by its distance from the camera

Members ​

constructor ​

ts
constructor(
    width: number, 
    depth: number, 
    size?: number);

Constructs a new instance of the FoliageChunks class

across ​

ts
readonly across: number;

Chunks across the map

bounds ​

ts
readonly bounds: Float32Array;

Where what is laid in each chunk stands, in world units: the least x, y, z and the greatest, six numbers a chunk. The least past the greatest for a chunk with nothing

changed ​

ts
readonly changed: Uint8Array;

The cells that changed since their chunk was laid, a byte a cell of the map: what is laid again of a chunk not laid whole

count ​

ts
readonly count: number;

Chunks in all

depth ​

ts
readonly depth: number;

The map's cells down

distance ​

ts
distance(key: number, x: number, y: number, z: number): number;

How far a point is from what is laid in a chunk (its bounds), in world units: 0 inside, Infinity for a chunk with nothing

distances ​

ts
readonly distances: Float32Array;

How far each chunk's bounds were from the camera as measure last said: Infinity for a chunk with nothing

done ​

ts
done(key: number): void;

A chunk laid: it waits no more, and none of its cells is changed

down ​

ts
readonly down: number;

Chunks down the map

empty ​

ts
empty(key: number): void;

A chunk with nothing laid in it: its bounds empty

has ​

ts
has(key: number): boolean;

Whether a chunk has anything laid in it, by its bounds

keyOf ​

ts
keyOf(cell: number): number;

The chunk a cell is in, by the cell's index (row by row)

laidCount ​

ts
laidCount: number;

Chunks laid since it was made, all together: what a test counts

laying ​

ts
readonly laying: {
        ms: number;
        runs: number;
        longest: number;
        chunks: number;
    };

Milliseconds the laying took since startLaying, in how many runs, the longest run

layNow ​

ts
layNow(test: (key: number) => boolean, lay: (key: number, whole: boolean) => void, budget?: FrameBudget): number;

Lays at once the waiting chunks test says, whatever the budget (a few cells changed, what is in view): how many

layWaiting ​

ts
layWaiting(x: number, z: number, budget: FrameBudget | undefined, lay: (key: number, whole: boolean) => void): number;

Lays the waiting chunks, the nearest a point first, as long as the frame's budget for it lasts (its foliage work), or all of them with no budget. A chunk is never cut: one is not begun where the longest laid so far would not fit in what is left of the room (one is always laid where the budget lets the work go ahead). lay is told each and whether whole; each is done after. How many it laid

level ​

ts
level(key: number, distance: number, edges: ArrayLike<number>): FoliageLevel;

The level a chunk is drawn at, at this distance (FOLIAGE_LEVEL): past edges[0] mid, past edges[1] far, past edges[2] none (Infinity for an edge not set). A chunk comes back to a nearer level only closer than its edge by DETAIL_HYSTERESIS, so that it does not flicker at the edge. Kept in levels

levels ​

ts
readonly levels: Uint8Array;

The level each chunk is drawn at (FOLIAGE_LEVEL), as level or measure last said

mark ​

ts
mark(key: number): void;

A chunk to be laid whole

markAll ​

ts
markAll(): void;

Every chunk to be laid whole

markCells ​

ts
markCells(cells: readonly number[]): number;

Cells that changed: their chunks to be laid again where they did. How many chunks wait now

measure ​

ts
measure(x: number, y: number, z: number, edges: ArrayLike<number>): void;

Every chunk's distance from a point (the camera) and its level by it (level), into distances and levels: once a frame, for all of them, nothing made

nearest ​

ts
nearest(x: number, z: number): number;

The waiting chunk nearest a point of the ground (its middle's), -1 when none waits

pending ​

ts
get pending(): number;

How many chunks wait to be laid

size ​

ts
readonly size: number;

Cells across a chunk

startLaying ​

ts
startLaying(): void;

The counts of laying begun again: a new laying of the layer starts

waiting ​

ts
waiting(key: number): number;

Whether a chunk waits to be laid, and how: 0 not, 1 where its cells changed, 2 whole

width ​

ts
readonly width: number;

The map's cells across

x0 ​

ts
x0(key: number): number;

The first column of a chunk's cells

x1 ​

ts
x1(key: number): number;

Past the last column of a chunk's cells

z0 ​

ts
z0(key: number): number;

The first row of a chunk's cells

z1 ​

ts
z1(key: number): number;

Past the last row of a chunk's cells