I'm new to working with three.js and I have a project where I need to create a "room" with doors and windows. It seems like a simple task, but all the answers I've found so far are not up-to-date.
Similar questions can be found here: - subtracting-geometry-in-three-js - is-it-possible-to-cut-parts-of-the-shape-geometry-away-in-three-js
In my specific case, I have a large box and I want to subtract a smaller one. You can view an example on JSFIDDLE here:
https://i.sstatic.net/Todln.png
var material = new THREE.MeshBasicMaterial({color: 0xffff00});
var faceMaterial_Y = new THREE.MeshLambertMaterial( { color: 0x0087E6 } );
var geometry_Y = new THREE.BoxBufferGeometry( 1.5, 1.5, 0.99 );
var cube_Y = new THREE.Mesh( geometry_Y, faceMaterial_Y);
scene.add(cube_Y);
var geometry_A = new THREE.BoxBufferGeometry( 0.7, 0.7, 0.7 );
material = new THREE.MeshBasicMaterial( {color: 0x00ff00} );
var faceMaterial_A = new THREE.MeshLambertMaterial( { color: 0x00ff00 } );
var cubeA = new THREE.Mesh( geometry_A, material );
cubeA.position.set( 0.5, 0.5, 0 );
// HOW TO SUBTRACT cube_Y - cubeA?
//create a group and add the three cubes
var group = new THREE.Group();
group.add( cubeA );
group.add( cube_Y );
scene.add( group );
If anyone could provide some guidance, it would be greatly appreciated. Thank you!