Single place to convert your 2D floor plans to 3d model (no LLM)
Python
Floor finish per room and a house-wide wall colour
23f20056399581ca4b021a
diff --git a/README.md b/README.mdindex 876d035..dd1f4df 100644--- a/README.md+++ b/README.md@@ -84,6 +84,7 @@ python server.py| | ||---|---|| **Review before building** | Detected walls, doors, windows and rooms drawn over your PDF. Click to change or delete, draw walls, add doors and windows, set the scale |+| **Floor finish and wall paint** | Pick a room's floor (marble, wood, tiles, bathroom tiles, terracotta, concrete; Auto follows the room type) and one wall colour for the house. Saved in the plan as `room.floor` and `wall_color` (`#rrggbb`) || **Furniture on or off** | Untick **Furniture** for empty rooms || **Time estimate** | The build box shows about how long is left, learned from earlier builds on the same machine || **Walkthrough** | W A S D and mouse on desktop, two thumbs on a phone. Starts at the entrance side of the plan |diff --git a/blender/gen.py b/blender/gen.pyindex d2f9ca4..249ab9f 100644--- a/blender/gen.py+++ b/blender/gen.py@@ -46,6 +46,10 @@ FLOOR_MAT = dict(dress="wood", bedroom="wood", toilet="bathtile", kitchen="marblgarden="turf", open="pebbles", parking="pavers", yard="pavers", stair="stair", room="tile",duct="concrete")OPEN_SKY = {"open", "garden", "yard"} # no slab above these+wall_hex = plan.get("wall_color") # "#rrggbb" picked on the review page (sRGB); absent = lib's warm white+if wall_hex: # Blender colour values are linear: undo the sRGB curve+ MATS["wall"].node_tree.nodes["Principled BSDF"].inputs["Base Color"].default_value = (*[+ v / 12.92 if v <= 0.04045 else ((v + 0.055) / 1.055) ** 2.4 for v in (int(wall_hex[i:i + 2], 16) / 255 for i in (1, 3, 5))], 1)# ------------------------------------------------------------------ helpers@@ -483,7 +487,7 @@ for k, f in enumerate(floors):fl = {}well = [(*stair_box_prev, -9, 99)] if stair_box_prev else []for zn in f["rooms"]:- m = FLOOR_MAT.get(zn["type"], "tile")+ m = zn.get("floor") or FLOOR_MAT.get(zn["type"], "tile") # a finish chosen on the review page winsfl.setdefault(m, []).extend((*b[:4], -0.02, 0.0, m) for r in zn["rects"] for b in subtract_all([(*r, -0.02, 0.0)], well))for m, bs in fl.items():mesh_from_boxes(f"floor_{k}_{m}", bs)diff --git a/server.py b/server.pyindex 6fd9918..2b500b8 100644--- a/server.py+++ b/server.py@@ -22,6 +22,7 @@ os.makedirs(JOBS, exist_ok=True)builds = queue.Queue()lock = threading.RLock() # reentrant: request handlers hold it around status() to check and set a stage in one stepBUSY = ("uploaded", "detecting", "queued", "building")+FINISHES = ("marble", "wood", "tile", "bathtile", "terracotta", "concrete") # room.floor: blender/lib.py materials, as in edit.js FINISHTYPES = {".html": "text/html; charset=utf-8", ".js": "text/javascript", ".css": "text/css", ".json": "application/json",".png": "image/png", ".jpg": "image/jpeg", ".webp": "image/webp", ".glb": "model/gltf-binary",".wasm": "application/wasm", ".svg": "image/svg+xml", ".pdf": "application/pdf", ".hdr": "application/octet-stream",@@ -393,6 +394,14 @@ class H(BaseHTTPRequestHandler):if what == "plan":if not isinstance(req.get("floors"), list) or not req["floors"]:return self.send(400, {"error": "invalid plan"})+ # both go to Blender as material names / colours: only values it knows+ rooms = [z for f in req["floors"] if isinstance(f, dict) and isinstance(f.get("rooms"), list)+ for z in f["rooms"] if isinstance(z, dict)]+ if any("floor" in z and z["floor"] not in FINISHES for z in rooms):+ return self.send(400, {"error": "Unknown floor finish."})+ wall = req.get("wall_color")+ if "wall_color" in req and not (isinstance(wall, str) and re.fullmatch(r"#[0-9a-fA-F]{6}", wall)):+ return self.send(400, {"error": "Wall colour must look like #rrggbb."})with open(os.path.join(jdir(jid), "plan.json"), "w") as fh:json.dump(req, fh)return self.send(200, {"ok": True})diff --git a/tests/test_server.py b/tests/test_server.pyindex 6b2d201..c752499 100644--- a/tests/test_server.py+++ b/tests/test_server.py@@ -42,9 +42,17 @@ try:assert call("POST", f"/api/jobs/{done}/plan", b"not json")[0] == 400assert call("POST", f"/api/jobs/{done}/plan", b'{"floors": [{"name": "G"}]}')[0] == 200assert json.load(open(os.path.join(server.jdir(done), "plan.json")))["floors"][0]["name"] == "G"+ # room finishes and wall colour reach Blender as material names and colours: only known values pass+ plan = lambda room, **kw: json.dumps({"floors": [{"rooms": [room]}], **kw}).encode()+ for bad in (plan({"floor": "lava"}), plan({"floor": ["wood"]}), plan({}, wall_color="red"), plan({}, wall_color="#12345g"),+ plan({}, wall_color="#123456\n"), plan({}, wall_color=None)):+ assert call("POST", f"/api/jobs/{done}/plan", bad)[0] == 400, bad+ assert call("POST", f"/api/jobs/{done}/plan", plan({"floor": "wood"}, wall_color="#C3cdb4"))[0] == 200+ saved = json.load(open(os.path.join(server.jdir(done), "plan.json")))+ assert saved["floors"][0]["rooms"][0]["floor"] == "wood" and saved["wall_color"] == "#C3cdb4"assert call("POST", f"/api/jobs/{done}/export")[0] == 400 # nothing built yetassert call("DELETE", f"/api/jobs/{done}")[0] == 200 and not os.path.exists(server.jdir(done))- print("ok server: hidden files, busy plans, bad bodies")+ print("ok server: hidden files, busy plans, bad bodies, room finishes")# a title sheet with no drawing before the plan: the plan on page 2 is found, and its page is the one drawncover = os.path.join(server.JOBS, "cover.pdf")diff --git a/web/edit.html b/web/edit.htmlindex 65e4bb4..5eed29d 100644--- a/web/edit.html+++ b/web/edit.html@@ -21,6 +21,9 @@.tools button.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 15%, transparent); }.row { display: flex; gap: 8px; align-items: center; justify-content: space-between; }select, input[type=text], input[type=number] { background: var(--bg); color: var(--ink); border: 1px solid var(--line); border-radius: 6px; padding: 5px 7px; }+ .sw { width: 26px; height: 26px; border-radius: 50%; border: 1px solid var(--line); cursor: pointer; padding: 0; }+ .sw.on { outline: 2px solid var(--accent); outline-offset: 2px; }+ #wc { width: 34px; height: 28px; padding: 0; border: 1px solid var(--line); border-radius: 6px; background: transparent; cursor: pointer; }.legend span { display: inline-flex; align-items: center; gap: 4px; margin-right: 10px; font-size: 12px; }.legend i { width: 12px; height: 8px; display: inline-block; border-radius: 2px; }#bfun { color: var(--accent); font-weight: 600; margin: 10px 0 0; display: flex; align-items: center; }@@ -77,6 +80,17 @@<div class="row"><span>Name</span><input type="text" id="fname" style="width:150px"></div><div class="row" style="margin-top:6px"><span>Ceiling height (ft)</span><input type="number" id="fh" min="8" max="14" step="0.5" style="width:70px"></div></div>+ <div>+ <h3>Wall paint</h3>+ <div class="row" id="paint" style="margin-top:6px">+ <button class="sw" data-c="#efe7da" title="Warm white" aria-label="Warm white"></button>+ <button class="sw" data-c="#dcdcd8" title="Light grey" aria-label="Light grey"></button>+ <button class="sw" data-c="#c3cdb4" title="Sage" aria-label="Sage"></button>+ <button class="sw" data-c="#e2d0b0" title="Sand" aria-label="Sand"></button>+ <button class="sw" data-c="#cddbe6" title="Pale blue" aria-label="Pale blue"></button>+ <input type="color" id="wc" title="Any colour" aria-label="Wall colour">+ </div>+ </div><div class="legend"><span><i style="background:#e53935"></i>wall</span><span><i style="background:#d81bd8"></i>low wall</span><span><i style="background:#2e9d3a"></i>door</span><span><i style="background:#1e6fe0"></i>window</span>diff --git a/web/edit.js b/web/edit.jsindex 6f75960..4a06a22 100644--- a/web/edit.js+++ b/web/edit.js@@ -7,6 +7,10 @@ const TYPES = ['bedroom', 'toilet', 'kitchen', 'living', 'dining', 'puja', 'washconst ZCOL = { bedroom: '#c8a2c8', toilet: '#8fc7e8', kitchen: '#f2c48d', living: '#e9d48a', dining: '#e7b7a0', puja: '#f0a0a0',wash: '#a8d5c2', store: '#bbb', study: '#b8c9a0', passage: '#d9d2c3', balcony: '#b6dfa0', garden: '#7fc97f', open: '#9fd8d0',parking: '#c9c9d6', yard: '#cfe6b8', stair: '#c49a6c', room: '#dcdcdc', duct: '#999', dress: '#e3d2b8' };+// room.floor: material names in blender/lib.py (server.py FINISHES checks them); no value = by room type+const FINISH = { '': 'Auto (by room type)', marble: 'Marble', wood: 'Wood', tile: 'Tiles', bathtile: 'Bathroom tiles',+ terracotta: 'Terracotta', concrete: 'Concrete' };+const WALL = '#efe7da'; // lib.py's warm white in sRGB: choosing it drops plan.wall_color, so the build is as beforeconst D = 100 / 72; // page image px per PDF pointlet plan, fi = 0, sel = null, tool = 'select', img = {}, history = [];let view = { k: 10, ox: 40, oy: 600 };@@ -133,7 +137,7 @@ function drawFloor(f, dx, dy, active) {if ((r[1] - r[0]) * view.k < 30) return;const [x, y] = toC((r[0] + r[1]) / 2, (r[2] + r[3]) / 2);g.fillStyle = '#111';- g.fillText(z.type, x, y);+ g.fillText(z.floor ? `${z.type} · ${(FINISH[z.floor] || z.floor).toLowerCase()}` : z.type, x, y);});g.globalAlpha = 1;}@@ -162,6 +166,8 @@ function ui() {document.querySelectorAll('#tabs button').forEach((b, i) => b.classList.toggle('on', i === fi));const f = F();$('fname').value = f.name;+ $('wc').value = plan.wall_color || WALL;+ document.querySelectorAll('#paint .sw').forEach((b) => b.classList.toggle('on', b.dataset.c === $('wc').value));const src = f.scale_source || plan.scale_source;$('scale').textContent = `${plan.floors.length} floor${plan.floors.length > 1 ? 's' : ''} · scale ${src === 'labels'? 'read from room sizes' : src === 'user' ? 'set by you' : 'GUESSED - use Set scale'}`;@@ -186,9 +192,12 @@ function ui() {const z = f.rooms[sel.i];h.innerHTML = `<h3>Room</h3><div class="row"><span>Type</span><select id="rt">${TYPES.map((t) => `<option>${t}</option>`).join('')}</select></div><div class="row" style="margin-top:6px"><span>Label</span><input type="text" id="rl" style="width:160px"></div>+ <div class="row" style="margin-top:6px"><span>Floor finish</span><select id="rf">${Object.entries(FINISH)+ .map(([v, t]) => `<option value="${v}">${t}</option>`).join('')}</select></div><p class="muted" style="font-size:12px">${+z.area} sq ft. Furniture follows the type.</p>`;P.appendChild(h);$('rt').value = z.type; $('rt').onchange = (e) => { snapshot(); z.type = e.target.value; draw(); };+ $('rf').value = z.floor || ''; $('rf').onchange = (e) => { snapshot(); if (e.target.value) z.floor = e.target.value; else delete z.floor; draw(); };$('rl').value = z.label || ''; $('rl').oninput = (e) => { z.label = e.target.value; };} else if (sel.kind === 'stair') {h.innerHTML = '<h3>Stair flight</h3>';@@ -202,6 +211,9 @@ function ui() {draw();}$('fname').oninput = (e) => { F().name = e.target.value; document.querySelectorAll('#tabs button')[fi].textContent = e.target.value; };+function paint(c) { if ((plan.wall_color || WALL) === c) return; snapshot(); if (c === WALL) delete plan.wall_color; else plan.wall_color = c; ui(); }+document.querySelectorAll('#paint .sw').forEach((b) => { b.style.background = b.dataset.c; b.onclick = () => paint(b.dataset.c); });+$('wc').onchange = (e) => paint(e.target.value);$('fh').onchange = (e) => { plan.floor_height = Math.max(8, Math.min(14, +e.target.value || 10)); };// ---------------------------------------------------------------- tools