2017-04-14 73 views
0

如何設置obj模型,在threejs中渲染雙面(r.84)?ThreeJS中的雙面,obj模型

這裏是OBJ裝載機代碼:

THREE.Loader.Handlers.add(/\.dds$/i, new THREE.DDSLoader()); 
    var mtlLoader = new THREE.MTLLoader(); 
    mtlLoader.setPath('house3/'); 
    mtlLoader.load('House.mtl', function(materials) { 
     materials.preload(); 
     var objLoader = new THREE.OBJLoader(); 
     objLoader.setMaterials(materials); 
     objLoader.setPath('house3/'); 
     objLoader.load('House.obj', function (object) { 
      scene.add(object); 
     }); 
    }); 
+0

[three.js如何製作雙面對象]可能的重複(http://stackoverflow.com/questions/16027131/three-js-how-to-make-double-side d-object) – Sam0

+0

THREE.DoubleSide是你的朋友。在你的OBJ加載的情況下,看看類似的問題[here](http://stackoverflow.com/questions/16027131/three-js-how-to-make-double-sided-object) – AquaVitae

+0

我試過解決方案,但它沒有奏效。任何暗示? – robcaa

回答

0

三JS修訂84沒有OBJMTLLoader: https://github.com/mrdoob/three.js/issues/8105

linked溶液用一個小的修改工作:

THREE.Loader.Handlers.add(/\.dds$/i, new THREE.DDSLoader()); 
    var mtlLoader = new THREE.MTLLoader(); 
    mtlLoader.setPath('house3/'); 
    mtlLoader.load('House.mtl', function(materials) { 
     materials.preload(); 
     var objLoader = new THREE.OBJLoader(); 
     objLoader.setMaterials(materials); 
     objLoader.setPath('house3/'); 
     objLoader.load('House.obj', function (object) { 
      object.traverse(function(node) { 
       if(node.material) { 
        node.material.side = THREE.DoubleSide; 
       } 
      }); 
      scene.add(object); 
     }); 
    });