AmbientLightDesc
The AmbientLightDesc class represents an ambient light descriptor that illuminates the entire scene uniformly. AmbientLight illuminates all objects evenly and does not cast shadows.
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, ambient: { ... }}Ambient Properties
Section titled “Ambient Properties”ambient
Section titled “ambient”Type: object | undefined
Description: Configuration options for the ambient light.
Type: Color | undefined
Description: Specifies the color of the ambient light using a Color object.
Default: new Color().setHex(0xffffff)
Example:
import { Color } from "@navaramap/three";
{ ambient: { color: new Color().setHex(0xffffff), }}intensity
Section titled “intensity”Type: number | undefined
Description: Specifies the intensity of the ambient light. Higher values result in brighter light.
Default: 1
Example:
{ ambient: { intensity: 1.0, }}Usage Examples
Section titled “Usage Examples”Basic Usage
Section titled “Basic Usage”import ThreeView, { Color } from "@navaramap/three";import { AmbientLightDesc } from "@navaramap/three_default_descs";
const view = new ThreeView();await view.init();
// Add an ambient light descriptorconst ambientLight = view.addLight<AmbientLightDesc>({ ambient: { color: new Color().setHex(0xffffff), intensity: 1.0 }});Updating the Ambient Light
Section titled “Updating the Ambient Light”// Update the ambient light color and intensityambientLight.update({ ambient: { color: new Color().setHex(0xaabbcc), intensity: 0.5 }});Simple Ambient Light
Section titled “Simple Ambient Light”// Add ambient light with default settingsview.addLight<AmbientLightDesc>({ ambient: {}});Adding as Initially Hidden
Section titled “Adding as Initially Hidden”// Add ambient light in a hidden state, then toggle visibility laterconst ambientLightDesc = view.addLight<AmbientLightDesc>({ visible: false, ambient: { intensity: 1, color: new Color().setHex(0xffffff), },});
// Toggle visibilityambientLightDesc.visible = true;- Ambient light does not cast shadows.
- Ambient light illuminates objects evenly from all directions.
- It can be used in combination with other light types (SunLightDesc, SkyLightProbeDesc, etc.).
- If the ambient light intensity is too high, the scene may appear flat.