# Constructive Solid Geometry CSG nodes create 3D meshes by combining primitive shapes with boolean operations. ## Primitives ```python from simvx.core import CSGBox3D, CSGSphere3D, CSGCylinder3D, Vec3 box = CSGBox3D(size=Vec3(2, 1, 1)) sphere = CSGSphere3D(radius=1.0, rings=16, sectors=16) cylinder = CSGCylinder3D(radius=0.5, height=2.0, segments=16) ``` | Node | Properties | |------|-----------| | `CSGBox3D` | `size` (Vec3, default 1,1,1) | | `CSGSphere3D` | `radius` (1.0), `rings` (16), `sectors` (16) | | `CSGCylinder3D` | `radius` (0.5), `height` (1.0), `segments` (16) | ## Boolean Operations `CSGCombiner3D` combines child CSG shapes using their `operation` property: ```python from simvx.core import CSGCombiner3D, CSGBox3D, CSGSphere3D, CSGOperation combiner = CSGCombiner3D() box = CSGBox3D(size=(2, 2, 2)) combiner.add_child(box) hole = CSGSphere3D(radius=1.2) hole.operation = CSGOperation.SUBTRACT combiner.add_child(hole) # Get the resulting mesh mesh = combiner.get_mesh() ``` | Operation | Result | |-----------|--------| | `CSGOperation.UNION` | Merge shapes together (default) | | `CSGOperation.SUBTRACT` | Cut the child shape from the first | | `CSGOperation.INTERSECT` | Keep only the overlapping region | ## Rendering CSG Attach the resulting mesh to a `MeshInstance3D` for rendering: ```python from simvx.core import MeshInstance3D, Material mesh_node = MeshInstance3D() mesh_node.mesh = combiner.get_mesh() mesh_node.material = Material(colour=(0.8, 0.3, 0.1)) self.add_child(mesh_node) ``` ## API Reference See {py:mod}`simvx.core.csg` for the complete CSG API.