IKEA assembly, step by step: animated, manual-style 3D guides. Scan any paper manual with Together AI.
TypeScript
Draw shelving units with a cabinet, a clothes rail or a storage box
Youssef4d9fe57c18c2
diff --git a/scripts/ikea/classify.ts b/scripts/ikea/classify.tsindex fa96596..baf079d 100644--- a/scripts/ikea/classify.ts+++ b/scripts/ikea/classify.ts@@ -92,7 +92,7 @@ const ROW_UNITS: Record<string, number> = { BILLY: 80, BESTÅ: 120, IVAR: 80, PA/** PAX frames under a pair of sliding doors: 150 is two 75s, 200 two 100s. */const PAX_SLIDE_UNITS = [100, 75];/** The frame widths a family's combinations are made of, widest first, and the post two IVAR sections share. */-const FRAME_SIZES: Record<string, number[]> = { BILLY: [80, 40], PAX: [100, 75, 50], IVAR: [89, 48], BROR: [85, 65] };+const FRAME_SIZES: Record<string, number[]> = { BILLY: [80, 40], PAX: [100, 75, 50], IVAR: [89, 48], BROR: [85, 65], OMAR: [92, 46] };const SHARED_POST: Record<string, number> = { IVAR: 3 };/** Two to four frames of these widths that make up w, give or take 2 cm: the fewest frames, the widest first. */@@ -156,6 +156,8 @@ const BLIND_DOOR: Record<string, number> = { METOD: 60, KNOXHULT: 50 };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] };+/** Shelving units with a cabinet at the bottom: how high the cabinet is, in cm. */+const CABINET_LOW: Record<string, number> = { BROR: 72, KOLBJÖRN: 81 };/** 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],@@ -427,6 +429,17 @@ const RULES: Rule[] = [return { kind: "kitchen", x: { z: h - 40 * k >= 20 ? `r${k}@${40 * k}+r1` : `r${k}`, cat: "High cabinet with drawers" } };}],[/^shelving unit\/bench$/, () => ({ kind: "open" })],+ // shelving units with a clothes rail, a cabinet at the bottom or a storage box on castors under them (the ones+ // that mix cabinets and drawers, or a box under a row of sections, stay skipped)+ [/^shelving unit with clothes rail$/, () => ({ kind: "open", x: { rail: true, cat: "Shelving unit with clothes rail" } })],+ [/^shelving unit with (?:\d )?(cabinet|cabinets)$/, (m, c) => {+ const low = CABINET_LOW[c.f.name];+ if (!low || (m[1] === "cabinets") !== ((c.sz.n[0] ?? 0) > 100) || /\d/.test(m[0])) return "shelving unit with cabinets of different sizes";+ return { kind: "cabinet", x: { low, cat: "Shelving unit with cabinet" } };+ }],+ [/^shelving unit with storage box$/, (_m, c) => ((c.sz.n[0] ?? 0) > 100 ? "row of shelving sections with a storage box" : { kind: "open", x: { box: 25, cat: "Shelving unit with storage box" } })],+ [/^shelving unit with plinth$/, () => ({ kind: "open", x: { plinth: true } })],+ [/^box shelf with divider$/, () => ({ kind: "cube", x: { t: 18, cat: "Box shelf" } })],// a laptop table is a small desk[/^laptop table$/, () => ({ kind: "desk" })],[/^bar stool with backrest, foldable$/, () => ({ kind: "chair", x: { seatH: 63 } })],diff --git a/scripts/ikea/slugs.json b/scripts/ikea/slugs.jsonindex 1612617..be8fb72 100644--- a/scripts/ikea/slugs.json+++ b/scripts/ikea/slugs.json@@ -159,6 +159,8 @@"BRIMNES|TV bench, 216 × 41 × 54 cm": "brimnes-tv-bench-216-x-41-x-54","BROR|Cabinet with 2 doors, 76 × 40 × 66 cm": "bror-cabinet-2-doors-76-x-40-x-66","BROR|Cabinet with doors, 85 × 40 × 191 cm": "bror-cabinet-doors-85-x-40-x-191",+ "BROR|Shelving unit with cabinet, 85 × 40 × 190 cm": "bror-shelving-unit-cabinet-85-x-40-x-190",+ "BROR|Shelving unit with cabinets, 170 × 40 × 190 cm": "bror-shelving-unit-cabinets-170-x-40-x-190","BROR|Shelving unit, 170 × 40 × 110 cm": "bror-shelving-unit-170-x-40-x-110","BROR|Shelving unit, 234 × 55 × 110 cm": "bror-shelving-unit-234-x-55-x-110","BROR|Shelving unit, 234 × 55 × 190 cm": "bror-shelving-unit-234-x-55-x-190",@@ -393,6 +395,7 @@"HAVSTA|Glass-door cabinet with plinth, 121 × 37 × 134 cm": "havsta-glass-door-cabinet-plinth-121-x-37-x-134","HAVSTA|Glass-door cabinet with plinth, 81 × 37 × 134 cm": "havsta-glass-door-cabinet-plinth-81-x-37-x-134","HAVSTA|Glass-door cabinet, 121 × 35 × 123 cm": "havsta-glass-door-cabinet-121-x-35-x-123",+ "HAVSTA|Shelving unit with plinth, 81 × 37 × 134 cm": "havsta-shelving-unit-plinth-81-x-37-x-134","HAVSTA|Shelving unit, 81 × 35 × 123 cm": "havsta-shelving-unit-81-x-35-x-123","HAVSTA|Sideboard basic unit, 121 × 47 × 89 cm": "havsta-sideboard-basic-unit-121-x-47-x-89","HAVSTA|TV bench with plinth, 160 × 47 × 62 cm": "havsta-tv-bench-plinth-160-x-47-x-62",@@ -467,6 +470,7 @@"INGOLF|Junior chair": "ingolf-junior-chair","INVALLNING|Trolley, 68 × 39 cm": "invallning-trolley-68-x-39","ISMANTORP|Armchair": "ismantorp-armchair",+ "IVAR|Box shelf with divider, 83 × 30 × 25 cm": "ivar-box-shelf-divider-83-x-30-x-25","IVAR|Cabinet with doors, 160 × 30 × 83 cm": "ivar-cabinet-doors-160-x-30-x-83","IVAR|Cabinet with doors, 89 × 30 × 124 cm": "ivar-cabinet-doors-89-x-30-x-124","IVAR|Cabinet with sliding doors, 80 × 30 × 60 cm": "ivar-cabinet-sliding-doors-80-x-30-x-60",@@ -475,6 +479,8 @@"IVAR|Shelving unit with doors, 259 × 30 × 226 cm": "ivar-shelving-unit-doors-259-x-30-x-226","IVAR|Shelving unit with doors, 89 × 30 × 124 cm": "ivar-shelving-unit-doors-89-x-30-x-124","IVAR|Shelving unit with doors, 89 × 30 × 179 cm": "ivar-shelving-unit-doors-89-x-30-x-179",+ "IVAR|Shelving unit with storage box, 89 × 30 × 124 cm": "ivar-shelving-unit-storage-box-89-x-30-x-124",+ "IVAR|Shelving unit with storage box, 89 × 30 × 179 cm": "ivar-shelving-unit-storage-box-89-x-30-x-179","IVAR|Shelving unit, 80 × 30 × 166 cm": "ivar-shelving-unit-80-x-30-x-166","IVAR|Shelving unit, 80 × 30 × 83 cm": "ivar-shelving-unit-80-x-30-x-83","IVAR|Shelving unit, 89 × 30 × 124 cm": "ivar-shelving-unit-89-x-30-x-124",@@ -575,6 +581,7 @@"KNOXHULT|Wall cabinet with doors, 120 × 75 cm": "knoxhult-wall-cabinet-doors-120-x-75","KOLBJÖRN|Cabinet, 90 × 161 cm": "kolbjorn-cabinet-90-x-161","KOLBJÖRN|Shelving unit in/outdoor, 80 × 35 × 162 cm": "kolbjorn-shelving-unit-in-outdoor-80-x-35-x-162",+ "KOLBJÖRN|Shelving unit with cabinet, 80 × 37 × 161 cm": "kolbjorn-shelving-unit-cabinet-80-x-37-x-161","KOLBJÖRN|Shelving unit, 80 × 45 cm": "kolbjorn-shelving-unit-80-x-45","KOMPISHÄNG|Desk, 100 × 55 cm": "kompishang-desk-100-x-55","KOMPISHÄNG|Side table, 50 cm": "kompishang-side-table-50",@@ -986,6 +993,8 @@"NYSJÖN|Wash-basin base cabinet w 2 doors, 50 × 65 cm": "nysjon-wash-basin-base-cabinet-w-2-doors-50-x-65","NYSJÖN|Wash-basin cabinet, 50 × 83 cm": "nysjon-wash-basin-cabinet-50-x-83","OLSERÖD|Side table, 53 × 50 cm": "olserod-side-table-53-x-50",+ "OMAR|Shelving unit with clothes rail, 186 × 50 × 201 cm": "omar-shelving-unit-clothes-rail-186-x-50-x-201",+ "OMAR|Shelving unit with clothes rail, 92 × 50 × 201 cm": "omar-shelving-unit-clothes-rail-92-x-50-x-201","OMAR|Shelving unit, 46 × 36 × 181 cm": "omar-shelving-unit-46-x-36-x-181","OMAR|Shelving unit, 46 × 36 × 94 cm": "omar-shelving-unit-46-x-36-x-94","OMAR|Shelving unit, 60 × 25 × 40 cm": "omar-shelving-unit-60-x-25-x-40",diff --git a/src/data/ikea-items.ts b/src/data/ikea-items.tsindex 3d8617d..c74caf8 100644--- a/src/data/ikea-items.ts+++ b/src/data/ikea-items.ts@@ -187,6 +187,8 @@ bror-shelving-unit-65-x-55-x-190|29619402bror-shelving-unit-85-x-190|19619407 19650233 09619403 49516139bror-shelving-unit-85-x-55-x-110|39272655 39272641 69272649bror-shelving-unit-85-x-55-x-190|89617443 99650253 59619405 69516138+bror-shelving-unit-cabinet-85-x-40-x-190|89516142+bror-shelving-unit-cabinets-170-x-40-x-190|09516141bror-trolley-85-x-55|60333850 80547384bror-work-bench-110-x-55|30333286brusali-shoe-cabinet-3-compartments|80480393@@ -423,6 +425,7 @@ havsta-glass-door-cabinet-121-x-35-x-123|00529256 90529252havsta-glass-door-cabinet-plinth-121-x-37-x-134|89534669 29534672havsta-glass-door-cabinet-plinth-81-x-37-x-134|49534652 09534654havsta-shelving-unit-81-x-35-x-123|50529273 60529277 00529275+havsta-shelving-unit-plinth-81-x-37-x-134|79534641 19534644havsta-sideboard-basic-unit-121-x-47-x-89|40529235 30529231havsta-tv-bench-plinth-160-x-47-x-62|10529270 90529266havsten-2-seat-sofa-outdoor|39500959@@ -508,6 +511,7 @@ ikea-ps-lomsk-children-s-swivel-armchair|30609237ingolf-junior-chair|60353838invallning-trolley-68-x-39|10569398ismantorp-armchair|60598218 10598225+ivar-box-shelf-divider-83-x-30-x-25|20596382ivar-cabinet-doors-160-x-30-x-83|89508118 99508108ivar-cabinet-doors-80-x-83|50531252 00531240 40033763 70033766ivar-cabinet-doors-89-x-30-x-124|69508162 49508158@@ -524,6 +528,8 @@ ivar-shelving-unit-doors-259-x-30-x-124|79403471ivar-shelving-unit-doors-259-x-30-x-226|59403472ivar-shelving-unit-doors-89-x-30-x-124|39403473 89507883 59508087 09507858ivar-shelving-unit-doors-89-x-30-x-179|89403461 19403474+ivar-shelving-unit-storage-box-89-x-30-x-124|09404582+ivar-shelving-unit-storage-box-89-x-30-x-179|59403815ivar-wall-cabinet-doors-160-x-30-x-83|09417382ivosjon-cabinet-doors-33-x-34-x-99|30569095 90609871ivosjon-wash-basin-base-cabinet-50-x-33-x-57|20597292@@ -629,6 +635,7 @@ kolbjorn-cabinet-80-x-81|30409295kolbjorn-cabinet-90-x-161|60601862kolbjorn-shelving-unit-80-x-45|20601864kolbjorn-shelving-unit-80-x-81|60409294+kolbjorn-shelving-unit-cabinet-80-x-37-x-161|19291645kolbjorn-shelving-unit-in-outdoor-80-x-35-x-162|99291646kompishang-desk-100-x-55|00628751kompishang-side-table-50|50628819@@ -1064,6 +1071,8 @@ omar-shelving-unit-46-x-36-x-94|00069768omar-shelving-unit-60-x-25-x-40|30483073omar-shelving-unit-92-x-36-x-94|10069763omar-shelving-unit-92-x-50-x-94|70483071+omar-shelving-unit-clothes-rail-186-x-50-x-201|99487691 59487688+omar-shelving-unit-clothes-rail-92-x-50-x-201|60530978ommjange-chair|50594678onnestad-armchair|09554473 49554471orfjall-children-s-desk-chair|30441771 90541433 60501886diff --git a/src/data/ikea-rows.ts b/src/data/ikea-rows.tsindex 4d87b06..342a348 100644--- a/src/data/ikea-rows.ts+++ b/src/data/ikea-rows.ts@@ -164,7 +164,9 @@ BROR|bookrow|Shelving unit, 234 × 55 × 190 cm|234|190|55|of=open,u=85+85+65BROR|bookrow|Shelving unit, 254 × 40 × 190 cm|254|190|40|of=open,u=85+85+85BROR|bookrow|Shelving unit, 254 × 55 × 190 cm|254|190|55|of=open,u=85+85+85BROR|cabinet|Cabinet with 2 doors, 76 × 40 × 66 cm|76|66|40+BROR|cabinet|Shelving unit with cabinet, 85 × 40 × 190 cm|85|190|40|cat=Shelving unit with cabinet,low=72BROR|cabinet|Cabinet with doors, 85 × 40 × 191 cm|85|191|40+BROR|cabrow|Shelving unit with cabinets, 170 × 40 × 190 cm|170|190|40|of=cabinet,u=85+85,cat=Shelving unit with cabinet,low=72BROR|open|Shelving unit, 65 × 40 × 190 cm|65|190|40BROR|open|Shelving unit, 65 × 55 × 190 cm|65|190|55BROR|open|Shelving unit, 85 × 55 × 110 cm|85|110|55@@ -395,6 +397,7 @@ HAVSTA|cabinet|Glass-door cabinet with plinth, 121 × 37 × 134 cm|121|134|37HAVSTA|chest|Chest of 3 drawers, 81 × 47 × 89 cm|81|89|47|rows=3HAVSTA|chest|Chest of 6 drawers, 121 × 47 × 89 cm|121|89|47|rows=3,cols=2HAVSTA|open|Shelving unit, 81 × 35 × 123 cm|81|123|35+HAVSTA|open|Shelving unit with plinth, 81 × 37 × 134 cm|81|134|37|plinth=1HAVSTA|sideboard|Sideboard basic unit, 121 × 47 × 89 cm|121|89|47HAVSTA|tv|TV bench with plinth, 160 × 47 × 62 cm|160|62|47HAVSTEN|armchair|Armchair, outdoor|75|90|80||outdoor garden@@ -476,9 +479,12 @@ IVAR|cabrow|Cabinet with doors, 160 × 30 × 83 cm|160|83|30|n=2,of=cabinetIVAR|cabrow|Wall cabinet with doors, 160 × 30 × 83 cm|160|83|30|n=2,of=wallcabIVAR|cabrow|Shelving unit with doors, 259 × 30 × 124 cm|259|124|30|of=cabinet,u=89+89+89IVAR|cabrow|Shelving unit with doors, 259 × 30 × 226 cm|259|226|30|of=cabinet,u=89+89+89+IVAR|cube|Box shelf with divider, 83 × 30 × 25 cm|83|25|30|cat=Box shelf,t=18IVAR|open|Shelving unit, 80 × 30 × 83 cm|80|83|30IVAR|open|Shelving unit, 80 × 30 × 166 cm|80|166|30+IVAR|open|Shelving unit with storage box, 89 × 30 × 124 cm|89|124|30|cat=Shelving unit with storage box,box=25IVAR|open|Shelving unit, 89 × 30 × 124 cm|89|124|30+IVAR|open|Shelving unit with storage box, 89 × 30 × 179 cm|89|179|30|cat=Shelving unit with storage box,box=25IVAR|open|Shelving unit, 89 × 50 × 179 cm|89|179|50IVAR|open|Shelving unit, 89 × 30 × 226 cm|89|226|30IVAR|open|Shelving unit, 89 × 50 × 226 cm|89|226|50@@ -574,6 +580,7 @@ KNOXHULT|wallcab|Wall cabinet with door, 40 × 75 cm|40|75|35|doors=1KNOXHULT|wallcab|Wall cabinet with door, 60 × 60 cm|60|60|35|doors=1KNOXHULT|wallcab|Wall cabinet with door, 60 × 75 cm|60|75|35|doors=1KNOXHULT|wallcab|Wall cabinet with doors, 120 × 75 cm|120|75|35+KOLBJÖRN|cabinet|Shelving unit with cabinet, 80 × 37 × 161 cm|80|161|37|cat=Shelving unit with cabinet,low=81|outdoor gardenKOLBJÖRN|cabinet|Cabinet, 90 × 161 cm|90|161|37||outdoor gardenKOLBJÖRN|open|Shelving unit, 80 × 45 cm|80|45|37||outdoor gardenKOLBJÖRN|open|Shelving unit in/outdoor, 80 × 35 × 162 cm|80|162|35||outdoor garden@@ -987,11 +994,13 @@ NYSJÖN|washstand|Wash-basin cabinet, 50 × 83 cm|50|83|47|z=d1NYSJÖN / BJÖRKÅN|washstand|Wash-basin base cabinet w 2 doors, 54 × 40 × 80 cm|54|80|40|z=d2,basin=15NYSJÖN / BJÖRKÅN|washstand|Wash-stnd w door/wash-basin/tap, 54 × 40 × 88 cm|54|88|40|z=d1,basin=16OLSERÖD|side|Side table, 53 × 50 cm|53|50|50+OMAR|bookrow|Shelving unit with clothes rail, 186 × 50 × 201 cm|186|201|50|rail=1,of=open,u=92+92,cat=Shelving unit with clothes railOMAR|open|Shelving unit, 46 × 36 × 94 cm|46|94|36OMAR|open|Shelving unit, 46 × 36 × 181 cm|46|181|36OMAR|open|Shelving unit, 60 × 25 × 40 cm|60|40|25OMAR|open|Shelving unit, 92 × 36 × 94 cm|92|94|36OMAR|open|Shelving unit, 92 × 50 × 94 cm|92|94|50+OMAR|open|Shelving unit with clothes rail, 92 × 50 × 201 cm|92|201|50|rail=1,cat=Shelving unit with clothes railOMMJÄNGE|chair|Chair|44|88|50ÖNNESTAD|armchair|Armchair|75|90|80ÖRFJÄLL|office|Children's desk chair|52|86|52|arms=none,seatH=42|kidsdiff --git a/src/lib/plan/cabinet.ts b/src/lib/plan/cabinet.tsindex ccadaea..dd71371 100644--- a/src/lib/plan/cabinet.ts+++ b/src/lib/plan/cabinet.ts@@ -8,6 +8,7 @@ import { buildSliding } from "./sliding";import { buildCornerCabinet } from "./cornercab";import { buildLidBox } from "./lidbox";import { CASTOR_H, castorStep, liftOntoCastors } from "./castors";+import { buildShelfCab } from "./shelfcab";export function defaultsCabinet(s: ProductSpec): CabinetParams {const p = s.cabinet ?? {};@@ -26,6 +27,7 @@ export function defaultsCabinet(s: ProductSpec): CabinetParams {export function buildCabinet(b: PlanBuilder, s: ProductSpec) {if (s.cabinet?.lid) return buildLidBox(b, s);+ if (s.cabinet?.low) return buildShelfCab(b, s);if (s.cabinet?.corner) return buildCornerCabinet(b, s);if (s.cabinet?.fit) return buildFitted(b, s);if (s.cabinet?.drawers) return buildMixed(b, s);diff --git a/src/lib/plan/shelf.ts b/src/lib/plan/shelf.tsindex 2cb7015..0c61351 100644--- a/src/lib/plan/shelf.ts+++ b/src/lib/plan/shelf.ts@@ -5,6 +5,7 @@ import { clamp } from "./math";import { buildChanging } from "./changing";import { buildRack } from "./rack";import { buildScreen } from "./screen";+import { CASTOR_H } from "./castors";export function defaultsShelf(s: ProductSpec): ShelfParams {const p = s.shelf ?? {};@@ -28,9 +29,118 @@ export function buildShelf(b: PlanBuilder, s: ProductSpec) {if (s.shelf?.style === "screen") return buildScreen(b, s);const p = defaultsShelf(s);if (p.style === "grid") return s.shelf?.underframe ? onUnderframe(b, s, p) : s.shelf?.inserts ? withInserts(b, s, p) : grid(b, s, p);+ if (s.shelf?.rail) return withRail(b, s, p);+ if (s.shelf?.boxUnder) return withBox(b, s, p);return bookcase(b, s, p);}+/** Open shelving with a clothes rail (OMAR): a fixed shelf near the top with the rail under it, and one shelf low down. */+function withRail(b: PlanBuilder, s: ProductSpec, p: ShelfParams) {+ const W = s.size.w * 10, H = s.size.h * 10, D = s.size.d * 10;+ const t = p.outer;+ const lying = H > 1100;+ const yTop = Math.round((H - Math.min(420, H * 0.22)) / 32) * 32;+ const f = new FrameKit(b, { W, H, D, t, base: 0, plinth: false, fixed: [yTop], back: p.back, pinRows: false, lying, names: { fixed: "Top shelf" } });+ const yLow = 320;+ const shT = b.part("Shelf", [W - 2 * t - 3, t, D - 26]);+ const low = b.place(shT, [0, yLow + 3 + t / 2, 11]);+ for (const dy of [-64, 0, 64])+ for (const [i, side] of f.sides.entries()) {+ const xi = i === 0 ? -W / 2 + t : W / 2 - t;+ for (const z of [D / 2 - 40, -D / 2 + 40]) b.hole(side, [xi, yLow + dy, z], [i === 0 ? 1 : -1, 0, 0], 2.5);+ }+ const two: 1 | 2 = H > 1500 ? 2 : 1;+ f.prepSides();+ f.join(lying ? 1 : two);+ f.otherSide(lying ? 1 : two);+ f.cams();+ if (p.back) f.backSteps();+ if (p.back || lying) f.standUp();+ b.step(+ {+ title: "Add the shelf pins and the low shelf",+ detail: "Near the bottom, for shoes or boxes. Use the same hole on all four corners.",+ kind: "shelves",+ },+ () => {+ const pins: FitOpts[] = [];+ for (const [i, sd] of f.sides.entries()) {+ const x = i === 0 ? -W / 2 + t : W / 2 - t;+ for (const z of [D / 2 - 40, -D / 2 + 40]) pins.push({ on: sd, at: [x, yLow, z], dir: [i === 0 ? -1 : 1, 0, 0], hole: false });+ }+ b.fits(HW.pin, pins, 0.06);+ b.then(0.2);+ b.add(low, [0, 0, 420]);+ },+ );+ const ry = yTop - t / 2 - 150; // low enough under the shelf to lift hangers on and off+ const railT = b.part("Clothes rail", [24, W - 2 * t - 2, 24], { shape: "cyl", material: "metal" });+ const rail = b.place(railT, [0, ry, 0], [0, 0, Math.PI / 2]);+ b.step(+ {+ title: "Fit the clothes rail",+ detail: "Screw the holders to the sides under the top shelf, then drop the rail in.",+ tools: ["screwdriver"],+ kind: "screws",+ },+ () => {+ b.fits(+ HW.screwS,+ f.sides.map((sd, i) => ({ on: sd, at: [(i === 0 ? -1 : 1) * (W / 2 - t), ry, 0] as Vec3, dir: [i === 0 ? -1 : 1, 0, 0] as Vec3, hole: false })),+ 0.1,+ );+ b.then(0.1);+ b.add(rail, [0, -180, 260]);+ },+ );+ f.anchor();+}++/** Open shelving with its bottom shelf raised, and a storage box on castors that rolls in under it (IVAR). */+function withBox(b: PlanBuilder, s: ProductSpec, p: ShelfParams) {+ const W = s.size.w * 10, H = s.size.h * 10, D = s.size.d * 10;+ const t = p.outer;+ const U = clamp(s.shelf!.boxUnder! * 10, 150, 500);+ const lying = H > 1100;+ const f = new FrameKit(b, { W, H, D, t, base: U, plinth: false, fixed: p.fixedShelf ? [Math.round((U + H) / 2 / 32) * 32] : [], back: p.back, pinRows: p.shelves > 0, lying });+ const two: 1 | 2 = H > 1500 ? 2 : 1;+ f.prepSides();+ f.join(lying ? 1 : two);+ f.otherSide(lying ? 1 : two);+ f.cams();+ if (p.back) f.backSteps();+ if (p.back || lying) f.standUp();+ f.shelves(p.shelves);+ const bw = W - 2 * t - 30, bh = U - CASTOR_H - 25, bd = D - 30;+ const boxT = b.part("Storage box", [bw, bh, bd]);+ const box = b.place(boxT, [0, CASTOR_H + bh / 2, 0]);+ b.step(+ {+ title: "Fit the castors under the storage box",+ detail: "Turn it upside down. Push a castor into each corner until it clicks.",+ scene: "box",+ kind: "legs",+ warnings: ["floor"],+ },+ () => {+ b.stage(box, [0, bh / 2, 0], [Math.PI, 0, 0], [0, 160, 0]);+ b.then(0.1);+ const list: FitOpts[] = [];+ for (const x of [-bw / 2 + 45, bw / 2 - 45]) for (const z of [-bd / 2 + 45, bd / 2 - 45]) list.push({ on: box, at: [x, CASTOR_H, z], dir: [0, 1, 0], travel: 70, hole: false });+ b.fits(HW.castor, list, 0.12);+ },+ );+ b.step(+ {+ title: "Roll the storage box in under the bottom shelf",+ detail: "It sits on its castors, clear of the floor, and pulls out from the front.",+ kind: "general",+ },+ () => b.add(box, [0, 0, 480]),+ );+ if (H >= 900) f.anchor();+}+function bookcase(b: PlanBuilder, s: ProductSpec, p: ShelfParams) {const W = s.size.w * 10, H = s.size.h * 10, D = s.size.d * 10;const t = p.outer;diff --git a/src/lib/plan/shelfcab.ts b/src/lib/plan/shelfcab.tsnew file mode 100644index 0000000..2dcf0e7--- /dev/null+++ b/src/lib/plan/shelfcab.ts@@ -0,0 +1,137 @@+import type { ProductSpec, Vec3 } from "../types";+import { HW, PlanBuilder, type FitOpts } from "./builder";+import { FrameKit } from "./frame";+import { clamp } from "./math";++/**+ * A shelving unit with a cabinet at the bottom (BROR, KOLBJÖRN): one carcass with a fixed shelf as high as the+ * cabinet, doors over the part below it and open shelves on pins above. Built like a cabinet: the carcass and its+ * back, the shelves, then the doors, and it is fixed to the wall last.+ */+export function buildShelfCab(b: PlanBuilder, s: ProductSpec) {+ const c = s.cabinet ?? {};+ const W = s.size.w * 10, H = s.size.h * 10, D = s.size.d * 10;+ const t = clamp(c.thickness ?? 18, 12, 25);+ const base = c.plinth ? 70 : 0;+ const yc = clamp((c.low ?? 80) * 10, base + 300, H - 400); // top of the cabinet+ const f = new FrameKit(b, { W, H, D, t, base, plinth: !!c.plinth, fixed: [yc - t / 2], back: true, pinRows: false, lying: H > 1100, names: { fixed: "Cabinet top" } });+ const nd = c.doors === 1 ? 1 : 2;+ const handles = c.handles ?? "knob";++ // shelves: one behind the doors when there's room, and the open part above shared out evenly+ const inner = W - 2 * t;+ const shT = b.part("Shelf", [inner - 3, t, D - 26]);+ const behind = yc - base - t > 600 ? [Math.round(((base + t + yc) / 2) / 32) * 32] : [];+ const nOpen = clamp(Math.round((H - yc) / 380) - 1, 1, 4);+ const open = Array.from({ length: nOpen }, (_, i) => Math.round((yc + ((H - t - yc) * (i + 1)) / (nOpen + 1)) / 32) * 32);+ const ys = [...behind, ...open];+ const shelves = ys.map((y) => b.place(shT, [0, y + 3 + t / 2, 11]));+ for (const y0 of ys)+ for (const dy of [-64, 0, 64])+ for (const [i, side] of f.sides.entries()) {+ const xi = i === 0 ? -W / 2 + t : W / 2 - t;+ for (const z of [D / 2 - 40, -D / 2 + 40]) b.hole(side, [xi, y0 + dy, z], [i === 0 ? 1 : -1, 0, 0], 2.5);+ }++ f.prepSides();+ f.join();+ f.otherSide();+ f.cams();+ f.plinthStep();+ f.backSteps();+ f.standUp();++ b.step(+ {+ title: ys.length > 1 ? "Add the shelf pins and shelves" : "Add the shelf pins and the shelf",+ detail: behind.length ? "One inside the cabinet, the rest in the open part above. Use the same hole on all four corners." : "In the open part above the cabinet. Use the same hole on all four corners.",+ kind: "shelves",+ },+ () => {+ const pins: FitOpts[] = [];+ for (const y of ys)+ for (const [i, sd] of f.sides.entries()) {+ const x = i === 0 ? -W / 2 + t : W / 2 - t;+ for (const z of [D / 2 - 40, -D / 2 + 40]) pins.push({ on: sd, at: [x, y, z], dir: [i === 0 ? -1 : 1, 0, 0], hole: false });+ }+ b.fits(HW.pin, pins, 0.05);+ b.then(0.2);+ b.stagger(0.25);+ shelves.forEach((k) => b.add(k, [0, 0, 420]));+ },+ );++ /* ---------- doors over the cabinet ---------- */+ const fz = D / 2 + t / 2;+ const dw = nd === 2 ? W / 2 - 3 : W - 4;+ const dh = yc - base - 4;+ const dy = base + 2 + dh / 2;+ const doorT = b.part("Door", [dw, dh, t]);+ const doors = Array.from({ length: nd }, (_, i) => b.place(doorT, [nd === 2 ? (i === 0 ? -1 : 1) * (W / 4) : 0, dy, fz]));+ const hn = dh > 900 ? 3 : 2;+ const hingeYs = Array.from({ length: hn }, (_, i) => base + 110 + (i * (dh - 220)) / (hn - 1));+ const hingeX = (i: number) => {+ const sgn = nd === 2 && i === 1 ? 1 : -1;+ return { x: sgn * (W / 2 - 22), sgn };+ };+ b.step(+ {+ title: nd > 1 ? "Press the hinges into the doors" : "Press the hinges into the door",+ detail: "Two small screws hold each one.",+ tools: ["screwdriver"],+ scene: "doors",+ kind: "hinges",+ warnings: ["floor"],+ },+ () => {+ b.stagger(0.2);+ doors.forEach((d, i) => b.stage(d, [(i - (nd - 1) / 2) * (dw + 80), t / 2, 0], [Math.PI / 2, 0, 0], [0, 160, 0]));+ b.then(0.1);+ const hinges: FitOpts[] = [];+ const screws: FitOpts[] = [];+ doors.forEach((d, i) => {+ const { x, sgn } = hingeX(i);+ for (const y of hingeYs) {+ hinges.push({ on: d, at: [x, y, D / 2], dir: [0, 0, 1], twist: sgn > 0 ? Math.PI : 0 });+ for (const dy2 of [-24, 24]) screws.push({ on: d, at: [x + sgn * 4, y + dy2, D / 2], dir: [0, 0, 1], hole: false });+ }+ });+ b.fits(HW.hinge, hinges, 0.1);+ b.then(0.05);+ b.fits(HW.screwS, screws, 0.03);+ },+ );+ b.step(+ {+ title: nd > 1 ? "Hang the doors" : "Hang the door",+ detail: "Slide each hinge arm onto its plate until it clicks, then turn the hinge screws until the gaps look even.",+ tools: ["screwdriver"],+ kind: "doors",+ },+ () => {+ b.stagger(0.35);+ doors.forEach((d) => b.add(d, [0, 0, 380]));+ },+ );+ if (handles !== "none") {+ const def = handles === "bar" ? HW.handle : HW.knob;+ b.step(+ {+ title: handles === "bar" ? "Screw on the handles" : "Screw on the knobs",+ detail: "Screw from the inside of the door, near its top edge.",+ tools: ["screwdriver"],+ kind: "screws",+ },+ () => {+ const list: FitOpts[] = doors.map((d, i) => {+ const { sgn } = hingeX(i);+ const x = b.partItem(d).final.pos[0] - sgn * (dw / 2 - 40);+ return { on: d, at: [x, yc - 90, D / 2 + t] as Vec3, dir: [0, 0, -1] as Vec3, hole: false, twist: handles === "bar" ? Math.PI / 2 : 0 };+ });+ b.fits(def, list, 0.12);+ },+ );+ }++ if (H >= 800) f.anchor();+}diff --git a/src/lib/products.ts b/src/lib/products.tsindex c03c86b..a828142 100644--- a/src/lib/products.ts+++ b/src/lib/products.ts@@ -431,11 +431,16 @@ function specOf(kind: Kind, name: string, variant: string, w: number, h: number,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 } };}+ // x.t: thinner panels than KALLAX's (IVAR's box shelf)+ if (x.t) return { ...base, shelf: { style: "grid", cols: Math.max(1, Math.round((w - 6) / 35)), rows: Math.max(1, Math.round((h - 6) / 35)), outer: x.t, inner: x.t, back: false } };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 } };case "open":- return { ...base, difficulty: 1, shelf: { style: "bookcase", shelves: x.shelves ?? Math.max(1, Math.round(h / 45) - 1), fixedShelf: h > 150, back: false, plinth: false, outer: 18 } };+ // x.rail: a clothes rail under a shelf near the top; x.box: room under the bottom shelf for a storage box on castors+ if (x.rail) return { ...base, difficulty: 2, people: 2, shelf: { style: "bookcase", shelves: 1, fixedShelf: false, back: false, plinth: false, outer: 18, rail: true } };+ if (x.box) return { ...base, minutes: x.min ?? MIN.open + 10, difficulty: 1, shelf: { style: "bookcase", shelves: x.shelves ?? Math.max(1, Math.round((h - x.box) / 45) - 1), fixedShelf: h > 150, back: false, plinth: false, outer: 18, boxUnder: x.box } };+ return { ...base, difficulty: 1, shelf: { style: "bookcase", shelves: x.shelves ?? Math.max(1, Math.round(h / 45) - 1), fixedShelf: h > 150, back: false, plinth: x.plinth ?? false, outer: 18 } };case "changing": {// x.rows: a chest of that many drawers under the changing top; otherwise an open frame with x.shelvesif (x.rows) {@@ -500,6 +505,8 @@ function specOf(kind: Kind, name: string, variant: string, w: number, h: number,case "wardrobe":return { ...base, people: 2, cabinet: { doors: x.doors ?? (w >= 60 ? 2 : 1), shelves: x.shelves ?? 1, rail: true, plinth: true, handles: x.knobs ?? "knob", thickness: 18 } };case "cabinet":+ // x.low: a shelving unit with a cabinet this many cm high at the bottom, open shelves above+ if (x.low) return { ...base, minutes: x.min ?? MIN.cabinet + 25, people: h > 150 ? 2 : 1, cabinet: { doors: x.doors ?? (w > 50 ? 2 : 1), shelves: 0, rail: false, plinth: false, handles: x.knobs ?? "knob", thickness: 18, low: x.low } };// x.cast: on castors, so no plinthif (x.cast) return { ...base, minutes: x.min ?? MIN.cabinet + 5, cabinet: { doors: x.doors ?? (w > 50 ? 2 : 1), shelves: x.shelves ?? (h > 100 ? 2 : 1), rail: false, plinth: false, handles: x.knobs ?? "knob", thickness: 18, castors: true } };return { ...base, cabinet: { doors: x.doors ?? (w > 50 ? 2 : 1), shelves: x.shelves ?? (h > 100 ? 2 : 1), rail: false, plinth: h > 100, handles: x.knobs ?? "knob", thickness: 18 } };diff --git a/src/lib/types.ts b/src/lib/types.tsindex a594f0e..69f9b95 100644--- a/src/lib/types.ts+++ b/src/lib/types.ts@@ -17,6 +17,8 @@ export interface ShelfParams {inserts?: number; // a cube grid sold with this many inserts with a door, from the bottom row upshoes?: boolean; // a rack with a shoe shelf low down instead of a lower railchanging?: boolean; // a changing table: a changing top goes on last (size.h takes it in)+ rail?: boolean; // open shelving with a clothes rail under a shelf near the top+ boxUnder?: number; // cm: open shelving with this much room under the bottom shelf, for a storage box on castors}export interface DrawersParams {@@ -81,6 +83,7 @@ export interface CabinetParams {lid?: { soft?: boolean }; // a box with a lid on hinges instead (storage benches); a padded lid on a footstoolcastors?: boolean; // stands on castors (size.h takes them in)onTop?: "bookcase" | "cabinet"; // a height extension unit: fixed on top of the bookcase or cabinet it extends+ low?: number; // cm: a shelving unit with a cabinet this high at the bottom, doors over it and open shelves above}/**