# What Is the Underlying Technology Behind Text-to-CAD? A Deep Dive into the Architecture

> Discover the underlying technology of text-to-CAD. Explore its Python, JavaScript, and GLSL stack for parametric STEP generation, browser rendering, and SDF modeling.

- Repository: [earthtojake/text-to-cad](https://github.com/earthtojake/text-to-cad)
- Tags: deep-dive
- Published: 2026-07-24

---

**The text-to-cad library is powered by a three-layer stack combining Python with build123d for parametric STEP generation, JavaScript with cadjs for browser rendering, and implicitjs for GLSL-based signed-distance-field modeling.**

The earthtojake/text-to-cad repository functions as a language-agnostic CAD workbench that transforms natural-language prompts into production-ready geometry. The underlying technology behind text-to-cad interweaves parametric Python modeling, browser-native JavaScript visualization, and implicit surface representation to create a seamless "text → CAD" pipeline orchestrated through unified CLI tools.

## Parametric Modeling with Python and build123d

The foundation of the geometry pipeline relies on **cadpy**, a Python package that wraps **build123d** to generate STEP-first artifacts. This runtime handles artifact creation, source hashing, and topology validation directly from Python source files, as documented in [`packages/cadpy/README.md`](https://github.com/earthtojake/text-to-cad/blob/main/packages/cadpy/README.md).

The core API entry point is `ensure_step_glb_artifact`, which emits both STEP files and accompanying GLB topology data. The CLI wrapper in [`skills/cad/scripts/step/cli.py`](https://github.com/earthtojake/text-to-cad/blob/main/skills/cad/scripts/step/cli.py) invokes this function to process Python generators.

To generate a STEP model from Python code, use the `AssemblyHelper` class:

```python

# example.py – a minimal build123d model

from cadpy import AssemblyHelper, Location, Box

def gen_step():
    # Create a simple box part

    part = Box(20, 30, 10)
    # Wrap it in an AssemblyHelper for labeling

    assembly = AssemblyHelper(name="example")
    assembly.add(part, Location((0, 0, 0)), name="body")
    return assembly

if __name__ == "__main__":
    # Export the STEP file and accompanying GLB topology

    from cadpy.api import ensure_step_glb_artifact
    ensure_step_glb_artifact(gen_step, output_path="example.step")

```

Execute the generator via the command line:

```bash
python scripts/step --kind part --output example.step example.py

```

## Browser Rendering with JavaScript and cadjs

For visualization, the stack employs **cadjs**, a UI-framework-agnostic JavaScript runtime that parses STEP topology and renders geometry using **Three.js**. According to [`packages/cadjs/README.md`](https://github.com/earthtojake/text-to-cad/blob/main/packages/cadjs/README.md), this package powers both the interactive CAD Viewer and automated snapshot generation.

The runtime provides selector logic for topological references, enabling precise identification of faces, edges, and vertices within STEP files. It processes geometry directly in the browser without framework dependencies, creating rendered assets for review workflows.

## Implicit CAD with Signed-Distance Fields

The third layer, **implicitjs**, implements browser-native implicit modeling using **GLSL ray-march shaders**. This runtime, detailed in [`packages/implicitjs/README.md`](https://github.com/earthtojake/text-to-cad/blob/main/packages/implicitjs/README.md), compiles signed-distance-field (SDF) code defined in [`.implicit.js`](https://github.com/earthtojake/text-to-cad/blob/main/.implicit.js) files, rendering surfaces via Three.js and supporting headless PNG/GIF capture through **Playwright**.

The implicit pipeline supports mesh exports to STL, 3MF, and GLB formats. Key functions include `loadImplicitModuleFromSource` for parsing SDF modules, `renderImplicitToDataUrl` for generating image previews, and `exportImplicitModel` for mesh extraction.

To render an implicit model programmatically:

```javascript
import { loadImplicitModuleFromSource, renderImplicitToDataUrl } from "implicitjs";
import * as THREE from "three";

const source = `
const GLSL = \`
float sdf(vec3 p) {
  return implicit_sphere(p, vec3(0.0), 20.0);
}
\`;
export default {
  schema: "implicit.js/0.1.0",
  name: "parametric sphere",
  units: "mm",
  glsl: GLSL
};
`;

(async () => {
  const model = await loadImplicitModuleFromSource(source);
  const dataUrl = await renderImplicitToDataUrl(THREE, model, {
    width: 800,
    height: 600,
    camera: "iso"
  });
  console.log("Rendered image data URL:", dataUrl);
})();

```

For mesh export to GLB:

```javascript
import { loadImplicitModuleFromSource, exportImplicitModel } from "implicitjs";

(async () => {
  const model = await loadImplicitModuleFromSource(source);
  const glb = await exportImplicitModel(model, {
    format: "glb",
    resolution: 96,
    params: { radius: 25 }
  });
  // `glb` is a Uint8Array – write to disk with Node's fs module
})();

```

## CLI Tools and Workflow Integration

The three layers interoperate through CLI tools defined in [`skills/cad/SKILL.md`](https://github.com/earthtojake/text-to-cad/blob/main/skills/cad/SKILL.md). These scripts orchestrate the transformation from text prompts to validated CAD artifacts:

- **`scripts/step`** – Invokes the Python generator (`cadpy`) to emit STEP and GLB files.
- **`scripts/inspect`** – Loads STEP files with `cadpy`, resolves selector references like `#o1.2.f1`, and reports geometry facts and measurements.
- **`scripts/snapshot`** – Uses either `cadjs` for STEP-based models or `implicitjs` for SDF models to produce PNG/GIF review packets.

To inspect a generated STEP file and resolve topological selectors:

```bash
python scripts/inspect refs example.step --facts --measure "#o1.2.f1"

```

This command leverages `cadpy` internals for selector handling, validating specific faces or edges within the STEP topology.

## Robot Description Support

Beyond pure CAD, the repository supports robot-description workflows through the same runtime foundations. The **URDF** and **SRDF** formats utilize Python generators to produce XML descriptions, validated by the MoveIt2 server located in `viewer/moveit2_server`.

For simulator-ready assets, the **SDF** format uses `cadpy` to assemble physics and sensor definitions. The entry point for URDF generation resides in [`skills/urdf/scripts/urdf/cli.py`](https://github.com/earthtojake/text-to-cad/blob/main/skills/urdf/scripts/urdf/cli.py), maintaining consistency with the core CAD pipeline.

## Summary

- The text-to-cad architecture consists of three layers: **cadpy** (Python/build123d for STEP), **cadjs** (JavaScript/Three.js for rendering), and **implicitjs** (GLSL shaders for SDF models).
- CLI tools in `skills/cad/scripts/` bridge these layers, supporting generation, inspection, and snapshotting workflows.
- The `ensure_step_glb_artifact` function serves as the primary Python API for STEP export, while `loadImplicitModuleFromSource` and `exportImplicitModel` handle implicit model processing.
- Selector references like `#o1.2.f1` enable precise topological queries across the pipeline.
- Robot description formats (URDF/SRDF/SDF) extend the core technology through the `cadpy` runtime and MoveIt2 validation.

## Frequently Asked Questions

### What programming languages does text-to-cad use?

The repository uses **Python** for parametric modeling and **JavaScript** for browser rendering and implicit surface representation. Python handles STEP generation through build123d, while JavaScript manages visualization via Three.js and GLSL shaders.

### How does text-to-cad handle file exports?

The system supports multiple export pathways. For parametric models, `cadpy` generates **STEP** and **GLB** files simultaneously via `ensure_step_glb_artifact`. For implicit models, `implicitjs` exports meshes to **STL**, **3MF**, and **GLB** formats using the `exportImplicitModel` function with configurable resolution settings.

### What is the role of the cadpy package in text-to-cad?

**cadpy** serves as the shared Python runtime that orchestrates STEP generation, topology validation, and artifact hashing. It provides the `AssemblyHelper` class for model structuring and the `ensure_step_glb_artifact` API for file export, forming the backbone of the parametric modeling layer as described in [`packages/cadpy/README.md`](https://github.com/earthtojake/text-to-cad/blob/main/packages/cadpy/README.md).

### Can text-to-cad validate robot descriptions?

Yes. The repository includes dedicated support for **URDF**, **SRDF**, and **SDF** formats through [`skills/urdf/scripts/urdf/cli.py`](https://github.com/earthtojake/text-to-cad/blob/main/skills/urdf/scripts/urdf/cli.py) and the `viewer/moveit2_server` MoveIt2 validation server. These components leverage the same `cadpy` foundations used for general CAD workflows to ensure simulator-ready asset integrity.