NatureGL Weatherv1.1.0

naturegl-weather v1.1.0

Weather that soaks into your scene

Rain, snow, lightning, volumetric fog, wet surfaces and puddles for three.js. The particles follow your camera, your own materials get wet and collect snow, and roofs keep the ground under them dry.

$ npm install && npm run dev

#Your scene, your materials, their weather

NatureGL Weather adds its particle meshes to your scene and patches your MeshStandardMaterials. Nothing is swapped out. Call weather.update(dt) every frame. Then render with weather.render() for volumetric fog, puddle reflections and bloom, or keep your own renderer.render(scene, camera).

Follow the quick start or compare the two render paths.

loadPreset('thunderstorm') on a running drizzle. Rain, wind, fog and the strike rate all ease to their new targets, and the demo sky follows the preset's time and cloud.
presets, one file each
7
quality tiers, low to ultra
4
rain streaks on ultra
90k
per frame on high (Apple M5, 1280×720)
5.5–10 ms

#What's in the box

#Seven presets, ready to load

Every preset is a plain object in src/config/presets/. loadPreset eases to it, set changes any part of it, and getParams() prints the current weather as a new one.

DownpourdownpourHeavy evening rain, full puddles, street lamps on.
ThunderstormthunderstormNight storm, strong wind, frequent strikes.
SnowfallsnowfallCalm snow over a settled blanket.
Foggy dawnfoggyDawnLow ground fog, sun shafts, dewy ground.

See all seven presets

#Minutes to a rainy street

main.js
import * as THREE from 'three';
import { WeatherSystem } from 'naturegl-weather';

// renderer, scene, camera, sun and your meshes as usual
const weather = await WeatherSystem.create({ renderer, scene, camera, preset: 'downpour' });

// any MeshStandardMaterial can get wet; `ground: true` adds puddles and a full snow blanket
weather.patchMaterial(ground.material, { ground: true });
weather.patchMaterial(houses.material);

weather.setOccluders([ground, houses]);   // no rain under the roofs
weather.setLighting({ sunDirection: sun.position.clone().normalize(), sunColor: sun.color, shadowLight: sun });

renderer.setAnimationLoop(() => {
  weather.update(timer.getDelta());
  weather.render();                      // or renderer.render(scene, camera)
});

#Surfaces keep a history

weather.set({ rain: 1, … }) on a dry afternoon. Wetness builds by about 0.08 per second at full rain. Puddles open once the ground is past 30 % wet, and raindrop rings ripple in them.

Wetness and snow cover are state, not settings. Rain wets the ground, sun and wind dry it, snow piles up and rain melts it. Presets ease the surfaces to their own values over about 4.5 s, and then the natural accumulation takes over again. Read more in Wet surfaces and puddles.

#Part of the NatureGL series

NatureGL Weather takes its light from NatureGL Sky and draws its rain over NatureGL Water's ocean. NatureGL Island uses all three.