IKEA assembly, step by step: animated, manual-style 3D guides. Scan any paper manual with Together AI.
TypeScript
Draw LILLEHEM's sofas and armchair with a side table
Youssef576f4bec0f62
diff --git a/scripts/ikea/classify.ts b/scripts/ikea/classify.tsindex e5a3a1d..7067aa2 100644--- a/scripts/ikea/classify.ts+++ b/scripts/ikea/classify.ts@@ -543,6 +543,9 @@ const RULES: Rule[] = [// a bench with a backrest and armrests, built like a wide chair (IKEA gives no size: a typical garden bench)[/^bench with backrest$/, (_m, c) => (c.f.spr ? "bench with backrest sold with cushions" : { kind: "backbench" })],[/^(armchair|easy chair|wing chair|high-back armchair|low-back armchair|rocking-chair|children's armchair|armchair with cushion)$/, () => ({ kind: "armchair" })],+ // a modular sofa or armchair with a side table module at the end+ [/^(?:(\d)-seat modular sofa|armchair) with side table$/, (m) =>+ m[1] ? { kind: "sofa", x: { seats: Number(m[1]), st: 45, cat: "Modular sofa with side table" } } : { kind: "armchair", x: { st: 45, cat: "Armchair with side table" } }],// a recliner and a wide armchair, built like any other armchair[/^recliner$/, () => ({ kind: "armchair", x: { cat: "Recliner" } })],[/^1,5-seat armchair$/, () => ({ kind: "armchair", x: { cat: "Armchair" } })],@@ -828,6 +831,8 @@ export function classify(f: Fact, hints: Hints): Verdict {if (kind === "chair" && x.seatH && guessed.h) h = x.seatH + 32;if (kind === "lounge" && guessed.h && /reclin/.test(t)) [w, h, d] = [66, 102, 84];if (kind === "sofa" && guessed.w) w = (x.seats ?? 3) * 60 + 50;+ // a sofa or armchair with a side table module is that much wider, as wide as we draw at most+ if (x.st && guessed.w) w = Math.min(400, (kind === "armchair" ? 75 : (x.seats ?? 3) * 60 + 50) + x.st);// more than four seats: two sections side by side, as wide as the family's own seats, or as wide as we drawif (kind === "sofa" && guessed.w && (x.seats ?? 3) > 4) w = Math.min(398, w);if (kind === "sofa" && guessed.w && (x.seats ?? 3) > 4 && hint?.kind === "sofa" && hint.x.seats) {diff --git a/scripts/ikea/slugs.json b/scripts/ikea/slugs.jsonindex 5f2732a..3bc1518 100644--- a/scripts/ikea/slugs.json+++ b/scripts/ikea/slugs.json@@ -672,12 +672,18 @@"LILLBERGET|Chest of 6 drawers, 140 × 43 × 68 cm": "lillberget-chest-6-drawers-140-x-43-x-68","LILLEHEM|1-seat module": "lillehem-1-seat-module","LILLEHEM|2-seat modular sofa": "lillehem-2-seat-modular-sofa",+ "LILLEHEM|2-seat modular sofa with side table": "lillehem-2-seat-modular-sofa-side-table","LILLEHEM|2-seat module": "lillehem-2-seat-module","LILLEHEM|3-seat modular sofa": "lillehem-3-seat-modular-sofa","LILLEHEM|3-seat modular sofa w chaise longue": "lillehem-3-seat-modular-sofa-w-chaise-longue",+ "LILLEHEM|3-seat modular sofa with side table": "lillehem-3-seat-modular-sofa-side-table","LILLEHEM|4-seat modular sofa": "lillehem-4-seat-modular-sofa",+ "LILLEHEM|4-seat modular sofa with side table": "lillehem-4-seat-modular-sofa-side-table",+ "LILLEHEM|5-seat modular sofa with side table": "lillehem-5-seat-modular-sofa-side-table","LILLEHEM|6-seat modular sofa": "lillehem-6-seat-modular-sofa",+ "LILLEHEM|6-seat modular sofa with side table": "lillehem-6-seat-modular-sofa-side-table","LILLEHEM|Armchair": "lillehem-armchair",+ "LILLEHEM|Armchair with side table": "lillehem-armchair-side-table","LILLEHEM|Modular corner sofa, 2-seat": "lillehem-modular-corner-sofa-2-seat","LILLEHEM|Modular corner sofa, 4 seat": "lillehem-modular-corner-sofa-4-seat","LILLESÄTER|3-seat sofa": "lillesater-3-seat-sofa",diff --git a/src/data/ikea-items.ts b/src/data/ikea-items.tsindex 27ce65a..2e4c7e1 100644--- a/src/data/ikea-items.ts+++ b/src/data/ikea-items.ts@@ -734,12 +734,18 @@ lillberget-chest-5-drawers-70-x-43-x-108|60630478lillberget-chest-6-drawers-140-x-43-x-68|40630479lillehem-1-seat-module|39552929 39471551 29471542 59471550 29552920 19552925lillehem-2-seat-modular-sofa|59471282 79471276 39471264 29471288 39471259 09471270+lillehem-2-seat-modular-sofa-side-table|49536062 89536084 59570324 29570325 19536073 09570326lillehem-2-seat-module|99536012 19536006 69536023 89536017 49535996 29536001 89577499 79577503 49577528 89577507 79577517 59577523lillehem-3-seat-modular-sofa|99617800 89617810 69617806 59617802 29617808 19617804+lillehem-3-seat-modular-sofa-side-table|99570322 89536258 79570323 39536270 19570321 09536262lillehem-3-seat-modular-sofa-w-chaise-longue|99570384 69570385 49570386 39570382 29570387 19570383lillehem-4-seat-modular-sofa|69536056 99536045 79536051 59536028 39536034 29536039+lillehem-4-seat-modular-sofa-side-table|89536239 79570318 59570319 39570320 39536232 19536228+lillehem-5-seat-modular-sofa-side-table|99553474 89570327 69570328 49570329 39553472 19553473lillehem-6-seat-modular-sofa|69536198 29536204 19536214 19536209 09536224 09536219+lillehem-6-seat-modular-sofa-side-table|89553484 89574778 79574774 79574750 69574760 19574809lillehem-armchair|89470323 89470295 69470300 39470306 19470312 09470317+lillehem-armchair-side-table|89570332 59536311 49536316 29570330 29536322 09570331lillehem-modular-corner-sofa-2-seat|89536282 79536287 49536298 59536293 09536304 09536276lillehem-modular-corner-sofa-4-seat|69536155 79536150 49536161 19536172 19536167 09536144lillesater-3-seat-sofa|40618496 00619073diff --git a/src/data/ikea-rows.ts b/src/data/ikea-rows.tsindex 8ecae70..69ba98d 100644--- a/src/data/ikea-rows.ts+++ b/src/data/ikea-rows.ts@@ -672,15 +672,21 @@ LILLBERGET|chest|Chest of 3 drawers, 70 × 43 × 68 cm|70|68|43|rows=3LILLBERGET|chest|Chest of 5 drawers, 70 × 43 × 108 cm|70|108|43|rows=5LILLBERGET|chest|Chest of 6 drawers, 140 × 43 × 68 cm|140|68|43|rows=3,cols=2LILLEHEM|armchair|Armchair|75|90|80+LILLEHEM|armchair|Armchair with side table|120|90|80|cat=Armchair with side table,st=45LILLEHEM|chaise|3-seat modular sofa w chaise longue|226|85|160|seats=3,arms=wide,chaise=right,sd=92LILLEHEM|corner|Modular corner sofa, 2-seat|173|85|92|seats=2,arms=wide,corner=left,sd=92LILLEHEM|corner|Modular corner sofa, 4 seat|237|85|173|seats=4,arms=wide,corner=left,sd=92LILLEHEM|section|1-seat module|64|83|92|seats=1LILLEHEM|section|2-seat module|128|83|92|seats=2LILLEHEM|sofa|2-seat modular sofa|170|85|92|seats=2+LILLEHEM|sofa|2-seat modular sofa with side table|215|85|92|seats=2,cat=Modular sofa with side table,st=45LILLEHEM|sofa|3-seat modular sofa|230|85|92|seats=3+LILLEHEM|sofa|3-seat modular sofa with side table|275|85|92|seats=3,cat=Modular sofa with side table,st=45LILLEHEM|sofa|4-seat modular sofa|290|85|92|seats=4+LILLEHEM|sofa|4-seat modular sofa with side table|335|85|92|seats=4,cat=Modular sofa with side table,st=45+LILLEHEM|sofa|5-seat modular sofa with side table|395|85|92|seats=5,cat=Modular sofa with side table,st=45LILLEHEM|sofa|6-seat modular sofa|398|85|92|seats=6+LILLEHEM|sofa|6-seat modular sofa with side table|398|85|92|seats=6,cat=Modular sofa with side table,st=45LILLESÄTER|sofa|3-seat sofa|230|85|92|seats=3LILLESÄTER|sofa|4-seat sofa|290|85|92|seats=4LILLESÄTER|sofa|5-seat sofa|350|85|92|seats=5diff --git a/src/lib/plan/sofa.ts b/src/lib/plan/sofa.tsindex e53e7f3..d8d82d0 100644--- a/src/lib/plan/sofa.ts+++ b/src/lib/plan/sofa.ts@@ -16,6 +16,7 @@ export function defaultsSofa(s: ProductSpec): SofaParams {/** Upholstered sofas and armchairs: legs on the base, arms and back bolted on, cushions last. */export function buildSofa(b: PlanBuilder, s: ProductSpec) {if (s.sofa?.pouffe) return buildPouffe(b, s);+ if (s.sofa?.table) return withSideTable(b, s);// more than four seats: two sections joined, like a corner sofa without the cornerif (s.sofa?.chaise || s.sofa?.corner || (s.sofa?.seats ?? 0) > 4) return buildCornerSofa(b, s);const p = defaultsSofa(s);@@ -164,3 +165,67 @@ export function buildSofa(b: PlanBuilder, s: ProductSpec) {}if (s.sofa?.foot) footstool(b, { w: Math.min(W * 0.8, 620), h: 420, d: 420, z: D / 2 + 140 + 210 });}++/**+ * A modular sofa or armchair with a side table module at its right-hand end (LILLEHEM): the sofa is built as it is on+ * its own, then the side table is put together, set at the end and joined to the seat frame with connectors.+ */+function withSideTable(b: PlanBuilder, s: ProductSpec) {+ const T = clamp(s.sofa!.table! * 10, 300, 700);+ const W = s.size.w * 10, D = s.size.d * 10, H = s.size.h * 10;+ const sofa: ProductSpec = { ...s, size: { ...s.size, w: s.size.w - T / 10 }, sofa: { ...s.sofa, table: undefined } };+ buildSofa(b, sofa);+ // the sofa stands at the left, the table at the right-hand end+ const dx = -T / 2;+ for (const it of b.items) {+ if (it.kind === "part") {+ const old = it.final.pos;+ it.final = { pos: [old[0] + dx, old[1], old[2]], rot: it.final.rot };+ for (const st of it.states) if (st.scene === "main") st.pos = st.pos === old ? it.final.pos : [st.pos[0] + dx, st.pos[1], st.pos[2]];+ } else if (!it.parent && it.scene === "main") it.pos = [it.pos[0] + dx, it.pos[1], it.pos[2]];+ }+ const th = clamp(H * 0.65, 420, 620), td = D - 120, t = 20;+ const xc = W / 2 - T / 2;+ const topT = b.part("Side table top", [T, 25, td], { material: "wood" });+ const sideT = b.part("Side table end", [t, th - 25, td], { material: "wood" });+ const shelfT = b.part("Side table shelf", [T - 2 * t, 18, td - 20], { material: "wood" });+ const top = b.place(topT, [xc, th - 12.5, 0]);+ const ends = [-1, 1].map((sx) => b.place(sideT, [xc + sx * (T / 2 - t / 2), (th - 25) / 2, 0]));+ const shelf = b.place(shelfT, [xc, 160, 0]);+ const parts = [...ends, shelf, top];+ const at = (k: string) => b.partItem(k).final.pos;+ b.step(+ {+ title: "Put the side table together",+ detail: "Screw the shelf in between the two ends, then the top down onto them.",+ tools: ["screwdriver"],+ scene: "table",+ kind: "screws",+ warnings: ["floor"],+ },+ () => {+ b.stagger(0.22);+ parts.forEach((k) => b.stage(k, [at(k)[0] - xc, at(k)[1], at(k)[2]], [0, 0, 0], [0, 160, 0]));+ b.then(0.1);+ const sc: FitOpts[] = [];+ for (const [i, k] of ends.entries()) for (const z of [-td / 4, td / 4]) sc.push({ on: k, at: [at(k)[0] + (i === 0 ? -t / 2 : t / 2), 160, z], dir: [i === 0 ? 1 : -1, 0, 0], mate: shelf });+ for (const [i, k] of ends.entries()) for (const z of [-td / 4, td / 4]) sc.push({ on: top, at: [at(k)[0], th, z], dir: [0, -1, 0], mate: k });+ b.fits(HW.screwM, sc, 0.06);+ },+ );+ b.step(+ {+ title: "Join the side table to the end of the sofa",+ detail: "Stand it tight against the end, then screw the connectors across underneath, into the seat frame and the table.",+ tools: ["screwdriver"],+ kind: "join",+ },+ () => {+ b.stagger(0);+ parts.forEach((k) => b.add(k, [260, 0, 0]));+ b.then(0.15);+ const x = W / 2 - T;+ b.fits(HW.connector, [-D / 4, D / 4].map((z) => ({ at: [x, 110, z] as Vec3, dir: [0, 1, 0] as Vec3, twist: 0 })), 0.15);+ },+ );+}diff --git a/src/lib/products.ts b/src/lib/products.tsindex 231af88..1536369 100644--- a/src/lib/products.ts+++ b/src/lib/products.ts@@ -538,6 +538,11 @@ function specOf(kind: Kind, name: string, variant: string, w: number, h: number,return { ...base, people: 1, difficulty: 2, sofa: { seats: 1, arms: x.arms ?? "none", legs: "round", bed: true } };case "sofa":case "armchair":+ // x.st: a side table module at the right-hand end, x.st cm wide+ if (x.st) {+ const seats = x.seats ?? (kind === "armchair" ? 1 : Math.max(1, Math.round((w - x.st - 30) / 62)));+ return { ...base, minutes: x.min ?? MIN[kind] + 20 + (seats > 4 ? 30 : 0), people: 2, difficulty: seats > 4 ? 3 : 2, sofa: { seats, arms: x.arms ?? "wide", legs: "round", table: x.st } };+ }// x.foot: an armchair with its footstoolif (x.foot) return { ...base, minutes: x.min ?? MIN.armchair + 15, people: 1, sofa: { seats: x.seats ?? 1, arms: x.arms ?? "wide", legs: "round", foot: true } };return {diff --git a/src/lib/types.ts b/src/lib/types.tsindex cd6cc52..60e38b8 100644--- a/src/lib/types.ts+++ b/src/lib/types.ts@@ -150,6 +150,7 @@ export interface SofaParams {foot?: boolean; // an armchair that comes with its footstool, built after it and stood in front of itpouffe?: boolean; // a pouffe or footstool on its own: a padded block on four legsbed?: boolean; // a chair-bed: it folds out into a bed+ table?: number; // cm: a side table module at the right-hand end (size.w takes it in)}/** A product read from someone's own manual: parts as boxes in the assembled product, steps that add them. */