NatureGL Weatherv1.1.0

Reference

Presets

Seven weathers, one file each, in src/config/presets/. Hover a card to see the weather move, click to enlarge it, or run one live.

ClearclearDry afternoon, light breeze, a few clouds.
DrizzledrizzleLight rain under a grey morning sky. Damp streets.
DownpourdownpourHeavy evening rain, full puddles, street lamps on.
ThunderstormthunderstormNight storm, strong wind, frequent strikes.
SnowfallsnowfallCalm snow over a settled blanket.
BlizzardblizzardDriving snow in a gale. A white-out.
Foggy dawnfoggyDawnLow ground fog, sun shafts, dewy ground.

#Loading presets

js
weather.loadPreset('downpour');                    // ease there
weather.loadPreset('downpour', { instant: true }); // snap
weather.loadPreset({ rain: 0.5, fog: 0.3 });       // a partial preset: missing keys come from `clear`

loadPreset sets every target in the preset. The weather amounts ease at transitionRate (0.9 per second), the time eases the short way round the clock, and wetness and snowCover ease over about 4.5 s. Then natural accumulation takes over again. A preset with lightning > 0 arms the first strike 1.5 s later.

set(values) does the same for a subset without touching the other targets:

js
weather.set({ rain: 0.4, wind: 0.8 });
weather.set({ time: 20 }, { instant: true });

#Presets are plain data

src/config/presets/downpour.js
/** Downpour: heavy evening rain, full puddles, lamps on. */
export default { rain: 1, snow: 0, wind: 0.5, windDirection: 1.2, fog: 0.2, fogHeight: 1, fogLight: 0.42, lightning: 0, cloud: 1, time: 18.1, wetness: 1, snowCover: 0, exposure: 0.8 };

Every key is described on Weather parameters. time and cloud are suggestions for your sky; the library itself doesn't draw one.

js
import { PRESETS, PRESET_LABELS, getPresetParams } from 'naturegl-weather';

Object.keys(PRESETS);           // ['clear', 'drizzle', 'downpour', 'thunderstorm', 'snowfall', 'blizzard', 'foggyDawn']
PRESET_LABELS.foggyDawn;        // 'Foggy Dawn'
getPresetParams('blizzard');    // a deep clone; throws on unknown names

#Try one live

Runs WebGL2 in this page · starts on snowfall
Starts on snowfall. Press 1–7 in the demo to switch presets.

#Reference

PresetrainsnowwindfoglightningcloudtimewetnesssnowCoverexposureNotes
clear000.150.0600.1514:00001Dry afternoon
drizzle0.2200.250.200.7210:300.600.92Damp streets, fogLight 0.65
downpour100.50.20118:06100.8Puddles, lamps on, fogLight 0.42
thunderstorm0.800.850.260.85121:300.9501Frequent strikes
snowfall00.550.120.1800.8511:000.10.81Settled blanket
blizzard0110.620115:30011White-out
foggyDawn000.050.6200.1506:330.3500.62Ground fog (fogHeight 0.3), sun shafts, fogLight 0.5

fogHeight and fogLight are 1 unless noted. The values match weatherpro.html; only the key names changed (see the changelog).