Single place to convert your 2D floor plans to 3d model (no LLM)
Python
VR mode (WebXR) in the walkthrough; windows now stop the walker
23f20056395e1dca8fe48c
diff --git a/README.md b/README.mdindex 2a9c936..e1a3364 100644--- a/README.md+++ b/README.md@@ -91,6 +91,7 @@ python server.py| **Move your furniture** | The **Furniture** tool on the review page shows each item: drag to move, turn it 90°, delete it, or add one from the list || **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 |+| **VR headset** | On a headset (Meta Quest and others with WebXR) the **VR** button shows up: the left stick walks where you look, the right stick turns in 30° steps, and your real height and head moves are used. Same walls and stairs as on screen. The browser allows VR only on `https://` pages or `localhost`: put the **Website** zip on any https host, or on a Quest over USB run `adb reverse tcp:8080 tcp:8080` and open `http://localhost:8080` || **Top view** (T) | The house from above, one storey at a time || **Map** (M) | Room names, stairs, where you stand and look; the big map adds each room's size and area || **Measure** (N) | Click or tap two points on the house for the distance in metres and feet-inches (drag to look around meanwhile); works in top view too. The line and label are drawn in the 3D view, so screenshots and recordings show them |@@ -155,7 +156,7 @@ sequenceDiagram```html<iframe src="https://your-planto3d-host/web/view.html?job=JOB_ID&embed"- style="width:100%;aspect-ratio:16/9;border:0" allow="fullscreen"></iframe>+ style="width:100%;aspect-ratio:16/9;border:0" allow="fullscreen; xr-spatial-tracking"></iframe>```[`examples/embed.html`](examples/embed.html) is a complete working page: upload, build, show.@@ -228,6 +229,7 @@ GitHub Actions runs `tests/run_all.sh` on every push to `main` and every pull re## Limits- **Vector PDFs only.** Scans, photos and images are refused.+- **VR** was tested with a simulated headset in Chromium, not on real hardware yet.- **Axis-aligned walls.** Slanted and curved walls are not detected; draw them on the review page.- **Labels in English**, sizes in feet and inches. Without size labels the scale is a guess and must be set on the review page.- **Wall groups.** If the drawing's walls fall into groups whose outlines do not overlap, the detector reads them as separate plans and can drop a part of the house.diff --git a/blender/gen.py b/blender/gen.pyindex 75c71a3..f7edc8f 100644--- a/blender/gen.py+++ b/blender/gen.py@@ -531,6 +531,7 @@ for k, f in enumerate(floors):name=f.get("name", f"Floor {k}"), z=round(z * F_, 3), height=round(H * F_, 3),colliders=[m(b) for b in subtract_all([(*w[:4], 0, 1) for w in f["walls"]],[(c[0], c[1], c[2], c[3], 0, 1) for c in cuts if c[4] < 1])],+ windows=[m(c) for c in cuts if c[4] >= 1], # gaps between the walls too, but with glass: they block like wallsrooms=[dict(label=zn.get("label") or zn["type"].title(), type=zn["type"], rects=[m(r) for r in zn["rects"]], i=i,**({"floor": MATS[f"floor_{k}_{i}"]["finish"]} if f"floor_{k}_{i}" in MATS else {}))for i, zn in enumerate(f["rooms"]) if zn["type"] not in ("duct",)],diff --git a/examples/embed.html b/examples/embed.htmlindex 517f463..7b6341c 100644--- a/examples/embed.html+++ b/examples/embed.html@@ -13,7 +13,7 @@</style><h1>Your site + PlanTo3D</h1><p><input type="file" id="file" accept="application/pdf"> <span id="state">Choose a CAD-exported plan PDF (try sample_plan.pdf).</span></p>-<iframe id="tour" hidden allow="fullscreen" title="3D walkthrough"></iframe>+<iframe id="tour" hidden allow="fullscreen; xr-spatial-tracking" title="3D walkthrough"></iframe><script>const SERVER = 'http://127.0.0.1:8080'; // where PlanTo3D runsconst say = (t) => { document.getElementById('state').textContent = t; };diff --git a/tests/test_walk.mjs b/tests/test_walk.mjsindex 092e667..d5c0fea 100644--- a/tests/test_walk.mjs+++ b/tests/test_walk.mjs@@ -47,6 +47,18 @@ meta.floors.forEach((f, k) => {check(Math.abs(p.z - target) < 0.05, `${f.name}: arrived at height ${p.z.toFixed(2)} m (next level ${target.toFixed(2)} m)`);});+// windows block: walking straight across the middle of each window, from either side, must stop before its glass+meta.floors.forEach((f) => (f.windows || []).forEach((r) => {+ const ax = r[1] - r[0] > r[3] - r[2] ? 'y' : 'x', c = ax === 'y' ? (r[2] + r[3]) / 2 : (r[0] + r[1]) / 2;+ for (const side of [-1, 1]) {+ const p = ax === 'y' ? { x: (r[0] + r[1]) / 2, y: c + side, z: f.z } : { x: c + side, y: (r[2] + r[3]) / 2, z: f.z };+ if (walk.groundNear(meta, p.x, p.y, p.z) === null || walk.blockedAt(meta, walk.levelOf(meta, f.z), p.x, p.y)) continue;+ goTo(p, ax === 'y' ? p.x : c - side, ax === 'y' ? c - side : p.y);+ const at = ax === 'y' ? p.y : p.x;+ check(Math.sign(at - c) === side, `${f.name}: window at ${ax}=${c.toFixed(2)} stopped the walker at ${at.toFixed(2)}`);+ }+}));+// walls block: walking straight at the first collider of the ground floor must stop before itconst w = meta.floors[0].colliders.find((r) => r[1] - r[0] > 2);if (w) {diff --git a/web/view.html b/web/view.htmlindex 396f7ed..03758a0 100644--- a/web/view.html+++ b/web/view.html@@ -57,7 +57,7 @@</div><div id="room"></div><div id="cross"></div>-<div id="bar"><button id="topbtn">Top view</button><span id="floors"></span><button id="measure" title="Measure a distance: click two points (N)">Measure</button><button id="finbtn" title="Try another wall colour, or another floor in this room (F)">Finishes</button><button id="shot" title="Save a picture of this view (P)">Screenshot</button><button id="rec" title="Record a video of your walk (R)">Record</button><button id="tour" title="Walk through every room by itself and record it as a video where this browser can record (G); any key or click stops">Tour</button><button id="blend" title="Download this house as a Blender file (.zip)">Blender file</button><button id="qty" title="Floor areas, wall paint and tiles, doors, windows and furniture of this plan">Quantities</button><button id="site" title="Download this walkthrough as a website for any web host (.zip)">Website</button><a href="/" id="newplan" style="color:#ccc;font-size:13px">Home</a><span id="fps"></span></div>+<div id="bar"><button id="topbtn">Top view</button><span id="floors"></span><button id="measure" title="Measure a distance: click two points (N)">Measure</button><button id="vr" hidden title="Walk through in a VR headset: left stick walks, right stick turns">VR</button><button id="finbtn" title="Try another wall colour, or another floor in this room (F)">Finishes</button><button id="shot" title="Save a picture of this view (P)">Screenshot</button><button id="rec" title="Record a video of your walk (R)">Record</button><button id="tour" title="Walk through every room by itself and record it as a video where this browser can record (G); any key or click stops">Tour</button><button id="blend" title="Download this house as a Blender file (.zip)">Blender file</button><button id="qty" title="Floor areas, wall paint and tiles, doors, windows and furniture of this plan">Quantities</button><button id="site" title="Download this walkthrough as a website for any web host (.zip)">Website</button><a href="/" id="newplan" style="color:#ccc;font-size:13px">Home</a><span id="fps"></span></div><div id="fin" hidden><div class="r" id="fwrow"><span>Wall colour</span><input type="color" id="fwall"></div><div class="r" id="frow" hidden><span>Floor · <b id="froom"></b></span><select id="ffloor"></select></div>diff --git a/web/view.js b/web/view.jsindex fadde9b..7ae83ff 100644--- a/web/view.js+++ b/web/view.js@@ -384,6 +384,45 @@ $('fsave').onclick = async () => {} catch (e) { $('fmsg').textContent = e.message || 'Could not save.'; }};+// ---- VR (WebXR): on a headset the left stick walks where you look, the right stick turns in steps. The camera rides+// on a rig standing at your feet (same walls and stairs as on screen); the headset adds your real height and head moves.+renderer.xr.enabled = true;+const rig = new THREE.Group();+scene.add(rig);+let vrTurn = 0; // the right stick must come back to the middle before the next step+renderer.xr.addEventListener('sessionstart', () => {+ if (tour) stopTour();+ if (topView) toggleTop();+ if (measuring) setMeasure(false);+ if (finishing) setFinish(false);+ rig.add(camera);+ $('vr').textContent = 'Exit VR';+});+renderer.xr.addEventListener('sessionend', () => { rig.remove(camera); $('vr').textContent = 'VR'; });+navigator.xr?.isSessionSupported('immersive-vr').then((ok) => { $('vr').hidden = !ok; }, () => {});+$('vr').onclick = async () => {+ const s = renderer.xr.getSession();+ if (s) return s.end();+ try {+ await renderer.xr.setSession(await navigator.xr.requestSession('immersive-vr', { optionalFeatures: ['local-floor'] }));+ } catch (e) { alert(`Could not start VR: ${e.message}`); }+};+function vrStep(dt) {+ for (const src of renderer.xr.getSession().inputSources) {+ const a = src.gamepad?.axes;+ if (!a || a.length < 4) continue;+ const [x, y] = [a[2], a[3]]; // thumbstick (xr-standard mapping)+ if (src.handedness === 'right') {+ if (Math.abs(x) < 0.3) vrTurn = 0;+ else if (!vrTurn) { vrTurn = Math.sign(x); p.yaw -= vrTurn * Math.PI / 6; }+ } else if (Math.hypot(x, y) > 0.15) {+ const d = camera.getWorldDirection(new THREE.Vector3()); // the headset pose on the rig (the XR camera itself lacks the rig turn here)+ const n = Math.hypot(d.x, d.z) || 1, fx = d.x / n, fy = -d.z / n, k = WALK * dt; // where you look, flat (plan axes)+ walk.move(meta, p, (fx * -y + fy * x) * k, (fy * -y - fx * x) * k); // stick up = forward, right = step right+ }+ }+}+// ---- screenshot (P) and video recording (R): the 3D view only, without the buttons and labelsfunction save(blob, ext) {const a = document.createElement('a');@@ -436,6 +475,7 @@ function toggleRec() {const LOOK = 5; // seconds of looking around in each roomlet tour = null, route = null;function startTour() {+ if (renderer.xr.isPresenting) return; // a camera turned for you in a headset makes people sickif (measuring) setMeasure(false); // the tape would be filmedif (topView) toggleTop();route ||= walk.tourRoute(meta); // it depends on the house only@@ -537,6 +577,8 @@ renderer.setAnimationLoop(() => {const raw = clock.getDelta(), dt = Math.min(raw, 0.05);frames++; fpsT += raw;if (fpsT > 0.5) { $('fps').textContent = `${Math.round(frames / fpsT)} fps`; frames = 0; fpsT = 0; }+ const vr = renderer.xr.isPresenting;+ if (vr) vrStep(dt);if (!topView && tour) tourStep(dt);if (!topView && !tour) {const sp = (keys.ShiftLeft || keys.ShiftRight ? RUN : WALK) * dt;@@ -557,7 +599,10 @@ renderer.setAnimationLoop(() => {walk.move(meta, p, dx, dy);}}- if (!topView) {+ if (vr) {+ rig.position.copy(W(p.x, p.y, p.z));+ rig.rotation.y = p.yaw;+ } else if (!topView) {const [cx, cy] = tour?.cam || [p.x, p.y];camera.position.copy(W(cx, cy, p.z + meta.eye));camera.rotation.set(0, 0, 0);diff --git a/web/walk.js b/web/walk.jsindex b9ac876..ce448c8 100644--- a/web/walk.js+++ b/web/walk.js@@ -26,7 +26,7 @@ export function levelOf(meta, z) {export function blockedAt(meta, lv, x, y) {const f = meta.floors[lv];if (!f) return false;- for (const r of f.colliders) {+ 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]));if ((x - cx) ** 2 + (y - cy) ** 2 < RADIUS * RADIUS) return true;}