WaterField
此内容尚不支持你的语言。
Defined in: sdk/src/water/zone.ts:161
The baked water of a zone.
Properties
Section titled “Properties”
readonlyamp:Float32Array
Defined in: sdk/src/water/zone.ts:165
readonlycalm:Float32Array
Defined in: sdk/src/water/zone.ts:166
readonlydepth:Float32Array
Defined in: sdk/src/water/zone.ts:170
exposure
Section titled “exposure”
readonlyexposure:Float32Array
Defined in: sdk/src/water/zone.ts:177
readonlyflowX:Float32Array
Defined in: sdk/src/water/zone.ts:168
readonlyflowZ:Float32Array
Defined in: sdk/src/water/zone.ts:169
readonlygrid:ZoneGrid
Defined in: sdk/src/water/zone.ts:162
height
Section titled “height”
readonlyheight:Float32Array
Defined in: sdk/src/water/zone.ts:163
readonlyocean:ZoneOcean|null
Defined in: sdk/src/water/zone.ts:181
The ocean, which goes on past the region: what a point outside it is.
readonlyowner: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.
readonlyshore:Float32Array
Defined in: sdk/src/water/zone.ts:164
readonlysteep: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.
readonlystill:Float32Array
Defined in: sdk/src/water/zone.ts:174
How much of the surf a current leaves (see FieldSample.still).
readonlysurf:Float32Array
Defined in: sdk/src/water/zone.ts:172
The distance the surf runs in by (see FieldSample.surf).
readonlyswell:Float32Array
Defined in: sdk/src/water/zone.ts:167
Methods
Section titled “Methods”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.
Parameters
Section titled “Parameters”number
number
Returns
Section titled “Returns”FieldSample | null
encode()
Section titled “encode()”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.
Parameters
Section titled “Parameters”ZoneRanges
Returns
Section titled “Returns”object
exposure
Section titled “exposure”exposure:
Uint8Array
field:
Uint8Array
heights
Section titled “heights”heights:
Uint8Array
query()
Section titled “query()”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.
Returns
Section titled “Returns”WaterQuery
ranges()
Section titled “ranges()”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).
Parameters
Section titled “Parameters”shoreReach?
Section titled “shoreReach?”number = 0
Returns
Section titled “Returns”ZoneRanges
sample()
Section titled “sample()”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.
Parameters
Section titled “Parameters”number
number
Returns
Section titled “Returns”FieldSample | null
bake()
Section titled “bake()”
staticbake(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.
Parameters
Section titled “Parameters”ZoneGrid
bodies
Section titled “bodies”readonly ZoneBody[]
ground?
Section titled “ground?”ZoneGround
surfLength?
Section titled “surfLength?”number = 0
Returns
Section titled “Returns”WaterField
baking()
Section titled “baking()”
staticbaking(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.
Parameters
Section titled “Parameters”ZoneGrid
bodies
Section titled “bodies”readonly ZoneBody[]
ground?
Section titled “ground?”ZoneGround
surfLength?
Section titled “surfLength?”number = 0
Returns
Section titled “Returns”Generator<number, WaterField, void>