Single place to convert your 2D floor plans to 3d model (no LLM)
Python
Audit fixes: roof stairwell and terrace walking, wall colour save, one GPU job
23f2005639aae9ca0423be
diff --git a/blender/gen.py b/blender/gen.pyindex c65b672..d79e619 100644--- a/blender/gen.py+++ b/blender/gen.py@@ -719,14 +719,19 @@ set_level(top)before = set(bpy.data.objects)bb = bboxes[-1]holes = [(*r, -9, 99) for zn in floors[-1]["rooms"] if zn["type"] in OPEN_SKY for r in zn["rects"]]-# the slab is plaster underneath (the top storey's ceiling) and tiled on top (the terrace)-mesh_from_boxes("roof", [(*b[:4], z0, z1, m) for b in boxes_minus((*bb, -SLAB, 0.0), holes)+# the slab is plaster underneath (the top storey's ceiling) and tiled on top (the terrace); open over the stairs+well = [(*stair_box_prev, -9, 99)] if stair_box_prev else []+mesh_from_boxes("roof", [(*b[:4], z0, z1, m) for b in boxes_minus((*bb, -SLAB, 0.0), holes + well)for z0, z1, m in ((-SLAB, -0.04, "ceiling"), (-0.04, 0.0, "terrace"))])t = 0.33-mesh_from_boxes("parapet", [(*b, "exterior") for b in disjoint(subtract_all([ # (none along open courtyards)+parapet = disjoint(subtract_all([ # (none along open courtyards)(bb[0], bb[1], bb[2], bb[2] + t, 0, 3.5), (bb[0], bb[1], bb[3] - t, bb[3], 0, 3.5),(bb[0], bb[0] + t, bb[2], bb[3], 0, 3.5), (bb[1] - t, bb[1], bb[2], bb[3], 0, 3.5)],- [(h[0] - t, h[1] + t, h[2] - t, h[3] + t, -9, 99) for h in holes]))])+ [(h[0] - t, h[1] + t, h[2] - t, h[3] + t, -9, 99) for h in holes]+ # (none where the stair cabin's own wall stands: the two faces in one place bake black)+ + ([(stair_box_prev[0] - t, stair_box_prev[1] + t, stair_box_prev[2] - t, stair_box_prev[3] + t, -9, 99)] if stair_box_prev else [])))+mesh_from_boxes("parapet", [(*b, "exterior") for b in parapet])+roof_block = parapet + holes # walker on the terrace: the parapet, the cabin and the courtyards stop youif stair_box_prev: # the top storey's stairs reach the roof: a small cabin over them with a doorx0, x1, y0, y1 = stair_box_prevwalls_m = disjoint([(x0 - t, x1 + t, y0 - t, y0, 0, 8), (x0 - t, x1 + t, y1, y1 + t, 0, 8),@@ -736,6 +741,7 @@ if stair_box_prev: # the top storey's stairs reach the roof: a small cabin oveend = q["start"] + q["dir"] * ((q["rect"][1] - q["rect"][0]) if q["axis"] == "x" else (q["rect"][3] - q["rect"][2]))door = (end - 1, end + 1, *q["rect"][2:], -1, 7) if q["axis"] == "x" else (*q["rect"][:2], end - 1, end + 1, -1, 7)walls_m = subtract_all(walls_m, [door])+ roof_block += [b for b in walls_m if b[4] < 1] # (not the lintel over the door)mesh_from_boxes("mumty", [(*b, "exterior") for b in walls_m] + [(x0 - t, x1 + t, y0 - t, y1 + t, 8, 8.5, "slab")])by_floor[NF] = new_objects(before)@@ -803,6 +809,7 @@ for n in FINISHES:shutil.copy(os.path.join(ASSETS, "textures", MATS[n]["tex"], "diff.jpg"), os.path.join(JOB, "finishes", n + ".jpg"))finishes[n] = dict(file=f"finishes/{n}.jpg", tile=MATS[n]["tile"])meta = dict(version=1, floors=META_FLOORS, roof_z=round(top * lib.F, 3), eye=1.6,+ roof=dict(colliders=[[round(v * lib.F, 3) for v in b[:4]] for b in roof_block]),bounds=[round(v * lib.F, 3) for v in (X0, X1, Y0, Y1)], finishes=finishes, **res)with open(os.path.join(JOB, "meta.json"), "w") as fh:json.dump(meta, fh)diff --git a/server.py b/server.pyindex 1146905..56dfb17 100644--- a/server.py+++ b/server.py@@ -55,6 +55,7 @@ def read_status(jid):_blender = None # Blender's version, read once ("" = not found)assets_job = dict(running=False, done=0, total=0, failed=[])export_lock, site_lock = threading.Lock(), threading.Lock() # the site zip takes a second: it must not wait for a Blender pack+gpu = threading.Lock() # a house build and the themes' pictures both render on the GPU: one at a timedef system():@@ -181,10 +182,11 @@ def render_thumbs():os.makedirs(out, exist_ok=True)with open(os.path.join(out, "plan.json"), "w") as fh:json.dump(catalog.preview_plan(tid), fh)- subprocess.run([BLENDER, "-b", "--factory-startup", "-P", os.path.join(HERE, "blender", "gen.py"), "--",- os.path.join(out, "plan.json"), out, "--no-bake"], capture_output=True, timeout=1800)- subprocess.run([BLENDER, "-b", os.path.join(out, "house.blend"), "-P", os.path.join(HERE, "blender", "thumbs.py"),- "--", out], capture_output=True, timeout=900)+ with gpu:+ subprocess.run([BLENDER, "-b", "--factory-startup", "-P", os.path.join(HERE, "blender", "gen.py"), "--",+ os.path.join(out, "plan.json"), out, "--no-bake"], capture_output=True, timeout=1800)+ subprocess.run([BLENDER, "-b", os.path.join(out, "house.blend"), "-P", os.path.join(HERE, "blender", "thumbs.py"),+ "--", out], capture_output=True, timeout=900)if tid not in themes.THEMES and tid not in themes.custom_ids(): # deleted meanwhileshutil.rmtree(out, ignore_errors=True)except Exception:@@ -326,7 +328,7 @@ def builder():status(jid, stage="building", progress=1, message="Starting Blender", started=t0, eta_total=estimate(jid, quality))cmd = [BLENDER, "-b", "--factory-startup", "-P", os.path.join(HERE, "blender", "gen.py"), "--",os.path.join(d, "plan.json"), d, "--quality", quality]- with open(os.path.join(d, "build.log"), "w") as log:+ with gpu, open(os.path.join(d, "build.log"), "w") as log:pr = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True, bufsize=1)watchdog = threading.Timer(BUILD_TIMEOUT, pr.kill) # a hung Blender must not block every later buildwatchdog.start()diff --git a/tests/test_walk.mjs b/tests/test_walk.mjsindex d5c0fea..9d517a7 100644--- a/tests/test_walk.mjs+++ b/tests/test_walk.mjs@@ -45,6 +45,11 @@ meta.floors.forEach((f, k) => {}check(ok, `${f.name}: walked up all ${flights.length} flight(s) without getting stuck (at ${p.x.toFixed(2)}, ${p.y.toFixed(2)})`);check(Math.abs(p.z - target) < 0.05, `${f.name}: arrived at height ${p.z.toFixed(2)} m (next level ${target.toFixed(2)} m)`);+ if (meta.roof && target === meta.roof_z) { // out of the stair cabin's door onto the terrace, straight on+ const s = flights[flights.length - 1];+ const out = goTo(p, s.axis === 'x' ? p.x + s.dir * 1.2 : p.x, s.axis === 'x' ? p.y : p.y + s.dir * 1.2);+ check(out && Math.abs(p.z - meta.roof_z) < 0.01, `${f.name}: walked out of the stair cabin onto the roof (at ${p.x.toFixed(2)}, ${p.y.toFixed(2)})`);+ }});// windows block: walking straight across the middle of each window, from either side, must stop before its glassdiff --git a/web/view.js b/web/view.jsindex 4768dff..1a96308 100644--- a/web/view.js+++ b/web/view.js@@ -325,7 +325,6 @@ function drawMap(lv) {// ---- finishes (F): another wall colour, or another floor for the room you stand in, tried on at once. The light stays// as it was baked for the old finish until the next build; Save puts the choice in the plan for that build.const FIN = { marble: 'Marble', wood: 'Wood', parquet: 'Parquet', tile: 'Tiles', bathtile: 'Bathroom tiles', terracotta: 'Terracotta', concrete: 'Concrete' };-const WALL0 = '#efe7da'; // edit.js WALL: the build's own white, saved as no wall_colorconst finTex = {}, chosen = { floors: {} }; // floors: '<level>_<room index in the plan>' -> finishlet finRoom;const finLoad = (n) => (finTex[n] ||= texLoader.loadAsync(base + meta.finishes[n].file).then((t) => {@@ -376,8 +375,7 @@ $('fsave').onclick = async () => {if (z?.type !== floors[lv].rooms.find((q) => q.i === i).type) throw new Error('The plan was changed after this build: choose floors on the review page.');z.floor = n;}- if (chosen.wall === WALL0) delete plan.wall_color;- else if (chosen.wall) plan.wall_color = chosen.wall;+ if (chosen.wall) plan.wall_color = chosen.wall; // (pinned even if it is the theme's own: you picked it)const r = await fetch(`/api/jobs/${job}/plan`, { method: 'POST', body: JSON.stringify(plan) }), j = await r.json();if (!r.ok) throw new Error(j.error);$('fmsg').textContent = 'Saved. Build again on the review page to bake the light for it.';diff --git a/web/walk.js b/web/walk.jsindex ce448c8..f96fa66 100644--- a/web/walk.js+++ b/web/walk.js@@ -23,8 +23,12 @@ export function levelOf(meta, z) {return lv;}+// what stops you at height z: a storey's walls, or on the terrace the parapet and stair cabin (meta.roof; houses+// built before it had none and use the top storey's walls)+export const blockLevel = (meta, z) => (meta.roof && z >= meta.roof_z - 0.3 ? meta.floors.length : levelOf(meta, z));+export function blockedAt(meta, lv, x, y) {- const f = meta.floors[lv];+ const f = lv === meta.floors.length ? meta.roof : meta.floors[lv];if (!f) return false;for (const rs of [f.colliders, f.windows || []]) for (const r of rs) { // (houses built before windows blocked have no windows)const cx = Math.max(r[0], Math.min(x, r[1])), cy = Math.max(r[2], Math.min(y, r[3]));@@ -73,7 +77,7 @@ export function move(meta, p, dx, dy) {const nx = p.x + ddx, ny = p.y + ddy;const g = groundNear(meta, nx, ny, p.z);if (g === null) continue;- if (blockedAt(meta, levelOf(meta, Math.max(g, p.z) - 0.05), nx, ny)) continue;+ if (blockedAt(meta, blockLevel(meta, Math.max(g, p.z) - 0.05), nx, ny)) continue;p.x = nx; p.y = ny; p.z = g;}return p;