UNPKG

@needle-tools/engine

Version:

Needle Engine is a web-based runtime for 3D apps. It runs on your machine for development with great integrations into editors like Unity or Blender - and can be deployed onto any device! It is flexible, extensible and networking and XR are built-in.

63 lines (62 loc) 2.27 kB
import { BoxHelperComponent } from "./BoxHelperComponent.js"; import { Behaviour } from "./Component.js"; /** * The [DeleteBox](https://engine.needle.tools/docs/api/DeleteBox) component creates an invisible deletion zone that destroys objects entering it. * Works with objects that have a {@link Deletable} component attached. * * ![](https://cloud.needle.tools/-/media/J-Gmdhl214kfdjkfYViG8g.gif) * * **Use cases:** * - Trash bins in sandbox builders * - Kill zones in physics simulations * - Cleanup areas for multiplayer scenes * * **Setup:** * 1. Add DeleteBox to a GameObject with a BoxCollider-like shape * 2. Add {@link Deletable} component to objects that should be destroyable * 3. Objects entering the box will be destroyed (synced across network) * * **Debug:** Use `?debugdeletable` URL parameter to visualize deletion areas. * * - Example: https://engine.needle.tools/samples/collaborative-sandbox * * @example Create a deletion zone * ```ts * const trashBin = trashBinModel.addComponent(DeleteBox); * // Objects with Deletable component will be destroyed when entering * ``` * * @summary Box area that deletes objects entering it * @category Interactivity * @group Components * @see {@link Deletable} - Add to objects that can be destroyed * @see {@link Duplicatable} for spawning objects * @see {@link DragControls} for moving objects */ export declare class DeleteBox extends BoxHelperComponent { static _instances: DeleteBox[]; onEnable(): void; onDisable(): void; } /** * Marks a GameObject as deletable by {@link DeleteBox} zones. * Objects with this component will be destroyed (and synced across network) * when they enter a DeleteBox area. * * **Note:** Objects currently being used (with {@link UsageMarker}) are protected from deletion. * * @example Make an object deletable * ```ts * const deletable = spawnedObject.addComponent(Deletable); * // Object can now be destroyed by entering a DeleteBox * ``` * * @summary Marks object as destroyable by DeleteBox * @category Interactivity * @group Components * @see {@link DeleteBox} for the deletion trigger * @see {@link UsageMarker} for protecting objects in use */ export declare class Deletable extends Behaviour { update(): void; }