@gov.nasa.jpl.honeycomb/interaction-manager
v0.0.6
Published
Class to handle and resolve user click and drag interactions in three.js
Downloads
3
Readme
interaction-manager
Class to handle and resolve user click and drag interactions.
Use
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, etcAPI
InteractionManagerEvent
type
type : StringThe event name.
target
target : Object3D | nullThe current target the event is being dispatched on.
originalTarget
originalTarget : Object3DThe target that the raycast originally hit and event dispatched on.
bubbling
bubbling : BooleanWhether the event bubbles.
interactionaManager
interactionaManager : InteractionManagerReference to the interactionManager that dispatched the event.
stopPropagation
stopPropagation : FunctionStop the bubbling of the event up the tree.
hit
hit : ObjectThe raycast hit information returned from three.js' Raycaster
mouseEvent
mouseEvent : EventThe 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
enabled : Boolean = trueWhether the manager is watching and dispatching events.
camera
camera : Camera = nullThe camera used to perform raycasts
objects
objects : Array<Object3D> = nullThe list of objects to raycast against when mouse events are dispatched. This must be populated manually.
constructor
constructor( renderer : WebGLRenderer ) : voidTakes the renderer with associated canvas that interaction event should be listed for on.
getLock
getLock( ) : anyReturns the object currently tracked lock on the manager indicating that a specific object has control over interactions.
lock
lock( key : any ) : BooleanSets 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
unlock( key : any ) : BooleanUnlocks 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
handleEvent( ) : voidTriggers that an event was handed and prevents it from bubbling up
the object tree any further. Dispatches and event-handled event.
getIntersection
getIntersection( objects : Array<Object3D>, recursive : Boolean = true ) : Object3DReturns the first object that was hit by the ray from the given list of object using the last mouse position.
getIntersections
getIntersections( objects : Array<Object3D>, recursive : Boolean = true ) : Object3DReturns the hit results that were found by the ray from the given list of object using the last mouse position.
