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

    Class Obj3D

    Wraps a THREE.Object3D and provides lifecycle hooks, scene integration, animation support, and position-, rotation- and visibility-change events. Extend this class to implement custom object behavior.

    Hierarchy (View Summary)

    Index
    canvas: HTMLElement
    cfg: Cfg
    name: string
    obj: Object3D<Object3DEventMap> | null = null

    The managed THREE.Object3D instance for this object. It is null until a scene object is assigned.

    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 once for each traversed child during GLTF parsing. Stores the currently traversed THREE.Object3D instance in this.obj.

      Parameters

      • objGltf: Object3D

        The traversed THREE.Object3D instance.

      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