[page:EventDispatcher] →

# [name]

This class can be used to provide a drag'n'drop interaction.

## Import

[name] is an add-on, and must be imported explicitly. See [link:#manual/introduction/Installation Installation / Addons].

`import { DragControls } from 'three/addons/controls/DragControls.js';`

## Code Example

`const controls = new DragControls( objects, camera, renderer.domElement ); // add event listener to highlight dragged objects controls.addEventListener( 'dragstart', function ( event ) { event.object.material.emissive.set( 0xaaaaaa ); } ); controls.addEventListener( 'dragend', function ( event ) { event.object.material.emissive.set( 0x000000 ); } );`

## Examples

[example:misc_controls_drag misc / controls / drag ]

## Constructor

### [name]( [param:Array objects], [param:Camera camera], [param:HTMLDOMElement domElement] )

[page:Array objects]: An array of draggable 3D objects.

[page:Camera camera]: The camera of the rendered scene.

[page:HTMLDOMElement domElement]: The HTML element used for event listeners.

Creates a new instance of [name].

## Events

### dragstart

Fires when the user starts to drag a 3D object.

### drag

Fires when the user drags a 3D object.

### dragend

Fires when the user has finished dragging a 3D object.

### hoveron

Fires when the pointer is moved onto a 3D object, or onto one of its children.

### hoveroff

Fires when the pointer is moved out of a 3D object.

## Properties

### [property:Boolean enabled]

Whether or not the controls are enabled.

### [property:Boolean recursive]

Whether children of draggable objects can be dragged independently from their parent. Default is `true`.

### [property:Boolean transformGroup]

This option only works if the [page:DragControls.objects] array contains a single draggable group object. If set to `true`, [name] does not transform individual objects but the entire group. Default is `false`.

### [property:String mode]

The current transformation mode. Possible values are `translate`, and `rotate`. Default is `translate`.

### [property:Float rotateSpeed]

The speed at which the object will rotate when dragged in `rotate` mode. The higher the number the faster the rotation. Default is `1`.

## Methods

See the base [page:EventDispatcher] class for common methods.

### [method:undefined activate] ()

Adds the event listeners of the controls.

### [method:undefined deactivate] ()

Removes the event listeners of the controls.

### [method:undefined dispose] ()

Should be called if the controls is no longer required.

### [method:Array getObjects] ()

Returns the array of draggable objects.

### [method:Raycaster getRaycaster] ()

Returns the internal [page:Raycaster] instance that is used for intersection tests.

### [method:undefined setObjects] ( [param:Array objects] )

Sets an array of draggable objects by overwriting the existing one.

## Source

[link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/controls/DragControls.js examples/jsm/controls/DragControls.js]