# Gerstner Ocean — calm day to night storm

A single-file Three.js scene (`index.html`, no build step, no external assets). Three.js r160 and `OrbitControls` load from the jsDelivr CDN.

- **Ocean:** a polar grid displaced on the GPU by six Gerstner waves, with per-pixel normals, crest foam, fresnel reflection of a procedural sky, a teal subsurface tint in the troughs, and sun/moon glitter.
- **Boat:** a procedurally modelled fishing boat. Its height and tilt come from the same wave table, sampled on the CPU at bow, stern, port and starboard, so it follows the surface. It sails a slow circle.
- **Weather:** calm sun, overcast chop, then night storm. Wave size, choppiness, foam, sky, clouds, fog, rain streaks and lightning all follow the slider.

## Controls

| Input | Action |
|---|---|
| Drag (mouse or one finger) | Orbit the camera around the boat |
| Scroll wheel / pinch | Zoom |
| **Weather** slider | Left is a calm sunny day, right is a night storm. Rain starts around the middle. Lightning flashes appear in the storm half. |

The renderer lowers its resolution automatically if the frame rate drops, which helps on phones.

## Running

Open `index.html` in a browser, or serve the folder (`python3 -m http.server`) and visit it. An internet connection is needed for the CDN.

Optional URL parameters:

- `?w=0..1` sets the starting weather.
- `?dpr=N` caps the pixel ratio.
- `?fixed` disables adaptive resolution.
- `?flash` triggers a lightning flash at load.
