Documentation Index
Fetch the complete documentation index at: https://v5.rpgjs.dev/llms.txt
Use this file to discover all available pages before exploring further.
Lighting
Manage map lighting from the server and add temporary client-only spots for local effects. Lighting is rendered by the engine with CanvasEngine presets. You do not need to importNightAmbient or SpriteShadows in your map components.
Shared Types
Lighting types are exported by@rpgjs/common:
Initial Map Lighting
Set initial lighting in@MapData() or in a map entry inside your server module:
Runtime API (Server)
RpgMap exposes:
map.getLighting(): LightingState | nullmap.setLighting(next: LightingState | null, options?: { sync?: boolean })map.patchLighting(patch: Partial<LightingState>, options?: { sync?: boolean })map.clearLighting(options?: { sync?: boolean })map.setDay(options?: { sync?: boolean })map.setNight(options?: { sync?: boolean })map.transitionLighting(toLighting, options?: { duration?: number, easing?: 'linear' | 'easeInOut' })
sync is not false, lighting is broadcast to players in the map.
Runtime API (Client)
RpgClientMap exposes local light spot helpers:
sceneMap.addLightSpot(id, spot)sceneMap.patchLightSpot(id, partialSpot)sceneMap.removeLightSpot(id)sceneMap.clearLightSpots()
NightAmbient is rendered only when synchronized lighting provides an ambient darkness value greater than 0, for example through map.setNight() or map.setLighting({ ambient: { darkness: ... } }). Spots still enable sprite shadows during daytime.
Ambient lighting fields map to CanvasEngine NightAmbient props: darkness and darkColor become the darkness overlay, while fogColor, fogRadius, fogSoftness, and fogOpacity configure the haze overlay.
Shadows
Setlighting.shadows.enabled to true to enable character shadows. The engine automatically marks character sprites as shadow casters and derives default shadow sizing from the sprite bounds and hitbox.
lightSpot entries, enable SpriteShadows with default shadow options so torch-lit Studio maps do not need a separate lighting.shadows block. ambientLight provides a directional baseline shadow for sprites outside point light radius; set it to null or { enabled: false } to disable it. In Studio maps, an element with a lightSpot is automatically registered as a local light spot, then used by NightAmbient when night is active and by SpriteShadows whenever the spot exists.