Documentation
Kernels
The pure geometry and machining kernels of packages/core, explained from the inside with real outputs and 3D examples.
The kernels and how they depend on each other
The geometry and machining code in packages/core is a set of pure kernels: same input, same output, no I/O. Each page in this section explains one of them from the inside: what it is for, its data structures and algorithms, the real API, limits and constants, output captured by running it, and 3D views built from that output.
| From | Imports from | Files importing |
|---|---|---|
| cam-generator | cam-kernel | 2 |
| cam-generator | history | 1 |
| cam-generator | mesh | 2 |
| cam-generator | sketch | 1 |
| cam-kernel | cam-generator | 4 |
| cam-kernel | mesh | 1 |
| drawing | brep | 1 |
| drawing | history | 4 |
| drawing | mesh | 7 |
| features | mesh | 5 |
| history | brep | 1 |
| history | features | 5 |
| history | mesh | 2 |
| history | sketch | 2 |
| mesh | tolerance | 1 |
The one cycle, CAM kernel ↔ CAM generator, is deliberate: the kernel reuses the generator's strategies and element schema, and the generator calls back into the kernel's cutting data and planner.
Kernel pages
| Page | What it covers | Source |
|---|---|---|
| Sketch solver | Levenberg–Marquardt on constraint residuals, rank analysis for degrees of freedom, free points and conflicts. | packages/core/src/cad/sketch.ts |
| Mesh and CSG | Closed triangle meshes, BSP Booleans with a convex fast path, soup cleanup and topology. | packages/core/src/cad/csg.ts, solid.ts, mesh-clean.ts |
| Exact B-rep | Analytic and NURBS faces, exact Booleans, fillets, hole recognition, mass properties, STEP. | packages/core/src/cad/brep/ |
| Feature generators | Involute gears, ISO threads, helices and sheet metal with flat patterns. | packages/core/src/cad/gear.ts, thread.ts, helix.ts, sheet-metal.ts |
| Tolerance and tessellation | One chord tolerance for segment counts, decimals and entity tessellation. | packages/core/src/cad/tolerance.ts, tessellate.ts |
| CAM machining kernel | Planning, cutters, voxel stock with a remaining-volume bracket, certified collision checks. | packages/core/src/cam/kernel/ |
Shared rules
- Millimetres everywhere, radians in code (degrees only where a field says so, such as a gear's pressure angle or a blend angle).
- Z up, counter-clockwise outer loops, outward-facing triangles.
- Plain data. Meshes are typed arrays, B-reps are index tables, sketches are entity lists; everything serialises to JSON and diffs in the project history.
- Errors are explicit. Invalid input throws a
RangeErroror a kernel error class (SketchError,BooleanError,BudgetExceeded) with a message the assistant can show; results that would be wrong are never returned. - Bounded work. Segment and vertex budgets in the mesh kernel, a time budget in the exact kernel, turn limits in threads, subdivision depth in collision checking.
Every number on these pages was produced by running the kernel with Bun against the source in this repository; re-run the snippets to reproduce them.