threejs-worldgen
    Preparing search index...

    Class Sky

    A complete, physically based sky from the ground to orbit: Keplerian sun and moon, single-scattering atmosphere, moon phases, stars and Milky Way turning with sidereal time, shooting stars, and the lights, environment and fog that go with them.

    const sky = await Sky.create({ renderer, scene, camera, clock: { date: '2026-08-12T21:30:00Z', dayLength: 600 } })
    renderer.setAnimationLoop(() => { sky.update(); renderer.render(scene, camera) })
    sky.setTimeOfDay(6.5) // jump to 06:30 local solar time
    sky.uniforms.night // TSL uniform 0..1 for your own materials
    Index
    atmosphere: AtmosphereOptions = DEFAULT_ATMOSPHERE

    The atmosphere as used for the home planet (altitudes scaled to its radius when scaleWithRadius).

    camera: Camera | undefined

    Camera the observer follows. Can be swapped at any time.

    clock: SkyClock = ...

    Simulation clock.

    clouds: Clouds = ...

    Sparse Gaussian clouds.

    dayNight: DayNight

    Lights, environment, fog and exposure.

    dome: Mesh<SphereGeometry, NodeMaterial, Object3DEventMap> = ...

    The atmosphere dome.

    followTarget: Vector3 | null = null

    Point the lights centre their shadows on; null = the camera position.

    lighting: Lighting | null = null

    Lighting derived from the last update.

    object: Group<Object3DEventMap> = ...

    Root of the dome, stars, meteors and lights. Added to scene for you when one is given.

    settings: SkySettings = ...

    Resolved settings. Change them with Sky.set / Sky.reset.

    shells: AltitudeShells = ...

    Labelled altitude shells around the home planet.

    shootingStars: ShootingStars = ...

    Meteors.

    stars: Stars

    Stars and Milky Way.

    state: SkyState = ...

    Everything about the current instant (sun/moon directions, phase, night…). Refreshed by Sky.update.

    system: StarSystem

    The star system model. Rebuilt when system settings change.

    uniforms: {
        airglow: UniformNode<"color", Color>;
        airglowBand: UniformNode<"float", number>;
        airglowBandColor: UniformNode<"vec3", Vector3>;
        airglowShell: UniformNode<"vec3", Vector3>;
        atmosphereHeight: UniformNode<"float", number>;
        bodyMatrix: UniformNode<"mat3", Matrix3>;
        cameraToPlanet: UniformNode<"vec3", Vector3>;
        celestialMatrix: UniformNode<"mat3", Matrix3>;
        density: UniformNode<"float", number>;
        earthshine: UniformNode<"float", number>;
        groundColor: UniformNode<"color", Color>;
        mie: UniformNode<"float", number>;
        mieAbsorption: UniformNode<"float", number>;
        mieG: UniformNode<"float", number>;
        mieScaleHeight: UniformNode<"float", number>;
        moonAlbedoScale: UniformNode<"float", number>;
        moonAngularRadius: UniformNode<"float", number>;
        moonBrightness: UniformNode<"float", number>;
        moonDirection: UniformNode<"vec3", Vector3>;
        moonIllumination: UniformNode<"float", number>;
        moonMatrix: UniformNode<"mat3", Matrix3>;
        moonSkyIntensity: UniformNode<"float", number>;
        night: UniformNode<"float", number>;
        nightFloor: UniformNode<"float", number>;
        nightLights: {
            color: UniformNode<"vec3", Vector3>;
            density: UniformNode<"float", number>;
            intensity: UniformNode<"float", number>;
            map: TextureNode<"vec4">;
            planetRadius: UniformNode<"float", number>;
            scale: UniformNode<"float", number>;
            twilight: UniformNode<"vec3", Vector3>;
            useTexture: UniformNode<"float", number>;
        };
        ozone: UniformNode<"vec3", Vector3>;
        ozoneCenter: UniformNode<"float", number>;
        ozoneWidth: UniformNode<"float", number>;
        planetRadius: UniformNode<"float", number>;
        rayleigh: UniformNode<"vec3", Vector3>;
        rayleighScaleHeight: UniformNode<"float", number>;
        sunAngularRadius: UniformNode<"float", number>;
        sunColor: UniformNode<"color", Color>;
        sunDirection: UniformNode<"vec3", Vector3>;
        sunDiscIntensity: UniformNode<"float", number>;
        sunIntensity: UniformNode<"float", number>;
        up: UniformNode<"vec3", Vector3>;
    } = ...

    Shared TSL uniforms (night, sunDirection, …) for use in your own materials.

    Type Declaration

    • airglow: UniformNode<"color", Color>

      Faint night-sky glow (linear RGB radiance).

    • airglowBand: UniformNode<"float", number>

      Airglow shell brightness.

    • airglowBandColor: UniformNode<"vec3", Vector3>

      Airglow shell colour (linear).

    • airglowShell: UniformNode<"vec3", Vector3>

      Airglow shell bottom and top altitudes, metres (mesopause … Kármán line).

    • atmosphereHeight: UniformNode<"float", number>

      Atmosphere thickness, metres.

    • bodyMatrix: UniformNode<"mat3", Matrix3>

      Render → home planet body frame.

    • cameraToPlanet: UniformNode<"vec3", Vector3>

      Camera position minus planet centre, render space, metres.

    • celestialMatrix: UniformNode<"mat3", Matrix3>

      Render → star frame (fixed stars; turns with sidereal time).

    • density: UniformNode<"float", number>

      Density multiplier (0 = no atmosphere).

    • earthshine: UniformNode<"float", number>

      Earthshine radiance factor on the moon's dark side.

    • groundColor: UniformNode<"color", Color>

      Ground albedo seen through the atmosphere where no terrain is drawn (linear RGB).

    • mie: UniformNode<"float", number>

      Mie scattering per metre.

    • mieAbsorption: UniformNode<"float", number>

      Mie absorption per metre.

    • mieG: UniformNode<"float", number>

      Mie anisotropy.

    • mieScaleHeight: UniformNode<"float", number>

      Mie scale height, metres.

    • moonAlbedoScale: UniformNode<"float", number>

      Multiplier on the moon's albedo map.

    • moonAngularRadius: UniformNode<"float", number>

      Apparent moon radius, radians (0 = no moon).

    • moonBrightness: UniformNode<"float", number>

      Multiplier on the moon disc's sunlit radiance.

    • moonDirection: UniformNode<"vec3", Vector3>

      Towards the moon (render space).

    • moonIllumination: UniformNode<"float", number>

      Lit fraction of the moon.

    • moonMatrix: UniformNode<"mat3", Matrix3>

      Render → moon body frame.

    • moonSkyIntensity: UniformNode<"float", number>

      How strongly moonlight lights the sky, relative to the sun.

    • night: UniformNode<"float", number>

      0 by day … 1 at night. Bind it in your own materials (e.g. lit windows).

    • nightFloor: UniformNode<"float", number>

      Minimum light on the night side of the planet seen from altitude (fraction of sunIntensity).

    • nightLights: {
          color: UniformNode<"vec3", Vector3>;
          density: UniformNode<"float", number>;
          intensity: UniformNode<"float", number>;
          map: TextureNode<"vec4">;
          planetRadius: UniformNode<"float", number>;
          scale: UniformNode<"float", number>;
          twilight: UniformNode<"vec3", Vector3>;
          useTexture: UniformNode<"float", number>;
      }

      City lights on the night side.

      • color: UniformNode<"vec3", Vector3>

        Light colour (linear).

      • density: UniformNode<"float", number>

        Procedural coverage.

      • intensity: UniformNode<"float", number>

        Radiance of fully lit areas (0 = off).

      • map: TextureNode<"vec4">

        Lights texture (equirectangular).

      • planetRadius: UniformNode<"float", number>

        Planet radius, metres (sets the size of the sparkle).

      • scale: UniformNode<"float", number>

        Procedural feature scale.

      • twilight: UniformNode<"vec3", Vector3>

        Sun-elevation sines where lights switch on (start, full).

      • useTexture: UniformNode<"float", number>

        1 = use the texture, 0 = procedural.

    • ozone: UniformNode<"vec3", Vector3>

      Ozone absorption per metre (RGB).

    • ozoneCenter: UniformNode<"float", number>

      Ozone peak altitude, metres.

    • ozoneWidth: UniformNode<"float", number>

      Ozone layer half-width, metres.

    • planetRadius: UniformNode<"float", number>

      Planet radius, metres.

    • rayleigh: UniformNode<"vec3", Vector3>

      Rayleigh scattering per metre (RGB).

    • rayleighScaleHeight: UniformNode<"float", number>

      Rayleigh scale height, metres.

    • sunAngularRadius: UniformNode<"float", number>

      Apparent sun radius, radians.

    • sunColor: UniformNode<"color", Color>

      Sun disc colour from the star's temperature (linear RGB).

    • sunDirection: UniformNode<"vec3", Vector3>

      Towards the sun (render space).

    • sunDiscIntensity: UniformNode<"float", number>

      Sun disc radiance (HDR; drives bloom).

    • sunIntensity: UniformNode<"float", number>

      Sun radiance scale.

    • up: UniformNode<"vec3", Vector3>

      Local up at the camera (render space).

    • get exposure(): number

      Suggested renderer.toneMappingExposure (smoothed); applied for you with lighting.autoExposure.

      Returns number

    • get moonLight(): DirectionalLight

      The moonlight DirectionalLight.

      Returns DirectionalLight

    • get night(): number

      0 by day … 1 at night, as a number (the TSL version is uniforms.night).

      Returns number

    • get sun(): DirectionalLight

      Lights. The sun DirectionalLight (size its shadow.camera to taste).

      Returns DirectionalLight

    • Near and far planes for the camera right now (see clipPlanes): pass the camera's height above the ground under it. With shells on, far reaches the outermost shell.

      Parameters

      • height: number = ...

      Returns [number, number]

    • Cloud cover 0..1 at a render-space position right now (the same field the clouds are placed from).

      Parameters

      • x: number
      • y: number
      • z: number

      Returns number

    • Removes everything from the scene and frees GPU resources.

      Returns void

    • Centres the lights' shadow cameras on target (e.g. your orbit-controls target); null follows the camera.

      Parameters

      • target: Vector3 | null

      Returns void

    • Which atmosphere layer an altitude (metres; default: the camera's) is in.

      Parameters

      • altitude: number = ...

      Returns LayerName

    • Merges settings (nested objects merge; arrays replace). The clock only jumps if clock.date changes.

      Parameters

      Returns this

    • Sets the city-lights field: a (latitude, longitude) => 0..1 callback (baked at nightLights.resolution), an equirectangular texture (longitude 0 at the centre, south at the bottom), or null for the procedural field.

      Parameters

      • field: Texture<unknown, TextureEventMap> | LightsField | null

      Returns this

    • Jumps to a local apparent solar time (hours, 12 = noon) on the current day, at the observer.

      Parameters

      • hours: number

      Returns this

    • Next sunrise and sunset after now at the observer, as Dates (null in polar day/night).

      Returns { sunrise: Date | null; sunset: Date | null }

    • Advances time and refreshes everything. Call once per frame, before rendering.

      Parameters

      • Optionaldt: number

        Real seconds since the last frame. Omit to measure it.

      Returns void

    • Creates a sky and computes the first frame (lights and environment included).

      Parameters

      Returns Promise<Sky>

      If renderer is not a WebGPURenderer.