---
name: build-twin
description: Make a 3D digital twin of a room from photos. Use this whenever someone wants a twin, 3D model, 3D view or floor plan in 3D of their room, bedroom, office, flat or any space from photos ("make a twin of my room", "I have photos of my room", "build my twin", "turn my room into 3D"), and when they want to fix, improve or install an existing twin as an app.
---
# Build a twin of a room
You are helping a person turn photos of their room into a 3D twin they can turn, click and keep.
They may not be a developer. Follow these steps in order.
## How to talk
- Plain language, short messages. Before each step, say in a few words what you're doing ("I'm making copies of your photos that I can look at.").
- Never mention JSON, coordinates, Python, scripts or file formats unless they ask. Say "the twin", "the 3D view", "your photos folder".
- Only create or change files inside `spaces/`. Never edit `tools/`, `viewer/` or anything else in this folder. If a tool is broken, tell the person plainly ("Something in TwinSpace itself isn't working: …") and stop. Don't work around it.
- If `python3` doesn't work, say: "TwinSpace needs Python 3, which isn't installed on this computer." On macOS, add: "Type `python3` once in Terminal and your Mac will offer to install it." Don't build the twin any other way.
- Run every command from the TwinSpace folder (where this `.claude` folder is), with paths exactly as written here, for example `python3 tools/twin.py prepare my-room` and `open spaces/my-room/photos`.
## 1. Start
Say in one sentence what will happen, for example: "I'll make a 3D twin of your room from a few photos. It takes about five to ten minutes."
Choose the space name: if they named the room ("my bedroom", "the office"), use a matching short name in lowercase with hyphens (`bedroom`, `office`). Otherwise use `my-room`.
If `spaces/<name>/scene.json` already exists, ask: "You already have a twin of this room. Should I improve that one, or start again from the photos?" If they want to improve it, go to step 10 (show it) and then step 11 (fix loop).
## 2. Space
Run `python3 tools/twin.py new <name>`.
## 3. Photos (and a floor plan, if they have one)
Run `python3 tools/twin.py prepare <name>`. If it lists prepared photos, the photos are already there: skip to step 5. If it says there are no photos, send **one** short message like this (use the real full paths that `new` printed):
> Please add 4 to 12 photos of the room:
> - Stand in each corner and photograph the opposite corner, then take one photo of each wall.
> - Daylight or lights on, and make sure the door is in at least one photo.
>
> Put them in this folder: `/full/path/to/spaces/<name>/photos`
>
<!-- ‹guest · 2026-12-02› -->
> If you have a floor plan of the room or your home (a drawing, a PDF, or a photo of one, for example from your rental contract or estate agent), put it in `/full/path/to/spaces/<name>/plan` too. It gives me the exact measurements. That part is optional.
>
> Tell me when they're in.
On macOS, also run `open spaces/<name>/photos` so the folder opens in Finder and they can drag the photos in. On Linux use `xdg-open`.
Then **wait**. Don't continue without photos. Don't wait for a floor plan.
**Ask for a floor plan whenever it would help**, not only here: when you're unsure about sizes, when the room isn't a simple rectangle, or when they tell you sizes look wrong. Ask at most once per reason, and never insist.
## 4. Prepare
When they say the photos are in, run `python3 tools/twin.py prepare <name>` again.
- If it asks for JPG versions or fewer photos, pass that on in plain words ("Two of the photos are in a format I can't read here. Could you export them as JPG?") and wait.
- Otherwise it prints a list of files. Those are the only files you look at in step 6.
## 5. One measurement (optional)
Skip this if a floor plan was listed and shows the room's size.
Otherwise read `spaces/<name>/notes.txt`. Lines starting with `#` don't count. If there are no other lines, ask once:
> Do you know one measurement? For example the room's width, or how long your bed or desk is. "Skip" is fine.
Write their answer into `notes.txt` as a normal line (for example `The desk is 1.4 m long.`). One real measurement makes every size better, so it's worth asking, but accept "skip" happily.
## 6. Look
Tell them: "I'm looking at your photos now. This takes a minute or two."
View **every** file that `prepare` listed, including the floor plan files. Then, before writing anything, make an inventory for yourself (don't show it unless it helps):
1. **Which wall is north.** North is the wall with the main window. No window: the wall opposite the door. Neither helps: the wall in the first photo. This has nothing to do with the compass. Note which photo shows which wall.
2. **The room's shape.** Most rooms are rectangles. Look for corners that aren't on the four outer sides: an L-shape, a window niche or alcove at least 20 cm deep, a chimney breast or pillar against a wall, a corner cut off by a cupboard built into the wall. Those need an `outline` (step 7). Smaller bumps aren't worth drawing; mention them in the notes. If the room isn't a rectangle and they haven't given a floor plan, ask once whether they have one: the shape is much easier to get right from a plan.
3. **Doors and windows** on each wall, with rough positions along the wall.
4. **Furniture** along each wall and in the middle, **counted once across all photos**. The same wardrobe seen in three photos is one wardrobe. Use fixed things (window, door, radiator, corners) to match photos to each other.
5. **Sizes.** Start from a measurement or floor plan if there is one. Otherwise use known sizes: a door is about 0.9 × 2.05 m, a single bed about 0.9 × 2.0 m, a double bed about 1.4–1.6 × 2.0 m, a desk is 0.75 m high, a ceiling about 2.5 m, a light switch about 1.05 m high, a kitchen counter 0.9 m high and 0.6 m deep. Make sizes agree across photos: if the bed fills the wall under the window, the wall can't be shorter than the bed.
6. **What you couldn't see** and had to guess.
**With a floor plan:** find this room on it. A plan of a whole home shows many rooms, so ask if it's unclear which one is theirs. Take the room's width and length and the positions of doors and windows from the plan: they beat any estimate from photos. Read the printed measurements carefully. Plans often give them in cm or as "3,62". Then scale the furniture from those walls. Furniture still comes from the photos, because plans often show none or show old furniture. If the plan and the photos disagree (a door missing, a wall moved), trust the photos for what exists and say so in the notes. A north arrow on the plan doesn't change which wall is "north" here: it's still the window wall.
<!-- ‹guest · 2026-12-02› -->
## 7. Write the twin
Write `spaces/<name>/scene.json`. The full format is in `SPEC.md` §2–§3. The essentials:
```json
{
"version": 1,
"name": "Bedroom",
"units": "m",
"room": { "width": 3.6, "length": 4.2, "height": 2.5, "floor": "#b08a64" },
"openings": [
{ "id": "window-1", "kind": "window", "wall": "north", "from": 1.0, "to": 2.4, "bottom": 0.9, "top": 2.2 },
{ "id": "door-1", "kind": "door", "wall": "south", "from": 2.6, "to": 3.5, "bottom": 0, "top": 2.05 }
],
"objects": [
{ "id": "bed", "type": "bed", "label": "Bed under the window", "at": [1.7, 1.05], "size": [1.4, 2.0, 0.5], "rot": 0, "elevation": 0, "color": "#c9c2b5" }
],
"confidence": { "room_size": "estimated", "notes": ["The ceiling height is a guess from the door."] },
"source": { "photos": ["IMG_0412.jpg"], "measurements": "none", "made_by": "Claude …", "made_at": "2026-12-01T21:00:00+01:00" }
}
```
**Rooms that aren't rectangles:** add `outline` to `room`: the floor's corners `[x, z]` in order around the room, every wall running exactly north–south or east–west, without repeating the first corner. The smallest x and the smallest z must both be 0. `width` and `length` are then the outline's overall size. Walls are numbered: wall `i` runs from corner `i` to corner `i + 1` (the last one back to corner 0). A door or window on any wall other than the longest one facing a direction gives `wall` as that **number**; `from`/`to` stay room coordinates (x along walls that run east–west, z along walls that run north–south). Two examples:
```json
"room": { "width": 4.0, "length": 5.0, "height": 2.5,
"outline": [[0, 0], [4.0, 0], [4.0, 3.0], [2.5, 3.0], [2.5, 5.0], [0, 5.0]] }
```
An L-shape missing its south-east part. Wall 2 is the step at z = 3, wall 3 the short east side at x = 2.5.
```json
"room": { "width": 3.1, "length": 4.6, "height": 2.5,
"outline": [[0.3, 0], [3.1, 0], [3.1, 4.6], [0.3, 4.6], [0.3, 0.9], [0, 0.9], [0, 0.3], [0.3, 0.3]] }
```
A window niche 0.3 m deep in the west wall, between z = 0.3 and z = 0.9: the main west wall is at x = 0.3, and the niche's back wall (wall 5, at x = 0) holds the window: `{ "kind": "window", "wall": 5, "from": 0.3, "to": 0.9, … }`. Furniture against the main west wall has `x = 0.3 + d / 2`.
`"wall": "north"` still works and means the longest wall facing north. `check` tells you when furniture sticks out of the outline.
**The room's coordinates (in metres):**
<!-- ‹guest · 2026-12-02› -->
- `width` = length of the north (window) wall. `length` = length of the west wall.
- `x` runs along the north wall from west (0) to east (`width`). Standing in the room facing the window, west is on your **left**.
- `z` runs from the north wall (0) to the south wall (`length`).
- Doors and windows: `from`/`to` are positions along their wall. On north and south walls that's `x`; on west and east walls it's `z`.
**Each object:**
- `at` = `[x, z]` of the **centre** of its footprint on the floor.
- `size` = `[w, d, h]` in the object's own frame: `w` across its front, `d` from front to back, `h` its height.
- `h` is the height of the main body. For a **bed** that's the top of the mattress (about 0.5 m), not the headboard: the 3D view adds the headboard by itself. For a sofa or chair it's the top of the backrest.
- `rot` = the direction its **front** faces: `0` faces south (into the room from the north wall), `90` faces east, `180` faces north, `270` faces west.
- Front: the doors of a wardrobe or cabinet, the **foot end** of a bed, the side you sit facing on a chair or sofa, the side you sit at for a desk, the open side of a shelf, the screen of a TV or monitor.
- Something standing against the north wall faces into the room: `rot: 0`. Against the south wall: `180`. Against the west wall: `90`. Against the east wall: `270`.
- A bed with its head against the east wall has its foot end facing west: `rot: 270`.
- When `rot` is 90 or 270, the footprint is turned: it covers `d` along `x` and `w` along `z`.
- **Against a wall** means touching it. On the west wall with rot 90: `x = d / 2`. On the north wall with rot 0: `z = d / 2`. On the east wall with rot 270: `x = width − d / 2`. On the south wall with rot 180: `z = length − d / 2`.
- `elevation` = the height of its bottom above the floor: a monitor on a desk sits at the desk's height, a wall shelf or TV at its mounting height. A ceiling light hangs at ceiling − its height.
- `type` is one of: bed, sofa, armchair, chair, desk, table, coffee-table, wardrobe, shelf, cabinet, nightstand, fitness, tv, monitor, floor-lamp, ceiling-light, radiator, plant, rug, box, appliance, sink, kitchen-counter, other. Pick the closest one and put the real name in `label` ("Dresser" → `cabinet`, "Washing machine" → `appliance`).
- `label`: short and specific, so the person recognises it ("Wardrobe by the door", not "Wardrobe 1"). `color` is the main colour you see (`#rrggbb`). Give a one-sentence `notes` when something is uncertain ("Partly hidden behind the door in all photos").
**Rules:**
- Only include what is visible in the photos. Don't invent furniture.
- Furniture that stands against a wall goes **against** that wall, not 20 cm away from it. Something **in a corner** touches both walls: check both coordinates (e.g. a wardrobe in the south-west corner facing north: `x = w / 2`, `z = length − d / 2`). If a corner piece and the furniture beside it don't fit along a wall, the room size is wrong, not the corner: fix the room size.
- **Which way does it face?** For every shelf, wardrobe, cabinet, desk and bed, find a photo where you see its front (books, doors, the seat, the foot end), then decide which wall its back touches. A bookcase whose shelves face across the room stands against a **side** wall, even if it's next to the window. A piece you see side-on in a photo taken along a wall usually stands against that wall. If two pieces seem to fight for the same spot ("how much they overlap is a guess"), you've most likely turned one of them the wrong way.
- `fitness` is drawn from its shape: tall and compact (h ≥ 1.5, w and d ≤ 1.3) → a pull-up/dip tower; lower than 0.8 → a bench; long (d ≥ 1.3) and lower than 1.6 → a treadmill; anything else → a rack with a barbell. Give the real size and the right look follows.
- `confidence.room_size` is `measured` only if a real measurement or a readable floor plan set the sizes. Otherwise it's `estimated`.
- `confidence.notes`: up to 12 short, honest sentences about what is certain and what was guessed.
- `source`: the photo file names you used, `plan` (the plan files, if any), `measurements` (what the person told you, the plan's room size such as `"floor plan: 3.62 × 4.18 m"`, or `"none"`), `made_by` (your model name, if you know it) and `made_at` (now, with time zone).
## 8. Bundle
Run `python3 tools/twin.py bundle <name>`.
- An **error** means nothing was made: fix `scene.json` and run it again.
- **Warnings** tell you what the tool changed or noticed. Fix real mistakes: two pieces of furniture overlapping, something pushed back into the room (it was placed wrong), a size cut to fit (it was too big). Leave the ones that are fine (a rug under a bed doesn't warn; a desk chair tucked under a desk is fine).
- Then run `bundle` once more if you changed anything.
## 9. Check it yourself
Don't try to take pictures of the 3D view (hidden browsers often draw it blank); check the data instead. Read `scene.json` once more with the photos in mind and ask yourself: Is the window on the right wall? Is every piece of furniture on the wall where it is in the photos? Does each one face the right way, and which photo shows its front? Does the bed's head touch the right wall? Fix what's wrong and bundle again.
## 10. Show
<!-- ‹guest · 2026-12-02› -->
Open the twin: `open spaces/<name>/twin.html` on macOS, `xdg-open spaces/<name>/twin.html` on Linux, `start "" spaces\<name>\twin.html` on Windows. If that fails, give the full path to `twin.html` and tell them to double-click it.
Tell them how to use it in one line: "Drag to turn the room, scroll or pinch to zoom, and click any piece of furniture to see its size and position."
## 11. Summary and fix loop
Give a summary in three to five short lines: the room size (and whether it's measured or estimated), what's in the twin, and what you were unsure about. Then ask:
> Does anything look wrong? Tell me like "the bed is against the other wall" and I'll fix it.
When they tell you something, change `scene.json`, run `bundle` again, and say: "Done. Reload the page to see it." (On a Mac: press Cmd + R in the browser.) Repeat until they're happy.
The twin uses "north wall", "west wall" and so on, and the page labels each wall (N, S, W, E). If they say "the left wall" or "the wall with the TV", work out which wall they mean from the photos. If you're unsure, ask in their words, not in compass words.
If they correct sizes and haven't given a floor plan, ask once whether they have one.
## 12. Make it an app (optional)
When they're happy, offer this, but only if you have Claude's **Artifact** tool in this session. Ask first:
> Would you like your twin as an app? I can put it into your Claude account as a private page, and you can install it as an app from the Claude desktop app, so it opens from your Dock like any other app. Only the 3D model goes there (room size and furniture), never your photos or floor plan. It stays private unless you share it. Shall I?
Publish only on a clear yes. Then:
1. Publish `spaces/<name>/twin.html` with the Artifact tool as a new artifact, with `icon` set to `home` and a one-sentence description such as "3D twin of my bedroom". Its title comes from the page ("Bedroom Twin").
2. Save the link you get back in `spaces/<name>/app.txt` (just the link on one line).
3. Tell them: "Here's your twin: <link>. Open it in the Claude desktop app, click **Share**, then **Install as app**. After that it opens from your Dock or Launchpad, without Terminal or Claude Code."
If `spaces/<name>/app.txt` already exists, they already have the app. After fixes, update the **same** app: publish `twin.html` again with the link from `app.txt` as the artifact's `url`. Read the artifact first if the tool asks you to. Tell them the app now shows the new version.
If you don't have an Artifact tool (another agent, an older Claude Code, or Artifacts turned off for their account), say: "Making it an app isn't possible from here, but `twin.html` works just as well: double-click it any time." Never upload the twin anywhere else instead.
## 13. End
Tell them, briefly:
- `twin.html` is one file they can keep or send to a friend. It needs an internet connection to load the 3D view.
- Their photos and floor plan stay in their folder. Apart from this Claude conversation looking at them, TwinSpace sends them nowhere.
- If they made the app: only the 3D model is in their Claude account, as a private page.
- They can come back any time and say "improve my twin" to fix things.
این نسخه با نشانهگذاری اختصاصی حساب شما نمایش داده میشود. برای نصب سریع، به تب نصب و راهاندازی بروید.