Enables objects to be interactively grabbed and manipulated in a virtual environment.

The Grabbable class extends the basic functionality provided by the Interactable component to allow objects to be picked up, held, and potentially thrown by the user. It facilitates the creation of immersive and interactive experiences by providing an intuitive interface for object manipulation within a 3D scene.

Hierarchy

  • Component
    • Grabbable

Properties

canThrow: boolean = true

Whether the object can be thrown with physics or not.

When the interactor releases this grabbable, it will be thrown based on the velocity the interactor had.

distanceHandle: number = 0

The index of the handle to use when distance-grabbed.

Use 0 for handle and 1 for handleSecondary.

distanceMarker: null | Object3D = null

The distance marker to use when distance-grabbed.

grabPoints: GrabPoint[] = []

Public Attributes

handleObjects: Object3D[] = []

List of objects to use as grab points.

Note

If no object is provided, the grabbable is treated as its own grab point.

Note

Objects with no GrabPoint component will have a default one created.

interactorVisualState: InteractorVisualState = InteractorVisualState.None

Visual state to apply to the interactor once interaction occurs.

Note

Behavior overriden by GrabPoint.interactorVisualState if set.

onGrabEnd: Emitter<[Grabbable]> = ...

Notifies once this object is released.

Note

The notification only occurs when both grip point are free.

onGrabPointRelease: Emitter<[Grabbable, GrabPoint]> = ...

Notifies once a grab point is released.

onGrabPointSelect: Emitter<[Grabbable, GrabPoint]> = ...

Notifies once a grab point is selected for interaction.

onGrabStart: Emitter<[Grabbable]> = ...

Notifies once this object is grabbed.

Note

The notification only occurs when first grabbed.

pivotAxis: PivotAxis = PivotAxis.Y

Pivot axis used when transformType is set to GrabRotationType.AroundPivot

releaseDistance: number = 0.25

Max distance to automatically stop grabbing.

Note

Set a negative value to disable.

secondaryPivot: null | Object3D = null
secondaryPivotAxis: PivotAxis = PivotAxis.Y

Pivot axis used when transformType is set to GrabRotationType.AroundPivot

throwAngularIntensity: number = 1.0

Linear multiplier for the throwing angular speed.

By default, throws at the controller speed.

throwLinearIntensity: number = 1.0

Linear multiplier for the throwing speed.

By default, throws at the controller speed.

transformType: GrabTransformType = GrabTransformType.Hand
useControllerVelocityData: boolean = true

If true, the grabbable will be updated based on the controller velocity data, if available.

When false, the linear and angular velocities will be emulated based on the grabbable previous orientation and position.

For more information, have a look at:

TypeName: string = 'grabbable'

Accessors

  • get primaryGrab(): null | GrabData
  • true if the primary handle is grabbed, the object pointer by handle.

    Returns null | GrabData

  • get secondaryGrab(): null | GrabData
  • true if the secondary handle is grabbed, the object pointer by handleSecondary.

    Returns null | GrabData

Methods

  • Programmatically grab an interactable.

    Parameters

    • interactor: Interactor

      The interactor issuing the interaction.

    • handleId: number

    Returns void

    Remarks

    The interactable must be one of Grabbable.handle or Grabbable.handleSecondary.

    This method is useful for grab emulation for non-VR applications. In general, you will not call this method but rather rely on collision checks between the Interactor and the Interactable.

  • Programmatically release an interactable.

    Parameters

    • interactor: Interactor

      The interactor issuing the interaction.

    Returns void

    Remarks

    The interactable must be one of Grabbable.handle or Grabbable.handleSecondary.

    This method is useful for grab emulation for non-VR applications. In general, you will not call this method but rather rely on collision checks between the Interactor and the Interactable.