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

  • Parameters

    • Optional width: number

      The width of the render target.

    • Optional height: number

      The height of the render target.

    • Optional count: number

      The number of render targets.

    • Optional options: 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

Default

true
depthTexture: DepthTexture

Default

null
height: number
isRenderTarget: true
isWebGLMultipleRenderTargets: true
isWebGLRenderTarget: true
samples: number

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

Default

0
scissor: Vector4
scissorTest: boolean

Default

false
stencilBuffer: boolean

Default

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
    • Optional depth: number

    Returns void