New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to subtract geometry ? #866
Comments
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: link removed |
@mrdoob Just a psa that link takes you to some other website now. |
I think nowadays you can use https://github.com/gkjohnson/three-bvh-csg. |
Why? |
I've deleted the link from @mrdoob comment. Thanks for the heads-up. |
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
The text was updated successfully, but these errors were encountered: