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.
Common Properties
Section titled “Common Properties”visible
Section titled “visible”Type: boolean | undefined
Description: Controls the visibility of the object.
Default: true
Example:
{ visible: false, skyLightProbe: { ... }}SkyLightProbe Properties
Section titled “SkyLightProbe Properties”skyLightProbe
Section titled “skyLightProbe”Type: object | undefined
Description: Configuration options for the sky light probe.
intensity
Section titled “intensity”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, }}Dynamic Updates
Section titled “Dynamic Updates”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.
Usage Examples
Section titled “Usage Examples”Basic Usage
Section titled “Basic Usage”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 objectsconst defaultLayers = plugin.addDefaultPhotorealScene();
// The sky light probe automatically follows the sun's positiondefaultLayers.skyLightProbe.update({ skyLightProbe: { intensity: 1.0 }});Changing Intensity for Day and Night
Section titled “Changing Intensity for Day and Night”const skyLightProbe = view.addLight<SkyLightProbeDesc>({ skyLightProbe: { intensity: 1.0 }});
// Set different intensities for day and nightconst 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 } });});Enable Only at Night
Section titled “Enable Only at Night”const skyLightProbe = view.addLight<SkyLightProbeDesc>({ skyLightProbe: { intensity: 1.0 },});
// Increase intensity only at nightview.atmosphere.on("sunChanged", () => { const isAtNight = view.atmosphere.isAtNight(view.camera.positionECEF); if(!isAtNight) return; skyLightProbe.update({ skyLightProbe: { intensity: 5.0 }, });});Integration with the Atmosphere System
Section titled “Integration with the Atmosphere System”SkyLightProbeDesc works closely with the atmospheric scattering simulation from the @takram/three-atmosphere package:
- Irradiance texture retrieval: Obtains pre-computed irradiance textures from the atmosphere object
- Sun direction synchronization: Synchronizes the sun direction every frame
- Position update: Calculates appropriate lighting based on camera position
This enables natural environment lighting that responds to time of day and sun position.
Differences from LightProbeDesc
Section titled “Differences from LightProbeDesc”| Feature | SkyLightProbeDesc | LightProbeDesc |
|---|---|---|
| Update method | Automatic (follows sun position) | Manual (fixed values) |
| Data source | Atmospheric simulation | Pre-computed coefficients |
| Use case | Dynamic sky lighting | Static environment lighting |
| Atmosphere | Required | Not 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.).