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

时间:2022-02-21 05:00:15

I'd like to get MeshLambertMaterial on this particular object 'result' which I get after making union of two meshes:

我想在这个特定的对象'结果'上得到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);

Here I have a box and a latheGeometry. After union is done I get random plain color ugly object. Instead I should get LambertMaterial white color object.

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

Images: http://imgur.com/a/nbSq1

1 个解决方案

#1


0  

You can apply the material when calling ThreeBSP.toMesh():

您可以在调用ThreeBSP.toMesh()时应用该材料:

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

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

or after the creation on the resulting mesh:

或者在结果网格上创建之后:

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

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

#1


0  

You can apply the material when calling ThreeBSP.toMesh():

您可以在调用ThreeBSP.toMesh()时应用该材料:

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

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

or after the creation on the resulting mesh:

或者在结果网格上创建之后:

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

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