3D comes to your apps: models, augmented reality and printable parts

· Cosimo Luigi Manes

Reactive apps gain the third dimension. From today a document can display interactive 3D models — with an augmented-reality view on supported devices — and, above all, generate parametric 3D parts with OpenSCAD, right in the browser, ready to download as STL for your 3D printer. As always: one line of text, no server, nothing to install.

A 3D model in one line: ::model

The ::model directive shows a glTF/GLB model inside the app: rotate it with a finger or the mouse, zoom in, and on compatible phones a button places it in augmented reality, right on your table:

::model{src="https://example.com/statue.glb" alt="Roman statue"}

For AR on iPhone and iPad just add the USDZ variant (ios-src="statue.usdz"). The viewer is downloaded only by documents that use it, and src can be a reactive reference: a dropdown that switches models, a catalog that shows the selected piece.

Parametric parts with OpenSCAD: ::cad

The big one. OpenSCAD is the makers’ language for describing solids with code; Reactive runs it in the browser (WebAssembly) and wires it into its reactive system. The code lives in a block inside the directive, like ::python — and the fields of the last row of the collections declared in data become variables of the code:

::form{path="box" id="p"}
::input{form="p" field="w" type="number" placeholder="Width"}
::input{form="p" field="h" type="number" placeholder="Height"}
::add-form{form="p" path="box" label="Generate"}
::/form

::cad{data="box"}
```
w = 30; h = 20;
cube([w, h, 10], center=true);
```
::/cad

The form becomes the part’s parameter panel: enter width and height, hit Generate, and the model regenerates in the interactive 3D preview. The button next to it downloads the print-ready STL. Assignments in the code (w = 30;) act as defaults while the collection is empty.

Nothing of the language is missing: fonts for text() (engravings, labels) and the MCAD and BOSL2 libraries (gears, threads, screws) are already mounted. The engine (~10MB) downloads on first use and stays cached: from then on it works offline too.

What you can build with it

And the editor writes with you

Alongside 3D comes autocompletion in the editor: typing : picks directives from a menu with descriptions and pre-filled snippets (Tab jumps between fields), inside braces the right attributes for each directive are suggested, in the frontmatter the app keys — and inside a ::cad block the completion speaks OpenSCAD: cube, cylinder, difference, the transforms and the special variables, signatures at a glance.

All of this is already in the app: open it and try the syntax in the guide, or start from the directives guide.