three.js 如何加载obj

r75中直接加载方法

var mesh = null;

var mtlLoader = new THREE.MTLLoader();
mtlLoader.setBaseUrl( "http://threejs.org/examples/obj/walt/" );
mtlLoader.setPath( "http://threejs.org/examples/obj/walt/" );
mtlLoader.load( 'WaltHead.mtl', function( materials ) {

  materials.preload();

  var objLoader = new THREE.OBJLoader();
  objLoader.setMaterials( materials );
  objLoader.setPath( "http://threejs.org/examples/obj/walt/" );
  objLoader.load( 'WaltHead.obj', function ( object ) {

    mesh = object;
    mesh.position.y = -50;
    scene.add( mesh );

  } );

} );

更多推荐