Hi All,
I have an object and a box,I want to subtract the object from the box, when I apply one material I get the fit shape, but when I apply materials I get the fit shape but I can not set value for the material for every face of the box,
my code is
const materials = [
new MeshStandardMaterial({ color: 0xff11ff }), // Right
new MeshStandardMaterial({ color: 0xff00ff }), // Left
new MeshStandardMaterial({ color: 0x55ffff }), // Top
new MeshStandardMaterial({ color: 0xffff11 }), // Bottom
new MeshStandardMaterial({ color: 0x00ffff }), // Front
new MeshStandardMaterial({ color: 0xff00ff }), // Back
];
var plane = new BoxGeometry( Length,Height , 0.2 ).toNonIndexed();
var planeMesh = new Mesh( plane, materials);
// emptyingBox is a boxGeometry
let mesh = emptyingBox.clone();
mesh.scale.x = object.userData.W - 0.05;
mesh.scale.z = (object.userData.H - 0.05) / 4;
mesh.scale.y = 1;
let bspFront = CSG.fromMesh(mesh);
bspResult = bspResult.subtract(bspFront);
planeMesh = CSG.toMesh(
bspResult,
planeMesh.matrix,
planeMesh.material
);
scene.add( planeMesh );
Thank you.