Illutions Engine API - v0.26.0
    Preparing search index...

    Class Light3D

    The Light3D class represents a managed light source.

    Hierarchy (View Summary)

    Index
    canvas: HTMLElement
    cfg: Cfg
    name: string
    obj: Light

    The underlying THREE.Light object that defines illumination parameters and behavior. It can be replaced to represent various light types such as point, directional, or spot lights.

    THREE.PointLight

    objs3D: Map<string, Obj3D> | null = null
    renderer: Readonly<WebGLRenderer> | Readonly<WebGPURenderer>

    The active Three.js renderer used by this object. It is exposed for advanced use cases that require renderer-dependent Three.js APIs, such as reading the canvas size, pixel ratio, drawing buffer size, or updating renderer-based helper objects like cube cameras.

    scene: Readonly<THREE_TYPE.Scene>

    The THREE.Scene instance this object belongs to.

    • Registers a listener that is called whenever the specified event occurs.

      Type Parameters

      • TType extends
            | "OBJ3D_POS_WORLD_CHANGED"
            | "OBJ3D_POS_SCREEN_CHANGED"
            | "OBJ3D_ROT_WORLD_CHANGED"
            | "OBJ3D_FRUSTUM_CHANGED"
            | "OBJ3D_VISIBLE_CHANGED"
            | "OBJ3D_CLICK"
            | "OBJ3D_POINTER_ENTER"
            | "OBJ3D_POINTER_DOWN"
            | "OBJ3D_POINTER_LEAVE"
            | "OBJ3D_POINTER_MOVE"
            | "OBJ3D_POINTER_UP"

      Parameters

      Returns Unsubscribe

      A function that unsubscribes the listener.

    • Returns the object's screen position in canvas coordinates.

      Parameters

      • cam3D: Cam3D

        Camera used for projection to canvas coordinates.

      Returns { x: number; y: number } | null

      The projected screen position in canvas coordinates, or null if no THREE.Object3D is assigned.

    • Called once after the THREE.Scene, the THREE.WebGLRenderer or THREE.WebGPURenderer, the EnvCtrls are initialized and an existing GLTF model has been loaded and traversed.

      Returns void

    • Called once after the THREE.Scene is initialized, before an existing GLTF model is loaded.

      Returns void

    • Called for each traversed light during .gltf parsing. Stores the current THREE.Light in this.obj.

      Parameters

      • objGltf: Light

        The currently traversed THREE.Light.

        Example

        import { SpotLight } from 'three';
        import { Light3D } from 'illutions';

        export class Spot extends Light3D {
        // Called while illutions traverses the loaded 3D scene.
        // The matching Three.js light from the GLTF scene is passed in here.
        public override onTraverse(light: SpotLight): void {
        // Limit the effective range of the spotlight.
        light.distance = 10;
        // Use physically realistic light falloff.
        light.decay = 2;
        // Enable shadow casting for this light.
        light.castShadow = true;

        // Store the configured 'THREE.Light' as the runtime light object.
        this.obj = light;
        }
        }

      Returns void

    • Called on every animation frame update.

      Parameters

      • deltaTime: number

        Time elapsed since the previous frame in seconds.

      Returns void

    • Removes a previously registered listener for the specified event.

      Type Parameters

      • TType extends
            | "OBJ3D_POS_WORLD_CHANGED"
            | "OBJ3D_POS_SCREEN_CHANGED"
            | "OBJ3D_ROT_WORLD_CHANGED"
            | "OBJ3D_FRUSTUM_CHANGED"
            | "OBJ3D_VISIBLE_CHANGED"
            | "OBJ3D_CLICK"
            | "OBJ3D_POINTER_ENTER"
            | "OBJ3D_POINTER_DOWN"
            | "OBJ3D_POINTER_LEAVE"
            | "OBJ3D_POINTER_MOVE"
            | "OBJ3D_POINTER_UP"

      Parameters

      Returns void