Skip to main content
Version: 0.12.0 (latest)

UeLight

All lights in Unique Engine inherit from UeLight. This base class provides common properties and methods for all light types.

Inherits from UeObject3D

Constructor

UeLight(data)

Constructs a new base light. This is typically not instantiated directly; use one of the specialized light classes instead.

  • data: Optional configuration object.

Properties

PropertyTypeDefaultDescription
isLightbooleantrueIdentifies this object as a light
typestringLightObject type
namestringundefinedObject name (optional)
lightTypestring"Light"Specific light type ("AmbientLight", etc.)
intensitynumber1Brightness multiplier for this light
paramsVersionnumber0Increments whenever light parameters change.
enabledbooleantrueWhether the light is currently active
colorarray[0.5, 0.5, 0.5]RGB color as normalized array [r, g, b]

Methods

.setColor(color)

Sets the RGB color of the light. Accepts a GM color constant (e.g., c_red) or an [r, g, b] array.

.setIntensity(intensity)

Sets the brightness multiplier for this light.

.setEnabled(enabled)

Enables or disables the light.

.toJSON()

Returns an object representing this light's properties.

🔁 Usage in Scene

Lights should be added to a UeScene using .add() and will be automatically collected by UeRenderer.

const ambient = new UeAmbientLight(c_gray);
const sun = new UeDirectionalLight(c_white, 2);
const point = new UePointLight(c_yellow, 1, 500);
const hemi = new UeHemisphereLight(c_white, c_gray, 1);

scene.add(ambient);
scene.add(sun);
scene.add(point);
scene.add(hemi);

🌑 Shadows

Lights can cast shadows when castShadow is enabled. The renderer will create and update shadow maps for each shadow-casting light.

Note: UeAmbientLight and UeHemisphereLight do not support shadow casting.

PropertyTypeDefaultDescription
castShadowbooleanfalseWhether this light casts shadows
shadowobjectAuto-createdShadow controller (type depends on light)

See the specific light documentation for details on shadow configuration:

⚙️ Renderer Configuration

To enable shadow rendering, you must configure the UeRenderer:

renderer.shadowMap.enabled = true;
renderer.shadowMap.autoUpdate = true;

For more advanced shadow settings, see the UeShadowMap documentation.