PointerDragBehavior

A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events

Hierarchy

  • PointerDragBehavior

Implements

Index

Constructors

constructor

Find examples in Playground
  • Creates a pointer drag behavior that can be attached to a mesh

    Parameters

    • Optional options: object

      The drag axis or normal of the plane that will be dragged across. If no options are specified the drag plane will always face the ray's origin (eg. camera)

    Returns PointerDragBehavior

Properties

currentDraggingPointerID

Find examples in Playground
currentDraggingPointerID: number

The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)

detachCameraControls

Find examples in Playground
detachCameraControls: boolean

If camera controls should be detached during the drag

dragDeltaRatio

Find examples in Playground
dragDeltaRatio: number

The distance towards the target drag position to move each frame. This can be useful to avoid jitter. Set this to 1 for no delay. (Default: 0.2)

dragging

Find examples in Playground
dragging: boolean

If the behavior is currently in a dragging state

enabled

Find examples in Playground
enabled: boolean

If the drag behavior will react to drag events (Default: true)

lastDragPosition

Find examples in Playground
lastDragPosition: Vector3

The last position where the pointer hit the drag plane in world space

maxDragAngle

Find examples in Playground
maxDragAngle: number

The maximum tolerated angle between the drag plane and dragging pointer rays to trigger pointer events. Set to 0 to allow any angle (default: 0)

moveAttached

Find examples in Playground
moveAttached: boolean

If the attached mesh should be moved when dragged

name

Find examples in Playground
name: string

The name of the behavior

onDragEndObservable

Find examples in Playground
onDragEndObservable: Observable<object>

Fires each time a drag ends (eg. mouse release after drag)

onDragObservable

Find examples in Playground
onDragObservable: Observable<object>

Fires each time the attached mesh is dragged with the pointer

  • delta between last drag position and current drag position in world space
  • dragDistance along the drag axis
  • dragPlaneNormal normal of the current drag plane used during the drag
  • dragPlanePoint in world space where the drag intersects the drag plane

onDragStartObservable

Find examples in Playground
onDragStartObservable: Observable<object>

Fires each time a drag begins (eg. mouse down on mesh)

updateDragPlane

Find examples in Playground
updateDragPlane: boolean

If the drag plane orientation should be updated during the dragging (Default: true)

useObjectOrienationForDragging

Find examples in Playground
useObjectOrienationForDragging: boolean

If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)

Methods

attach

Find examples in Playground
  • attach(ownerNode: Mesh): void
  • Attaches the drag behavior the passed in mesh

    Parameters

    • ownerNode: Mesh

      The mesh that will be dragged around once attached

    Returns void

detach

Find examples in Playground
  • detach(): void
  • Detaches the behavior from the mesh

    Returns void

init

Find examples in Playground
  • init(): void
  • Initializes the behavior

    Returns void

releaseDrag

Find examples in Playground
  • releaseDrag(): void
  • Force relase the drag action by code.

    Returns void

startDrag

Find examples in Playground
  • startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void
  • Simulates the start of a pointer drag event on the behavior

    Parameters

    • Optional pointerId: number

      pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)

    • Optional fromRay: Ray

      initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)

    • Optional startPickedPoint: Vector3

      picked point of the pointer to be simulated (Default: attached mesh position)

    Returns void

Generated using TypeDoc