Capítulo 307 de 859

Chapter 307: Controls

Core Idea

Abstract base class for controls.

Key Concepts

  • domElement : HTMLElement: The HTML element used for event listeners.
  • enabled : boolean: Whether the controls responds to user input or not.
  • keys : Object: This object defines the keyboard input of the controls.
  • mouseButtons : Object: This object defines what type of actions are assigned to the available mouse buttons. It depends on the control implementation what kind of…
  • object : Object3D: The object that is managed by the controls.
  • state : number: The internal state of the controls.
  • touches : Object: This object defines what type of actions are assigned to what kind of touch interaction. It depends on the control implementation what kind…

Reference Tables

Constructor

Signature
new Controls( object : Object3D, domElement : HTMLElement ) (abstract)

Properties

PropertyDescription
.domElement : HTMLElementThe HTML element used for event listeners.
.enabled : booleanWhether the controls responds to user input or not.
.keys : ObjectThis object defines the keyboard input of the controls.
.mouseButtons : ObjectThis object defines what type of actions are assigned to the available mouse buttons. It depends on the control implementation what kind of mouse buttons and actions are supported.
.object : Object3DThe object that is managed by the controls.
.state : numberThe internal state of the controls.
.touches : ObjectThis object defines what type of actions are assigned to what kind of touch interaction. It depends on the control implementation what kind of touch interaction and actions are supported.

Methods

MethodDescription
.connect( element : HTMLElement )Connects the controls to the DOM. This method has so called "side effects" since it adds the module's event listeners to the DOM.
.disconnect()Disconnects the controls from the DOM.
.dispose()Call this method if you no longer want use to the controls. It frees all internal resources and removes all event listeners.
.update( delta : number )Controls should implement this method if they have to update their internal state per simulation step.

Key Takeaways

  1. Controls extends: EventDispatcher
  2. Most relevant properties: domElement, enabled, keys, mouseButtons.
  3. Key methods: connect, disconnect, dispose, update.

Connects To