• Destroys a GameObject or Component, removing it from the scene and cleaning up resources.
    Calls onDisable() and onDestroy() lifecycle methods on all affected components.

    Parameters

    • instance: Object3D<Object3DEventMap> | IComponent

      The Object3D or Component to destroy

    • recursive: boolean = true

      If true (default), also destroys all children recursively

    • dispose: boolean = false

      If true, also disposes GPU resources (geometries, materials, textures)

    Returns void

    import { destroy } from "@needle-tools/engine";
    destroy(this.gameObject);
    destroy(myObject, true, true); // recursive + dispose GPU resources