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

97 lines (96 loc) 4.18 kB
import { Object3D } from "three"; import { Behaviour } from "./Component.js"; import type { IPointerEventHandler, PointerEventData } from "./ui/PointerEvents.js"; /** * The DragMode determines how an object is dragged around in the scene. */ export declare enum DragMode { /** Object stays at the same horizontal plane as it started. Commonly used for objects on the floor */ XZPlane = 0, /** Object is dragged as if it was attached to the pointer. In 2D, that means it's dragged along the camera screen plane. In XR, it's dragged by the controller/hand. */ Attached = 1, /** Object is dragged along the initial raycast hit normal. */ HitNormal = 2, /** Combination of XZ and Screen based on the viewing angle. Low angles result in Screen dragging and higher angles in XZ dragging. */ DynamicViewAngle = 3, /** The drag plane is adjusted dynamically while dragging. */ SnapToSurfaces = 4, /** Don't allow dragging the object */ None = 5 } /** * DragControls allows you to drag objects around in the scene. It can be used to move objects in 2D (screen space) or 3D (world space). * @category Interactivity * @group Components */ export declare class DragControls extends Behaviour implements IPointerEventHandler { /** * @returns True if any DragControls component is currently active */ static get HasAnySelected(): boolean; private static _active; /** @returns a list of DragControl components that are currently active */ static get CurrentlySelected(): DragControls[]; /** Currently active and enabled DragControls components */ private static _instances; /** How and where the object is dragged along. */ dragMode: DragMode; /** Snap dragged objects to a XYZ grid – 0 means: no snapping. */ snapGridResolution: number; /** Keep the original rotation of the dragged object. */ keepRotation: boolean; /** How and where the object is dragged along while dragging in XR. */ xrDragMode: DragMode; /** Keep the original rotation of the dragged object while dragging in XR. */ xrKeepRotation: boolean; /** Accelerate dragging objects closer / further away when in XR */ xrDistanceDragFactor: number; /** When enabled, draws a line from the dragged object downwards to the next raycast hit. */ showGizmo: boolean; /** The currently dragged object (if any) */ get draggedObject(): Object3D<import("three").Object3DEventMap> | null; /** * Use to update the object that is being dragged by the DragControls */ setTargetObject(obj: Object3D | null): void; private _rigidbody; /** The object to be dragged – we pass this to handlers when they are created */ private _targetObject; private _dragHelper; private static lastHovered; private _draggingRigidbodies; private _potentialDragStartEvt; private _dragHandlers; private _totalMovement; /** A marker is attached to components that are currently interacted with, to e.g. prevent them from being deleted. */ private _marker; private _isDragging; private _didDrag; /** @internal */ awake(): void; /** @internal */ start(): void; /** @internal */ onEnable(): void; /** @internal */ onDisable(): void; private allowEdit; /** @internal */ onPointerEnter?(evt: PointerEventData): void; /** @internal */ onPointerMove?(args: PointerEventData): void; /** @internal */ onPointerExit?(evt: PointerEventData): void; /** @internal */ onPointerDown(args: PointerEventData): void; /** @internal */ onPointerUp(args: PointerEventData): void; /** @internal */ update(): void; /** Called when the first pointer starts dragging on this object. Not called for subsequent pointers on the same object. */ private onFirstDragStart; /** Called each frame as long as any pointer is dragging this object. */ private onAnyDragUpdate; /** Called when the last pointer has been removed from this object. */ private onLastDragEnd; }