Skip to content

eulerjs API / @eulerjs/marine / WaveSurface

WaveSurface ​

Defined in: packages/marine/src/waves/WaveSurface.ts:8

A moving sea surface, as the physics needs it: a pure function of position and time, whose points also move sideways (so a world position's height takes finding which point of the undisturbed grid has moved there). SumOfSines and SpectralWaves are both one.

Properties ​

PropertyModifierTypeDescriptionDefined in
lastGridPointreadonlyobjectThe undisplaced grid point the last heightAt or heightFrom found.packages/marine/src/waves/WaveSurface.ts:18
lastGridPoint.xreadonlynumber-packages/marine/src/waves/WaveSurface.ts:18
lastGridPoint.zreadonlynumber-packages/marine/src/waves/WaveSurface.ts:18

Methods ​

heightAt() ​

ts
heightAt(
   worldX, 
   worldZ, 
   time
): number;

Defined in: packages/marine/src/waves/WaveSurface.ts:10

Height of the surface directly above or below the world position (worldX, worldZ) at time.

Parameters ​

ParameterType
worldXnumber
worldZnumber
timenumber

Returns ​

number


heightFrom() ​

ts
heightFrom(
   worldX, 
   worldZ, 
   time, 
   startGridX, 
   startGridZ, 
   iterations
): number;

Defined in: packages/marine/src/waves/WaveSurface.ts:16

Like heightAt, but starts the search for the undisplaced grid point at (startGridX, startGridZ) and runs iterations steps; a good start needs one. The grid point found is left in lastGridPoint.

Parameters ​

ParameterType
worldXnumber
worldZnumber
timenumber
startGridXnumber
startGridZnumber
iterationsnumber

Returns ​

number


normalAt() ​

ts
normalAt(
   worldX, 
   worldZ, 
   time, 
   target?
): Vector3;

Defined in: packages/marine/src/waves/WaveSurface.ts:20

Upward unit normal of the surface at the world position (worldX, worldZ).

Parameters ​

ParameterType
worldXnumber
worldZnumber
timenumber
target?Vector3

Returns ​

Vector3


prefetch()? ​

ts
optional prefetch(time): void;

Defined in: packages/marine/src/waves/WaveSurface.ts:31

A hint that the surface will be asked about at time soon, for a surface that can get ready ahead (SpectralWaves in a worker).

Parameters ​

ParameterType
timenumber

Returns ​

void


riseRate()? ​

ts
optional riseRate(
   gridX, 
   gridZ, 
   time
): number;

Defined in: packages/marine/src/waves/WaveSurface.ts:29

How fast the surface point that started at grid position (gridX, gridZ) rises at time, in m/s: the water's own vertical velocity there, which is slower than the surface rises at a fixed place as a steep crest passes it. For floating bodies to move with the water. A surface without it, Buoyancy damps against the surface's rise at the place instead.

Parameters ​

ParameterType
gridXnumber
gridZnumber
timenumber

Returns ​

number


surfacePoint() ​

ts
surfacePoint(
   gridX, 
   gridZ, 
   time, 
   target?
): Vector3;

Defined in: packages/marine/src/waves/WaveSurface.ts:22

Where the surface point that started at grid position (gridX, gridZ) is at time, displaced sideways as well as up.

Parameters ​

ParameterType
gridXnumber
gridZnumber
timenumber
target?Vector3

Returns ​

Vector3

Released under the MIT License.