View on GitHub

leaflet-city-mapper

A small 3D rendering engine for leaflet

Lighting

Source guide Project README

Collects point lights from visible scene layers and maintains spatial grids for fixed and moving lights. Grid data is uploaded for the shared renderer.

Point-light grids

flowchart LR
  Layers["Visible nightLight layers"] --> Collect["Collect world-space lights"]
  Collect --> Fixed["Fixed grid"]
  Collect --> Moving["Moving grid"]
  Fixed --> Buffer["Shared GPU storage buffer"]
  Moving --> Buffer
  Buffer --> Shader["Nearby-light lookup"]

Grids use 32-metre cells. If their data exceeds the GPU storage limit, the update throws; buffer growth also refreshes bindings. Directional sunlight uses separate shadows.

Related: shadows, sunlight, rendering.