这是我的代码:
var materialNormal = new THREE.MeshNormalMaterial();
var cubeGeometry = new THREE.CubeGeometry( 20, 500, 1000, 1, 1, 1 );
var cubeMesh = new THREE.Mesh( cubeGeometry );
cubeMesh.position.set(-50, 60, 0);
//scene.add(cubeMesh); //Meu
var cubeBSP = new ThreeBSP( cubeMesh );
var cubeGeometry = new THREE.CubeGeometry( 90, 90, 90, 1, 1, 1 );
var mat = new THREE.MeshBasicMaterial({color:0xffffff, shading: THREE.FlatShading, overdraw:0.5});
var cube3Mesh = new THREE.Mesh( cubeGeometry, mat );
cube3Mesh.position.set(-50, 60, 0);
//scene.add(cubeMesh); //Meu
var cubeOutroBSP = new ThreeBSP( cube3Mesh );
// Example #1 - Cube subtract
var newBSP = cubeBSP.subtract(cubeOutroBSP);
var newMesh = newBSP.toMesh(materialNormal);
newMesh.position.set(-180, 60, 0);
scene.add( newMesh );
如何为减法生成的对象添加纹理?
答案 0 :(得分:0)
three.CSG
返回的网格类似于默认three.js
mesh
,您可以在其中应用带纹理的材质。
在您的示例中,这将是newMesh
,所以:
var texture = THREE.ImageUtils.loadTexture('yourtexture.jpg');
var material = new THREE.MeshPhongMaterial( { map: texture } );
//...
var newMesh = newBSP.toMesh( material );
newMesh.position.set(-180, 60, 0);
scene.add( newMesh );