GizStackGizStack
View .mdOpen in ChatGPTOpen in Claude

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.

gizlang
import * as Sea from "gizgame/sea";

Types

SeaSample

gizlang
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: f64
  • nx: f64
  • ny: f64
  • nz: f64
  • crest: f64

WindField

gizlang
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: f64
  • z: f64
  • knots: f64
  • angle: f64
  • amp: f64

Functions

seaStateOf

gizlang
function seaStateOf(weather: string): f64

Wave amplitude multiplier for WEATHER (0.45 calm clear -> 2.85 raging typhoon).

Effects: fail, alloc.

windOf

gizlang
function windOf(weather: string, time: f64): WindField

Live wind direction, knots, and wave amplitude for WEATHER at TIME (gently shifting like real maritime trade winds).

Effects: fail, alloc.

stormFlash

gizlang
function stormFlash(weather: string, time: f64): f64

Periodic storm/typhoon lightning flash intensity (0..1) at TIME.

Effects: fail, alloc.

seaSample

gizlang
function seaSample(x: f64, z: f64, time: f64, weather: string): SeaSample

Evaluates the exact 4-wave directional Gerstner ocean height, surface normal, and crest intensity at world (X, Z).

Effects: fail, alloc.

oceanGrid

gizlang
function oceanGrid(cells: i64 = 76): Geometry throws string

Subdivided unit-square [-0.5..0.5] XZ ocean mesh with CELLS x CELLS quads (radial density concentrates triangles near center).

Effects: fail, alloc.