Combinations
It is now time to introduce a way to combine shapes together, the main operations of constructive geometry, also known as the boolean operations.
We will play with two shapes, a box and a cylinder.
Pasting shapes together
This is what we call the fuse operation:
const main = ({ sketchCircle, sketchRectangle }) => {
const cylinder = sketchCircle(20).extrude(50);
const box = sketchRectangle(60, 90).extrude(25);
return box.fuse(cylinder);
};
Cutting one shape with another
This is what we call the cut operation:
const main = ({ sketchCircle, sketchRectangle }) => {
const cylinder = sketchCircle(20).extrude(50);
const box = sketchRectangle(60, 90).extrude(25);
return box.cut(cylinder);
};
Intersecting two shapes
For the intersection we will intersect the cylinder with itself you create a fun shape:
const main = ({ sketchCircle }) => {
const cylinder = sketchCircle(20).extrude(40);
const sideCylinder = cylinder.clone().rotate(90, [0, 0, 20], [1, 0, 0]);
return sideCylinder.intersect(cylinder);
};