UNPKG

1.61 kBTypeScriptView Raw
1import { EventDispatcher } from "../core/EventDispatcher.js";
2import { Object3D } from "../core/Object3D.js";
3
4/**
5 * Abstract base class for controls.
6 */
7declare abstract class Controls<TEventMap extends {}> extends EventDispatcher<TEventMap> {
8 /**
9 * The 3D object that is managed by the controls.
10 */
11 object: Object3D;
12
13 /**
14 * The HTML element used for event listeners. If not provided via the constructor, {@link .connect} must be called
15 * after `domElement` has been set.
16 */
17 domElement: HTMLElement | null;
18
19 /**
20 * When set to `false`, the controls will not respond to user input. Default is `true`.
21 */
22 enabled: boolean;
23
24 /**
25 * Creates a new instance of {@link Controls}.
26 * @param object The object the controls should manage (usually the camera).
27 * @param domElement The HTML element used for event listeners. (optional)
28 */
29 constructor(object: Object3D, domElement?: HTMLElement | null);
30
31 /**
32 * Connects the controls to the DOM. This method has so called "side effects" since it adds the module's event
33 * listeners to the DOM.
34 */
35 connect(): void;
36
37 /**
38 * Disconnects the controls from the DOM.
39 */
40 disconnect(): void;
41
42 /**
43 * Call this method if you no longer want use to the controls. It frees all internal resources and removes all event
44 * listeners.
45 */
46 dispose(): void;
47
48 /**
49 * Controls should implement this method if they have to update their internal state per simulation step.
50 */
51 update(delta: number): void;
52}
53
54export { Controls };