Single place to convert your 2D floor plans to 3d model (no LLM)
Python
Merge #5: automatic tour video
23f2005639b51c1699c5d4
diff --cc README.mdindex 885b3a4,02f8963..bec23f2--- a/README.md+++ b/README.md@@@ -90,10 -88,10 +90,11 @@@ python server.p| **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 || **Top view** (T) | The house from above, one storey at a time |-| **Map** (M) | Room names, stairs, where you stand and look |+| **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 || **Screenshot** (P) | PNG of about 4K size || **Record** (R) | Video of your walk as MP4 (browsers that record WebM are converted on the server; needs ffmpeg) |+ | **Tour** (G) | Walks itself from the entrance through every room and up the stairs, looks around in each, and records it as one video. Any key or click stops it || **Your own furniture** | The Furniture models page shows each item and lets you replace it with your `.glb` model || **Sample plan, delete** | "Try the sample plan" on the home page; every plan in the list has Delete || **Blender file** | The house as one `.blend` with every texture packed inside, in a zip |diff --cc web/view.htmlindex 1fe83f6,6c43013..f99e174--- a/web/view.html+++ b/web/view.html@@@ -45,12 -43,12 +45,12 @@@<h1>3D walkthrough</h1><p id="status">Loading…</p><p class="desk"><kbd>W A S D</kbd> walk · <kbd>Mouse</kbd> look · <kbd>Shift</kbd> run · <kbd>T</kbd> top view · <kbd>Esc</kbd> pause</p>- <p class="desk"><kbd>P</kbd> screenshot · <kbd>R</kbd> start / stop recording · <kbd>M</kbd> map · <kbd>N</kbd> measure</p>- <p class="desk"><kbd>P</kbd> screenshot · <kbd>R</kbd> start / stop recording · <kbd>M</kbd> map · <kbd>G</kbd> guided tour (recorded)</p>++ <p class="desk"><kbd>P</kbd> screenshot · <kbd>R</kbd> start / stop recording · <kbd>M</kbd> map · <kbd>N</kbd> measure · <kbd>G</kbd> guided tour (recorded)</p><p class="touch">Left thumb: move · right thumb: look</p></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="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="blend" title="Download this house as a Blender file (.zip)">Blender file</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="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><a href="/" id="newplan" style="color:#ccc;font-size:13px">Home</a><span id="fps"></span></div>-<script type="module" src="/web/view.js"></script>++<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="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="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>+<script type="module" src="view.js"></script></body></html>diff --cc web/view.jsindex 937efe9,eb4a326..12eba70--- a/web/view.js+++ b/web/view.js@@@ -92,9 -91,11 +92,11 @@@ function roomAt(lv, x, y)// ---- playerconst p = { ...walk.entrance(meta), z: floors[0].z, yaw: 0, pitch: 0 };const keys = {};-let locked = false, topView = false;+let locked = false, topView = false, measuring = false;addEventListener('keydown', (e) => {+ if (tour) { if (!e.repeat) stopTour(); return; } // any key ends the tour (a held G only repeats)keys[e.code] = true;+ if (e.code === 'KeyG' && !e.repeat) startTour();if (e.code === 'KeyT') toggleTop();if (e.code === 'KeyP' && !e.repeat) screenshot();if (e.code === 'KeyR' && !e.repeat) toggleRec();@@@ -113,12 -110,13 +115,13 @@@ $('overlay').addEventListener('click',});document.addEventListener('pointerlockchange', () => {locked = document.pointerLockElement === canvas;- $('overlay').style.display = locked || topView || measuring ? 'none' : 'flex';- $('overlay').style.display = locked || topView || tour ? 'none' : 'flex';++ $('overlay').style.display = locked || topView || measuring || tour ? 'none' : 'flex';+ if (locked && tour) document.exitPointerLock(); // (a lock asked for by leaving the top view lands late)});// the browser refused to capture the mouse: show the start screen, whose click captures it- document.addEventListener('pointerlockerror', () => { if (!topView && !measuring) $('overlay').style.display = 'flex'; });-document.addEventListener('pointerlockerror', () => { if (!topView) $('overlay').style.display = 'flex'; });++document.addEventListener('pointerlockerror', () => { if (!topView && !measuring && !tour) $('overlay').style.display = 'flex'; });addEventListener('mousemove', (e) => {- if (!locked && !(measuring && !topView && e.buttons)) return; // measuring frees the mouse: drag to look instead- if (!locked || tour) return;++ if (tour || (!locked && !(measuring && !topView && e.buttons))) return; // measuring frees the mouse: drag to look insteadp.yaw -= e.movementX * 0.0022;p.pitch = Math.max(-1.4, Math.min(1.4, p.pitch - e.movementY * 0.0022));});@@@ -362,6 -298,67 +365,68 @@@ function toggleRec()$('rec').classList.add('live');label();}+ // ---- automatic tour (G): the route of walk.tourRoute, stepped like its test, recorded as one video+ const LOOK = 5; // seconds of looking around in each room+ let tour = null, route = null;+ function startTour() {++ if (measuring) setMeasure(false); // the tape would be filmed+ if (topView) toggleTop();+ route ||= walk.tourRoute(meta); // it depends on the house only+ if (route.length < 2) return;+ document.exitPointerLock?.(); // the mouse would fight the camera+ $('overlay').style.display = 'none';+ Object.assign(p, { x: route[0].x, y: route[0].y, z: route[0].z, pitch: 0 });+ tour = { route, i: 0, n: 0, budget: 0, look: -1, yaw: 0, cam: null, rec: !rec };+ if (tour.rec) toggleRec();+ $('tour').textContent = 'Stop tour';+ $('tour').classList.add('live');+ }+ function stopTour() {+ if (!tour) return;+ if (tour.rec && rec) toggleRec(); // stopping saves the video+ tour = null;+ $('tour').textContent = 'Tour';+ $('tour').classList.remove('live');+ $('overlay').style.display = locked || topView ? 'none' : 'flex';+ }+ function tourStep(dt) {+ const w = tour.route[tour.i];+ tour.cam = null;+ if (tour.look >= 0) { // pan left, right and back to the heading, like tools/tour.py films it+ const t = Math.min(1, tour.look += dt / LOOK);+ p.yaw = tour.yaw + 1.2 * Math.sin(2 * Math.PI * t * t * (3 - 2 * t));+ if (t === 1) { tour.look = -1; if (++tour.i === tour.route.length) stopTour(); }+ return;+ }+ const head = Math.atan2(p.x - w.x, w.y - p.y), turn = Math.atan2(Math.sin(head - p.yaw), Math.cos(head - p.yaw)); // shortest way round+ p.yaw += turn * Math.min(1, 3 * dt); // eased turn towards the next waypoint+ p.pitch *= 1 - Math.min(1, 3 * dt);+ tour.budget += WALK * dt * Math.max(0, Math.cos(turn)); // slow down while turning; stand still to turn around+ for (; tour.budget >= walk.SUB; tour.budget -= walk.SUB) {+ if (Math.hypot(w.x - p.x, w.y - p.y) < 0.03) break;+ const bx = p.x, by = p.y;+ walk.stepTo(meta, p, w.x, w.y);+ // shortcut: a stuck (or endlessly sliding) walker hops to the waypoint so the recording cannot run forever;+ // tests/test_walk.mjs fails a route where that would happen+ if ((p.x === bx && p.y === by) || ++tour.n > 2000) Object.assign(p, { x: w.x, y: w.y, z: w.z });+ }+ const d = Math.hypot(w.x - p.x, w.y - p.y);+ if (d < 0.03) { // arrived: start the next leg exactly where the planner did+ Object.assign(p, { x: w.x, y: w.y, z: w.z });+ tour.budget = tour.n = 0;+ if (w.room) { tour.look = 0; tour.yaw = p.yaw; } else tour.i++;+ return;+ }+ // whole steps keep the walk exact; show the part of a step not yet taken so the camera glides+ const r = Math.min(tour.budget, d) / d;+ tour.cam = [p.x + (w.x - p.x) * r, p.y + (w.y - p.y) * r];+ }+ $('tour').onclick = startTour;+ // a click or touch ends the tour, and does nothing else (a click on Record must not start a second video)+ let eat = false;+ addEventListener('pointerdown', () => { eat = !!tour; stopTour(); }, true);+ addEventListener('click', (e) => { if (eat) { eat = false; e.stopPropagation(); } }, true);+$('blend').onclick = async () => { // the server packs the textures into one .blend (a few seconds, once per build)const b = $('blend');b.disabled = true;