@zaisma/lighting
Lighting and sky for three.js: a sky with sun, moon, stars and clouds, sunlight whose shadows follow the player, fill light, reflections and fog that match the sky (glowing toward a low sun, and pooling low as ground fog), all set by the time of day, with quality that fits every device from a phone up.
- Kind
- Foundation
- Built on
- @zaisma/standard
- Version
- 1.1.0
- Licence
- MIT, open source
- By
- btc7274
- Rated
- No ratings yet
ShellCopied
npx @zaisma/cli pieces add @zaisma/lightingWhat it needs
- @zaisma/piece^1.0.0 · 1.1.0 on the marketplace · Not testedPiece
- three>=0.163.0 <1.0.0 · A library from npm · Not testedLibrary
Nothing: it stands on its own.
Fits is said only for what Zaisma ran together. Not tested means nobody at Zaisma has.
Settings and hooks
Everything a game can change without editing the piece, so it moves to a newer version and keeps the game's changes.
- time_of_day_hoursThe time of day, from 0 to 24: the sun rises at 6, is highest at 12 and sets at 18. While day_length_min is above 0 it moves on its own, and setting it jumps there.Number, 0 to 24, starts at 13Setting
- day_length_minHow many real minutes a whole day takes, so the sun crosses the sky while playing; 0 keeps the time where it's set.Number, 0 to 10080, starts at 0Setting
- sun_peak_elevation_degHow high the sun climbs at noon, in degrees above the horizon: lower gives long shadows all day, 90 passes straight overhead.Number, 5 to 90, starts at 62Setting
- sun_path_turn_degTurns the sun's path round the up axis, in degrees counterclockwise seen from above, to choose which way shadows fall. At 0 the sun rises toward +x and is highest toward +z.Number, 0 to 360, starts at 0Setting
- quality_levelHow much the lighting draws. low: no shadows, reflections or clouds, for the weakest phones. medium: shadows, reflections and clouds. high: sharper, soft-edged shadows. auto starts at what the device can carry (medium on phones and tablets, high elsewhere) and steps down while frames run slow.One of auto, low, medium, high; starts at autoSetting
- shadows_enabledWhether the sun casts shadows at medium quality and above. Things cast and take shadows once the game passes them to giveShadows, or sets castShadow and receiveShadow itself.On or off, starts onSetting
- shadow_distance_mHow far the sun's shadows reach round what they follow, in metres: smaller is sharper, larger reaches further.Number, 4 to 400, starts at 30Setting
- light_strength_pctHow strong the sun (or the moon at night) is, against the time of day's own strength.Number, 0 to 400, starts at 100Setting
- fill_strength_pctHow strong the light from the sky and the ground is, which lights what the sun doesn't reach, against the time of day's own strength.Number, 0 to 400, starts at 100Setting
- reflections_enabledWhether three's standard and physical materials reflect the sky and are lit by it, at medium quality and above, so metal and shiny surfaces look right.On or off, starts onSetting
- exposure_pctHow bright the whole picture is, as a camera's exposure.Number, 10 to 400, starts at 100Setting
- tone_mappingHow bright light is fitted to the screen. neutral keeps the colours a game picks; aces is a filmic look with deeper contrast; agx softens bright colours toward white; none leaves three's output as it is.One of neutral, aces, agx, none; starts at neutralSetting
- fog_enabledWhether far things fade into the sky's colour, so the world's edge is never a hard line.On or off, starts onSetting
- fog_start_mHow far from the camera the fog starts, in metres.Number, 0 to 100000, starts at 60Setting
- fog_end_mHow far from the camera the fog hides everything, in metres. Keep it inside the camera's far distance.Number, 1 to 100000, starts at 320Setting
- fog_sun_glow_pctHow warmly the fog glows toward the sun while it's low, at sunrise and sunset, in the sun's own colour: 0 keeps the fog one colour all round.Number, 0 to 300, starts at 100Setting
- ground_fog_pctHow thick the fog pooling low over the ground is, a valley's mist or a marsh's: 0 is none, 100 hides the ground 50 metres away. It's in the fog's colour, and shows with fog_enabled off too.Number, 0 to 100, starts at 0Setting
- ground_fog_height_mHow high the ground fog reaches, in metres: it thins by two thirds each this far up from its floor.Number, 0.1 to 500, starts at 3Setting
- ground_fog_floor_mThe height the ground fog lies on, in metres, where it's thickest: the ground's height, or a valley's floor.Number, -10000 to 10000, starts at 0Setting
- clouds_pctHow much of the sky the clouds cover: 0 is clear, 100 overcast. Clouds drift slowly, and are left out at low quality.Number, 0 to 100, starts at 35Setting
- stars_enabledWhether stars and the moon show in the night sky.On or off, starts onSetting
- before_lookAsked whenever the time of day or a setting changes the look, with every colour and strength: { zenithColor, horizonColor, fogColor, lightColor, lightLux, fillSkyColor, fillGroundColor, fillLux, cloudColor, starsPct }, colours as "#rrggbb". Answer a look with any of them changed (a storm, an alien sky, a cave), or nothing to leave it.Decision
- day_startedTold when the sun comes up and lights the scene again, with the time of day in hours.Event
- night_startedTold when the sun goes down far enough that the moon lights the scene, with the time of day in hours.Event
- quality_changedTold when the quality level in use changes, with { qualityLevel, reason }: reason is setting, or slow_frames when auto stepped down because frames ran slow.Event
None.
Versions
- 1.1.0Nov 29, 2026 · 7 files · 71 KBNewest
No version has passed its checks yet.







