Class ObjectLoader

JavaScript events for custom objects

Example

var Car = function () {

    EventDispatcher.call( this );
    this.start = function () {

        this.dispatchEvent( { type: 'start', message: 'vroom vroom!' } );

    };

};

var car = new Car();
car.addEventListener( 'start', function ( event ) {

    alert( event.message );

} );
car.start();
source

src/core/EventDispatcher.js

Hierarchy

Index

Constructor methods

Methods

Constructor methods

constructor(manager?: LoadingManager): ObjectLoader

Parameters

Returns

ObjectLoader

Methods

public addEventListener(type: string, listener: (event: any) => void)

Adds a listener to an event type.

Parameters

  • type: string

    The type of the listener that gets removed.

  • listener: (event: any) => void

    The listener function that gets removed.

public dispatchEvent(event: { type: string; target: any; })

Fire an event type.

Parameters

  • event: { type: string; target: any; }

public hasEventListener(type: string, listener: (event: any) => void)

Adds a listener to an event type.

Parameters

  • type: string

    The type of the listener that gets removed.

  • listener: (event: any) => void

    The listener function that gets removed.

public load(url: string, onLoad: (object: THREE.Object3D) => void)

Parameters

  • url: string
  • onLoad: (object: THREE.Object3D) => void

public parse(json: any): T

Parameters

  • json: any

Returns

T

public parseGeometries(json: any): Array<any>

Parameters

  • json: any

Returns

Array<any>

public parseMaterials(json: any): Material[]

Parameters

  • json: any

Returns

Material[]

public parseObject(data: any, geometries: Array<any>, materials: Material[]): T

Parameters

  • data: any
  • geometries: Array<any>
  • materials: Material[]

Returns

T

public removeEventListener(type: string, listener: (event: any) => void)

Removes a listener from an event type.

Parameters

  • type: string

    The type of the listener that gets removed.

  • listener: (event: any) => void

    The listener function that gets removed.

public setCrossOrigin(crossOrigin: string)

Parameters

  • crossOrigin: string