IKEA assembly, step by step: animated, manual-style 3D guides. Scan any paper manual with Together AI.
TypeScript
Draw NORDLI chests with open sections
Youssefb085407a6aa5
diff --git a/scripts/ikea/build.ts b/scripts/ikea/build.tsindex 9a684c3..5554770 100644--- a/scripts/ikea/build.ts+++ b/scripts/ikea/build.ts@@ -65,8 +65,9 @@ function baseMatch(name: string, draw: Draw): CatalogEntry | undefined {const fam = fold(name);const spec = specFor(draw.kind, name, "", draw.w, draw.h, draw.d, draw.x);const g = draw.guessed;- // a cube shelf with inserts or on an underframe is more than the hand made shelf of the same size- if (draw.x.ins || draw.x.uf) return undefined;+ // a cube shelf with inserts or on an underframe is more than the hand made shelf of the same size, and a modular+ // chest's drawers and open sections are its own+ if (draw.x.ins || draw.x.uf || draw.x.mods) return undefined;for (const e of BASE) {if (fold(e.name) !== fam) continue;if (e.archetype !== spec.archetype && e.category !== spec.category) continue;diff --git a/scripts/ikea/classify.ts b/scripts/ikea/classify.tsindex 19ded23..b416184 100644--- a/scripts/ikea/classify.ts+++ b/scripts/ikea/classify.ts@@ -154,6 +154,8 @@ const DAYBED_SIZE: Record<string, [number, number, number]> = { HEMNES: [210, 83const BLIND_DOOR: Record<string, number> = { METOD: 60, KNOXHULT: 50 };/** Corner base cabinets IKEA measures wide by high, with the worktop on top, and how deep they are. */const CORNER_WH: Record<string, number> = { KNOXHULT: 61 };+/** Modular chests: how wide a column is and how tall a drawer slot is, in cm (a NORDLI chest is 7 cm of top and plinth). */+const MODULE: Record<string, [number, number, number]> = { NORDLI: [40, 23, 7] };/** Pieces IKEA gives no size for, by type: typical ones (w, h, d). */const TYPICAL: Record<string, [number, number, number]> = {"trolley table with storage": [50, 52, 50],@@ -784,6 +786,16 @@ export function classify(f: Fact, hints: Hints): Verdict {const total = x.rows ?? (kind === "nightstand" ? (h >= 60 ? 2 : 1) : Math.min(6, Math.max(2, Math.round(h / 14))));if (kind === "chest" && total === 2 && w <= 60 && h <= 65 && !/^mini/.test(t)) return finish("nightstand");const shape = kind === "nightstand" ? { rows: Math.min(total, 3), cols: 1 as const } : chestShape(total, w, h);+ // a modular chest: columns of drawer slots, some left open+ const mod = !shape && kind === "chest" ? MODULE[family] : undefined;+ if (mod) {+ const mods = Math.round(w / mod[0]), rows = Math.round((h - mod[2]) / mod[1]);+ if (mods >= 1 && mods <= 4 && rows >= 1 && rows <= 8 && mods * rows >= total) {+ Object.assign(x, { mods, rows, ...(total < mods * rows ? { dr: total } : {}) });+ if (hint?.x.knobs) x.knobs = hint.x.knobs;+ return finish(kind);+ }+ }if (!shape) return { skip: "drawers we can't lay out (open sections or 3 columns)" };x.rows = shape.rows;if (shape.cols === 2) x.cols = 2;diff --git a/scripts/ikea/slugs.json b/scripts/ikea/slugs.jsonindex 21fdd20..5a021d9 100644--- a/scripts/ikea/slugs.json+++ b/scripts/ikea/slugs.json@@ -921,11 +921,15 @@"NORDLI|Chest of 12 drawers, 120 × 145 cm": "nordli-chest-12-drawers-120-x-145","NORDLI|Chest of 12 drawers, 160 × 145 cm": "nordli-chest-12-drawers-160-x-145","NORDLI|Chest of 2 drawers, 40 × 54 cm": "nordli-chest-2-drawers-40-x-54",+ "NORDLI|Chest of 2 drawers, 40 × 99 cm": "nordli-chest-2-drawers-40-x-99","NORDLI|Chest of 2 drawers, 80 × 54 cm": "nordli-chest-2-drawers-80-x-54",+ "NORDLI|Chest of 3 drawers, 120 × 169 cm": "nordli-chest-3-drawers-120-x-169","NORDLI|Chest of 3 drawers, 120 × 54 cm": "nordli-chest-3-drawers-120-x-54","NORDLI|Chest of 3 drawers, 40 × 76 cm": "nordli-chest-3-drawers-40-x-76",+ "NORDLI|Chest of 3 drawers, 80 × 192 cm": "nordli-chest-3-drawers-80-x-192","NORDLI|Chest of 3 drawers, 80 × 76 cm": "nordli-chest-3-drawers-80-x-76","NORDLI|Chest of 4 drawers, 160 × 54 cm": "nordli-chest-4-drawers-160-x-54",+ "NORDLI|Chest of 4 drawers, 80 × 192 cm": "nordli-chest-4-drawers-80-x-192","NORDLI|Chest of 5 drawers, 120 × 169 cm": "nordli-chest-5-drawers-120-x-169","NORDLI|Chest of 5 drawers, 120 × 76 cm": "nordli-chest-5-drawers-120-x-76","NORDLI|Chest of 5 drawers, 80 × 122 cm": "nordli-chest-5-drawers-80-x-122",@@ -935,8 +939,16 @@"NORDLI|Chest of 6 drawers, 160 × 169 cm": "nordli-chest-6-drawers-160-x-169","NORDLI|Chest of 6 drawers, 160 × 54 cm": "nordli-chest-6-drawers-160-x-54","NORDLI|Chest of 6 drawers, 80 × 145 cm": "nordli-chest-6-drawers-80-x-145",+ "NORDLI|Chest of 7 drawers, 120 × 76 cm": "nordli-chest-7-drawers-120-x-76",+ "NORDLI|Chest of 7 drawers, 80 × 122 cm": "nordli-chest-7-drawers-80-x-122",+ "NORDLI|Chest of 7 drawers, 80 × 99 cm": "nordli-chest-7-drawers-80-x-99","NORDLI|Chest of 8 drawers, 120 × 99 cm": "nordli-chest-8-drawers-120-x-99",+ "NORDLI|Chest of 8 drawers, 160 × 169 cm": "nordli-chest-8-drawers-160-x-169",+ "NORDLI|Chest of 8 drawers, 160 × 192 cm": "nordli-chest-8-drawers-160-x-192","NORDLI|Chest of 8 drawers, 160 × 54 cm": "nordli-chest-8-drawers-160-x-54",+ "NORDLI|Chest of 8 drawers, 80 × 99 cm": "nordli-chest-8-drawers-80-x-99",+ "NORDLI|Chest of 9 drawers, 160 × 76 cm": "nordli-chest-9-drawers-160-x-76",+ "NORDLI|Chest of 9 drawers, 160 × 99 cm": "nordli-chest-9-drawers-160-x-99","NORDLI|Chest of drawers, 40 × 54 cm": "nordli-chest-drawers-40-x-54","NORDLI|Modular chest of 2 drawers, 40 × 45 cm": "nordli-modular-chest-2-drawers-40-x-45","NORDLI|Modular chest of 2 drawers, 80 × 23 cm": "nordli-modular-chest-2-drawers-80-x-23",diff --git a/src/data/ikea-items.ts b/src/data/ikea-items.tsindex 2a245fd..10e6ba8 100644--- a/src/data/ikea-items.ts+++ b/src/data/ikea-items.ts@@ -991,12 +991,16 @@ nordli-bed-frame-storage-140-x-200|40349847 00349849nordli-chest-12-drawers-120-x-145|99239489nordli-chest-12-drawers-160-x-145|79239490nordli-chest-2-drawers-40-x-54|09239827+nordli-chest-2-drawers-40-x-99|49276549nordli-chest-2-drawers-80-x-54|99239494+nordli-chest-3-drawers-120-x-169|39295138nordli-chest-3-drawers-120-x-54|69276567nordli-chest-3-drawers-40-x-76|39239835+nordli-chest-3-drawers-80-x-192|59295217nordli-chest-3-drawers-80-x-76|69239495nordli-chest-4-drawers|79239843nordli-chest-4-drawers-160-x-54|49239496+nordli-chest-4-drawers-80-x-192|89336872nordli-chest-5-drawers-120-x-169|09295286nordli-chest-5-drawers-120-x-76|49248033nordli-chest-5-drawers-80-x-122|29276550@@ -1006,9 +1010,17 @@ nordli-chest-6-drawers-120-x-99|69276633nordli-chest-6-drawers-160-x-169|89295169nordli-chest-6-drawers-160-x-54|49276629nordli-chest-6-drawers-80-x-145|89239499+nordli-chest-7-drawers-120-x-76|39336884+nordli-chest-7-drawers-80-x-122|99239502+nordli-chest-7-drawers-80-x-99|09248006nordli-chest-8-drawers|19276621 29239505 29248010 59239491nordli-chest-8-drawers-120-x-99|79239503+nordli-chest-8-drawers-160-x-169|69295349 49295208+nordli-chest-8-drawers-160-x-192|79295377nordli-chest-8-drawers-160-x-54|59239504+nordli-chest-8-drawers-80-x-99|69336887+nordli-chest-9-drawers-160-x-76|89239507+nordli-chest-9-drawers-160-x-99|19248015nordli-chest-drawers-40-x-54|19276522nordli-modular-chest-2-drawers-40-x-45|90383457nordli-modular-chest-2-drawers-80-x-23|70471619diff --git a/src/data/ikea-rows.ts b/src/data/ikea-rows.tsindex d41be9b..4a0bfbd 100644--- a/src/data/ikea-rows.ts+++ b/src/data/ikea-rows.ts@@ -923,26 +923,38 @@ NORDLI|chest|Modular chest of drawers, 40 × 45 cm|40|45|48|rows=3,knobs=noneNORDLI|chest|Chest of drawers, 40 × 54 cm|40|54|48|rows=4,knobs=noneNORDLI|chest|Modular chest of 3 drawers, 40 × 68 cm|40|68|48|rows=3,knobs=noneNORDLI|chest|Chest of 3 drawers, 40 × 76 cm|40|76|48|rows=3,knobs=none+NORDLI|chest|Chest of 2 drawers, 40 × 99 cm|40|99|48|rows=4,knobs=none,mods=1,dr=2NORDLI|chest|Modular chest of 2 drawers, 80 × 23 cm|80|23|48|rows=2,knobs=noneNORDLI|chest|Modular chest of 2 drawers, 80 × 45 cm|80|45|48|rows=2,knobs=noneNORDLI|chest|Chest of 2 drawers, 80 × 54 cm|80|54|48|rows=2,knobs=noneNORDLI|chest|Modular chest of 3 drawers, 80 × 68 cm|80|68|48|rows=3,knobs=noneNORDLI|chest|Chest of 3 drawers, 80 × 76 cm|80|76|48|rows=3,knobs=none+NORDLI|chest|Chest of 7 drawers, 80 × 99 cm|80|99|48|rows=4,knobs=none,mods=2,dr=7+NORDLI|chest|Chest of 8 drawers, 80 × 99 cm|80|99|48|rows=4,knobs=none,mods=2NORDLI|chest|Chest of 5 drawers, 80 × 122 cm|80|122|48|rows=5,knobs=none+NORDLI|chest|Chest of 7 drawers, 80 × 122 cm|80|122|48|rows=5,knobs=none,mods=2,dr=7NORDLI|chest|Chest of 6 drawers, 80 × 145 cm|80|145|48|rows=6,knobs=none+NORDLI|chest|Chest of 3 drawers, 80 × 192 cm|80|192|48|rows=8,knobs=none,mods=2,dr=3+NORDLI|chest|Chest of 4 drawers, 80 × 192 cm|80|192|48|rows=8,knobs=none,mods=2,dr=4NORDLI|chest|Chest of 3 drawers, 120 × 54 cm|120|54|47|rows=3,knobs=noneNORDLI|chest|Chest of 6 drawers, 120 × 54 cm|120|54|47|rows=3,cols=2,knobs=noneNORDLI|chest|Chest of 5 drawers, 120 × 76 cm|120|76|47|rows=5,knobs=noneNORDLI|chest|Chest of 6 drawers, 120 × 76 cm|120|76|47|rows=3,cols=2,knobs=none+NORDLI|chest|Chest of 7 drawers, 120 × 76 cm|120|76|47|rows=3,knobs=none,mods=3,dr=7NORDLI|chest|Chest of 6 drawers, 120 × 99 cm|120|99|47|rows=3,cols=2,knobs=noneNORDLI|chest|Chest of 8 drawers, 120 × 99 cm|120|99|47|rows=4,cols=2,knobs=noneNORDLI|chest|Chest of 12 drawers, 120 × 145 cm|120|145|47|rows=6,cols=2,knobs=none+NORDLI|chest|Chest of 3 drawers, 120 × 169 cm|120|169|47|rows=7,knobs=none,mods=3,dr=3NORDLI|chest|Chest of 5 drawers, 120 × 169 cm|120|169|47|rows=5,knobs=noneNORDLI|chest|Chest of 4 drawers, 160 × 54 cm|160|54|47|rows=2,cols=2,knobs=noneNORDLI|chest|Chest of 6 drawers, 160 × 54 cm|160|54|47|rows=3,cols=2,knobs=noneNORDLI|chest|Chest of 8 drawers, 160 × 54 cm|160|54|47|rows=4,cols=2,knobs=none+NORDLI|chest|Chest of 9 drawers, 160 × 76 cm|160|76|47|rows=3,knobs=none,mods=4,dr=9+NORDLI|chest|Chest of 9 drawers, 160 × 99 cm|160|99|47|rows=4,knobs=none,mods=4,dr=9NORDLI|chest|Chest of 12 drawers, 160 × 145 cm|160|145|47|rows=6,cols=2,knobs=noneNORDLI|chest|Chest of 6 drawers, 160 × 169 cm|160|169|47|rows=6,knobs=none+NORDLI|chest|Chest of 8 drawers, 160 × 169 cm|160|169|47|rows=7,knobs=none,mods=4,dr=8+NORDLI|chest|Chest of 8 drawers, 160 × 192 cm|160|192|47|rows=8,knobs=none,mods=4,dr=8NORDLI|nightstand|Modular chest of 2 drawers, 40 × 45 cm|40|45|48|rows=2,knobs=noneNORDLI|nightstand|Chest of 2 drawers, 40 × 54 cm|40|54|48|rows=2,knobs=noneNORDMANSSKÄR|chair|Chair|44|88|50diff --git a/src/lib/plan/drawers.ts b/src/lib/plan/drawers.tsindex bacc563..710409c 100644--- a/src/lib/plan/drawers.ts+++ b/src/lib/plan/drawers.ts@@ -4,6 +4,7 @@ import { FrameKit } from "./frame";import { clamp } from "./math";import { buildChanging } from "./changing";import { CASTOR_H, castorStep, liftOntoCastors } from "./castors";+import { buildModular } from "./modular";export function defaultsDrawers(s: ProductSpec): DrawersParams {const p = s.drawers ?? {};@@ -18,6 +19,7 @@ export function defaultsDrawers(s: ProductSpec): DrawersParams {export function buildDrawers(b: PlanBuilder, s: ProductSpec) {if (s.drawers?.changing) return buildChanging(b, s, buildDrawers);+ if (s.drawers?.modules) return buildModular(b, s);const p = defaultsDrawers(s);// on castors: the carcass is built on the floor, then lifted onto themconst ch = s.drawers?.castors ? CASTOR_H : 0;diff --git a/src/lib/plan/modular.ts b/src/lib/plan/modular.tsnew file mode 100644index 0000000..f0f44f4--- /dev/null+++ b/src/lib/plan/modular.ts@@ -0,0 +1,247 @@+import type { ProductSpec, Vec3 } from "../types";+import { HW, PlanBuilder, type FitOpts } from "./builder";+import { FrameKit } from "./frame";+import { clamp } from "./math";++/**+ * A modular chest (NORDLI): one carcass split into columns by dividers, every column the same grid of drawer slots.+ * Drawers fill the slots from the bottom row up, a short top row centred; whatever is left above stays open, with a+ * shelf on pins over the drawers and every two slots higher up. Built like a chest of drawers: runners on the sides+ * while they lie flat, the carcass with its dividers, the back, then the shelves and the drawers.+ */+export function buildModular(b: PlanBuilder, s: ProductSpec) {+ const p = s.drawers ?? {};+ const cols = clamp(Math.round(p.modules ?? 2), 1, 4);+ const rows = clamp(Math.round(p.rows ?? 4), 1, 8);+ const n = clamp(Math.round(p.count ?? cols * rows), 1, cols * rows);+ const knobs = p.knobs ?? "none";+ const W = s.size.w * 10, H = s.size.h * 10, D = s.size.d * 10;+ const t = clamp(p.thickness ?? 16, 12, 24);+ const base = 0;+ const f = new FrameKit(b, { W, H, D, t, base, plinth: false, fixed: [], back: true, pinRows: false, lying: H > 1100 });+ const innerH = H - 2 * t;+ const colW = (W - (cols + 1) * t) / cols;+ const colX = (c: number) => -W / 2 + t + colW / 2 + c * (colW + t);+ const slotH = innerH / rows;+ const slotY = (r: number) => t + r * slotH; // bottom of slot r++ // which slots hold a drawer: full rows from the bottom, the last row's drawers in the middle+ const full = Math.floor(n / cols), rest = n % cols;+ const slots: [number, number][] = [];+ for (let r = 0; r < full; r++) for (let c = 0; c < cols; c++) slots.push([c, r]);+ const first = Math.floor((cols - rest) / 2);+ for (let c = first; c < first + rest; c++) slots.push([c, full]);+ const drawersIn = (c: number) => slots.filter(([cc]) => cc === c).length;++ /* ---------- dividers ---------- */+ const divT = cols > 1 ? b.part("Divider", [t, innerH, D - 4]) : "";+ const divX = (c: number) => -W / 2 + t + (c + 1) * colW + c * t + t / 2;+ const dividers = Array.from({ length: cols - 1 }, (_, c) => b.place(divT, [divX(c), t + innerH / 2, -2]));++ /* ---------- drawers ---------- */+ const runLen = Math.round((D - 60) / 10) * 10;+ const runner = { kind: "runner" as const, len: runLen, dia: 20 };+ const fw = colW - 4, fh = slotH - 4;+ const bw = colW - 26;+ const sh = Math.min(fh - 46, 170);+ const dd = D - t - 50;+ const frT = b.part("Drawer front", [fw, fh, t]);+ const dsT = b.part("Drawer side", [12, sh, dd]);+ const dbT = b.part("Drawer back", [bw - 24, sh - 22, 12]);+ const dbtT = b.part("Drawer bottom", [bw - 10, 3, dd - 8], { material: "fiber" });+ interface Drawer {+ front: string;+ sides: [string, string];+ back: string;+ bottom: string;+ x: number;+ ys: number;+ }+ const drawers: Drawer[] = slots.map(([c, r]) => {+ const ys = slotY(r), x = colX(c);+ const sy = ys + 24 + sh / 2;+ return {+ x,+ ys,+ front: b.place(frT, [x, ys + slotH / 2, D / 2 - t / 2]),+ sides: [b.place(dsT, [x - bw / 2 + 6, sy, D / 2 - t - dd / 2]), b.place(dsT, [x + bw / 2 - 6, sy, D / 2 - t - dd / 2])],+ back: b.place(dbT, [x, ys + 24 + 22 + (sh - 22) / 2, D / 2 - t - dd + 6]),+ bottom: b.place(dbtT, [x, ys + 24 + 9, D / 2 - t - dd / 2 - 2]),+ };+ });+ const runnerY = (ys: number) => ys + 14;+ const runnerZ = D / 2 - t - runLen / 2 - 8;++ /* ---------- shelves in the open sections ---------- */+ const shT = b.part("Shelf", [colW - 3, t, D - 26]);+ const shelfYs: [number, number][] = []; // column, height of the pins+ for (let c = 0; c < cols; c++) {+ const lo = slotY(drawersIn(c)), hi = H - t;+ if (hi - lo < slotH * 0.9) continue;+ const ys: number[] = drawersIn(c) ? [lo + 3] : [];+ for (let y = lo + 2 * slotH; y < hi - slotH * 0.9; y += 2 * slotH) ys.push(y);+ for (const y of ys) shelfYs.push([c, y]);+ }+ const shelves = shelfYs.map(([c, y]) => b.place(shT, [colX(c), y + 3 + t / 2, 11]));+ // the faces either side of a column, where its pins and runners go+ const facesOf = (c: number) => {+ const out: { key: string; x: number; into: Vec3 }[] = [];+ out.push(c === 0 ? { key: f.sides[0], x: -W / 2 + t, into: [-1, 0, 0] } : { key: dividers[c - 1], x: divX(c - 1) + t / 2, into: [-1, 0, 0] });+ out.push(c === cols - 1 ? { key: f.sides[1], x: W / 2 - t, into: [1, 0, 0] } : { key: dividers[c], x: divX(c) - t / 2, into: [1, 0, 0] });+ return out;+ };+ for (const [c, y0] of shelfYs)+ for (const dy of [-64, 0, 64])+ for (const fc of facesOf(c)) for (const z of [D / 2 - 40, -D / 2 + 40]) b.hole(fc.key, [fc.x, y0 + dy, z], [-fc.into[0], 0, 0], 2.5);++ /* ---------- steps: the carcass ---------- */+ f.prepSides();+ const edgeSlots = slots.filter(([c]) => c === 0 || c === cols - 1);+ if (edgeSlots.length) {+ b.step(+ {+ title: "Screw the runners onto the sides",+ detail: "Only where the drawers go. The open end of each runner points to the front.",+ tools: ["screwdriver"],+ scene: "prep",+ kind: "runners",+ warnings: ["face"],+ },+ () => {+ const list: FitOpts[] = [];+ const screws: FitOpts[] = [];+ for (const [c, r] of edgeSlots)+ for (const fc of facesOf(c)) {+ if (fc.key !== f.sides[0] && fc.key !== f.sides[1]) continue;+ const y = runnerY(slotY(r));+ list.push({ on: fc.key, at: [fc.x, y, runnerZ], dir: fc.into, hole: false });+ for (const dz of [-runLen / 2 + 30, runLen / 2 - 30]) screws.push({ on: fc.key, at: [fc.x - fc.into[0] * 12, y, runnerZ + dz], dir: fc.into, hole: false });+ }+ b.fits(runner, list, 0.1);+ b.then(0.1);+ b.fits(HW.screwS, screws, 0.04);+ },+ );+ }+ f.join();+ if (dividers.length) {+ b.step(+ {+ title: dividers.length > 1 ? "Slide in the dividers" : "Slide in the divider",+ detail: "Screw each one to the top and bottom, then fit its runners on both faces, level with the ones on the sides.",+ tools: ["screwdriver"],+ pose: f.pose,+ kind: "join",+ },+ () => {+ b.stagger(0.25);+ dividers.forEach((k) => b.add(k, [0, 0, 420]));+ b.then(0.1);+ const sc: FitOpts[] = [];+ for (const [i, k] of dividers.entries())+ for (const y of [t, H - t]) for (const z of [-D / 4, D / 4]) sc.push({ on: k, at: [divX(i), y === t ? 0 : H, z], dir: [0, y === t ? 1 : -1, 0], hole: false });+ b.fits(HW.screwM, sc, 0.05);+ b.then(0.1);+ const list: FitOpts[] = [];+ for (const [c, r] of slots)+ for (const fc of facesOf(c)) {+ if (fc.key === f.sides[0] || fc.key === f.sides[1]) continue;+ list.push({ on: fc.key, at: [fc.x, runnerY(slotY(r)), runnerZ], dir: fc.into, hole: false });+ }+ b.fits(runner, list, 0.06);+ },+ );+ }+ f.otherSide();+ f.cams();+ f.backSteps();+ f.standUp();++ if (shelves.length) {+ b.step(+ {+ title: shelves.length > 1 ? "Add the shelf pins and shelves" : "Add the shelf pins and the shelf",+ detail: "Into the open sections, above the drawers. Use the same hole on all four corners.",+ kind: "shelves",+ },+ () => {+ const pins: FitOpts[] = [];+ for (const [c, y] of shelfYs) for (const fc of facesOf(c)) for (const z of [D / 2 - 40, -D / 2 + 40]) pins.push({ on: fc.key, at: [fc.x, y, z], dir: fc.into, hole: false });+ b.fits(HW.pin, pins, Math.min(0.05, 2 / pins.length));+ b.then(0.2);+ b.stagger(0.2);+ shelves.forEach((k) => b.add(k, [0, 0, 420]));+ },+ );+ }++ /* ---------- steps: the drawers ---------- */+ const d0 = drawers[0];+ const c0: Vec3 = [d0.x, d0.ys + slotH / 2, D / 2 - t - dd / 2];+ const at = (k: string) => b.partItem(k).final.pos;+ const rel = (k: string): Vec3 => [at(k)[0] - c0[0], at(k)[1] - c0[1], at(k)[2] - c0[2]];+ const backScrews = (d: Drawer): FitOpts[] => {+ const bp = at(d.back);+ return d.sides.flatMap((sd, i) => {+ const xo = at(sd)[0] + (i === 0 ? -6 : 6);+ return [-(sh - 22) / 4, (sh - 22) / 4].map((dy) => ({ on: sd, at: [xo, bp[1] + dy, bp[2]] as Vec3, dir: [i === 0 ? 1 : -1, 0, 0] as Vec3 }));+ });+ };+ b.step(+ {+ title: n > 1 ? "Put the drawers together" : "Put the drawer together",+ detail: "Sides onto the front, slide the bottom in along the grooves, then screw on the back.",+ tools: ["screwdriver"],+ scene: "drawer",+ pose: "-z",+ repeat: n > 1 ? n : undefined,+ kind: "drawer",+ warnings: ["floor"],+ },+ () => {+ b.stage(d0.front, rel(d0.front), [0, 0, 0], [0, 0, -160]);+ b.then(0.1);+ b.stagger(0.25);+ for (const sd of d0.sides) b.stage(sd, rel(sd), [0, 0, 0], [0, 0, -300]);+ b.then(0.1);+ b.stage(d0.bottom, rel(d0.bottom), [0, 0, 0], [0, 0, -420]);+ b.then(0.1);+ b.stage(d0.back, rel(d0.back), [0, 0, 0], [0, 0, -260]);+ b.then(0.15);+ b.fits(HW.screwM, backScrews(d0), 0.12);+ },+ );+ b.step(+ {+ title: n > 1 ? `Slide in all ${n} drawers` : "Slide in the drawer",+ detail: "Rest the back on the runners, then push until it clicks closed.",+ kind: "drawer",+ weight: 0.8 + 0.4 * n,+ },+ () => {+ for (const [i, d] of drawers.entries()) {+ b.stagger(0);+ for (const k of [d.front, d.sides[0], d.sides[1], d.back, d.bottom]) b.add(k, [0, 0, 520]);+ if (i > 0) for (const o of backScrews(d)) b.preset(HW.screwM, o);+ b.wait(0.18);+ }+ },+ );++ if (knobs !== "none") {+ const def = knobs === "bar" ? HW.handle : HW.knob;+ b.step(+ {+ title: knobs === "bar" ? "Screw on the handles" : "Screw on the knobs",+ detail: "Screw from inside the drawer. Snug is enough.",+ tools: ["screwdriver"],+ kind: "screws",+ },+ () => b.fits(def, drawers.map((d) => ({ on: d.front, at: [d.x, at(d.front)[1], D / 2] as Vec3, dir: [0, 0, -1] as Vec3, hole: false })), 0.08),+ );+ }++ f.anchor(f.top, H);+ const last = b.steps[b.steps.length - 1];+ last.detail = "Chests of drawers can tip over if they're not fixed. Wall screws aren't included: pick ones made for your wall.";+}diff --git a/src/lib/products.ts b/src/lib/products.tsindex ef5f1cf..1650ec8 100644--- a/src/lib/products.ts+++ b/src/lib/products.ts@@ -477,6 +477,11 @@ function specOf(kind: Kind, name: string, variant: string, w: number, h: number,return { ...base, difficulty: 1, people: 1, shelf: { style: "bookcase", shelves: x.shelves ?? (h >= 55 ? 1 : 0), fixedShelf: true, back: false, plinth: false, outer: 18 } };case "chest":case "nightstand": {+ // x.mods: a modular chest, columns of x.rows slots with x.dr drawers from the bottom up+ if (x.mods) {+ const dr = x.dr ?? x.mods * (x.rows ?? 4);+ return { ...base, minutes: x.min ?? 40 + 20 * dr + 10 * (x.mods - 1), people: 2, drawers: { cols: 1, rows: x.rows ?? 4, knobs: x.knobs ?? "none", plinth: false, thickness: 16, modules: x.mods, ...(x.dr ? { count: x.dr } : {}) } };+ }// x.cast: a drawer unit on castorsconst cast = x.cast ? { castors: true } : {};return { ...base, minutes: x.min ?? (kind === "nightstand" ? 30 + 15 * (x.rows ?? 2) : 30 + 20 * (x.rows ?? 3) * (x.cols ?? 1)) + (x.cast ? 5 : 0), drawers: { cols: x.cols ?? 1, rows: x.rows ?? (kind === "nightstand" ? 2 : 3), knobs: x.knobs ?? "knob", plinth: x.plinth ?? false, thickness: 16, ...cast } };diff --git a/src/lib/types.ts b/src/lib/types.tsindex d9ec1bf..e616bbe 100644--- a/src/lib/types.ts+++ b/src/lib/types.ts@@ -27,6 +27,8 @@ export interface DrawersParams {thickness: number;changing?: boolean; // a changing table: a changing top goes on last (size.h and size.d take it in)castors?: boolean; // stands on castors (size.h takes them in)+ modules?: number; // a modular chest (NORDLI): this many columns of `rows` slots, split by dividers+ count?: number; // modular chests: drawers in the slots, from the bottom row up; the rest stay open}export interface TableParams {