Single place to convert your 2D floor plans to 3d model (no LLM)
Guide for AI coding agents
PlanTo3D turns a CAD-exported floor plan PDF into a furnished 3D house you can walk through in a browser. There is no AI model in the pipeline: detection is geometry, furniture is rules, the 3D is Blender. Keep it that way.
Run it
./run.sh --port 8080 # npm install (three.js) + python3 server.py
python3 fetch_assets.py # CC0 textures and models into assets/ (about 150 MB), once
Needs Python 3, Node 18+, Blender 4.2+ and poppler. If Blender is not on PATH, set BLENDER to its full path.
GET /api/system says what is missing. Try it with examples/sample_plan.pdf.
Map
| File | Job |
|---|---|
server.py |
HTTP routes only (standard library only). Names jobs.X / theme_store.X, never a copy, so tests can swap the folders |
jobs.py |
a plan's folder in jobs/ and the work on it: status, run_detect, the build queue (one Blender at a time), exports, the furniture list and check_items, the setup check |
theme_store.py |
people's own themes on disk, the Themes page's list, the pictures of each theme's pieces |
vector.py |
PDF page -> line segments, curves, fills, words (poppler) |
detect.py |
segments -> plan JSON: walls, openings, rooms, stairs, scale. Units: feet, y up |
furnish.py |
plan JSON -> furniture items {fn, args, kw, box}. Pure Python, no Blender |
quantities.py |
plan JSON -> areas, paint, tiles, doors, windows, furniture counts. Also holds FLOOR_MAT and opening_heights, which gen.py imports, so the sheet counts what is built |
themes.py |
interior themes: LIBRARY (Poly Haven models with their measured sizes and turn), STYLES (pieces gen.py draws), THEMES (built-in), check/load for people's own (assets/themes/<id>.json, uploads in assets/themes/<id>/<slot>.glb) |
catalog.py |
built-in pieces' default footprints, and preview_plan(theme): the row of a theme's pieces that blender/thumbs.py photographs |
blender/gen.py |
plan JSON -> house (run inside Blender): walls, openings, stairs, roof, site, lights, then bake |
blender/furniture.py |
every furniture piece and fixture, the parts they are made of, theme models fitted to a box. CALLS maps item fn to its builder; build(item) builds one item in the theme's piece |
blender/lib.py |
materials and box meshes. Feet in, metres out (F = 0.3048); LEVEL and WALL_H are the storey being built |
blender/bake.py |
light maps (Cycles) and house.glb export |
web/ |
index.html (upload), edit.html + edit.js (review), view.html + view.js (walkthrough), walk.js (collision, stairs, start point), themes.html |
examples/ |
sample_plan.pdf, its generator make_sample.py, embed.html |
tools/ |
video and debugging helpers, not used by the server |
Flow: upload -> run_detect -> plan.json -> review page edits it -> POST …/build -> gen.py -> bake.py -> house.glb, meta.json, light maps -> view.js.
Conventions
- Units. Plan JSON and all furniture code are in feet.
meta.jsonand the browser are in metres. - Rotation.
rot0 = the item's front faces -y and its back is on +y; 90 = front +x; 180 = +y; 270 = -x. - Furniture items
{fn, args, kw, box, solid, room}: a floor with anitemslist (written by the review page's Furniture tool) is built with exactly that list,[]= empty rooms; without the key the rules infurnish.pydecide. - Rectangles are
[x0, x1, y0, y1]. A wall is[x0, x1, y0, y1, low](low1 = parapet height). - Stages of a job:
uploaded,detecting,detected,queued,building,done,failed(injobs/<id>/status.json). - Messages a person will read are raised as
detect.PlanError. Anything else is logged and shown as a generic message. - The server uses the standard library only. Do not add Python dependencies. The browser uses three.js and nothing else.
- Comments say why, not what. Match the style of the file you are in.
Tests: run them before you finish
tests/run_all.sh # detector on the sample, quantities, themes, furniture rules, server guards, furniture clashes, stair and wall walking
python3 tests/test_sample.py # the sample must be read exactly
CHROME=/path/to/chromium node tests/test_site.mjs examples/sample_plan.pdf http://127.0.0.1:8080
test_site.mjs needs a running server and takes about 2 minutes (it builds a draft house in a real headless browser).
Run it after any change to web/, server.py, jobs.py, theme_store.py or blender/.
If you change examples/make_sample.py, run it to rewrite the PDF and keep its EXPECT in step.
Refactors (code moves, behaviour stays): prove the house is the same. On main, then on your branch:
python3 tests/same_house.py snapshot before.json [jobs/<id>/plan.json] # the sample in every theme (+ a storeyed plan: stairs, roof)
python3 tests/same_house.py snapshot after.json [jobs/<id>/plan.json]
python3 tests/same_house.py compare before.json after.json # must print SAME HOUSE
It builds without baking (about 20 s a house) and compares every Blender object (name, box, vertices, materials) and meta.json.
How to change things
- A new furniture item: write the builder in
blender/furniture.py, add it toCALLSand toITEM_FNSinjobs.py(what the review page may send), place it from a rule infurnish.pywith its footprintbox. Add it tothemes.SLOTS(and its size tocatalog.py) if themes should be able to change it. - A model for the themes: measure it as Blender imports it (feet, front facing -y after
turn), add it tothemes.LIBRARYwith the slots it may fill;fetch_assets.pydownloads every library model. Large ones: keep it under about 30k triangles. - A new theme: an entry in
themes.THEMES. Furniture rules read only sizes from it (Room.sizes), so a model that does not fit falls back to the built-in piece in the theme's colours. Check it withtests/test_themes.pyand look at a build: rules can be right and a room still look wrong. - A new built-in piece style: a
style=branch in its builder, listed inthemes.STYLES. New materials go inlib.py; a coloured one goes inPAINTingen.pyso themes repaint it. - A new room type: add its keywords to
ROOM_TYPESindetect.py, a rule infurnish.py, a floor material inquantities.py(FLOOR_MAT, andINDOORinfurnish.py), and a colour inweb/edit.js(TYPES,ZCOL). - A change to what a house looks like (anything in
blender/,furnish.pyor a theme that changes a build): raiseENGINEinjobs.py, so houses built before it are marked out of date. - A detector fix: make it general, not a special case for one drawing. Check the sample still passes. The scores on real drawings need private fixtures (
PLANTO3D_FIXTURES) that are not in the repository. - A new API call: add it in
server.py(do_GET/do_POST/do_DELETE), and to the table inREADME.md. - A new texture or model: add its Poly Haven name to
fetch_assets.py; never commit asset files.
Workflow: branches, commits, pull requests
Before you code
- One feature or fix per branch, made from an up-to-date
main:feat/<name>,fix/<name>,refactor/<name>,docs/<name>,ci/<name>. - If the change crosses pipeline stages (detect -> plan -> furnish -> gen -> bake -> viewer), first write down which fields of
plan.jsonormeta.jsonchange. Those two files are the contracts between the stages. - Find the existing place for the code (the Map and "How to change things" above) before making a new one. A new job gets its own module; never a new file just to make another one shorter.
Contracts
- A field added to
plan.jsonormeta.jsonis written and read in the same pull request, and every reader copes with it missing: houses built earlier must still open (seemeta.roofinwalk.js). - Never rename or reuse a field. Add a new one.
Commits
- One logical change per commit, with its test in the same commit.
- The subject says what changed for the person using it, in plain English, at most about 72 characters:
Fix stair headroom on upper floors, notfix stufforwip. Add a body when the why is not obvious. - Never commit
jobs/,assets/,.blendfiles, secrets, client drawings or screenshots of them.
Pull requests
- The title says what the user gets. The description follows
.github/pull_request_template.md. - Keep a refactor (moving or renaming code) and a behaviour change in separate pull requests. A refactor must build the sample to the same house: compare
meta.jsonand the object list before and after. - Done means:
tests/run_all.shpasses;tests/test_site.mjspasses after changes toweb/, the server's Python files orblender/; after changes toblender/orfurnish.pyyou built the sample, walked it and put a screenshot in the pull request;README.mdand this file are updated for a new file, API call or rule; new risky logic (a parser, geometry, a guard) has a test. - Screenshots: drag them into the pull request on GitHub, or from the command line commit them to the
pr-assetsbranch (never merged) and linkhttps://raw.githubusercontent.com/23f2005639/planTo3D/pr-assets/<file>. Sample plan only. - Two open pull requests that change the same lines: make the second from the first's branch and open it with
--base <first branch>. GitHub moves it tomainwhen the first is merged. - CI must be green. Merge only when the owner says "merge", with a merge commit:
gh pr merge <n> --merge --delete-branch.
When something breaks in 3D
- Reproduce it on the sample plan, or on a copy of the job (
jobs/<new id>/). Never rebuild someone's own house unless asked. - Look at it (a screenshot from the walkthrough) before and after the fix. Rules can be right and the room still look wrong.
- Blender exits 0 even when its script fails: check for
GEN OKin the log.
Traps
- Blender is often installed as a snap: it cannot read
/tmp. Give it paths inside the project. blender/furniture.pyreads the storey fromlib.LEVEL/lib.WALL_H: neverfrom lib import LEVEL(a copy that does not follow the storey).- Everything in a saved plan comes from a browser. Validate it before it reaches a file path or
innerHTML. jobs/,assets/andnode_modules/are not in git. Do not commit real client drawings or screenshots of them: use the sample plan.- The walkthrough's lighting is baked. Hiding or moving objects in the browser leaves their shadows behind; change the build instead.
- High-poly models make the browser slow. Trees and plants are procedural for that reason.
- There is no login. Do not add features that assume the server is private unless you add the protection too.