Three.js CSG如何改变结果的材质和颜色?

时间:2016-05-02 13:49:21

标签: javascript three.js threecsg

我想在这个特定的对象上得到MeshLambertMaterial'结果'我在制作两个网格之后得到的结果:

var lathe = new THREE.Mesh(latheGeometry);
var cube_bsp = new ThreeBSP( lathe );

var box = new THREE.BoxGeometry( 2,30,3);

var sub = new THREE.Mesh( box );
sub.position = new THREE.Vector3(0,0,19);
var substract_bsp  = new ThreeBSP( sub );
var subtract_bsp  = cube_bsp.union( substract_bsp );

var result = subtract_bsp.toMesh(); 
    result.rotation.x = Math.PI * -0.5;
    scene.add(result);

这里我有一个盒子和一个latheGeometry。在结合之后,我得到随机的纯色丑陋对象。相反,我应该得到LambertMaterial白色物体。

图片:http://imgur.com/a/nbSq1

1 个答案:

答案 0 :(得分:0)

您可以在致电ThreeBSP.toMesh()时使用该材料:

subtract_bsp.toMesh( new THREE.MeshLambertMaterial( {color:0xFFFFFF} ) );

或在生成的网格上创建之后:

result.material = new THREE.MeshLambertMaterial( {color:0xFFFFFF} ) );