// the find
evanw/csg.js
Constructive solid geometry on meshes using BSP trees in JavaScript
csg.js implements Constructive Solid Geometry — boolean mesh operations (union, subtract, intersect) using BSP trees — in a single JavaScript file. It's a reference implementation first, a production library second. Evanw wrote it to be readable, not fast.
The BSP tree approach correctly handles coplanar polygon edge cases that trip up most naive CSG implementations. The entire implementation fits in one file (~460 lines), making it genuinely auditable — you can understand exactly what's happening. The algorithm explanation in the README is actually good: it walks through the set-theory derivations for each operation rather than just showing usage. MIT licensed, no dependencies.
Abandoned since 2019 — open issues with no responses, no releases, no maintenance. BSP-tree CSG is known to be slow and numerically fragile on complex meshes; this implementation does nothing to address that. There's no TypeScript, no npm package, no module system — you're copy-pasting a script tag. For anything beyond toy examples or learning the algorithm, you'd want a maintained fork like OpenJSCAD's geometry library or a WASM-based solution.