Create a new lighting manager
The Three.js scene to add lights to
Configuration options for lighting
Update head light position based on camera position and controls target. This should be called in the animation loop for smooth tracking.
The head light maintains a fixed angular offset from the camera direction, following the camera while respecting the configured offset angles.
The active camera
The point the camera is looking at (typically controls.target)
PrivateapplyApply the angular headLightOffset to compute headLight position relative to camera.
Algorithm:
The active camera
The point to position relative to
Set the head light angular offset.
Angular offset [horizontal, vertical] in radians
Set the head light offset from degrees (convenience method). Useful when loading from configuration files that store degrees.
Horizontal angle in degrees
Vertical angle in degrees
Get the current head light offset in radians
Toggle head light on/off
New state (true = enabled, false = disabled)
Set head light enabled state
Whether to enable the head light
Check if head light is enabled
Set the head light intensity
Light intensity (0 to 1+)
Set the environment map for IBL (Image-Based Lighting)
The environment texture or null to clear
Toggle environment lighting on/off
New state (true = enabled, false = disabled)
Set environment lighting enabled state
Whether to enable environment lighting
Check if environment lighting is enabled
Get the current lighting state
Get the ambient light object
Get the directional head light object
Set ambient light intensity
Light intensity (0 to 1+)
Clean up resources
PrivatescenePrivateambientPrivateheadPrivateheadPrivateheadPrivateenvPrivateenvPrivateconfig
LightingManager handles all lighting for the 3D scene.
Features:
The head light uses a sophisticated offset system:
Example