Skip to content

WaterField

Defined in: sdk/src/water/zone.ts:161

The baked water of a zone.

readonly amp: Float32Array

Defined in: sdk/src/water/zone.ts:165


readonly calm: Float32Array

Defined in: sdk/src/water/zone.ts:166


readonly depth: Float32Array

Defined in: sdk/src/water/zone.ts:170


readonly exposure: Float32Array

Defined in: sdk/src/water/zone.ts:177


readonly flowX: Float32Array

Defined in: sdk/src/water/zone.ts:168


readonly flowZ: Float32Array

Defined in: sdk/src/water/zone.ts:169


readonly grid: ZoneGrid

Defined in: sdk/src/water/zone.ts:162


readonly height: Float32Array

Defined in: sdk/src/water/zone.ts:163


readonly ocean: ZoneOcean | null

Defined in: sdk/src/water/zone.ts:181

The ocean, which goes on past the region: what a point outside it is.


readonly owner: Int32Array

Defined in: sdk/src/water/zone.ts:179

The body that owns the most of each texel, as its key; -1 where there is no water.


readonly shore: Float32Array

Defined in: sdk/src/water/zone.ts:164


readonly steep: Float32Array

Defined in: sdk/src/water/zone.ts:176

How steep the shore is, 0 (a gentle beach) to 1 (rock, a cliff): where waves burst white rather than wash up.


readonly still: Float32Array

Defined in: sdk/src/water/zone.ts:174

How much of the surf a current leaves (see FieldSample.still).


readonly surf: Float32Array

Defined in: sdk/src/water/zone.ts:172

The distance the surf runs in by (see FieldSample.surf).


readonly swell: Float32Array

Defined in: sdk/src/water/zone.ts:167

at(x, z): FieldSample | null

Defined in: sdk/src/water/zone.ts:319

The field at a world point inside the region, read as the texels around it blend; null outside the region.

number

number

FieldSample | null


encode(r): object

Defined in: sdk/src/water/zone.ts:385

The field as two RGBA8 images, rows from minZ. heights (read texel by texel: filtered bytes are no number): rg the height, high byte first; b the depth, as its square root (fine where the water is shallow, where the shore is drawn by it); a the swell (the body’s waves’ height). field (filtered): r the shore distance (0.5 at it, a signed square root); gb the current (0.5 still); a the calm. exposure (filtered): r how open the water is to the wind; g the distance the surf runs in by; b how much surf a current leaves; a how steep the shore is. Each over its range in r.

ZoneRanges

object

exposure: Uint8Array

field: Uint8Array

heights: Uint8Array


query(): WaterQuery

Defined in: sdk/src/water/zone.ts:352

The part of the field a world is laid out by (how deep water stands over a height, how far a point is from the shore), as a query over this field’s own arrays.

WaterQuery


ranges(shoreReach?): ZoneRanges

Defined in: sdk/src/water/zone.ts:359

The ranges the encoding spans, from what the field holds; the shore distance reaches shoreReach at least (as far out as the surf is drawn).

number = 0

ZoneRanges


sample(x, z): FieldSample | null

Defined in: sdk/src/water/zone.ts:343

The water at a world point: the field inside the region, the ocean past it (as deep as it likes, waves whole), null where there is none. shore above zero is water.

number

number

FieldSample | null


static bake(grid, bodies, ground?, surfLength?): WaterField

Defined in: sdk/src/water/zone.ts:208

Bakes bodies over grid. Each texel takes every body’s say (its height, its distance to its own shore, its waves and current) and weighs them by how far inside each it is, over a texel and a half, so where two bodies meet the values run from one to the other. The lakes come first, then the rivers have what they leave (a river runs into a lake and is the lake there), and the ocean what both leave. A texel no body holds keeps the height of the nearest water, so the surface’s vertices there (which the shore cuts away) do not pull the water’s edge down to nothing.

ZoneGrid

readonly ZoneBody[]

ZoneGround

number = 0

WaterField


static baking(grid, bodies, ground?, surfLength?): Generator<number, WaterField, void>

Defined in: sdk/src/water/zone.ts:217

WaterField.bake as a job that yields its progress (0 to 1) every few rows, for spreading over frames.

ZoneGrid

readonly ZoneBody[]

ZoneGround

number = 0

Generator<number, WaterField, void>