The MapLibre map to drive.
Prefix for the source/layer this controller owns. Default bitruvius-ground-grade.
Remove the overlay source + layer (best-effort; no-op if the style is gone).
Set the overlay's colour and strength from SunState.gradeLinear.
A SunConsumer that grades the map SURFACE — the basemap and, because MapLibre drapes 2D layers onto the terrain mesh, the terrain with it.
Remarks
BasemapController drives
raster-brightness-maxon ONE raster layer. That covers a satellite basemap and nothing else: a vector style is dozens of fill/line/symbol layers with no brightness property between them, and MapLibre has no global tint. So on a vector style — which is most styles, including the one in our own sun-control example — the ground stayed at full daylight while the buildings darkened, and under 3D terrain that reads as "the terrain ignores the time of day".This takes the one approach that works for any style: a world-covering fill whose opacity follows the sun, inserted BELOW the first symbol layer so labels stay legible, and above everything else so it tints what is underneath. It is part of the draped set, so the terrain surface darkens with the flat map rather than staying lit on its own.
Additive to BasemapController rather than a replacement — on a raster basemap, grading the imagery itself is the better-looking result, and both can run.
Example