SDK JS
    Preparing search index...
    • Compute the SunState for an instant at a place — the one place the sun is calculated. Wraps the vendored SunCalc, converts its south-clockwise azimuth into a compass bearing and an ENU direction vector, and folds in the altitude lighting ramp. Everything downstream consumes the returned state; nobody else calls SunCalc.

      Parameters

      • date: Date

        The instant to evaluate (a Date; the underlying solar math is UTC-based).

      • lng: number

        Longitude in degrees (−180..180).

      • lat: number

        Latitude in degrees (−90..90).

      Returns SunState

      The immutable SunState: date/lng/lat echoed back; altitudeRad and azimuthRad in radians (azimuth SunCalc-raw, 0 = south, clockwise); altitudeDeg in degrees and azimuthDeg as a compass bearing in degrees from north (0 = N, 90 = E); directionEnu a unit Vec3 toward the sun in ENU (east/north/up); color a CSS #rrggbb and colorLinear/ambientLinear/ambientFloorLinear/gradeLinear linear RGB Vec3s; intensity and ambientIntensity scalars in 0..1; isDay true when the upper limb is at/above the horizon (altitude > −0.833°); and the TwilightPhase band.

      Does not throw. An invalid Date yields NaN angle fields rather than an error.

      import { computeSunState } from '@bitruvius/sdk-maplibre';
      const sun = computeSunState(new Date(), -73.98, 40.75); // NYC, now
      console.log(sun.altitudeDeg, sun.azimuthDeg, sun.directionEnu);

      GeoSunSystem to fan this state out to MapLibre + the renderers automatically.