Skip to content

SkyLightProbeDesc

The SkyLightProbeDesc class represents a dynamic sky light probe Descriptor that works in conjunction with atmospheric scattering simulation. It provides environment lighting that automatically updates based on the sun’s position, reproducing realistic sky lighting.

The sun direction is automatically calculated based on view.atmosphere.date, and lighting is updated every frame.

Type: boolean | undefined

Description: Controls the visibility of the object.

Default: true

Example:

{
visible: false,
skyLightProbe: { ... }
}

Type: object | undefined

Description: Configuration options for the sky light probe.

Type: number | undefined

Description: Specifies the intensity of the sky light probe. Higher values result in brighter light.

Default: 1

Example:

{
skyLightProbe: {
intensity: 1.0,
}
}

SkyLightProbeDesc automatically updates based on the following factors:

  • Sun direction: Obtained from view.atmosphere.sunDirection
  • Camera position: Considers differences in lighting inside and outside the atmosphere
  • Atmosphere texture: Uses the irradiance texture

These updates are performed automatically every frame, so manual updating is unnecessary.

import ThreeView from "@navaramap/three";
import { SkyLightProbeDesc } from "@navaramap/three_default_descs";
import { DefaultPlugin } from "@navaramap/three_default_plugin";
const view = new ThreeView();
const plugin = new DefaultPlugin();
view.addPlugin(plugin);
await view.init();
// Add default photorealistic objects
const defaultLayers = plugin.addDefaultPhotorealScene();
// The sky light probe automatically follows the sun's position
defaultLayers.skyLightProbe.update({
skyLightProbe: {
intensity: 1.0
}
});
const skyLightProbe = view.addLight<SkyLightProbeDesc>({
skyLightProbe: {
intensity: 1.0
}
});
// Set different intensities for day and night
const params = {
dayIntensity: 1.0,
nightIntensity: 5.0
};
view.atmosphere.on("sunChanged", () => {
const isAtNight = view.atmosphere.isAtNight(view.camera.positionECEF);
const intensity = isAtNight ? params.nightIntensity : params.dayIntensity;
skyLightProbe.update({
skyLightProbe: { intensity }
});
});
const skyLightProbe = view.addLight<SkyLightProbeDesc>({
skyLightProbe: {
intensity: 1.0
},
});
// Increase intensity only at night
view.atmosphere.on("sunChanged", () => {
const isAtNight = view.atmosphere.isAtNight(view.camera.positionECEF);
if(!isAtNight) return;
skyLightProbe.update({
skyLightProbe: {
intensity: 5.0
},
});
});

SkyLightProbeDesc works closely with the atmospheric scattering simulation from the @takram/three-atmosphere package:

  1. Irradiance texture retrieval: Obtains pre-computed irradiance textures from the atmosphere object
  2. Sun direction synchronization: Synchronizes the sun direction every frame
  3. Position update: Calculates appropriate lighting based on camera position

This enables natural environment lighting that responds to time of day and sun position.

FeatureSkyLightProbeDescLightProbeDesc
Update methodAutomatic (follows sun position)Manual (fixed values)
Data sourceAtmospheric simulationPre-computed coefficients
Use caseDynamic sky lightingStatic environment lighting
AtmosphereRequiredNot required
  • SkyLightProbeDesc requires the atmosphere object (Atmosphere) to function.
  • Using plugin.addDefaultPhotorealScene() automatically includes SkyLightProbeDesc.
  • Setting a higher intensity at night can achieve more natural nightscape lighting.
  • It can be used in combination with other light Descriptors (AmbientLight, SunLight, etc.).