Johannes Kaindl Uplink Deutsch

3D Codeblocks

A 3D model in a note is usually a screenshot: the one view that someone happened to have set when exporting. This Obsidian plugin turns it into an object you can handle — rotate, zoom, orbit, without leaving the note. A code block with a file path is enough:

```3d
file: weltmodell/3d/eg.gltf
title: Ground floor
```

Why this one

The occasion was a world model: five floors of a house, generated from Python geometry, regenerated again and again. Anyone discussing such models needs them in the text — where the reasoning is, not in a second program.

From this followed the most interesting decision of the project: The code block is the only memory. If you rotate a model into a good position and press Save view, the viewing angle lands as a line in the block — never in the 3D file. The file stays an untouched product of the pipeline, the note keeps the intent.

So that this holds across regenerations, the angle is stored relatively: azimuth,elevation,distance, where the distance is a multiple of the automatically fitted distance. If the same room is generated twice as large tomorrow, the remembered view is still right. If the angle is close enough to a standard direction, the block simply says view: iso instead of three numbers — readable for people who edit the block by hand later.

And then: talking back

Since v0.2.0 you can not only watch the model but also contradict it. A pen button opens edit mode: click a room, drag the arrow gizmo or type exact numbers — move, scale, done. Rotation is deliberately absent; the world model behind it only knows axis-aligned boxes, and an editor should not make promises the pipeline cannot keep.

Saving follows the same principle as with the viewing angle: never into the original. A sibling file eg.edit.gltf is created — not a new model, but a change request. On the Python side, a diff script reads this file and translates "move Stove & Kitchen five metres to the left" into exact target values for the geometry source. The circle closes: code generates the model, the human pushes rooms into place in the note, the diff carries the intent back into the code. Both sides keep their truth — and because the requests are attached to the room's name, they even survive a complete regeneration of the model in between.

Whose view is this?

A model without its surroundings looks different from how it looked in its author's program. Since v0.4.0 it gets back what the author took for granted: the light and the viewing angle.

Shiny surfaces need something to reflect. glTF sets metallicFactor to 1 by default, and anyone who only gives a base colour – the most common case – got polished metal bodies in front of black nothing. So the plugin brings an environment; the Lighting setting chooses how faithful it should be, and the default leaves your theme's colours untouched. If a file brings its own lights, the plugin steps back.

Many files also carry cameras that their author placed: the section, the entrance, the angle they thought was the right one. view: camera:Section A starts exactly there. From then on you orbit as usual, around the point that camera looks at – a view that shows a detail keeps its detail.

One small thing makes the principle above visible (v0.3.0): if an .edit.gltf sits next to the model, a hint appears in the top-left corner of the viewport. The viewer deliberately shows the original, because the edit file is a request and not a model – and without the hint that looked like lost work.

A model from words

Since v0.6.0 a model can also be written down: one part per line – box, cylinder, sphere, cone, with size, position, rotation and colour –, in a shapes code block or in a .shapes file that shows text and model side by side. A broken line only costs its own part and is reported with its line number, never the whole model.

This small language is also what a language model can write reliably. The prompt panel creates a model from a description or changes an existing one ("the wall blue, the table to the left"). It streams the answer, shows a preview and a list of changes, and every request stays as a round you can go back to. Nothing is written until Apply – into the block, into the file or as a new model. The same caution as everywhere in the plugin: a suggestion stays a change request until you accept it.

The panel is also honest about its own yardstick. One line says whether the chosen model was measured in the plugin's test runs (one attempt per case) – or, if not, what the one small model that was tested managed. The provider is a local server or, through the LLM Endpoint Manager, Claude. Whatever stands in the prompt as a key or token leaves the plugin only as a placeholder and returns to its place in the answer.

Under the hood

Four routes lead to the same viewer: the 3d code block, a gltf block with inline JSON, a ![[modell.glb]] embed and the file itself in the file explorer. Only the first can save — the others have no block that anything could be written into, and they say so honestly through disabled buttons.

Before every write, the plugin checks whether the same block is still at the remembered position. If it does not match, it would rather write nothing at all. A saved view is a convenience; a broken note would be damage.

Because WebGL contexts are expensive, never more models run live at the same time than configured. Older ones freeze into a still image and wake up again on click.

A model loads nothing from the web unless you allow it (Allow external resources, off by default): opening a note should not contact a server you did not choose.