IKEA assembly, step by step: animated, manual-style 3D guides. Scan any paper manual with Together AI.
TypeScript
Draw KALLAX on an underframe
Youssef93d42aada5f3
diff --git a/scripts/ikea/classify.ts b/scripts/ikea/classify.tsindex 71f0b07..8a0f7c2 100644--- a/scripts/ikea/classify.ts+++ b/scripts/ikea/classify.ts@@ -257,6 +257,8 @@ const RULES: Rule[] = [[/^(shelving unit|shelf unit|open shelving unit|open storage|storage unit|shelving unit in\/outdoor|shelf section|1 shelf section|shelving unit with (\d+) shelves)$/, (m, c) =>c.f.name === "KALLAX" ? { kind: "cube" } : { kind: "open", x: m[2] ? { shelves: Math.min(6, Number(m[2]) - 2) } : {} }],[/^(wall shelf unit|wall shelf|wall-mounted shelving unit|wall storage unit)$/, (m, c) => (c.sz.n.length === 3 && c.sz.n[2] >= 25) || (m[1] === "wall shelf unit" && c.sz.n.length >= 2) ? { kind: "wallshelf" } : "single shelf board"],+ // KALLAX on an underframe 17 cm high, sold together: the shelf, then the frame screwed to its bottom+ [/^shelving unit with underframe$/, (_m, c) => (c.f.name === "KALLAX" ? { kind: "cube", x: { uf: 17 } } : "shelving unit on an underframe")],[/^(modular )?chest of (\d+) drawers$/, (m) => ({ kind: "chest", x: { rows: Number(m[2]) } })],[/^(drawer unit|drawer unit on castors|chest of drawers|dresser)$/, () => ({ kind: "chest" })],[/^(bedside table|nightstand|bedside table with (\d) drawers?)$/, (m) => ({ kind: "nightstand", x: m[2] ? { rows: Number(m[2]) } : {} })],@@ -400,6 +402,8 @@ export function classify(f: Fact, hints: Hints): Verdict {}if (h - (x.basin ?? 0) <= 70 && !WASH_FLOOR.has(family)) x.hung = true;}+ // IKEA lists one KALLAX on an underframe with its depth and one without: the same thing, so the same row+ if (kind === "cube" && x.uf && v.length === 3) sz = { ...sz, text: `${v[0]} × ${v[2]} cm` };// a METOD wall cabinet is 37 deep, except the one over a fridge, which is as deep as the fridge's cabinetif (kind === "appliance" && guessed.d) d = x.hung && x.use !== "fridge" ? 37 : 60;} else if (FLAT.has(kind)) {@@ -544,7 +548,7 @@ export function classify(f: Fact, hints: Hints): Verdict {}if (kind === "tv" && h > 100) return { skip: "TV storage wall" };if (kind === "shoe" && x.c === undefined) x.c = h < 60 ? 1 : h < 115 ? 2 : 3;- if (kind === "cube" && (Math.round((w - 6) / 35) > 5 || Math.round((h - 6) / 35) > 5)) return { skip: "cube grid larger than 5 x 5" };+ if (kind === "cube" && (Math.round((w - 6) / 35) > 5 || Math.round((h - (x.uf ?? 0) - 6) / 35) > 5)) return { skip: "cube grid larger than 5 x 5" };if (kind === "desk" || kind === "coffee" || kind === "side") {if (hint?.x.attach) x.attach = hint.x.attach;if (hint?.x.legs) x.legs = hint.x.legs;diff --git a/scripts/ikea/slugs.json b/scripts/ikea/slugs.jsonindex 4a62466..c35bce4 100644--- a/scripts/ikea/slugs.json+++ b/scripts/ikea/slugs.json@@ -442,6 +442,12 @@"JUTHOLMEN|Modular corner sofa 3-seat, outdoor": "jutholmen-modular-corner-sofa-3-seat-outdoor","JUTTERSBO|Trolley, 36 × 36 cm": "juttersbo-trolley-36-x-36","KALLAX|Desk, 111 × 39 cm": "kallax-desk-111-x-39",+ "KALLAX|Shelving unit with underframe, 147 × 129 cm": "kallax-shelving-unit-underframe-147-x-129",+ "KALLAX|Shelving unit with underframe, 147 × 164 cm": "kallax-shelving-unit-underframe-147-x-164",+ "KALLAX|Shelving unit with underframe, 147 × 59 cm": "kallax-shelving-unit-underframe-147-x-59",+ "KALLAX|Shelving unit with underframe, 147 × 94 cm": "kallax-shelving-unit-underframe-147-x-94",+ "KALLAX|Shelving unit with underframe, 77 × 164 cm": "kallax-shelving-unit-underframe-77-x-164",+ "KALLAX|Shelving unit with underframe, 77 × 94 cm": "kallax-shelving-unit-underframe-77-x-94","KALLAX|Shelving unit, 112 × 147 cm": "kallax-shelving-unit-112-x-147","KALLAX|Shelving unit, 182 × 182 cm": "kallax-shelving-unit-182-x-182","KALLAX|Shelving unit, 42 × 41 cm": "kallax-shelving-unit-42-x-41",diff --git a/src/data/ikea-items.ts b/src/data/ikea-items.tsindex 7764eee..5b48559 100644--- a/src/data/ikea-items.ts+++ b/src/data/ikea-items.ts@@ -496,6 +496,12 @@ kallax-shelving-unit-182-x-182|70301537 90324509 90477936 70301542kallax-shelving-unit-42-x-41|80395875 20301554 60477933 70309840kallax-shelving-unit-77-x-112|50522417 70522421 90522420kallax-shelving-unit-77-x-41|40395877 40311873 10477935 20395878 90301555+kallax-shelving-unit-underframe-147-x-129|79442694 99442711 39442691 19442710 99442706 79442707 19442692+kallax-shelving-unit-underframe-147-x-164|09442720 49442718 79442712 39442714 89442721 29442719 59442713+kallax-shelving-unit-underframe-147-x-59|29442663 39442672 99442674 39442667 19442668 09442664 59442666+kallax-shelving-unit-underframe-147-x-94|29442677 39442686 89442679 79442689 59442685 69442680 59442690 59552914 29552915 79552913 19552911 99552912 39552910 49607554+kallax-shelving-unit-underframe-77-x-164|69442642 89442655 19442654 99442645 79442646 49442643 29442615 79607557+kallax-shelving-unit-underframe-77-x-94|89442617 59442628 49442619 69442618 79442627 09442616 29634983kallso-bench-shoe-storage-80-x-38-x-56|20599328karskar-chair|00611251karskar-extendable-table-160-220-x-90|50611263diff --git a/src/data/ikea-rows.ts b/src/data/ikea-rows.tsindex d8e669b..af1246e 100644--- a/src/data/ikea-rows.ts+++ b/src/data/ikea-rows.ts@@ -444,8 +444,14 @@ JUTHOLMEN|sofa|3-seat modular sofa, outdoor|230|85|92|seats=3|outdoor gardenJUTTERSBO|trolley|Trolley, 36 × 36 cm|36|80|36KALLAX|cube|Shelving unit, 42 × 41 cm|42|41|39KALLAX|cube|Shelving unit, 77 × 41 cm|77|41|39+KALLAX|cube|Shelving unit with underframe, 77 × 94 cm|77|94|39|uf=17KALLAX|cube|Shelving unit, 77 × 112 cm|77|112|39+KALLAX|cube|Shelving unit with underframe, 77 × 164 cm|77|164|39|uf=17KALLAX|cube|Shelving unit, 112 × 147 cm|112|147|39+KALLAX|cube|Shelving unit with underframe, 147 × 59 cm|147|59|39|uf=17+KALLAX|cube|Shelving unit with underframe, 147 × 94 cm|147|94|39|uf=17+KALLAX|cube|Shelving unit with underframe, 147 × 129 cm|147|129|39|uf=17+KALLAX|cube|Shelving unit with underframe, 147 × 164 cm|147|164|39|uf=17KALLAX|cube|Shelving unit, 182 × 182 cm|182|182|39KALLAX|desk|Desk, 111 × 39 cm|111|74|39KALLSÖ|bench|Bench with shoe storage, 80 × 38 × 56 cm|80|56|38diff --git a/src/lib/ikea.ts b/src/lib/ikea.tsindex 1ed0ab7..eea13c1 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", "leaves", "leaf", "under", "mats", "dtop", "rail", "slides", "n", "of", "hinge", "use", "z", "basin", "hung"] 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", "under", "mats", "dtop", "rail", "slides", "n", "of", "hinge", "use", "z", "basin", "hung", "uf"] as const;const FLAGS = new Set<string>(["plinth", "shelf", "round", "open", "drawer", "dtop", "rail", "hinge", "hung"]);const WORDS = new Set<string>(["knobs", "arms", "legs", "attach", "chaise", "corner", "under", "of", "use", "z"]);diff --git a/src/lib/plan/shelf.ts b/src/lib/plan/shelf.tsindex d7d4608..f2fe2b5 100644--- a/src/lib/plan/shelf.ts+++ b/src/lib/plan/shelf.ts@@ -1,4 +1,4 @@-import type { ProductSpec, ShelfParams, Vec3 } from "../types";+import type { PartPiece, ProductSpec, ShelfParams, Vec3 } from "../types";import { HW, PlanBuilder, type FitOpts } from "./builder";import { FrameKit, anchorStep } from "./frame";import { clamp } from "./math";@@ -21,7 +21,7 @@ export function defaultsShelf(s: ProductSpec): ShelfParams {export function buildShelf(b: PlanBuilder, s: ProductSpec) {const p = defaultsShelf(s);- if (p.style === "grid") return grid(b, s, p);+ if (p.style === "grid") return s.shelf?.underframe ? onUnderframe(b, s, p) : grid(b, s, p);return bookcase(b, s, p);}@@ -53,7 +53,7 @@ function bookcase(b: PlanBuilder, s: ProductSpec, p: ShelfParams) {}/** Cube shelving: full-width top and bottom, sides between, an inner grid on dowels. Built upright from the bottom. */-function grid(b: PlanBuilder, s: ProductSpec, p: ShelfParams) {+function grid(b: PlanBuilder, s: ProductSpec, p: ShelfParams, beforeAnchor?: () => void) {const W = s.size.w * 10, H = s.size.h * 10, D = s.size.d * 10;const T = p.outer, ti = p.inner;const { cols, rows } = p;@@ -223,7 +223,66 @@ function grid(b: PlanBuilder, s: ProductSpec, p: ShelfParams) {},);+ beforeAnchor?.();if (H >= 700) anchorStep(b, { W, D, top, y: H, backZ: -D / 2, severe: H > 1200 });}+/**+ * A cube shelf on an underframe (KALLAX): the shelf is built exactly as it is on its own, then laid on its back+ * for the underframe to be screwed to its bottom, and stood up on it. Built with its bottom at zero, then lifted.+ */+function onUnderframe(b: PlanBuilder, s: ProductSpec, p: ShelfParams) {+ const U = clamp(s.shelf!.underframe! * 10, 80, 400);+ const W = s.size.w * 10, D = s.size.d * 10;+ const shelf: ProductSpec = { ...s, size: { ...s.size, h: s.size.h - U / 10 } };+ const tall = shelf.size.h > 120;+ const leg = 40, rail = 50;+ grid(b, shelf, p, () => {+ const xs = W / 2 - leg / 2, zs = D / 2 - leg / 2;+ const pieces: PartPiece[] = [];+ for (const x of [-xs, xs]) for (const z of [-zs, zs]) pieces.push({ shape: "box", size: [leg, U, leg], pos: [x, -U / 2, z] });+ for (const z of [-zs, zs]) pieces.push({ shape: "box", size: [W - 2 * leg, rail, 22], pos: [0, -rail / 2, z] });+ for (const x of [-xs, xs]) pieces.push({ shape: "box", size: [22, rail, D - 2 * leg], pos: [x, -rail / 2, 0] });+ const c = b.compound("Underframe", pieces, { material: "wood" });+ const frame = b.place(c.type, c.mid);+ b.step(+ {+ title: "Lay it on its back and screw on the underframe",+ detail: "Line the frame up with the bottom's edges, then screw it on through the rails.",+ tools: ["screwdriver"],+ pose: "+z",+ kind: "legs",+ people: tall ? 2 : 1,+ warnings: tall ? ["two", "floor"] : ["floor"],+ },+ () => {+ b.add(frame, [0, -320, 0]);+ b.then(0.15);+ const list: FitOpts[] = [];+ for (const z of [-zs, zs]) for (const x of [-W / 4, W / 4]) list.push({ on: frame, at: [x, -rail, z], dir: [0, 1, 0], hole: false });+ for (const x of [-xs, xs]) list.push({ on: frame, at: [x, -rail, 0], dir: [0, 1, 0], hole: false });+ b.fits(HW.screwL, list, 0.08);+ },+ );+ b.step(+ {+ title: tall ? "Stand it up together" : "Stand it up",+ detail: "Tip it up onto the underframe on a flat floor, and check it doesn't rock.",+ kind: "standup",+ people: tall ? 2 : 1,+ warnings: tall ? ["two"] : [],+ },+ () => {},+ );+ });+ // everything was built with the shelf's bottom at zero: lift it all onto the underframe+ for (const it of b.items) {+ if (it.kind === "part") {+ const old = it.final.pos;+ it.final = { pos: [old[0], old[1] + U, 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], st.pos[1] + U, st.pos[2]];+ } else if (!it.parent && it.scene === "main") it.pos = [it.pos[0], it.pos[1] + U, it.pos[2]];+ }+}+export type { Vec3 };diff --git a/src/lib/products.ts b/src/lib/products.tsindex c755b75..84aa790 100644--- a/src/lib/products.ts+++ b/src/lib/products.ts@@ -92,6 +92,7 @@ export type X = {z?: string;basin?: number;hung?: boolean;+ uf?: number;};export type Row = [name: string, kind: Kind, variant: string, w: number, h: number, d: number, x?: X, keywords?: string];@@ -364,6 +365,11 @@ export function specFor(kind: Kind, name: string, variant: string, w: number, h:};switch (kind) {case "cube":+ // x.uf: cm of an underframe the grid stands on+ if (x.uf) {+ const cols = Math.max(1, Math.round((w - 6) / 35)), rows = Math.max(1, Math.round((h - x.uf - 6) / 35));+ return { ...base, minutes: x.min ?? 30 + 7 * cols * rows, people: cols * rows > 4 ? 2 : 1, shelf: { style: "grid", cols, rows, outer: 40, inner: 16, back: false, underframe: x.uf } };+ }return { ...base, shelf: { style: "grid", cols: Math.max(1, Math.round((w - 6) / 35)), rows: Math.max(1, Math.round((h - 6) / 35)), outer: 40, inner: 16, back: false } };case "bookcase":return { ...base, shelf: { style: "bookcase", shelves: x.shelves ?? Math.max(1, Math.round(h / 45) - 1), fixedShelf: h > 150, back: true, plinth: h > 100, outer: 16 } };diff --git a/src/lib/types.ts b/src/lib/types.tsindex a572e76..a90816f 100644--- a/src/lib/types.ts+++ b/src/lib/types.ts@@ -13,6 +13,7 @@ export interface ShelfParams {outer: number; // mm panel thickness of frameinner: number; // mm thickness of inner shelves/dividerswall?: boolean; // hangs on the wall instead of standing on the floor+ underframe?: number; // cm: a cube grid standing on an underframe this tall (size.h takes it in)}export interface DrawersParams {