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

Three.js CSG How to change result's material and color?

我想在这个特定对象上获取 MeshLambertMaterial 'result',这是我在合并两个网格后得到的:

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

您可以在调用 ThreeBSP.toMesh() 时应用 material:

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

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

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