0

I've been trying to load an .obj model into 'THREE' using ObjLoader.js, but I'm not seeing the model and I'm getting 2 pairs of errors saying:

Uncaught TypeError: Object [object Object] has no method 'dispatchEvent'

...twice from line 24 and the other pair from line 32 in ObjLoader.js:

line 24: scope.dispatchEvent( { type: 'load', content: hierarchy } );

line 32: scope.dispatchEvent( { type: 'progress', loaded: event.loaded, total: event.total } );

Here's the code I'm using to load the model:

var manager = new THREE.LoadingManager();
manager.onProgress = function ( item, loaded, total ) {
    console.log( item, loaded, total );
};

var loader = new THREE.OBJLoader( manager );
loader.load( 'models/shipfighter.obj', function ( object ) {
    var shipTexture = new THREE.MeshLambertMaterial({ color: 0xff0000 });
    object.traverse( function ( child ) {

        if ( child instanceof THREE.Mesh ) {

            child.material.map = shipTexture;
            child.material.needsUpdate = true;

        }

    } );

    object.position.y = 20;
    scene.add( object )

} );

Any ideas what I'm doing wrong? Cheers.

moosefetcher
  • 1,841
  • 2
  • 23
  • 39

0 Answers0