Skip to main content Link Menu Expand (external link) Copy Copied

listen link

The FreeformControls.ControlsManager instance allows listening to the following events on controls:

  • DRAG_START: Triggered once when the controls become active.
import { EVENTS } from 'three-freeform-controls';
// ...
controlsManager.listen(EVENTS.DRAG_START, (object, handleName) => {
  // This place can be used to disable the scene controls like OrbitControls
  orbitControls.enabled = false;
});
  • DRAG_STOP: Triggered once when the controls become inactive.
import { EVENTS } from 'three-freeform-controls';
// ...
controlsManager.listen(EVENTS.DRAG_STOP, (object, handleName) => {
  // This place can be used to re-enable the scene controls like OrbitControls
  orbitControls.enabled = true;
});
  • DRAG: Triggered on each drag event on the controls object.
import { EVENTS } from 'three-freeform-controls';
// ...
controlsManager.listen(EVENTS.DRAG, (object, handleName) => {
  // This place can be used to ingest information about the object
  // to which the controls were anchored
  const positionOfObjectToWhichControlsWereAnchored = object.position;
  websocket.send(positionOfObjectToWhichControlsWereAnchored);
});

The signature of the callback is:

callback: (object: THREE.Object3d, handleName: string) => void

Here the object is the object to which the controls were anchored to and handleName is the name of the handle that was involved in the interaction - it can be one of the default names or the corresponding string for custom handles.

removeListen link

An attached listener function can be removed like this:

controlsManager.removeListen(EVENTS.DRAG, listenerFn);

An example illustrating these events can be accessed below.

View example

Next section: Partial Controls