IKEA assembly, step by step: animated, manual-style 3D guides. Scan any paper manual with Together AI.
TypeScript
Draw drop-leaf tables
Youssef5061912bb92c
diff --git a/scripts/ikea/build.ts b/scripts/ikea/build.tsindex c3dd63b..9a67deb 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"]);+const LATER_KINDS = new Set<Kind>(["office", "chaise", "corner", "cot", "bunk", "loft", "dropleaf"]);function baseMatch(name: string, draw: Draw): CatalogEntry | undefined {const fam = fold(name);diff --git a/scripts/ikea/classify.ts b/scripts/ikea/classify.tsindex bb77619..54e9d29 100644--- a/scripts/ikea/classify.ts+++ b/scripts/ikea/classify.ts@@ -172,7 +172,16 @@ const RULES: Rule[] = [[/^(shoe cabinet|shoe cabinet\/storage|shoe cabinet with (\d) compartments)$/, (m) => ({ kind: "shoe", x: m[2] ? { c: Number(m[2]) } : {} })],// tables- [/^(gateleg|drop-leaf|folding) table$/, () => "folding or drop-leaf table"],+ // a drop-leaf table is measured closed, then open: "74/134x80 cm", or "55/82/109x74 cm" with two leaves+ [/^drop-leaf table$/, (_m, c) => {+ const s = c.f.size.match(/^(\d+)\/(\d+)(?:\/(\d+))?x\d+ cm$/);+ if (!s) return "drop-leaf table with a size we can't read";+ const [closed, open1, open2] = [Number(s[1]), Number(s[2]), s[3] ? Number(s[3]) : undefined];+ const extra = (open2 ?? open1) - closed;+ const leaves = open2 !== undefined || extra >= 50 ? 2 : 1;+ return { kind: "dropleaf", x: { leaves, leaf: Math.round(extra / leaves) } };+ }],+ [/^(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" })],[/^coffee table$/, () => ({ kind: "coffee" })],@@ -282,6 +291,11 @@ 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") {+ // drawn with the leaves up: as wide as it opens+ const open = Math.max(...f.size.replace(/x.*$/, "").split("/").map(Number));+ set(open, undefined, v[1]);+ h = hint?.kind === kind ? hint.h : 75;} else if (kind === "bunk" || kind === "loft") {// IKEA gives the mattress size; the height is a typical one (KURA, which turns over, is low)if (v.length !== 2 || v[1] < 180 || v[1] > 210) return { skip: "bunk or loft bed without a mattress size" };diff --git a/scripts/ikea/slugs.json b/scripts/ikea/slugs.jsonindex 051984a..43d0838 100644--- a/scripts/ikea/slugs.json+++ b/scripts/ikea/slugs.json@@ -131,6 +131,7 @@"BUSUNGE|Extendable bed, 80 × 200 cm": "busunge-extendable-bed-80-x-200","BYÅS|TV bench, 160 × 42 × 45 cm": "byas-tv-bench-160-x-42-x-45","DANDERYD|Dining table, 130 × 80 cm": "danderyd-dining-table-130-x-80",+ "DANDERYD|Drop-leaf table, 74/134 × 80 cm": "danderyd-drop-leaf-table-74-134-x-80","DOCKSTA|Table, 103 cm": "docksta-table-103","DOMSTEN|Stool": "domsten-stool","DUVSKÄR|Chair, in/outdoor": "duvskar-chair-in-outdoor",@@ -272,6 +273,7 @@"HAUGA|Bedside table, 40 × 36 cm": "hauga-bedside-table-40-x-36","HAUGA|Cabinet with 2 doors, 70 × 116 cm": "hauga-cabinet-2-doors-70-x-116","HAUGA|Chair": "hauga-chair",+ "HAUGA|Drop-leaf table, 55/82/109 × 74 cm": "hauga-drop-leaf-table-55-82-109-x-74","HAUGA|Glass-door cabinet, 105 × 116 cm": "hauga-glass-door-cabinet-105-x-116","HAUGA|Sideboard, 140 × 46 × 84 cm": "hauga-sideboard-140-x-46-x-84","HAUGA|Table, 118 × 74 cm": "hauga-table-118-x-74",@@ -632,6 +634,7 @@"NORDMANSSKÄR|Chair": "nordmansskar-chair","NORDVIKEN|Bar stool with backrest, 62 cm": "nordviken-bar-stool-backrest-62","NORDVIKEN|Chair": "nordviken-chair",+ "NORDVIKEN|Drop-leaf table, 74/104 × 74 cm": "nordviken-drop-leaf-table-74-104-x-74","NORDVIKEN|Extendable table, 152/223 × 95 cm": "nordviken-extendable-table-152-223-x-95","NORRMANSÖ|Bench, outdoor, 100 cm": "norrmanso-bench-outdoor-100","NORRMANSÖ|Bench, outdoor, 200 cm": "norrmanso-bench-outdoor-200",diff --git a/src/data/ikea-items.ts b/src/data/ikea-items.tsindex ff3d5de..79b7f7d 100644--- a/src/data/ikea-items.ts+++ b/src/data/ikea-items.ts@@ -151,6 +151,7 @@ buslatt-chair|90601139busunge-extendable-bed-80-x-200|70305700byas-tv-bench-160-x-42-x-45|80227797danderyd-dining-table-130-x-80|40568726 20568727 10463858+danderyd-drop-leaf-table-74-134-x-80|10516121docksta-table-103|19324995domsten-stool|60554380duvskar-chair-in-outdoor|70515760@@ -299,6 +300,7 @@ hauga-cabinet-2-doors-70-x-116|00415052 40415050hauga-chair|10576718 30576717hauga-chest-3-drawers|20581521 80581518hauga-chest-6-drawers|00581536 70581533+hauga-drop-leaf-table-55-82-109-x-74|20586000 80586002hauga-glass-door-cabinet-105-x-116|80415048 30415055hauga-sideboard-140-x-46-x-84|40621489 60621488hauga-table-118-x-74|00576709 50576716@@ -704,6 +706,7 @@ nordli-modular-chest-3-drawers-80-x-68|40383469nordmansskar-chair|39618435 29618426 09618432nordviken-bar-stool-backrest-62|60424690 00424693 60369113nordviken-chair|40369109 30488546 00369111+nordviken-drop-leaf-table-74-104-x-74|70368716 50368717nordviken-extendable-table-152-223-x-95|20368714 90368715 80488544norrmanso-bench-outdoor-100|70586696norrmanso-bench-outdoor-200|30586698diff --git a/src/data/ikea-rows.ts b/src/data/ikea-rows.tsindex d6c95a2..439b6ad 100644--- a/src/data/ikea-rows.ts+++ b/src/data/ikea-rows.ts@@ -132,6 +132,7 @@ BUSLÄTT|chair|Chair|44|88|50BUSUNGE|bed|Extendable bed, 80 × 200 cm|96|100|209|m=80BYÅS|tv|TV bench, 160 × 42 × 45 cm|160|45|42DANDERYD|dining|Dining table, 130 × 80 cm|130|74|80+DANDERYD|dropleaf|Drop-leaf table, 74/134 × 80 cm|134|75|80|leaves=2,leaf=30DOCKSTA|dining|Table, 103 cm|103|74|103|round=1DOMSTEN|stool|Stool|35|45|35DUVSKÄR|chair|Chair, in/outdoor|44|88|50||outdoor garden@@ -274,6 +275,7 @@ HAUGA|cabinet|Cabinet with 2 doors, 70 × 116 cm|70|116|40|knobs=barHAUGA|cabinet|Glass-door cabinet, 105 × 116 cm|105|116|40|knobs=barHAUGA|chair|Chair|44|88|50HAUGA|dining|Table, 118 × 74 cm|118|74|74+HAUGA|dropleaf|Drop-leaf table, 55/82/109 × 74 cm|109|75|74|leaves=2,leaf=27HAUGA|nightstand|Bedside table, 40 × 36 cm|40|55|36|rows=1,knobs=barHAUGA|sideboard|Sideboard, 140 × 46 × 84 cm|140|84|46|knobs=barHAUGA|tv|TV bench, 206 × 46 × 54 cm|206|54|46|knobs=bar@@ -634,6 +636,7 @@ NORDMANSSKÄR|chair|Chair|44|88|50NORDVIKEN|chair|Chair|44|88|50NORDVIKEN|chair|Bar stool with backrest, 62 cm|44|94|50|seatH=62NORDVIKEN|dining|Extendable table, 152/223 × 95 cm|152|74|95+NORDVIKEN|dropleaf|Drop-leaf table, 74/104 × 74 cm|104|75|74|leaves=1,leaf=30NORRMANSÖ|bench|Bench, outdoor, 100 cm|100|45|38||outdoor gardenNORRMANSÖ|bench|Bench, outdoor, 200 cm|200|45|38||outdoor gardenNORRMANSÖ|chair|Chair, outdoor|44|88|50||outdoor gardendiff --git a/src/lib/ikea.ts b/src/lib/ikea.tsindex 7620ab6..95b7215 100644--- a/src/lib/ikea.ts+++ b/src/lib/ikea.ts@@ -23,7 +23,7 @@ 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"] as const;+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"] as const;const FLAGS = new Set<string>(["plinth", "shelf", "round", "open", "drawer"]);const WORDS = new Set<string>(["knobs", "arms", "legs", "attach", "chaise", "corner"]);diff --git a/src/lib/plan/dropleaf.ts b/src/lib/plan/dropleaf.tsnew file mode 100644index 0000000..a30773a--- /dev/null+++ b/src/lib/plan/dropleaf.ts@@ -0,0 +1,175 @@+import type { ProductSpec, Vec3 } from "../types";+import { HW, PlanBuilder, type FitOpts } from "./builder";+import { clamp } from "./math";++/**+ * Drop-leaf tables: a fixed top on four legs with an apron, and one or two leaves hinged to its ends,+ * held up by supports that swing out from under the top. size.w is the width with the leaves up.+ * Built upside down like the other tables; turned over, the leaves hang down until you raise them.+ */+export function buildDropLeaf(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 ?? 30) * 10, 150, Math.min(600, (W - 400) / nL));+ const Wc = W - nL * leaf;+ const cx = nL === 1 ? -leaf / 2 : 0; // centre of the fixed top+ const tt = 25, ls = 45, inset = 45;+ const Lh = H - tt;+ const big = W > 1000;++ 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]);+ // leaves on the right (+x) first; a single leaf is always on the right+ const sides = nL === 1 ? [1] : [1, -1];+ 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]) }));++ // apron and legs under the fixed top, as on a dining table+ const lx = Wc / 2 - ls / 2 - inset, lz = D / 2 - ls / 2 - inset;+ 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 = 80, rt = 20;+ const ry = H - tt - rh / 2;+ const longT = b.part("Long rail", [Wc - 2 * inset - 2 * ls, rh, rt], { material: "wood" });+ const shortT = b.part("Short rail", [rt, rh, D - 2 * inset - 2 * ls], { material: "wood" });+ const rails = [+ b.place(longT, [cx, ry, lz + ls / 2 - rt / 2]),+ b.place(longT, [cx, ry, -(lz + ls / 2 - rt / 2)]),+ b.place(shortT, [cx + lx + ls / 2 - rt / 2, ry, 0]),+ b.place(shortT, [cx - (lx + ls / 2 - rt / 2), ry, 0]),+ ];++ // a support for each leaf, pivoting on the outside of a short rail: folded along it, or swung out under the leaf+ const armL = Math.min(leaf + inset - 10, D / 2 - 20);+ const armT = b.part("Leaf support", [armL, 22, 36], { material: "wood" });+ const armY = H - tt - 11;+ const supports = sides.map((sgn) => {+ const px = cx + sgn * (lx + ls / 2 + 18); // pivot, just outside the short rail+ const open: Vec3 = [px + sgn * (armL / 2 - 18), armY, 0];+ const folded: Vec3 = [px, armY, armL / 2 - 18];+ return { sgn, px, folded, key: b.place(armT, open) };+ });++ b.step(+ {+ title: "Lay the top upside down",+ detail: "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]));+ },+ );++ 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 ? Wc - 2 * inset - 2 * ls : D - 2 * inset - 2 * ls;+ for (const f of [-0.33, 0.33]) 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[] = [];+ const y = H - tt - 40;+ const off = ls / 2 - 10;+ corners.forEach(([sx, sz], i) => {+ bolts.push({ on: legs[i], at: [cx + sx * (lx + ls / 2), y, sz * (lz + off)], dir: [-sx, 0, 0] });+ bolts.push({ on: legs[i], at: [cx + sx * (lx + off), y, sz * (lz + ls / 2)], dir: [0, 0, -sz] });+ });+ b.fits(HW.boltL, bolts, 0.08);+ },+ );++ b.step(+ {+ title: nL > 1 ? "Screw on the leaf supports" : "Screw on the leaf support",+ detail: "Fold them in along the rails for now.",+ tools: ["screwdriver"],+ pose: "-y",+ kind: "screws",+ },+ () => {+ b.stagger(0.3);+ supports.forEach((sp) => b.stage(sp.key, sp.folded, [0, -sp.sgn * (Math.PI / 2), 0], [0, -200, 0]));+ b.then(0.1);+ b.fits(+ HW.screwM,+ supports.map((sp) => ({ on: sp.key, at: [sp.px, armY - 11, 0] as Vec3, dir: [0, 1, 0] as Vec3, hole: false })),+ 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"] : [],+ },+ () => {+ // each leaf hangs from its hinge at the edge of the top+ for (const l of leaves) {+ const hx = hinge(l.sgn);+ b.stage(l.key, [hx + 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 supports" : "Raise the leaf and swing out the support",+ detail: "Each support turns out under its leaf. Fold them back in to drop the leaves.",+ kind: "general",+ },+ () => {+ b.stagger(0);+ leaves.forEach((l) => b.add(l.key));+ b.then(0.05);+ supports.forEach((sp) => b.add(sp.key));+ },+ );+}diff --git a/src/lib/plan/table.ts b/src/lib/plan/table.tsindex 2ebb803..0732445 100644--- a/src/lib/plan/table.ts+++ b/src/lib/plan/table.ts@@ -1,6 +1,7 @@import type { ProductSpec, TableParams, Vec3 } from "../types";import { HW, PlanBuilder, type FitOpts } from "./builder";import { clamp } from "./math";+import { buildDropLeaf } from "./dropleaf";export function defaultsTable(s: ProductSpec): TableParams {const p = s.table ?? {};@@ -17,6 +18,7 @@ export function defaultsTable(s: ProductSpec): TableParams {}export function buildTable(b: PlanBuilder, s: ProductSpec) {+ if (s.table?.leaves) return buildDropLeaf(b, s);const p = defaultsTable(s);const W = s.size.w * 10, H = s.size.h * 10;const D = p.round ? W : s.size.d * 10;diff --git a/src/lib/products.ts b/src/lib/products.tsindex 9700ef8..3ffc426 100644--- a/src/lib/products.ts+++ b/src/lib/products.ts@@ -40,7 +40,8 @@ export type Kind =| "corner"| "cot"| "bunk"- | "loft";+ | "loft"+ | "dropleaf";export type X = {rows?: number;@@ -66,6 +67,8 @@ export type X = {open?: boolean;sd?: number;drawer?: boolean;+ leaves?: number;+ leaf?: number;};export type Row = [name: string, kind: Kind, variant: string, w: number, h: number, d: number, x?: X, keywords?: string];@@ -239,7 +242,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,+ office: 20, chaise: 55, corner: 70, cot: 35, bunk: 90, loft: 75, dropleaf: 40,};const CATEGORY: Record<Kind, string> = {@@ -248,7 +251,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",+ office: "Office chair", chaise: "Sofa with chaise longue", corner: "Corner sofa", cot: "Cot", bunk: "Bunk bed", loft: "Loft bed", dropleaf: "Drop-leaf table",};export const KIND_ARCH: Record<Kind, Archetype> = {@@ -256,7 +259,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",+ office: "seat", chaise: "sofa", corner: "sofa", cot: "bed", bunk: "bed", loft: "bed", dropleaf: "table",};const round = (x: X) => (x.round ? { round: true } : {});@@ -343,6 +346,8 @@ export function specFor(kind: Kind, name: string, variant: string, w: number, h:case "bunk":case "loft":return { ...base, people: 2, difficulty: 3, bed: { type: kind, mattressW: x.m ?? 90, mattressL: x.l ?? 200, headH: h, footH: h, slats: 14, centerBeam: false } };+ case "dropleaf":+ return { ...base, people: w > 120 ? 2 : 1, table: { attach: "apron", legs: "square", legSize: 45, topThickness: 25, shelf: false, leaves: x.leaves ?? 2, leaf: x.leaf ?? 30 } };}}@@ -371,5 +376,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: [250, 85, 160], corner: [250, 85, 220], cot: [130, 84, 68], bunk: [211, 160, 100], loft: [211, 195, 100],+ office: [64, 105, 64], chaise: [250, 85, 160], corner: [250, 85, 220], cot: [130, 84, 68], bunk: [211, 160, 100], loft: [211, 195, 100], dropleaf: [134, 75, 80],};diff --git a/src/lib/types.ts b/src/lib/types.tsindex f091faf..fac22ca 100644--- a/src/lib/types.ts+++ b/src/lib/types.ts@@ -30,6 +30,8 @@ export interface TableParams {shelf: boolean;attach: "screw" | "plate" | "apron";round?: boolean; // round top, size.w is the diameter+ leaves?: number; // a drop-leaf table: 1 or 2 hinged leaves; size.w is the width with them up+ leaf?: number; // cm, width of each leaf}export interface BedParams {