SDK JS
    Preparing search index...

    Computes one SunState per update and fans it out to a set of SunConsumer controllers (MapLibre light/sky/hillshade and the renderers). The fan-out is the structural guarantee behind the cardinal rule: every consumer sees the same SunState object, so MapLibre's light and the renderer's sun can never disagree.

    Most consumers should use setTimeOfDay, which builds and wires a GeoSunSystem for you. Construct one directly only when you need full control over the controller list.

    import { GeoSunSystem, MapLibreLightController, SkyController } from '@bitruvius/sdk-maplibre';
    const system = new GeoSunSystem(map, {
    reference: 'map-center',
    controllers: [new MapLibreLightController(map), new SkyController(map)],
    });
    system.update(new Date()); // compute + push the sun once
    Index

    Constructors

    Accessors

    • get current(): SunState | null

      The most recently computed SunState, or null before the first update.

      Returns SunState | null

    Methods

    • Compute the sun for date and push it to every controller.

      Parameters

      • date: Date

        The instant to evaluate (a Date, UTC for solar math).

      • Optionalcenter: { lat: number; lng: number }

        Optional explicit { lng, lat } in degrees to evaluate at; when omitted, the configured SunReference is used (map-center or the fixed point).

      Returns SunState

      The new SunState (also retrievable via GeoSunSystem.current).

      Propagates from the controllers it drives — e.g. MapLibre's setLight / setSky if the map's style is not ready. Call after the map's load event.