Skip to content

API Class WaterSurface

github-actions[bot] edited this page Dec 2, 2026 · 5 revisions

Class: WaterSurface

Defined in: src/engine/render/water/WaterSurface.ts:52

A moving water surface: a square grid of size world units centred on its node, in the node's XZ plane, displaced by up to 8 Gerstner waves. sample(x, z) (and Water.sample) returns the height and normal of the drawn surface, for buoyancy and gameplay.

Keep the node level (turn it about Y only): sampling assumes the water's up is the world's.

Extends

Extended by

Constructors

Constructor

new WaterSurface(): WaterSurface;

Returns

WaterSurface

Inherited from

Component.constructor

Properties

contactFoam

contactFoam: number = 0.4;

Defined in: src/engine/render/water/WaterSurface.ts:102

Foam where things not in the shore map (hulls, moving bodies) meet the water, within this many metres of the scene's depth (ADR 0663 §2; 0: none). Medium and high water quality only.


deepColor

deepColor: Color;

Defined in: src/engine/render/water/WaterSurface.ts:62

Colour looking straight down into the water and in troughs.


depthMap

depthMap: string = "";

Defined in: src/engine/render/water/WaterSurface.ts:93

The baked shore map (ADR 0663 §2, asset kind "waterDepth"): the depth to the ground and the distance to the shore over the surface, and the wall points waves throw spray off. It makes waves shoal and break into surf, lays foam along shores and makes wake ripples bounce off walls. Made by the inspector's "Bake shoreline"; empty: open water.


farWakes

farWakes: boolean = true;

Defined in: src/engine/render/water/WaterSurface.ts:87

Draw wakes beyond the field as trails along their sterns' paths (ADR 0459's far LOD; how many: the water quality's farWakes). Off, wakes end at the field's edge. The World's first enabled surface decides it, as with interaction.


foamAmount

foamAmount: number = 0.5;

Defined in: src/engine/render/water/WaterSurface.ts:67

0 (none) to 1: how readily foam forms where crests fold.


foamColor

foamColor: Color;

Defined in: src/engine/render/water/WaterSurface.ts:65


impactEffect

impactEffect: string = "";

Defined in: src/engine/render/water/WaterSurface.ts:106

The particle effect played where waves strike a wall or a hull (ADR 0663 §3); empty: the engine's own spray.


interaction

interaction: WaterInteraction = "auto";

Defined in: src/engine/render/water/WaterSurface.ts:82

How much the water reacts to what is in it (ADR 0663 §4): the wake field around the camera that WaterWake hulls and moving bodies press into, splash and impact spray, and contact foam. "auto" follows the graphics tier's water quality; "low", "medium" and "high" fix it; "off" turns them all off. The World's first enabled surface decides it for every surface. Shoaling and shore foam from depthMap don't follow it: buoyancy mustn't change with settings. (Replaces ADR 0459's wakeMode; older scenes load "off" as "off" and its other values as "auto".)


normalDetail

normalDetail: number = 0.5;

Defined in: src/engine/render/water/WaterSurface.ts:69

Strength of the scrolling ripple normals on top of the waves (0 = none).


opacity

opacity: number = 1;

Defined in: src/engine/render/water/WaterSurface.ts:72

Below 1 the surface is drawn transparent.


reflectivity

reflectivity: number = 0.5;

Defined in: src/engine/render/water/WaterSurface.ts:74

Strength of the Fresnel reflection of the environment (0–1).


resolution

resolution: number = 128;

Defined in: src/engine/render/water/WaterSurface.ts:56

Vertices per side (2–1024). Quality tiers with the "low" shader level use half.


roughness

roughness: number = 0.08;

Defined in: src/engine/render/water/WaterSurface.ts:70


shallowColor

shallowColor: Color;

Defined in: src/engine/render/water/WaterSurface.ts:64

Colour at grazing angles and on crests.


shoreFoam

shoreFoam: number = 1.5;

Defined in: src/engine/render/water/WaterSurface.ts:97

Foam along the shore line, out to this many metres from it (ADR 0663 §2; 0: none). Needs depthMap.


shoreResolution

shoreResolution: number = 256;

Defined in: src/engine/render/water/WaterSurface.ts:95

Texels per side of the shore map when it is baked (ADR 0663 §2).


size

size: number = 100;

Defined in: src/engine/render/water/WaterSurface.ts:54

Side of the square grid, in the node's local units.


splashEffect

splashEffect: string = "";

Defined in: src/engine/render/water/WaterSurface.ts:104

The particle effect played where something falls into the water (ADR 0663 §3); empty: the engine's own splash.


waves

waves: WaterWave[];

Defined in: src/engine/render/water/WaterSurface.ts:58

Up to 8 waves: direction (degrees, 0 = +X), wavelength, steepness 0–1, speed (0: deep-water speed; negative: backward).


waveScale

waveScale: number = 1;

Defined in: src/engine/render/water/WaterSurface.ts:60

Multiplies every wave's amplitude; raise it at runtime for a storm.

Accessors

enabled

Get Signature

get enabled(): boolean;

Defined in: src/engine/core/Component.ts:63

Returns

boolean

Set Signature

set enabled(value): void;

Defined in: src/engine/core/Component.ts:67

Parameters
value

boolean

Returns

void

Inherited from

Component.enabled


gameObject

Get Signature

get gameObject(): GameObject;

Defined in: src/engine/core/Component.ts:43

Unity-style alias for node.

Returns

GameObject

Inherited from

Component.gameObject


isActiveAndEnabled

Get Signature

get isActiveAndEnabled(): boolean;

Defined in: src/engine/core/Component.ts:74

True when enabled, the node is active in the hierarchy, and the node is in a loaded world.

Returns

boolean

Inherited from

Component.isActiveAndEnabled


node

Get Signature

get node(): GameObject;

Defined in: src/engine/core/Component.ts:38

The node this component is on.

Returns

GameObject

Inherited from

Component.node


owner

Get Signature

get owner(): GameObject;

Defined in: src/engine/core/Component.ts:51

The node this component acts for: the node itself when attached directly, or the parent node when this component lives on a component node (ADR 0009).

Returns

GameObject

Inherited from

Component.owner


time

Get Signature

get time(): Readonly<TimeState>;

Defined in: src/engine/core/Component.ts:99

This component's World's clock (ADR 0032): the same values as Time, but safe to read outside the World's frame too (after an await, say).

Returns

Readonly<TimeState>

Inherited from

Component.time


transform

Get Signature

get transform(): Transform;

Defined in: src/engine/core/Component.ts:57

The Transform of the node this component is on, if it has one.

Returns

Transform

Inherited from

Component.transform


world

Get Signature

get world(): WorldHandle;

Defined in: src/engine/core/Component.ts:88

A handle on this component's World (ADR 0132): the same one Engine.findWorld returns. Load a scene into it, pause, connect or destroy it: this.world.loadScene("scenes/level2.scene.json"). Throws for a World no Engine owns.

Returns

WorldHandle

Inherited from

Component.world

Methods

instantiate()

instantiate(prefabPath, options?): GameObject;

Defined in: src/engine/core/Component.ts:109

Instantiate a prefab in this component's World (ADR 0034), like GameObject.instantiate. Use it in code that may run after an await: by then the frame is over and the current World is the Engine's default one, which may not be this component's. A parent from another World throws.

Parameters

prefabPath

string

options?

InstantiateOptions = {}

Returns

GameObject

Inherited from

Component.instantiate


sample()

sample(x, z): WaterSample;

Defined in: src/engine/render/water/WaterSurface.ts:144

The surface's height and normal at world (x, z), at the water clock's current time: the same waves, waveScale and time the renderer draws, with the waves' sideways motion undone. The waves continue past the edge of the drawn grid.

Parameters

x

number

z

number

Returns

WaterSample

Clone this wiki locally