LightSyncSystem
Applies LightComponent authoring values to the underlying THREE.js light objects each frame, supporting directional, ambient, point, spot, hemisphere, and area light types.
Overview
LightSyncSystem runs every frame and is responsible for:
- Writing
color,intensity,castShadow, andfrustumCulledto every light object. - Writing
distanceanddecayforTHREE.PointLightandTHREE.SpotLight. - Writing
angleandpenumbraforTHREE.SpotLight. - Writing
widthandheightforTHREE.RectAreaLight. - Applying the optional
values.shadowblock (mapSize,bias,normalBias,radius,cameraSize,near,far) to shadow-casting lights. See Tune shadow quality.
Queried components
| Component | Access |
|---|---|
LightComponent | Read (values sub-state) |
Behavior notes
- Signature-based change detection: per-entity signatures are computed from the serialized
valuesobject each frame. Light properties are only written when the signature changes, preventing redundant THREE.js mutations on every frame. - Value clamping:
intensityis clamped to≥ 0.distanceis clamped to≥ 0.angleis clamped to[0, π/2].penumbrais clamped to[0, 1]. Non-finite values use safe defaults. - Shadow fields: only the fields present in
values.shadoware written; a light without the block keeps three's defaults. Removing a field restores its default. A newmapSizedisposes the allocated shadow map so three rebuilds it at the new size, and any camera change callsshadow.camera.updateProjectionMatrix().mapSizeis clamped to[16, 8192]. - Stale entity cleanup: when an entity is destroyed the system removes its entry from the signature map to prevent unbounded memory growth.
API reference
- Class:
LightComponent - Source:
core/systems/LightSyncSystem.ts

