ReadonlytypeReadonlyobjectThe drawable — LineSegments for rain, Points for snow. Already added by addTo.
Add the layer to a scene (or any parent).
Fade precipitation: scales how many particles are drawn (drawRange — no reallocation) and their opacity, so weather can ramp smoothly from drizzle to downpour.
Set the horizontal wind drift (world units/sec). Streak direction follows.
Safe to call every frame with a gusting wind: the drift it feeds is integrated in update, so a change of wind bends the fall from where it had got to rather than displacing the whole field.
Link (or unlink) precipitation to a cloud field: only where the field exceeds the coverage threshold does precipitation fall. Pass the SAME offset/scale the terrain cloud shadows use, and a coverage at or below the shadows' coverage — the difference is the "clouds that are just clouds" margin.
Keep the cloud gate's drift in sync (called per frame by WeatherSystem).
Per-cell weather mask: a texture whose selected channel scales
precipitation at each world position. rect is the world-space span of
the texture (min corner + size). Pass null to clear.
The seasons layer drives this with a ClimateData texture: snow gates on
the snow channel ('b') and rain on the same channel inverted, so
precipitation falls as snow exactly where snow is lying and as rain
everywhere else, with no band where both or neither appear.
Optionalrect: { x: number; z: number; width: number; depth: number }Advance the animation and recenter the volume — call once per frame with the camera's ground target (e.g. RtsCameraController.targetPosition).
Remove from the scene graph and free GPU resources.
A camera-following volume of GPU-animated rain streaks or snowflakes.
The volume (an
area×height×areabox) is repositioned to the camera target each frame, but the particles inside are world-anchored (see the vertex-shader note), so panning never drags precipitation along — drops fall over the same hexes regardless of the camera. All motion (fall, wind, snow sway, streaks) runs in the vertex shader from a single time uniform; per-frame CPU cost is two uniform writes.Pair with the terrain's cloud shadows through setCloudGate (a WeatherSystem does this automatically) so rain only falls under the denser clouds, and lighter clouds are just clouds.
Example