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.
clearDry afternoon, light breeze, a few clouds.drizzleLight rain under a grey morning sky. Damp streets.downpourHeavy evening rain, full puddles, street lamps on.thunderstormNight storm, strong wind, frequent strikes.snowfallCalm snow over a settled blanket.blizzardDriving snow in a gale. A white-out.foggyDawnLow ground fog, sun shafts, dewy ground.#Loading presets
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:
weather.set({ rain: 0.4, wind: 0.8 });
weather.set({ time: 20 }, { instant: true });#Presets are plain data
/** 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.
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
snowfall. Press 1–7 in the demo to switch presets.#Reference
| Preset | rain | snow | wind | fog | lightning | cloud | time | wetness | snowCover | exposure | Notes |
|---|---|---|---|---|---|---|---|---|---|---|---|
clear | 0 | 0 | 0.15 | 0.06 | 0 | 0.15 | 14:00 | 0 | 0 | 1 | Dry afternoon |
drizzle | 0.22 | 0 | 0.25 | 0.2 | 0 | 0.72 | 10:30 | 0.6 | 0 | 0.92 | Damp streets, fogLight 0.65 |
downpour | 1 | 0 | 0.5 | 0.2 | 0 | 1 | 18:06 | 1 | 0 | 0.8 | Puddles, lamps on, fogLight 0.42 |
thunderstorm | 0.8 | 0 | 0.85 | 0.26 | 0.85 | 1 | 21:30 | 0.95 | 0 | 1 | Frequent strikes |
snowfall | 0 | 0.55 | 0.12 | 0.18 | 0 | 0.85 | 11:00 | 0.1 | 0.8 | 1 | Settled blanket |
blizzard | 0 | 1 | 1 | 0.62 | 0 | 1 | 15:30 | 0 | 1 | 1 | White-out |
foggyDawn | 0 | 0 | 0.05 | 0.62 | 0 | 0.15 | 06:33 | 0.35 | 0 | 0.62 | Ground 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).