JavaScript events for custom objects

Example

// Adding events to a custom object
class Car extends EventDispatcher {
start() {
this.dispatchEvent( { type: 'start', message: 'vroom vroom!' } );
}
};
// Using events with the custom object
const car = new Car();
car.addEventListener( 'start', ( event ) => {
alert( event.message );
} );
car.start();

See

Hierarchy (view full)

Constructors

Properties

time: number

Default

0
timeScale: number

Default

1.0

Methods

  • Parameters

    • timeInSeconds: number

    Returns AnimationMixer

  • Parameters

    Returns void

  • Parameters

    • deltaTime: number

    Returns AnimationMixer