I have been building Plan Your Layout, a floor plan editor that runs entirely in the browser. You draw walls, drop in furniture at real sizes, look at it in 3D, print it to scale or export DXF. It is free, there is no account and no watermark, and your plans stay in localStorage on your own device.

This post is not a feature list. It is about the parts that were interesting to build, and a few decisions that went the other way.

The 2D plan editor

The stack: deliberately boring

  • Vanilla JavaScript ES modules. No framework.
  • The UI is template strings plus one delegated click handler. Every button carries a data-act="…", and a single table of actions in main.js handles them. Property edits use data-set / data-k and go through one applyProp function.
  • Canvas 2D for the plan, three.js for 3D, jsPDF for PDFs, Vite to build.
document.addEventListener('click', (e) => { const el = e.target.closest('[data-act]'); if (el) ACT[el.dataset.act]?.(el, e); }); 

That is roughly the whole "framework". With a few hundred buttons across panels, menus and modals, it has held up better than I expected: re-rendering a panel is just replacing its innerHTML, and nothing needs to be re-bound.

Rooms are never stored

This is the decision that shaped everything else. A plan stores walls, not rooms. Rooms are detected from closed wall loops on every change.

Why? Because users edit walls. If rooms were stored, every wall drag, split or delete would have to keep a separate list of polygons in sync, and that breaks in all the ways you can imagine. If rooms are derived, they are always right.

The detection is classic planar-graph face finding:

  1. Split walls at every junction and crossing, so each piece of wall is an edge between two nodes.
  2. Build a graph, merging nodes that share a position, and prune dead ends repeatedly (a wall sticking into a room does not close anything).
  3. Walk the faces with half-edges: every edge becomes two directed half-edges; at each node the outgoing half-edges are sorted by angle; from each half-edge you take the next one clockwise at its end node until you are back where you started.
// at each node, outgoing half-edges sorted by angle for (const n of nodes.values()) n.out.sort((a, b) => a.ang - b.ang); for (const h of half) { if (h.done) continue; const loop = []; let cur = h; while (!cur.done) { cur.done = true; loop.push(cur); const out = cur.to.out, i = out.indexOf(cur.twin); cur = out[(i - 1 + out.length) % out.length]; // next edge, turning the same way every time } // signed area > 0: a room; < 0: the outer boundary of a building } 

The sign of the polygon area tells you which faces are rooms and which one is the outside of the building (that outline is reused later for roofs and wall trim). Collinear vertices get merged, and the polygon is inset by half of each wall's thickness to get the inner floor area.

Then the obvious question: if rooms are recomputed all the time, where do their names and floor finishes live? In a roomMeta list, each entry with an anchor point. After detection, each room claims the metadata whose anchor lies inside its polygon, and the anchor moves to the room's label position. Split a room in two and one half keeps the name; delete a wall between two rooms and one name survives. It behaves the way people expect without any bookkeeping in the wall tools.

The result is cached on a revision counter, so the detection only runs when something actually changed.

One plan, many drawings

Everything else is a projection of the same data:

  • 3D: plan x → three.js X, plan y → Z. Walls are extruded with real holes for openings. A window can be round, arched or triangular; the wall keeps a rectangular hole and a wall-coloured plate fills everything outside the shape, which was far simpler than boolean geometry.
  • Elevations, sections and interior wall views are drawn on canvas from the same walls and openings.
  • Sheets (A4/A3 with a title block), PDF to scale at 1:50, 1:100 or 1:200, SVG, DXF for CAD programs and GLB for 3D tools.

3D view of a house with the roof off

A few things in 3D that took longer than they look:

  • Gable roofs over L, T and U outlines. The stored roof keeps its outline; when the 3D view is built, a right-angled outline is split into rectangles and each wing gets its own gable roof.
  • Dormers sample the roof surface across their width and return the strips the roof mesh has to lose.
  • Curved walls are chains of short segments that share an arc id, so every tool treats them as one wall.

Surfaces as strings

Any paintable surface (a wall face, a floor, a roof, a part of a sofa) holds a single string:

Value Meaning
#aabbcc a colour
tex:<id> a procedural texture painted on a canvas
pho:<id> a CC0 photo texture (232 of them)
img:<id> an image you uploaded, shrunk to a small JPEG data URL in the plan

Three helpers turn that string into what each renderer needs: a three.js material (surf()), a canvas pattern for elevations (surfFill()) and a flat colour for the plan (surfColor()). Adding a new kind of surface means touching three functions, not every renderer.

Procedural furniture, real models on demand

The symbol library has about 600 items, and each one has a procedural 2D drawing and a procedural 3D shape. For about 100 of them there is also a detailed CC0 model (glTF), loaded only when the 3D view needs it. Until it arrives, or when the item has been resized beyond what the model can stretch to, the procedural shape stays. A wide item like a wardrobe or a run of cabinets is tiled from several modules instead of being stretched.

On touch devices detailed models are off by default; the procedural ones are cheap and look consistent.

A kitchen whose doors open

The Kitchen Builder is a separate full-screen wizard with its own three.js scene. Cabinets are hollow carcasses, and every door, drawer and appliance door is registered as a leaf with a type: hinge, slide, drop or flap. Clicking a front toggles its target in K.open, and the animation loop eases each leaf towards its target.

Kitchen Builder

Once fronts move, you can check them: findClashes reports an open dishwasher that hits the island, or a door that swings into a wall. That planning check is the most useful part of the builder, and it only exists because the doors are real geometry instead of a picture.

When you add the kitchen to the plan, it becomes ordinary furniture items. Their doors do not open in the main 3D view. That is a known limit.

What I tried and dropped: path tracing

I wanted the "Render" button to produce a path-traced image, so I tried three-gpu-pathtracer. On a fast GPU it is lovely. On a weak one (the machine I build on has an old Radeon), a single frame ran for tens of seconds, the WebGL context was lost even with small tiles, and Chrome then refused WebGL until a restart.

A free tool that can crash someone's browser is worse than one with plainer pictures, so it went out. "Render" is a high-resolution three.js still. The better route for everyone is cheaper: normal and roughness maps, a sky, softer shadows.

No backend for your plans

There is a small PHP backend, but it never sees a plan. Plans are saved to localStorage automatically, with a version history in the browser. You can also save a .json plan file or share a link that carries the plan.

The backend handles the feedback form, error reports from the editor and anonymous daily counts. A few rules I set for it:

  • No cookies for visitors. The only cookie is the admin session.
  • IP addresses are never stored. A visitor of the day is an HMAC of IP and user agent, keyed by a secret and the date, and kept only for that day. It can count unique visitors today; it cannot link today to tomorrow.
  • Country comes from the browser's time zone, not IP geolocation.
  • Page views go out with sendBeacon. A page never GETs a PHP URL, because the host's cache adds a cookie to PHP responses fetched with GET; the public plan counter is a static stats.json rewritten by the server.

These are small things, but "no account" only means something if the rest of the site behaves the same way.

Things I would tell myself at the start

  • Derive, don't store. Rooms, outlines, areas, roof wings: everything computed from walls is one less thing to keep in sync.
  • One string per surface saved me from a matrix of "material type × renderer" branches.
  • A delegated click handler scales further than you think when the UI is mostly panels and buttons.
  • Test on weak hardware. The path tracer worked fine until it met an ordinary computer.
  • Touch needs one fake hover. A finger does not hover, so on touch the pointer-down handler runs the move handler once before handling the tap. Everything that depends on hover state (which wall a door snaps to, for example) started working on phones after that one line.

Try it

I would like to hear what breaks, what is missing and how you would have solved room detection. The feedback button in the editor goes straight to me.