gizgame/sea
unified Gerstner ocean wave mathematics, weather-coupled sea state, wind field, and subdivided ocean mesh. The CPU functions here match the GPU OCEAN shader 1:1 so vessels, buoys, and floating bodies heave, pitch, and roll on the exact waves rendered on screen.
import * as Sea from "gizgame/sea";Types
SeaSample
type SeaSample = { y: f64; nx: f64; ny: f64; nz: f64; crest: f64; }Sampled ocean surface point at world (X, Z) and TIME: height Y, unit normal (NX, NY, NZ), and wave crest intensity.
y:f64nx:f64ny:f64nz:f64crest:f64
WindField
type WindField = { x: f64; z: f64; knots: f64; angle: f64; amp: f64; }Live wind & sea telemetry derived from weather and time: unit direction (X, Z), speed in knots, and heading angle.
x:f64z:f64knots:f64angle:f64amp:f64
Functions
seaStateOf
function seaStateOf(weather: string): f64Wave amplitude multiplier for WEATHER (0.45 calm clear -> 2.85 raging typhoon).
Effects: fail, alloc.
windOf
function windOf(weather: string, time: f64): WindFieldLive wind direction, knots, and wave amplitude for WEATHER at TIME (gently shifting like real maritime trade winds).
Effects: fail, alloc.
stormFlash
function stormFlash(weather: string, time: f64): f64Periodic storm/typhoon lightning flash intensity (0..1) at TIME.
Effects: fail, alloc.
seaSample
function seaSample(x: f64, z: f64, time: f64, weather: string): SeaSampleEvaluates the exact 4-wave directional Gerstner ocean height, surface normal, and crest intensity at world (X, Z).
Effects: fail, alloc.
oceanGrid
function oceanGrid(cells: i64 = 76): Geometry throws stringSubdivided unit-square [-0.5..0.5] XZ ocean mesh with CELLS x CELLS quads (radial density concentrates triangles near center).
Effects: fail, alloc.