Skip to content

API Class WaterSurface

github-actions[bot] edited this page Nov 30, 2026 · 5 revisions

Class: WaterSurface

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

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

Constructors

Constructor

new WaterSurface(): WaterSurface;

Returns

WaterSurface

Inherited from

Component.constructor

Properties

deepColor

deepColor: Color;

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

Colour looking straight down into the water and in troughs.


foamAmount

foamAmount: number = 0.5;

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

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


foamColor

foamColor: Color;

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


normalDetail

normalDetail: number = 0.5;

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

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:60

Below 1 the surface is drawn transparent.


reflectivity

reflectivity: number = 0.5;

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

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


resolution

resolution: number = 128;

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

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:58


shallowColor

shallowColor: Color;

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

Colour at grazing angles and on crests.


size

size: number = 100;

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

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


wakeMode

wakeMode: WaterWakeMode = "trail";

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

How the surface draws the wakes of WaterWake nodes on it (ADR 0459): "trail" (foam and Kelvin ripples along each stern's path, shaded per pixel), "field" (a simulated wave height field around the camera that hulls press into; it also raises the surface) or "off".


waves

waves: WaterWave[];

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

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:48

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:62

Returns

boolean

Set Signature

set enabled(value): void;

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

Parameters
value

boolean

Returns

void

Inherited from

Component.enabled


gameObject

Get Signature

get gameObject(): GameObject;

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

Unity-style alias for node.

Returns

GameObject

Inherited from

Component.gameObject


isActiveAndEnabled

Get Signature

get isActiveAndEnabled(): boolean;

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

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:37

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:50

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:98

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:56

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:87

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:108

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:106

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