npm package: @gov.nasa.jpl.honeycomb/interaction-manager
Description: Class to handle and resolve user click and drag interactions in three.js
Latest version: 0.0.6

# interaction-manager

Class to handle and resolve user click and drag interactions.

<!--{package-dependencies ./package.json}-->

# Use

```js
import { WebGLRenderer } from 'three';
import { InteractionManager } from '@gov.nasa.jpl.honeycomb/interaction-manager';

const renderer = new WebGLRenderer();
const interactionManager = new InteractionManager( renderer );

// TODO: listen to events, lock interctions, etc
```

# API

<!-- START_AUTOGENERATED_DOCS -->
## InteractionManagerEvent

### type<a name="InteractionManagerEvent#type"></a>

```js
type : String
```


The event name.


### target<a name="InteractionManagerEvent#target"></a>

```js
target : Object3D | null
```


The current target the event is being dispatched on.


### originalTarget<a name="InteractionManagerEvent#originalTarget"></a>

```js
originalTarget : Object3D
```


The target that the raycast originally hit and event dispatched on.


### bubbling<a name="InteractionManagerEvent#bubbling"></a>

```js
bubbling : Boolean
```


Whether the event bubbles.


### interactionaManager<a name="InteractionManagerEvent#interactionaManager"></a>

```js
interactionaManager : InteractionManager
```


Reference to the interactionManager that dispatched the event.


### stopPropagation<a name="InteractionManagerEvent#stopPropagation"></a>

```js
stopPropagation : Function
```


Stop the bubbling of the event up the tree.


### hit<a name="InteractionManagerEvent#hit"></a>

```js
hit : Object
```


The raycast hit information returned from three.js' Raycaster


### mouseEvent<a name="InteractionManagerEvent#mouseEvent"></a>

```js
mouseEvent : Event
```


The original mouse event that trigged this event.


## InteractionManager

Class for managing and dispatching mouse events in a three.js scene. Events are dispatched up
the objects parents if relevant until "event.stopPropagation" is called. If an event is not
handled by any handler as the event bubbles then it is dispatched on the InteractionManager itself.

_extends EventDispatcher_

### Events

`mouse-enter`

Fired whenever the pointer moves over an object.

`mouse-move`

Fired whenever the pointer moves on an object.

`mouse-exit`

Fired whenever the points leaves an object.

`mouse-up`

Fired whenever a mouse up event occurs.

`mouse-down`

Fired whenever a mouse down event occurs.

`click`

Fired whenever the pointer is clicked.

`key-down`

Fired whenever a keydown event occurs.

`locked`

Fired whenever the InteractionManager is locked using {@link #InteractionManager#lock lock}.

`unlocked`

Fired whenever the InteractionManager is unlocked using {@link #InteractionManager#unlock unlock}.

`event-handled`

Fired whenever stopPropagation is called to denote the event has been handled by a handler.

### enabled<a name="InteractionManager#enabled"></a>

```js
enabled : Boolean = true
```


Whether the manager is watching and dispatching events.


### camera<a name="InteractionManager#camera"></a>

```js
camera : Camera = null
```


The camera used to perform raycasts


### objects<a name="InteractionManager#objects"></a>

```js
objects : Array<Object3D> = null
```


The list of objects to raycast against when mouse events are
dispatched. This must be populated manually.


### constructor

```js
constructor( renderer : WebGLRenderer ) : void
```

Takes the renderer with associated canvas that interaction event should
be listed for on.

### getLock<a name="InteractionManager#getLock"></a>

```js
getLock(  ) : any
```

Returns the object currently tracked lock on the manager indicating that a specific object
has control over interactions.

### lock<a name="InteractionManager#lock"></a>

```js
lock( key : any ) : Boolean
```

Sets the interaction manager lock and dispatches a `locked` event if a lock was not already set.
Returns `true` if the lock was set, false otherwise.

### unlock<a name="InteractionManager#unlock"></a>

```js
unlock( key : any ) : Boolean
```

Unlocks the interaction manager if the given object is currently being used to lock
interactions. Dispatches an `unlocked` event if the lock was successfully unlocked.
Returns true if the manager was unlocked, false otherwise.

### handleEvent<a name="InteractionManager#handleEvent"></a>

```js
handleEvent(  ) : void
```

Triggers that an event was handed and prevents it from bubbling up
the object tree any further. Dispatches and `event-handled` event.

### getIntersection<a name="InteractionManager#getIntersection"></a>

```js
getIntersection( objects : Array<Object3D>, recursive : Boolean = true ) : Object3D
```

Returns the first object that was hit by the ray from the given list of
object using the last mouse position.

### getIntersections<a name="InteractionManager#getIntersections"></a>

```js
getIntersections( objects : Array<Object3D>, recursive : Boolean = true ) : Object3D
```

Returns the hit results that were found by the ray from the given list of
object using the last mouse position.


<!-- END_AUTOGENERATED_DOCS -->