JavaScript events for custom objects

// 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();

Hierarchy (view full)

Constructors

Properties

time: number
0
timeScale: number
1.0

Methods

  • Parameters

    • timeInSeconds: number

    Returns AnimationMixer

  • Parameters

    Returns void

  • Parameters

    • deltaTime: number

    Returns AnimationMixer