Skip to content

Sun ​

Controls the sun's direction, brightness, color, and apparent size. The sky, clouds, and god rays share these values.

Properties ​

azimuthDeg ​

Type: number (read-only)
Units: degrees

Current compass azimuth, from -180 to 180 degrees. 0 points toward +Z and 90 toward +X. setFromAngles uses the same convention.


elevationDeg ​

Type: number (read-only)
Units: degrees

Current elevation, from -90 to 90 degrees. 0 is the horizon and 90 is directly overhead. setFromAngles uses the same convention.


color.value ​

Type: uniform<color>
Default: (1.0, 0.95, 0.85)
Units: linear RGB

Sets the sun's color before the atmosphere absorbs any of it. The default is a warm white.

Sunset reddening comes from the atmosphere rather than from here, so leave this near white unless the scene calls for a deliberately tinted star.


direction.value ​

Type: uniform<vec3>
Default: -
Units: unit vector

Points from the scene toward the sun, in world space.

The day/night clock updates this value when timeOfDay.time, latitude, or azimuth changes. To preserve a direction set with setFromAngles(), pause the clock with autoAdvanceSecondsPerDay = 0.


discSize.value ​

Type: uniform<float>
Default: 0.0003
Units: -

Sets the angular size of the sun disc, measured as 1 - cos θ. The default radius is approximately 1.4 degrees. Typical range: 0.00005–0.005.


intensity.value ​

Type: uniform<float>
Default: 6.6
Units: -

Current sun radiance after the horizon fade is applied to peakIntensity.

The driver overwrites this every frame. Set peakIntensity instead.


peakIntensity ​

Type: number
Default: 6.6
Units: -

Sets the sun's full-daylight radiance. intensity.value fades down from this value as the sun sets.

Not a uniform; assign it directly. Passing intensity to applyParams writes this field.

Methods ​

applyParams(params) ​

Writes any subset of SunParams in one call. Omitted fields are left unchanged.

You may pass elevation or azimuth independently; the omitted angle remains unchanged.

Returns: void

typescript
sky.sun.applyParams({
  intensity: 18.0,
  color: new THREE.Color(1.0, 0.9, 0.7),
  discSize: 0.0005,
});

setFromAngles(elevationDeg, azimuthDeg) ​

Sets the direction from spherical angles.

ParamTypeRequiredDescription
elevationDegnumberrequiredDegrees. 0 is the horizon, 90 straight overhead.
azimuthDegnumberrequiredDegrees. 0 faces +Z, 90 faces +X.

Returns: void

typescript
sky.sun.setFromAngles(35, 120);

toParams() ​

Returns a new SunParams containing the current position, brightness, color, and disc size. Pass it to applyParams to restore the state, or store it in a preset's sun block.

Returns: SunParams

typescript
const saved = sky.sun.toParams();
sky.sun.setFromAngles(80, 0);
sky.sun.applyParams(saved); // back to where it was

Types ​

SunParams ​

Every field is required — toParams() returns all of them, and applyParams takes Partial<SunParams>. This is also the shape of a preset's sun block.

The fields are not a one-to-one map of the properties above. There is no direction: applyParams builds it from the elevation / azimuth pair, and toParams decomposes it back. intensity reads and writes peakIntensity, not the per-frame intensity uniform.

typescript
interface SunParams {
  // degrees, 0 = horizon, 90 = zenith
  elevation: number;
  // degrees, 0 = +Z, 90 = +X
  azimuth: number;
  // writes `peakIntensity`
  intensity: number;
  // linear RGB
  color: THREE.Color;
  // angular radius as `1 - cos θ`
  discSize: number;
}
typescript
import type { SunParams } from 'threejs-sky-pro';

See Also ​

Commercial License - All Rights Reserved.