我一直在尝试使用ObjLoader.js将.obj模型加载到'THREE'中,但是我没有看到模型,我得到了两对错误说:
Uncaught TypeError:Object [object Object]没有方法'dispatchEvent'
......第24行两次,另一对来自ObjLoader.js中的第32行:
第24行:scope.dispatchEvent({type:'load',content:hierarchy});
第32行:scope.dispatchEvent({type:'progress',loaded:event.loaded,total:event.total});
以下是我用来加载模型的代码:
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 )
} );
任何想法我做错了什么?欢呼声。