如何在three.js中使用多个纹理objLoader,mtlLoader?

时间:2018-03-02 07:10:02

标签: javascript three.js objloader

我能够看到对象但不能处理多个素材纹理图像。它是可见的黑色。我的代码中缺少什么?

  case 'plant':   
  var mtlLoader = new THREE.MTLLoader();
  mtlLoader.setPath('models/LivingRoom/Sample1/');
  mtlLoader.load( '3dbts103601T.mtl', function( materials ) {
  materials.preload();  

  var loader = new THREE.OBJLoader();
  loader.setPath('models/LivingRoom/Sample1/');   
  loader.load('3dbts103601T.obj', function (object) {

    var geometry = object.children[ 0 ].geometry;   
    var materials = []; 
    var mat1=new THREE.MeshBasicMaterial( { map : THREE.ImageUtils.loadTexture('models/LivingRoom/Sample1/3dbts103601T1.jpg')});
    var mat2=new THREE.MeshBasicMaterial({ map : THREE.ImageUtils.loadTexture('models/LivingRoom/Sample1/3dbts103601T2.jpg')});

    materials.push(mat1);
    materials.push(mat2);
    Mesh = THREE.SceneUtils.createMultiMaterialObject(geometry,materials);    

       object.traverse(function (child) {
        if (child instanceof THREE.Mesh) {
                child.materials = materials;

        }
        });
        scene1.add(object);
  });
  });   
  break;

0 个答案:

没有答案