ThreePresenter API Documentation - v0.1.2
    Preparing search index...

    Class LightingManager

    LightingManager handles all lighting for the 3D scene.

    Features:

    • Ambient lighting for base illumination
    • Directional head light that follows camera
    • Environment map lighting support
    • Configurable head light offset (angular position relative to camera)
    • Toggle controls for head light and environment lighting

    The head light uses a sophisticated offset system:

    • headLightOffset.x: horizontal angle (theta) in radians (positive → rotate right)
    • headLightOffset.y: vertical angle (phi) in radians (positive → rotate up)
    • Offset is relative to camera direction, maintaining consistent distance
    const manager = new LightingManager(scene, {
    ambientIntensity: 0.1,
    headLightIntensity: 0.9
    });

    // In animation loop
    manager.updateHeadLight(camera, controls.target);

    // Toggle lighting
    manager.toggleHeadLight();
    manager.toggleEnvironmentLighting();
    Index

    Constructors

    Methods

    • 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.

      Parameters

      • camera: Camera

        The active camera

      • target: Vector3 = ...

        The point the camera is looking at (typically controls.target)

      Returns void

    • Apply the angular headLightOffset to compute headLight position relative to camera.

      Algorithm:

      1. Get camera direction in spherical coordinates (theta, phi)
      2. Add offset angles
      3. Convert back to Cartesian coordinates
      4. Maintain same distance from target as camera

      Parameters

      • camera: Camera

        The active camera

      • target: Vector3

        The point to position relative to

      Returns void

    • Set the head light angular offset.

      Parameters

      • offset: Vector2

        Angular offset [horizontal, vertical] in radians

        • x (horizontal): positive = rotate right
        • y (vertical): positive = rotate up

      Returns void

    • Set the head light offset from degrees (convenience method). Useful when loading from configuration files that store degrees.

      Parameters

      • horizontalDegrees: number

        Horizontal angle in degrees

      • verticalDegrees: number

        Vertical angle in degrees

      Returns void

    • Set head light enabled state

      Parameters

      • enabled: boolean

        Whether to enable the head light

      Returns void

    • Set the head light intensity

      Parameters

      • intensity: number

        Light intensity (0 to 1+)

      Returns void

    • Set the environment map for IBL (Image-Based Lighting)

      Parameters

      • envMap: Texture | null

        The environment texture or null to clear

      Returns void

    • Toggle environment lighting on/off

      Returns boolean

      New state (true = enabled, false = disabled)

    • Set environment lighting enabled state

      Parameters

      • enabled: boolean

        Whether to enable environment lighting

      Returns void

    • Set ambient light intensity

      Parameters

      • intensity: number

        Light intensity (0 to 1+)

      Returns void

    Properties

    scene: Scene
    ambientLight: AmbientLight
    headLight: DirectionalLight
    headLightOffset: Vector2
    headLightEnabled: boolean = true
    envLightingEnabled: boolean = true
    envMap: Texture | null = null
    config: Required<LightingConfig>