voxolith

makeAtmosphereTransition()

Change weather smoothly. The game decides when to call set; the transition only blends (see blendAtmosphere: a change of precipitation kind fades one out before the other fades in, and wind turns the short way round).

function makeAtmosphereTransition(start?: Atmosphere): AtmosphereTransition;

Defined in: engine/src/atmosphere/weather.ts:131

Parameters

ParameterTypeDefault valueDescription
start?AtmosphereATMOSPHERES.clearDefault ATMOSPHERES.clear.

Returns

AtmosphereTransition

The transition; call update(dt) once per frame.

Example

const weather = makeAtmosphereTransition(ATMOSPHERES.clear);
weather.set(ATMOSPHERES.rain, 6);
// per frame:
const sky = weather.update(dt);
wetness = approach(wetness, sky.precipitation.kind === "rain" ? 1 : 0, 0.1, dt);
renderer.render({ ...frame(), ...atmosphereFrame(timeOfDay(phase), { ...sky, wetness }), time });
loop.setContinuous(weather.changing() || sky.precipitation.intensity > 0);

On this page