Is there any way to subtract geometries?
I have an outline of a building and the outline of an inner courtyard. I've extruded the outline of the building by the height to create a solid for the building but I now need to remove he courtyard form the middle.
Thanks
I've worked out the answer - not sure if it's the best way but it works.
I add the outer geometry clockwise and then the bits to remove anti-clockwise to a path before converting to a shape to extrude.
var path = new THREE.Path();
// outer clockwise
path.moveTo(-10, 10);
path.lineTo(10, 10);
path.lineTo(10, -10);
path.lineTo(-10, -10);
path.lineTo(-10, 10);
// inner anti-clockwise
path.moveTo(-5, 5);
path.lineTo(-5, -5);
path.lineTo(-2, -5);
path.lineTo(-2, 5);
path.lineTo(-5, 5);
// inner anti-clockwise
path.moveTo(2, 5);
path.lineTo(2, -5);
path.lineTo(5, -5);
path.lineTo(5, 5);
path.lineTo(2, 5);
var height = 20;
var shapes = path.toShapes();
var solid = new THREE.ExtrudeGeometry(shapes, { amount: height, bevelEnabled: false });
var mesh = new THREE.Mesh(solid, materials['building']);
mesh.position.y = height;
mesh.rotation.x = 90 * Math.PI * 2 / 360;
scene.add(mesh);
You could also use this:
http://learningthreejs.com/blog/2011/12/10/constructive-solid-geometry-with-csg-js/
Most helpful comment
You could also use this:
http://learningthreejs.com/blog/2011/12/10/constructive-solid-geometry-with-csg-js/