IKEA assembly, step by step: animated, manual-style 3D guides. Scan any paper manual with Together AI.
TypeScript
Draw gateleg tables
Youssef36aafe87b02b
diff --git a/scripts/ikea/build.ts b/scripts/ikea/build.tsindex b7df22f..01696df 100644--- a/scripts/ikea/build.ts+++ b/scripts/ikea/build.ts@@ -59,7 +59,7 @@ function hints(family: string, kind: Kind): Hint | undefined {/* ---------- matching against hand made entries ---------- */-const LATER_KINDS = new Set<Kind>(["office", "chaise", "corner", "cot", "bunk", "loft", "dropleaf", "daybed", "mixed", "sliding", "slidecab", "bookrow", "cabrow", "section"]);+const LATER_KINDS = new Set<Kind>(["office", "chaise", "corner", "cot", "bunk", "loft", "dropleaf", "daybed", "mixed", "sliding", "slidecab", "bookrow", "cabrow", "section", "gateleg"]);function baseMatch(name: string, draw: Draw): CatalogEntry | undefined {const fam = fold(name);diff --git a/scripts/ikea/check.ts b/scripts/ikea/check.tsindex f50fb23..4037644 100644--- a/scripts/ikea/check.ts+++ b/scripts/ikea/check.ts@@ -112,6 +112,7 @@ async function main() {// a row of frames when asked for, the single frame otherwiseexpect("billy bookcase combination", "billy-bookcase-160-x-28-x-202");expect("pax bergsbo", "pax-bergsbo-wardrobe");+ expect("vihals gateleg table", "vihals-gateleg-table-39-95-151-x-90");if (articleNo("S292.975.72") !== "29297572") fail("article numbers with an S in front don't parse");for (const [no, slug] of [["60324520", "kallax-2x2"]] as const) {if (articleSlug(no) !== slug) fail(`article ${no} gave ${articleSlug(no)}, expected ${slug}`);diff --git a/scripts/ikea/classify.ts b/scripts/ikea/classify.tsindex a857979..1b12d3e 100644--- a/scripts/ikea/classify.ts+++ b/scripts/ikea/classify.ts@@ -80,6 +80,9 @@ const FLAT = new Set<Kind>(["desk", "coffee", "side", "dining", "bar", "console"const OFFICE_ARMS = new Set(["MARKUS", "ALEFJÄLL"]);/** Office chairs with a tall back and a headrest. */const OFFICE_TALL = new Set(["MARKUS"]);+/** Gateleg tables with drawers in the middle, which we can't draw, and ones with a storage shelf and loose leaves. */+const GATE_DRAWERS = new Set(["NORDEN"]);+const GATE_STORAGE = new Set(["VIHALS"]);/** The frame a family's combinations are rows of, in cm: two BILLY 80s, two BESTÅ 120s, two PAX 100s. */const ROW_UNITS: Record<string, number> = { BILLY: 80, BESTÅ: 120, IVAR: 80, PAX: 100 };/** Day-beds' outer size (w, h, d) from IKEA's product pages: IKEA's measure is only the mattress size. */@@ -201,6 +204,17 @@ const RULES: Rule[] = [const leaves = open2 !== undefined || extra >= 50 ? 2 : 1;return { kind: "dropleaf", x: { leaves, leaf: Math.round(extra / leaves) } };}],+ // a gateleg table, measured like a drop-leaf one: "67/124x75 cm" with one leaf, "39/95/151x90 cm" with two+ [/^gateleg table$/, (_m, c) => {+ const s = c.f.size.match(/^(\d+)\/(\d+)(?:\/(\d+))?x\d+ cm$/);+ if (!s) return "gateleg table with a size we can't read";+ if (GATE_DRAWERS.has(c.f.name)) return "gateleg table with drawers";+ const [closed, open1, open2] = [Number(s[1]), Number(s[2]), s[3] ? Number(s[3]) : undefined];+ const leaves = open2 !== undefined ? 2 : 1;+ const x: X = { leaves, leaf: Math.round(((open2 ?? open1) - closed) / leaves) };+ if (GATE_STORAGE.has(c.f.name)) Object.assign(x, { shelf: true, hinge: true });+ return { kind: "gateleg", x };+ }],[/^(gateleg|folding) table$/, () => "gateleg or folding table"],[/^(table|dining table|extendable table|kitchen table)$/, (_m, c) => ({ kind: c.kids ? "kidstable" : "dining" })],[/^children's table$/, () => ({ kind: "kidstable" })],@@ -315,7 +329,7 @@ export function classify(f: Fact, hints: Hints): Verdict {} else if (hint?.kind === kind) set(hint.w, hint.h, hint.d);else if (kind !== "bench") return { skip: "no size given" };if (guessed.h && hint?.kind === kind) h = hint.h;- } else if (kind === "dropleaf") {+ } else if (kind === "dropleaf" || kind === "gateleg") {// drawn with the leaves up: as wide as it opensconst open = Math.max(...f.size.replace(/x.*$/, "").split("/").map(Number));set(open, undefined, v[1]);diff --git a/scripts/ikea/slugs.json b/scripts/ikea/slugs.jsonindex 4b90bff..fa658ae 100644--- a/scripts/ikea/slugs.json+++ b/scripts/ikea/slugs.json@@ -700,6 +700,7 @@"PAX|Wardrobe frame, 75 × 58 × 201 cm": "pax-wardrobe-frame-75-x-58-x-201","PERSBOL|Armchair": "persbol-armchair","PINNTORP|Chair": "pinntorp-chair",+ "PINNTORP|Gateleg table, 67/124 × 75 cm": "pinntorp-gateleg-table-67-124-x-75","PINNTORP|Table, 125 × 75 cm": "pinntorp-table-125-x-75","PINNTORP|Table, 85 cm": "pinntorp-table-85","PIPLÄRKA|Desk, 80 × 63 cm": "piplarka-desk-80-x-63",@@ -1060,6 +1061,7 @@"VIHALS|Extendable table, 120/180 × 74 cm": "vihals-extendable-table-120-180-x-74","VIHALS|Extendable table, 84/120 × 74 cm": "vihals-extendable-table-84-120-x-74","VIHALS|Folding chair": "vihals-folding-chair",+ "VIHALS|Gateleg table, 39/95/151 × 90 cm": "vihals-gateleg-table-39-95-151-x-90","VIHALS|Shelving unit with 10 shelves, 95 × 37 × 200 cm": "vihals-shelving-unit-10-shelves-95-x-37-x-200","VIHALS|Shelving unit with 4 shelves, 95 × 37 × 90 cm": "vihals-shelving-unit-4-shelves-95-x-37-x-90","VIHALS|Sideboard, 140 × 37 × 75 cm": "vihals-sideboard-140-x-37-x-75",diff --git a/src/components/art/Hardware.tsx b/src/components/art/Hardware.tsxindex 15cb4b6..fee3234 100644--- a/src/components/art/Hardware.tsx+++ b/src/components/art/Hardware.tsx@@ -265,6 +265,22 @@ function draw(kind: HwKind, len: number, dia: number): Drawn {</g>),};+ case "flatHinge":+ // two leaves with screw holes, the pin between them+ return {+ w: len,+ h: dia,+ scalable: true,+ node: (+ <g>+ {[0, len / 2 + 3].map((x) => (+ <rect key={x} x={x} y={-dia / 2} width={len / 2 - 3} height={dia} rx={2} fill={METAL} {...stroke} />+ ))}+ <rect x={len / 2 - 4} y={-dia / 2 - 1} width={8} height={dia + 2} rx={4} fill={METAL} {...stroke} />+ {[len * 0.17, len * 0.83].flatMap((x) => [-dia / 4, dia / 4].map((y) => <circle key={`${x}:${y}`} cx={x} cy={y} r={2.2} fill="#fff" {...stroke} />))}+ </g>+ ),+ };case "roller":// a plate with two screw holes, an arm, and the wheel on topreturn {diff --git a/src/data/ikea-items.ts b/src/data/ikea-items.tsindex e0e49a6..88974e9 100644--- a/src/data/ikea-items.ts+++ b/src/data/ikea-items.ts@@ -774,6 +774,7 @@ pax-wardrobe-frame-50-x-58-x-201|70458217 90458221 90458216 10458215 50458218 10pax-wardrobe-frame-75-x-58-x-201|80458231 90458235 60458232 00458230 70458236 20458229 20458234persbol-armchair|50525915 90525923 70525924pinntorp-chair|90635177 00635167 30635175 00590480 00529478 40529476+pinntorp-gateleg-table-67-124-x-75|70529465pinntorp-table-125-x-75|20635171 30529467pinntorp-table-85|30637834piplarka-desk-80-x-63|20579943@@ -1148,6 +1149,7 @@ vihals-day-bed-w-trundle-bed-2-mattresses-80-x-2|79580633 59580629 19580626 0958vihals-extendable-table-120-180-x-74|20589777 30592755vihals-extendable-table-84-120-x-74|90569097vihals-folding-chair|30569104 00592752 90651742+vihals-gateleg-table-39-95-151-x-90|70593574vihals-shelving-unit-10-shelves-95-x-37-x-200|70483274 50542905vihals-shelving-unit-4-shelves-95-x-37-x-90|50483289 30542911vihals-sideboard-140-x-37-x-75|30491718diff --git a/src/data/ikea-rows.ts b/src/data/ikea-rows.tsindex f25d265..776bec5 100644--- a/src/data/ikea-rows.ts+++ b/src/data/ikea-rows.ts@@ -703,6 +703,7 @@ PERSBOL|armchair|Armchair|75|90|80PINNTORP|chair|Chair|44|88|50PINNTORP|dining|Table, 85 cm|85|74|85|round=1PINNTORP|dining|Table, 125 × 75 cm|125|74|75+PINNTORP|gateleg|Gateleg table, 67/124 × 75 cm|124|75|75|leaves=1,leaf=57PIPLÄRKA|desk|Desk, 80 × 63 cm|80|74|63||kids childrenPLATSA|cabinet|Frame, 60 × 55 × 40 cm|60|40|55|doors=0PLATSA|cabinet|Frame, 60 × 55 × 60 cm|60|60|55|doors=0@@ -1061,6 +1062,7 @@ VIHALS|dining|Extendable table, 84/120 × 74 cm|84|74|74VIHALS|dining|Table, 107 cm|107|74|107|round=1VIHALS|dining|Extendable table, 120/180 × 74 cm|120|74|74VIHALS|dining|Table, 125 × 74 cm|125|74|74+VIHALS|gateleg|Gateleg table, 39/95/151 × 90 cm|151|75|90|shelf=1,leaves=2,leaf=56,hinge=1VIHALS|nightstand|Bedside table, 37 × 37 cm|37|55|37|rows=1,knobs=barVIHALS|open|Shelving unit with 4 shelves, 95 × 37 × 90 cm|95|90|37|shelves=2VIHALS|open|Shelving unit with 10 shelves, 95 × 37 × 200 cm|95|200|37|shelves=6diff --git a/src/engine/drawable.ts b/src/engine/drawable.tsindex 4dde083..fe3f4b9 100644--- a/src/engine/drawable.ts+++ b/src/engine/drawable.ts@@ -259,6 +259,11 @@ export function hwDrawable(kind: HwKind, len: number, dia: number) {addSolid(d, `ca:wheel:${dia}`, () => new THREE.CylinderGeometry(r, r, dia * 0.26, 24).rotateZ(Math.PI / 2), plastic, { hull: "radial", position: [x * dia * 0.21, len - r, -dia * 0.16] });break;}+ case "flatHinge":+ // two leaves either side of a pin, lying flat across a joint+ for (const x of [-1, 1]) addSolid(d, `fh:leaf:${len}:${dia}`, () => new THREE.BoxGeometry(len / 2 - 3, 1.6, dia), metal, { position: [x * (len / 4 + 1.5), 0.8, 0] });+ addSolid(d, `fh:pin:${dia}`, () => new THREE.CylinderGeometry(3, 3, dia, 12).rotateX(Math.PI / 2), metal, { hull: "radial", position: [0, 2.2, 0] });+ break;case "roller":// a sliding door's roller: a plate screwed to the door's edge, an arm, and a wheel that runs in the trackaddSolid(d, `ro:plate:${len}`, () => new THREE.BoxGeometry(len, 3, 14), metal, { position: [0, 1.5, 0] });diff --git a/src/lib/ikea.ts b/src/lib/ikea.tsindex e9cb643..bf6e7b4 100644--- a/src/lib/ikea.ts+++ b/src/lib/ikea.ts@@ -23,8 +23,8 @@ export interface IkeaRow {slug?: string;}-const X_KEYS = ["rows", "cols", "knobs", "plinth", "doors", "shelves", "c", "m", "l", "f", "seats", "arms", "legs", "attach", "shelf", "min", "round", "seatH", "chaise", "corner", "open", "sd", "drawer", "leaves", "leaf", "under", "mats", "dtop", "rail", "slides", "n", "of"] as const;-const FLAGS = new Set<string>(["plinth", "shelf", "round", "open", "drawer", "dtop", "rail"]);+const X_KEYS = ["rows", "cols", "knobs", "plinth", "doors", "shelves", "c", "m", "l", "f", "seats", "arms", "legs", "attach", "shelf", "min", "round", "seatH", "chaise", "corner", "open", "sd", "drawer", "leaves", "leaf", "under", "mats", "dtop", "rail", "slides", "n", "of", "hinge"] as const;+const FLAGS = new Set<string>(["plinth", "shelf", "round", "open", "drawer", "dtop", "rail", "hinge"]);const WORDS = new Set<string>(["knobs", "arms", "legs", "attach", "chaise", "corner", "under", "of"]);export function encodeX(x: X): string {diff --git a/src/lib/plan/builder.ts b/src/lib/plan/builder.tsindex 2a1f276..4af2391 100644--- a/src/lib/plan/builder.ts+++ b/src/lib/plan/builder.ts@@ -52,6 +52,7 @@ export const HW = {gasLift: { kind: "gasLift", len: 200, dia: 50 },connector: { kind: "connector", len: 120, dia: 30 },roller: { kind: "roller", len: 44, dia: 26 },+ flatHinge: { kind: "flatHinge", len: 60, dia: 34 },} satisfies Record<string, HwDef>;const HW_NAMES: Record<HwKind, string> = {@@ -75,6 +76,7 @@ const HW_NAMES: Record<HwKind, string> = {gasLift: "Gas lift",connector: "Connector",roller: "Door roller",+ flatHinge: "Flat hinge",};export function hwSpecText(kind: HwKind, len: number, dia: number) {diff --git a/src/lib/plan/gateleg.ts b/src/lib/plan/gateleg.tsnew file mode 100644index 0000000..536c6b8--- /dev/null+++ b/src/lib/plan/gateleg.ts@@ -0,0 +1,237 @@+import type { PartPiece, ProductSpec, Vec3 } from "../types";+import { HW, PlanBuilder, type FitOpts } from "./builder";+import { clamp, rotate } from "./math";++/**+ * Gateleg tables: a narrow fixed top on four legs, one or two leaves hinged to its sides, and for each leaf+ * a gate (a frame with a leg of its own) hinged to the frame that swings out under the leaf to hold it up.+ * size.w is the width with the leaves up. Built upside down, then turned over: the leaves hang down+ * until you raise them and swing the gates out.+ */+export function buildGateleg(b: PlanBuilder, s: ProductSpec) {+ const p = s.table ?? {};+ const W = s.size.w * 10, H = s.size.h * 10, D = s.size.d * 10;+ const nL = p.leaves === 1 ? 1 : 2;+ const leaf = clamp((p.leaf ?? 50) * 10, 300, Math.min(700, (W - 250) / nL));+ const Wc = W - nL * leaf;+ const cx = nL === 1 ? -leaf / 2 : 0; // centre of the fixed top+ const tt = 22, ls = 40;+ const Lh = H - tt;+ const big = W > 1000;+ const sides = nL === 1 ? [1] : [1, -1];++ /* ---------- top and leaves ---------- */+ const topT = b.part("Table top", [Wc, tt, D]);+ const top = b.place(topT, [cx, H - tt / 2, 0]);+ const leafT = b.part("Leaf", [leaf - 2, tt, D]);+ const hinge = (sgn: number) => cx + sgn * (Wc / 2);+ const leaves = sides.map((sgn) => ({ sgn, key: b.place(leafT, [hinge(sgn) + sgn * (leaf / 2 + 1), H - tt / 2, 0]) }));++ /* ---------- the frame: legs at the corners of the fixed top, rails under it, stretchers low down ---------- */+ const inset = 20;+ const lx = Wc / 2 - ls / 2 - inset, lz = D / 2 - ls / 2 - 40;+ const legT = b.part("Leg", [ls, Lh, ls], { material: "wood" });+ const corners: [number, number][] = [+ [-1, 1],+ [1, 1],+ [1, -1],+ [-1, -1],+ ];+ const legs = corners.map(([sx, sz]) => b.place(legT, [cx + sx * lx, Lh / 2, sz * lz]));+ const rh = 70, rt = 20;+ const ry = H - tt - rh / 2;+ const shortT = b.part("Short rail", [2 * lx - ls, rh, rt], { material: "wood" });+ const longT = b.part("Long rail", [rt, rh, 2 * lz - ls], { material: "wood" });+ const rails = [+ b.place(shortT, [cx, ry, lz]),+ b.place(shortT, [cx, ry, -lz]),+ b.place(longT, [cx + lx, ry, 0]),+ b.place(longT, [cx - lx, ry, 0]),+ ];+ const sy = 160;+ const stretchT = b.part("Stretcher", [rt, 50, 2 * lz - ls], { material: "wood" });+ const stretchers = [-1, 1].map((sx) => b.place(stretchT, [cx + sx * lx, sy, 0]));+ const shelf = p.shelf ? b.place(b.part("Shelf", [2 * lx + ls - 4, 18, 2 * lz - ls], { material: "board" }), [cx, sy + 25 + 9, 0]) : undefined;++ /* ---------- gates: hinged at a front or back leg, folded along the frame or swung out under the leaf ---------- */+ const Lg = clamp(leaf * 0.72, 250, 2 * lz - 60);+ const gTop = H - tt - 30, gH = gTop - 10;+ const gatePieces: PartPiece[] = [+ { shape: "box", size: [ls, gH, ls], pos: [Lg - ls / 2, 10 + gH / 2, 0] },+ { shape: "box", size: [30, gTop - 150, 30], pos: [15, 150 + (gTop - 150) / 2, 0] },+ { shape: "box", size: [Lg, 50, 25], pos: [Lg / 2, gTop - 25, 0] },+ { shape: "box", size: [Lg, 40, 25], pos: [Lg / 2, 190, 0] },+ ];+ const gateC = b.compound("Gate leg", gatePieces, { material: "wood" });+ const gates = sides.map((sgn) => {+ // the right gate hangs on the front leg and folds back along the frame; the left one the other way round+ const pivot: Vec3 = [cx + sgn * (lx + ls / 2 + 8), 0, sgn * lz];+ const open = sgn > 0 ? 0 : Math.PI;+ const fold = sgn > 0 ? Math.PI / 2 : -Math.PI / 2;+ const at = (a: number): Vec3 => {+ const m = rotate(gateC.mid, [0, a, 0]);+ return [pivot[0] + m[0], pivot[1] + m[1], pivot[2] + m[2]];+ };+ return { sgn, pivot, folded: { pos: at(fold), rot: [0, fold, 0] as Vec3 }, key: b.place(gateC.type, at(open), [0, open, 0]) };+ });++ /* ---------- steps ---------- */+ const loose = !!p.hinges;+ b.step(+ {+ title: "Lay the top upside down",+ detail: loose ? "Put the leaves at its sides, on the flattened box." : "The leaves come hinged on. Keep them flat on the box while you work.",+ pose: "-y",+ kind: "general",+ warnings: ["floor"],+ people: big ? 2 : 1,+ },+ () => {+ b.stagger(0);+ b.add(top, [0, 200, 0]);+ leaves.forEach((l) => b.add(l.key, [0, 200, 0]));+ },+ );++ if (loose) {+ b.step(+ {+ title: nL > 1 ? "Screw the leaves on with the hinges" : "Screw the leaf on with the hinges",+ detail: "Two hinges across each joint, the pin right on the line.",+ tools: ["screwdriver"],+ pose: "-y",+ kind: "screws",+ },+ () => {+ const list: FitOpts[] = [];+ const screws: FitOpts[] = [];+ for (const l of leaves) {+ const x = hinge(l.sgn);+ for (const z of [-D / 3, D / 3]) {+ list.push({ on: l.key, at: [x, H - tt, z], dir: [0, 1, 0], hole: false, mate: top });+ for (const dx of [-16, 16]) screws.push({ on: dx * l.sgn > 0 ? l.key : top, at: [x + dx, H - tt - 2, z], dir: [0, 1, 0], hole: false });+ }+ }+ b.fits(HW.flatHinge, list, 0.12);+ b.then(0.1);+ b.fits(HW.screwS, screws, 0.04);+ },+ );+ }++ b.step(+ {+ title: "Screw the rails under the top",+ detail: "They frame the fixed middle, set in from the edge.",+ tools: ["screwdriver"],+ pose: "-y",+ kind: "screws",+ },+ () => {+ b.stagger(0.2);+ rails.forEach((r) => b.add(r, [0, -260, 0]));+ b.then(0.1);+ const sc: FitOpts[] = [];+ for (const r of rails) {+ const pos = b.partItem(r).final.pos;+ const alongX = Math.abs(pos[2]) > 1;+ const len = alongX ? 2 * lx - ls : 2 * lz - ls;+ for (const f of [-0.3, 0.3]) sc.push({ on: r, at: [pos[0] + (alongX ? f * len : 0), H - tt - rh, pos[2] + (alongX ? 0 : f * len)], dir: [0, 1, 0], hole: false });+ }+ b.fits(HW.screwL, sc, 0.06);+ },+ );++ b.step(+ {+ title: "Bolt the legs into the corners",+ detail: "Hand tight for now. Tighten them all once every leg is on.",+ tools: ["allen"],+ pose: "-y",+ kind: "legs",+ warnings: ["loose"],+ },+ () => {+ b.stagger(0.3);+ legs.forEach((l) => b.add(l, [0, -360, 0]));+ b.then(0.1);+ const bolts: FitOpts[] = [];+ corners.forEach(([sx, sz], i) => {+ bolts.push({ on: legs[i], at: [cx + sx * (lx + ls / 2), H - tt - 35, sz * (lz - 10)], dir: [-sx, 0, 0] });+ bolts.push({ on: legs[i], at: [cx + sx * (lx - 10), H - tt - 35, sz * (lz + ls / 2)], dir: [0, 0, -sz] });+ });+ b.fits(HW.boltL, bolts, 0.08);+ },+ );++ b.step(+ {+ title: shelf ? "Screw in the stretchers and the shelf" : "Screw in the stretchers",+ detail: shelf ? "One low down between each pair of legs. The shelf rests on them." : "One low down between each pair of legs. Then tighten every bolt.",+ tools: ["allen"],+ pose: "-y",+ kind: "bolts",+ },+ () => {+ b.stagger(0.3);+ stretchers.forEach((k) => b.add(k, [0, -300, 0]));+ b.then(0.1);+ const bolts: FitOpts[] = [];+ for (const [i, k] of stretchers.entries()) {+ const sx = i === 0 ? -1 : 1;+ for (const sz of [-1, 1]) bolts.push({ on: legs[corners.findIndex(([a, c]) => a === sx && c === sz)], at: [cx + sx * lx, sy, sz * (lz + ls / 2)], dir: [0, 0, -sz], mate: k });+ }+ b.fits(HW.boltL, bolts, 0.1);+ if (shelf) {+ b.then(0.1);+ b.add(shelf, [0, -240, 0]);+ }+ },+ );++ b.step(+ {+ title: nL > 1 ? "Hinge the gate legs onto the frame" : "Hinge the gate leg onto the frame",+ detail: nL > 1 ? "One at each end, folded flat along the frame for now." : "Folded flat along the frame for now.",+ tools: ["screwdriver"],+ pose: "-y",+ kind: "screws",+ },+ () => {+ b.stagger(0.3);+ gates.forEach((g) => b.stage(g.key, g.folded.pos, g.folded.rot, [0, -280, 0]));+ b.then(0.1);+ const list: FitOpts[] = [];+ for (const g of gates) for (const y of [260, gTop - 120]) list.push({ on: g.key, at: [g.pivot[0], y, g.pivot[2]], dir: [-g.sgn, 0, 0], twist: Math.PI / 2, hole: false });+ b.fits(HW.flatHinge, list, 0.12);+ },+ );++ b.step(+ {+ title: big ? "Turn it over together" : "Turn it over",+ detail: "Lift it by the top, not the legs. The leaves drop down.",+ pose: "+y",+ kind: "flip",+ people: big ? 2 : 1,+ warnings: big ? ["two"] : [],+ },+ () => {+ for (const l of leaves) b.stage(l.key, [hinge(l.sgn) + l.sgn * (tt / 2), H - tt - leaf / 2, 0], [0, 0, -l.sgn * (Math.PI / 2)]);+ },+ );++ b.step(+ {+ title: nL > 1 ? "Raise the leaves and swing out the gate legs" : "Raise the leaf and swing out the gate leg",+ detail: "Each gate turns out under its leaf. Fold it back in to drop the leaf.",+ kind: "general",+ },+ () => {+ b.stagger(0);+ leaves.forEach((l) => b.add(l.key));+ b.then(0.05);+ gates.forEach((g) => b.add(g.key));+ },+ );+}diff --git a/src/lib/plan/table.ts b/src/lib/plan/table.tsindex 0732445..64baa14 100644--- a/src/lib/plan/table.ts+++ b/src/lib/plan/table.ts@@ -2,6 +2,7 @@ import type { ProductSpec, TableParams, Vec3 } from "../types";import { HW, PlanBuilder, type FitOpts } from "./builder";import { clamp } from "./math";import { buildDropLeaf } from "./dropleaf";+import { buildGateleg } from "./gateleg";export function defaultsTable(s: ProductSpec): TableParams {const p = s.table ?? {};@@ -18,6 +19,7 @@ export function defaultsTable(s: ProductSpec): TableParams {}export function buildTable(b: PlanBuilder, s: ProductSpec) {+ if (s.table?.gate) return buildGateleg(b, s);if (s.table?.leaves) return buildDropLeaf(b, s);const p = defaultsTable(s);const W = s.size.w * 10, H = s.size.h * 10;diff --git a/src/lib/products.ts b/src/lib/products.tsindex 31b22ea..0ec9436 100644--- a/src/lib/products.ts+++ b/src/lib/products.ts@@ -48,7 +48,8 @@ export type Kind =| "slidecab"| "bookrow"| "cabrow"- | "section";+ | "section"+ | "gateleg";export type X = {rows?: number;@@ -83,6 +84,7 @@ export type X = {slides?: number;n?: number;of?: "bookcase" | "cabinet" | "tv" | "wardrobe" | "wallcab";+ hinge?: boolean;};export type Row = [name: string, kind: Kind, variant: string, w: number, h: number, d: number, x?: X, keywords?: string];@@ -256,7 +258,7 @@ const MIN: Record<Kind, number> = {cube: 40, bookcase: 50, open: 40, chest: 90, nightstand: 40, desk: 25, coffee: 20, side: 15, dining: 40,bed: 100, wardrobe: 120, cabinet: 60, sideboard: 80, tv: 60, shoe: 45, chair: 25, stool: 12, bench: 20, sofa: 40, armchair: 30,wallshelf: 25, wallcab: 40, kitchen: 50, trolley: 25, bar: 35, console: 30, kidstable: 15, kidschair: 20,- office: 20, chaise: 55, corner: 70, cot: 35, bunk: 90, loft: 75, dropleaf: 40, daybed: 60, mixed: 50, sliding: 110, slidecab: 60, bookrow: 120, cabrow: 120, section: 25,+ office: 20, chaise: 55, corner: 70, cot: 35, bunk: 90, loft: 75, dropleaf: 40, daybed: 60, mixed: 50, sliding: 110, slidecab: 60, bookrow: 120, cabrow: 120, section: 25, gateleg: 50,};const CATEGORY: Record<Kind, string> = {@@ -265,7 +267,7 @@ const CATEGORY: Record<Kind, string> = {cabinet: "Cabinet", sideboard: "Sideboard", tv: "TV bench", shoe: "Shoe cabinet", chair: "Chair", stool: "Stool",bench: "Bench", sofa: "Sofa", armchair: "Armchair", wallshelf: "Wall shelf", wallcab: "Wall cabinet", kitchen: "Kitchen cabinet",trolley: "Trolley", bar: "Bar table", console: "Console table", kidstable: "Children's table", kidschair: "Children's chair",- office: "Office chair", chaise: "Sofa with chaise longue", corner: "Corner sofa", cot: "Cot", bunk: "Bunk bed", loft: "Loft bed", dropleaf: "Drop-leaf table", daybed: "Day-bed", mixed: "Cabinet with doors and drawers", sliding: "Wardrobe with sliding doors", slidecab: "Cabinet with sliding doors", bookrow: "Bookcase combination", cabrow: "Storage combination", section: "Sofa section",+ office: "Office chair", chaise: "Sofa with chaise longue", corner: "Corner sofa", cot: "Cot", bunk: "Bunk bed", loft: "Loft bed", dropleaf: "Drop-leaf table", daybed: "Day-bed", mixed: "Cabinet with doors and drawers", sliding: "Wardrobe with sliding doors", slidecab: "Cabinet with sliding doors", bookrow: "Bookcase combination", cabrow: "Storage combination", section: "Sofa section", gateleg: "Gateleg table",};export const KIND_ARCH: Record<Kind, Archetype> = {@@ -273,7 +275,7 @@ export const KIND_ARCH: Record<Kind, Archetype> = {side: "table", dining: "table", bed: "bed", wardrobe: "cabinet", cabinet: "cabinet", sideboard: "cabinet", tv: "cabinet",shoe: "cabinet", chair: "seat", stool: "seat", bench: "seat", sofa: "sofa", armchair: "sofa", wallshelf: "shelf", wallcab: "cabinet",kitchen: "cabinet", trolley: "table", bar: "table", console: "table", kidstable: "table", kidschair: "seat",- office: "seat", chaise: "sofa", corner: "sofa", cot: "bed", bunk: "bed", loft: "bed", dropleaf: "table", daybed: "bed", mixed: "cabinet", sliding: "cabinet", slidecab: "cabinet", bookrow: "shelf", cabrow: "cabinet", section: "sofa",+ office: "seat", chaise: "sofa", corner: "sofa", cot: "bed", bunk: "bed", loft: "bed", dropleaf: "table", daybed: "bed", mixed: "cabinet", sliding: "cabinet", slidecab: "cabinet", bookrow: "shelf", cabrow: "cabinet", section: "sofa", gateleg: "table",};const round = (x: X) => (x.round ? { round: true } : {});@@ -390,6 +392,9 @@ export function specFor(kind: Kind, name: string, variant: string, w: number, h:const robe = kind === "sliding";return { ...base, people: robe || h > 150 ? 2 : 1, difficulty: robe ? 3 : 2, cabinet: { fronts: "sliding", slides: x.slides ?? 2, doors: 0, shelves: x.shelves ?? (robe ? 1 : h > 150 ? 3 : h > 100 ? 2 : 1), rail: robe, plinth: x.plinth ?? h > 120, handles: "none", thickness: robe ? 18 : 16 } };}+ case "gateleg":+ // x.leaves of x.leaf cm, each on a gate leg; x.shelf: storage on the stretchers; x.hinge: the leaves come loose+ return { ...base, people: w > 120 ? 2 : 1, table: { attach: "apron", legs: "square", legSize: 40, topThickness: 22, shelf: !!x.shelf, leaves: x.leaves ?? 2, leaf: x.leaf ?? 50, gate: true, ...(x.hinge ? { hinges: true } : {}) } };case "section": {// a straight section of a modular sofa, sold alone: no armrestsconst seats = x.seats ?? 1;@@ -436,5 +441,5 @@ export const KIND_DEFAULT_SIZE: Record<Kind, [number, number, number]> = {sideboard: [140, 85, 45], tv: [150, 50, 42], shoe: [60, 100, 28], chair: [44, 88, 50], stool: [35, 45, 35], bench: [100, 45, 38],sofa: [210, 85, 92], armchair: [75, 90, 80], wallshelf: [60, 60, 22], wallcab: [60, 60, 35], kitchen: [60, 80, 60], trolley: [50, 80, 40],bar: [120, 105, 60], console: [100, 79, 35], kidstable: [77, 48, 55], kidschair: [34, 60, 34],- office: [64, 105, 64], chaise: [226, 85, 160], corner: [233, 85, 171], cot: [130, 84, 68], bunk: [211, 160, 100], loft: [211, 195, 100], dropleaf: [134, 75, 80], daybed: [207, 83, 91], mixed: [80, 120, 40], sliding: [118, 200, 60], slidecab: [80, 110, 45], bookrow: [160, 202, 28], cabrow: [240, 48, 42], section: [192, 83, 92],+ office: [64, 105, 64], chaise: [226, 85, 160], corner: [233, 85, 171], cot: [130, 84, 68], bunk: [211, 160, 100], loft: [211, 195, 100], dropleaf: [134, 75, 80], daybed: [207, 83, 91], mixed: [80, 120, 40], sliding: [118, 200, 60], slidecab: [80, 110, 45], bookrow: [160, 202, 28], cabrow: [240, 48, 42], section: [192, 83, 92], gateleg: [151, 75, 90],};diff --git a/src/lib/search.ts b/src/lib/search.tsindex d69cae2..7203ecc 100644--- a/src/lib/search.ts+++ b/src/lib/search.ts@@ -34,7 +34,8 @@ const CATEGORY_WORDS: [Kind, string[]][] = [["console", ["console", "console table", "hall table"]],["trolley", ["trolley", "cart", "kitchen island"]],["desk", ["desk"]],- ["dropleaf", ["drop leaf", "drop leaf table", "gateleg", "gateleg table"]],+ ["gateleg", ["gateleg", "gateleg table", "gate leg", "gate leg table"]],+ ["dropleaf", ["drop leaf", "drop leaf table"]],["dining", ["dining", "table", "kitchen table"]],["cot", ["cot", "crib", "baby bed"]],["bunk", ["bunk", "bunk bed", "bunkbed"]],diff --git a/src/lib/types.ts b/src/lib/types.tsindex d0d6c9c..90a8595 100644--- a/src/lib/types.ts+++ b/src/lib/types.ts@@ -32,6 +32,8 @@ export interface TableParams {round?: boolean; // round top, size.w is the diameterleaves?: number; // a drop-leaf table: 1 or 2 hinged leaves; size.w is the width with them upleaf?: number; // cm, width of each leaf+ gate?: boolean; // a gateleg table: each leaf rests on a gate leg that swings out from the frame+ hinges?: boolean; // the leaves come loose and are screwed on with hinges}export interface BedParams {@@ -205,7 +207,8 @@ export type HwKind =| "castor"| "gasLift"| "connector"- | "roller";+ | "roller"+ | "flatHinge";export interface HwType {id: string;