Compiling CAD in the Browser: Inside CADAM
How an open-source project uses WebAssembly and a decades-old C++ engine to turn language models into parametric 3D designers.
- By compiling the OpenSCAD C++ engine to WebAssembly, CADAM moves heavy geometry computation entirely into the user's browser, eliminating server costs.
- Instead of generating un-editable meshes, the system produces mathematically precise, parametric OpenSCAD scripts that engineers can actually tweak.
- A self-healing compilation loop feeds Web Worker STDOUT errors back to the LLM, enabling the AI to autonomously debug its own syntax failures.
- To provide instant feedback without token costs, CADAM uses deterministic regex replacements to update variables locally when users adjust UI sliders.
The Illusion of Text-to-3D
Most AI 3D generation tools produce messy, un-editable polygon meshes. They treat the prompt like a request for a sculpture, resulting in topology-heavy blobs that are mathematically imprecise. Engineers don't want clay; they want actionable parameters.
CADAM flips this script. It doesn't generate 3D models at all. Instead, it generates code. By using Anthropic's Claude to write OpenSCAD scripts, CADAM ensures the resulting geometry is mathematically perfect and, crucially, editable.
Resurrecting a Decades-Old Engine in the Browser
The standard approach for programmatic 3D generation involves spinning up a beefy GPU server to compile the code and render an STL file. CADAM sidesteps this entirely by compiling the OpenSCAD C++ codebase to WebAssembly (WASM).
This architectural choice is profound. It moves the computationally expensive geometry generation into a background Web Worker in the user's browser. The result is a system that incurs nearly zero server costs, relying only on LLM API calls.
By combining AI agents for conversational modeling with deterministic regex updates for quick tweaks, it dramatically lowers the barrier to complex CAD workflows.
The Self-Healing Compiler
Because OpenSCAD is a strict programming language, a single missing semicolon or syntax error will halt compilation. CADAM handles this gracefully with a built-in FixWithAIButton mechanism.
When a generation fails, the application captures the STDOUT and STDERR logs from the Web Worker. It feeds these precise error messages back to Claude, creating a self-healing loop where the AI acts as a software engineer, debugging its own code.
Cheating the Token Limit with Determinism
If you want to adjust the radius of a generated gear by a few millimeters, waiting for an LLM to rewrite the entire script is slow and expensive. CADAM solves this in the ParametricEditorView.
The system extracts key dimensions from the OpenSCAD code and presents them as interactive UI sliders. When a user moves a slider, CADAM uses a deterministic regex replacement to update the variable directly in the local file, triggering a WASM recompile in milliseconds without ever calling the AI.
export function updateParameter(code: string, paramName: string, newValue: number): string {
const regex = new RegExp(`^(${paramName}\\s*=\\s*)[0-9.]+`, 'm');
return code.replace(regex, `$1${newValue}`);
}
The STEP File Ceiling
While the WASM architecture is clever, CADAM faces a significant limitation: OpenSCAD cannot natively export STEP files. STEP is the industry standard for professional CAD interoperability, allowing complex solid bodies to be imported into tools like SolidWorks or Fusion 360 without losing geometric integrity.
Currently, CADAM outputs STL meshes and SCAD scripts. This cements its current position as a rapid prototyping tool for hobbyists and educators, rather than a direct replacement for professional engineering workflows.
Adam just confirmed $4.1 million to transform its viral text-to-3D into an AI copilot for computer-aided design (CAD), reasoning that consumer traction can speed adoption in professional engineering workflows.
The project's recent funding indicates a pivot. The goal is to evolve beyond OpenSCAD by integrating these self-healing, programmatic generation concepts directly into professional cloud platforms like Onshape.
| Feature | CADAM (OpenSCAD WASM) | Traditional CAD (SolidWorks) | Generic AI (Shape-E) |
|---|---|---|---|
| Output Type | Parametric Code | Solid Body | Static Mesh |
| Editing Paradigm | Text / Sliders | Feature Tree | Un-editable |
| Compute Location | Browser WASM | Local App / Cloud | Heavy Cloud GPU |
| Export Formats | STL / SCAD | STEP / IGES | OBJ |