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

  • Parameters

    • Optionalwidth: number

      The width of the render target.

    • Optionalheight: number

      The height of the render target.

    • Optionalcount: number

      The number of render targets.

    • Optionaloptions: WebGLRenderTargetOptions

      object that holds texture parameters for an auto-generated target texture and depthBuffer/stencilBuffer booleans. For an explanation of the texture parameters see Texture.

    Returns WebGLMultipleRenderTargets

Properties

depth: number
depthBuffer: boolean
true
depthTexture: DepthTexture
null
height: number
isRenderTarget
isWebGLMultipleRenderTargets
isWebGLRenderTarget
samples: number

Defines the count of MSAA samples. Can only be used with WebGL 2. Default is 0.

0
scissor: Vector4
scissorTest: boolean
false
stencilBuffer: boolean
true
texture: Texture[]
viewport: Vector4
width: number

Methods

  • Returns this

  • Fire an event type.

    Type Parameters

    • T extends "dispose"

    Parameters

    • event: BaseEvent<T> & {
          dispose: {};
      }[T]

      The event that gets fired.

    Returns void

  • Returns void

  • Parameters

    • width: number
    • height: number
    • Optionaldepth: number

    Returns void