import { ContextManager, Event, Observable } from '@zcomponent/core'; import { Group } from '@zcomponent/three'; import { IRigidBody } from '../index'; /** * Allows an entity to grab dynamic rigidbodies and move them around. * Only one object can be grabbed at a time per grabber. * * In order for an object to be grabbable, it must: * - Have a RigidBody Behavior which has a `DYNAMIC` motion type. * - The RigidBody behavior must have `grabbable` set to true. * - The object must not be the grabber itself. * * The grab radius is the distance from the grabber that an object can be grabbed. * * The grabber will grab the dynamic object on `perform` and release it on `perform` when an object is already grabbed. * * Events: * - `onGrabInRange`: Emitted when a grabbable object enters the grab radius. Only one object can be in range at a time. * - `onGrabOutOfRange`: Emitted when the in-range object leaves the grab radius or when the grabbed object is released. * - `onGrab`: Emitted when an object is grabbed. * - `onRelease`: Emitted when the grabbed object is released. * * The grabber continuously checks for the closest grabbable object within the grab radius every frame. * When an object enters the grab radius, the `onGrabInRange` event is fired for that object. * If the in-range object leaves the grab radius or the grabbed object is released, the `onGrabOutOfRange` event is fired for that object. * * The grabber also supports grabbing objects at their current distance from the grabber or snapping them to the grabber's origin based on the `grabAtCurrentDistance` property. * * The `limitToTags` property allows specifying an array of tags that the grabbable objects must have in order to be considered for grabbing. * * @zcomponent * @ztag three/Object3D/Physics/RigidbodyGrabber * @zparents three/Object3D/** * @zgroup Physics Transforms * @zicon pan_tool */ export declare class RigidbodyGrabber extends Group { /** * Emitted when a grabbable object enters the grab radius. Only one object can be in range at a time. * @zprop */ onGrabInRange: Event<[IRigidBody]>; /** * Emitted when the in-range object leaves the grab radius or when the grabbed object is released. * @zprop */ onGrabOutOfRange: Event<[IRigidBody]>; /** * Emitted when an object is grabbed. * @zprop */ onGrab: Event<[IRigidBody]>; /** * Emitted when an object is released. * @zprop */ onRelease: Event<[IRigidBody]>; private _currentGrabbedObject; private _currentInRangeObject; private myWorldPos; private targetWorldPos; /** * The radius around the grabber that objects can be grabbed. * * This is the world distance between the origin of the grabber and the origin of the grabbed object. * @zprop * @zdefault 1 */ grabRadius: Observable; /** * Controls whether the grabbed body remains at its current distance or snaps to the origin of the grabber. * If true, the body will be grabbed at its current distance. If false, it will snap to the grabber's origin. * @zprop * @zdefault false */ grabAtCurrentDistance: Observable; /** * If set, the grabber will only grab objects with these tags. * If empty, the grabber will grab any object that meets the requirements. * @zprop * @zdefault [] */ limitToTags: Observable; private helper; constructor(contextManager: ContextManager, props: {}); private getClosestWithinGrabRadius; private activeTargetWorldPos; private activeTargetWorldQuat; private _frame; setGrabbing: (shouldGrab: boolean) => void; perform: () => void; dispose: () => never; }