View on GitHub

leaflet-city-mapper

A small 3D rendering engine for leaflet

Shadows

Source guide Project README

Creates and renders directional sunlight shadow maps, with cached camera and mesh state to avoid unnecessary redraws.

Shadow pass and cache

flowchart LR
  Sun["Sun position"] --> Check{"Casters + sun altitude ≥ 3°?"}
  Meshes["Loaded shadow casters"] --> Check
  Check -->|no| Disable["Disable shadow pass"]
  Check -->|yes| Cache{"Cache matches?"}
  Cache -->|yes| Reuse["Reuse depth map"]
  Cache -->|no| Draw["Fit matrix + render depth map"]

Loaded off-screen geometry can cast shadows. Cache snapshots include direction, world versions, geometry and draw ranges: changes affecting shadows must invalidate the cache. Point lights are separate.

Related: lighting, sunlight, rendering.