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.

8 min read • View on GitHub • More from Adam-CAD

A glowing wireframe gear hovering over a vintage drafting table while a mechanical arm writes math equations.
CADAM treats the LLM not as a 3D artist, but as a software engineer that writes, compiles, and self-debugs parametric geometry.
Key Takeaways

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.

A lumpy clay gear contrasted against a razor-sharp metal gear with precise caliper measurements.
Generative AI meshes (left) produce static blobs. Programmatic CAD generation (right) creates mathematically precise, editable parameters.

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.

The in-browser compilation pipeline. By moving the OpenSCAD engine into a WASM worker, CADAM bypasses the need for server-side rendering.

By combining AI agents for conversational modeling with deterministic regex updates for quick tweaks, it dramatically lowers the barrier to complex CAD workflows.

LavX Team, Authoring Team · LavX News

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.

A robotic pincer extracting a broken gear tooth while a laser welds a new one into a complex clockwork mechanism.
The self-healing compilation loop feeds syntax errors back to the LLM, allowing it to fix its own code at a granular level.

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.

Gregory Zuckerman, Author · FindArticles

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.

FeatureCADAM (OpenSCAD WASM)Traditional CAD (SolidWorks)Generic AI (Shape-E)
Output TypeParametric CodeSolid BodyStatic Mesh
Editing ParadigmText / SlidersFeature TreeUn-editable
Compute LocationBrowser WASMLocal App / CloudHeavy Cloud GPU
Export FormatsSTL / SCADSTEP / IGESOBJ