Options
All
  • Public
  • Public/Protected
  • All
Menu

Class 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

  • Creates a pointer drag behavior that can be attached to a mesh

    Parameters

    • Optional options: { dragAxis?: Vector3; dragPlaneNormal?: Vector3 }

      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

attachedNodeSearch playground for attachedNode

attachedNode: AbstractMesh

Abstract mesh the behavior is set on

currentDraggingPointerIdSearch playground for currentDraggingPointerId

currentDraggingPointerId: number

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

detachCameraControlsSearch playground for detachCameraControls

detachCameraControls: boolean

If camera controls should be detached during the drag

dragButtonsSearch playground for dragButtons

dragButtons: number[]

Butttons that can be used to initiate a drag

dragDeltaRatioSearch playground for dragDeltaRatio

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)

draggingSearch playground for dragging

dragging: boolean

If the behavior is currently in a dragging state

lastDragPositionSearch playground for lastDragPosition

lastDragPosition: Vector3

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

maxDragAngleSearch playground for maxDragAngle

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)

moveAttachedSearch playground for moveAttached

moveAttached: boolean

If the attached mesh should be moved when dragged

onDragEndObservableSearch playground for onDragEndObservable

onDragEndObservable: Observable<{ dragPlanePoint: Vector3; pointerId: number }>

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

onDragObservableSearch playground for onDragObservable

onDragObservable: Observable<{ delta: Vector3; dragDistance: number; dragPlaneNormal: Vector3; dragPlanePoint: Vector3; pointerId: number }>

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

onDragStartObservableSearch playground for onDragStartObservable

onDragStartObservable: Observable<{ dragPlanePoint: Vector3; pointerId: number }>

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

onEnabledObservableSearch playground for onEnabledObservable

onEnabledObservable: Observable<boolean>

Fires each time behavior enabled state changes

startAndReleaseDragOnPointerEventsSearch playground for startAndReleaseDragOnPointerEvents

startAndReleaseDragOnPointerEvents: boolean

If pointer events should start and release the drag (Default: true)

updateDragPlaneSearch playground for updateDragPlane

updateDragPlane: boolean

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

useObjectOrientationForDraggingSearch playground for useObjectOrientationForDragging

useObjectOrientationForDragging: boolean

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

validateDragSearch playground for validateDrag

validateDrag: (targetPosition: Vector3) => boolean

Predicate to determine if it is valid to move the object to a new position when it is moved

param

Type declaration

    • (targetPosition: Vector3): boolean
    • Parameters

      Returns boolean

Accessors

currentDraggingPointerID

  • get currentDraggingPointerID(): number
  • set currentDraggingPointerID(currentDraggingPointerID: number): any
  • Get or set the currentDraggingPointerId

    deprecated

    Please use currentDraggingPointerId instead

    Returns number

  • Get or set the currentDraggingPointerId

    deprecated

    Please use currentDraggingPointerId instead

    Parameters

    • currentDraggingPointerID: number

    Returns any

enabled

  • get enabled(): boolean
  • set enabled(value: boolean): any
  • If the drag behavior will react to drag events (Default: true)

    Returns boolean

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

    Parameters

    • value: boolean

    Returns any

name

  • get name(): string
  • The name of the behavior

    Returns string

options

  • get options(): { dragAxis?: Vector3; dragPlaneNormal?: Vector3 }
  • set options(options: { dragAxis?: Vector3; dragPlaneNormal?: Vector3 }): any
  • Gets the options used by the behavior

    Returns { dragAxis?: Vector3; dragPlaneNormal?: Vector3 }

  • Sets the options used by the behavior

    Parameters

    Returns any

Methods

attachSearch playground for attach

  • Attaches the drag behavior the passed in mesh

    Parameters

    Returns void

detachSearch playground for detach

  • detach(): void
  • Detaches the behavior from the mesh

    Returns void

initSearch playground for init

  • init(): void
  • Initializes the behavior

    Returns void

releaseDragSearch playground for releaseDrag

  • releaseDrag(): void
  • Force release the drag action by code.

    Returns void

startDragSearch playground for startDrag

  • 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

Legend

  • Constructor
  • Property
  • Method
  • Accessor
  • Property
  • Method
  • Inherited property
  • Inherited method
  • Static property
  • Static method