Skip to content

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, and frustumCulled to every light object.
  • Writing distance and decay for THREE.PointLight and THREE.SpotLight.
  • Writing angle and penumbra for THREE.SpotLight.
  • Writing width and height for THREE.RectAreaLight.

Queried components

ComponentAccess
LightComponentRead (values sub-state)

Behavior notes

  • Signature-based change detection — per-entity signatures are computed from the serialized values object each frame. Light properties are only written when the signature changes, preventing redundant THREE.js mutations on every frame.
  • Value clampingintensity is clamped to ≥ 0. distance is clamped to ≥ 0. angle is clamped to [0, π/2]. penumbra is clamped to [0, 1]. Non-finite values use safe defaults.
  • Stale entity cleanup — when an entity is destroyed the system removes its entry from the signature map to prevent unbounded memory growth.

API reference