Skip to content

armgit / bygga

Public Imported from GitHub
0

IKEA assembly, step by step: animated, manual-style 3D guides. Scan any paper manual with Together AI.

TypeScript

Draw cabinets with doors and drawers

Youssefc720e1cfc513
diff --git a/scripts/ikea/build.ts b/scripts/ikea/build.ts
index 2c44588..a9c4ec7 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", "dropleaf", "daybed"]);
+const LATER_KINDS = new Set<Kind>(["office", "chaise", "corner", "cot", "bunk", "loft", "dropleaf", "daybed", "mixed"]);
function baseMatch(name: string, draw: Draw): CatalogEntry | undefined {
const fam = fold(name);
diff --git a/scripts/ikea/check.ts b/scripts/ikea/check.ts
index b5045b6..40aa825 100644
--- a/scripts/ikea/check.ts
+++ b/scripts/ikea/check.ts
@@ -103,6 +103,9 @@ async function main() {
// a day-bed is its own kind, and doesn't take over the family's bed
expect("hemnes daybed", "hemnes-day-bed-frame-3-drawers-80-x-200");
expect("hemnes bed", "hemnes-bed-frame-160-x-200");
+ // doors and drawers together, without taking the chests of drawers
+ expect("hemnes cabinet with drawers", "hemnes-glass-door-cabinet-3-drawers-90-x-197");
+ expect("hemnes chest of drawers", "hemnes-3-drawers");
if (articleNo("S292.975.72") !== "29297572") fail("article numbers with an S in front don't parse");
for (const [no, slug] of [["60324520", "kallax-2x2"]] as const) {
if (articleSlug(no) !== slug) fail(`article ${no} gave ${articleSlug(no)}, expected ${slug}`);
diff --git a/scripts/ikea/classify.ts b/scripts/ikea/classify.ts
index 57e45da..a2541b3 100644
--- a/scripts/ikea/classify.ts
+++ b/scripts/ikea/classify.ts
@@ -73,7 +73,7 @@ export function measure(s: string): Size | null {
return { n: parts.map((p) => Number(p.split("/")[0])), ext: parts.some((p) => p.includes("/")), text: parts.join(" × ") + " cm" };
}
-const UPRIGHT = new Set<Kind>(["cube", "bookcase", "open", "chest", "nightstand", "wardrobe", "cabinet", "sideboard", "tv", "shoe", "wallcab", "wallshelf", "kitchen"]);
+const UPRIGHT = new Set<Kind>(["cube", "bookcase", "open", "chest", "nightstand", "wardrobe", "cabinet", "sideboard", "tv", "shoe", "wallcab", "wallshelf", "kitchen", "mixed"]);
const FLAT = new Set<Kind>(["desk", "coffee", "side", "dining", "bar", "console", "kidstable", "trolley", "bench"]);
/** Office chairs IKEA sells with armrests although the type doesn't say so. */
@@ -110,6 +110,10 @@ const withDoors = (kind: Kind, t: string): Pick => {
/** Most specific first. A string result is the reason to skip. */
const RULES: Rule[] = [
+ // cabinets with doors and drawers: the drawers under the doors, or one drawer above the door of a kitchen base cabinet
+ [/^(glass-door cabinet with|high cabinet w gls-drs and) (\d) drawers?$/, (m) => ({ kind: "mixed", x: { rows: Number(m[2]) } })],
+ [/^wardrobe with (\d) doors and (\d) drawers$/, (m) => (Number(m[1]) > 2 ? "wardrobe with more than 2 doors and drawers" : { kind: "mixed", x: { doors: Number(m[1]) as 1 | 2, rows: Number(m[2]), rail: true } })],
+ [/^base cabinet with drawer\/(2 )?doors?$/, (m) => ({ kind: "mixed", x: { doors: m[1] ? 2 : 1, rows: 1, dtop: true } })],
// things that are several products, or only part of one
[/\b(and|set of \d|sets?)\b|\+|combination|\bcomb\b|\bchairs\b|armchairs|benches/, () => "set or combination"],
// office and swivel chairs: a star base on castors, a gas lift, the seat on top
@@ -156,6 +160,7 @@ const RULES: Rule[] = [
[/day-?bed|divan/, () => "divan, or bedding for a day-bed"],
[/sliding/, () => "sliding doors"],
[/sink|wash-?basin|wash-?st|hob\b|oven|fridge|freezer|dishwasher|microwave|extractor|appliances|kitchenette|outdoor kitchen/, () => "appliance or sink unit"],
+ [/^(door\/)?drawer front|^drawer (without |with (framed )?(glass )?)front|^(high|medium|low) drawer with front|^fitting for mounting/, () => "door or drawer front sold alone"],
[/drawers?\b.*\b(doors?|fronts?|shelves|baskets?)\b|\b(doors?|fronts?|shelves|baskets?)\b.*\bdrawers?\b/, () => "mixed doors and drawers"],
// storage
@@ -276,7 +281,7 @@ export function classify(f: Fact, hints: Hints): Verdict {
if (sz.ext) return { skip: "corner or extendable unit" };
if (v.length === 3) set(v[0], v[2], v[1]);
else if (v.length === 2) {
- if (kind === "kitchen" && /^base/.test(t)) set(v[0], 80, v[1]);
+ if ((kind === "kitchen" || kind === "mixed") && /^base/.test(t)) set(v[0], 80, v[1]);
// bedside tables are measured from above, like tables
else if (kind === "nightstand" && /bedside|nightstand/.test(t)) set(v[0], hint?.kind === kind ? hint.h : 55, v[1]);
else set(v[0], v[1]);
@@ -284,6 +289,9 @@ export function classify(f: Fact, hints: Hints): Verdict {
else if (hint?.kind === kind) set(hint.w, hint.h, hint.d);
else return { skip: "no size given" };
if (guessed.d && hint?.kind === kind && Math.abs(hint.w - w) < 60) d = hint.d;
+ // a cabinet with drawers is as deep as the family's cabinet
+ const cab = kind === "mixed" ? hints(family, "cabinet") : undefined;
+ if (guessed.d && cab?.kind === "cabinet" && Math.abs(cab.w - w) < 60) d = cab.d;
} else if (FLAT.has(kind)) {
if (v.length === 3) set(v[0], v[2], v[1]);
else if (v.length === 2) set(v[0], undefined, v[1]);
@@ -379,7 +387,7 @@ export function classify(f: Fact, hints: Hints): Verdict {
}
// parameters from the type name, the size and the family's hand made rows
- if (hint?.x.knobs && ["chest", "nightstand", "wardrobe", "cabinet", "sideboard", "tv", "shoe", "wallcab", "kitchen"].includes(kind)) x.knobs = hint.x.knobs;
+ if (hint?.x.knobs && ["chest", "nightstand", "wardrobe", "cabinet", "sideboard", "tv", "shoe", "wallcab", "kitchen", "mixed"].includes(kind)) x.knobs = hint.x.knobs;
if (kind === "chest" || kind === "nightstand") {
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) return finish("nightstand");
diff --git a/scripts/ikea/slugs.json b/scripts/ikea/slugs.json
index baaec2b..d825185 100644
--- a/scripts/ikea/slugs.json
+++ b/scripts/ikea/slugs.json
@@ -298,6 +298,7 @@
"HEMNES|Day-bed frame with 3 drawers, 80 × 200 cm": "hemnes-day-bed-frame-3-drawers-80-x-200",
"HEMNES|Day-bed w 3 drawers/2 mattresses, 80 × 200 cm": "hemnes-day-bed-w-3-drawers-2-mattresses-80-x-200",
"HEMNES|Desk, 155 × 65 cm": "hemnes-desk-155-x-65",
+ "HEMNES|Glass-door cabinet with 3 drawers, 90 × 197 cm": "hemnes-glass-door-cabinet-3-drawers-90-x-197",
"HERRÅKRA|Armchair": "herrakra-armchair",
"HÖGVED|Chair": "hogved-chair",
"HOL|Side table, 50 × 50 cm": "hol-side-table-50-x-50",
@@ -324,6 +325,7 @@
"IDANÄS|Coffee table, 80 × 80 cm": "idanas-coffee-table-80-x-80",
"IDANÄS|Console table, 104 × 32 × 95 cm": "idanas-console-table-104-x-32-x-95",
"IDANÄS|Desk, 152 × 70 cm": "idanas-desk-152-x-70",
+ "IDANÄS|High cabinet w gls-drs and 1 drawer, 81 × 39 × 211 cm": "idanas-high-cabinet-w-gls-drs-and-1-drawer-81-x",
"IDANÄS|Open wardrobe, 59 × 211 cm": "idanas-open-wardrobe-59-x-211",
"IDANÄS|Side table, 46 × 36 cm": "idanas-side-table-46-x-36",
"IDANÄS|Sideboard, 124 × 50 × 95 cm": "idanas-sideboard-124-x-50-x-95",
@@ -542,6 +544,10 @@
"MARKUS|Office chair": "markus-office-chair",
"MARKUS|Office chair with armrests": "markus-office-chair-armrests",
"MATCHSPEL|Gaming chair": "matchspel-gaming-chair",
+ "METOD / KNIVSHULT|Base cabinet with drawer/2 doors, 80 × 60 cm": "metod-knivshult-base-cabinet-drawer-2-doors-80-x",
+ "METOD / KNIVSHULT|Base cabinet with drawer/door, 40 × 60 cm": "metod-knivshult-base-cabinet-drawer-door-40-x-60",
+ "METOD / MAXIMERA|Base cabinet with drawer/2 doors, 80 × 60 cm": "metod-maximera-base-cabinet-drawer-2-doors-80-x",
+ "METOD / MAXIMERA|Base cabinet with drawer/door, 60 × 60 cm": "metod-maximera-base-cabinet-drawer-door-60-x-60",
"METOD|Base cabinet with shelves, 60 × 60 cm": "metod-base-cabinet-shelves-60-x-60",
"METOD|Base cabinet with shelves/2 doors, 80 × 60 cm": "metod-base-cabinet-shelves-2-doors-80-x-60",
"METOD|High cabinet with shelves, 40 × 37 × 200 cm": "metod-high-cabinet-shelves-40-x-37-x-200",
@@ -1031,6 +1037,7 @@
"VIHALS|TV bench, 176 × 37 × 50 cm": "vihals-tv-bench-176-x-37-x-50",
"VIHALS|Wardrobe with 2 doors, 105 × 57 × 200 cm": "vihals-wardrobe-2-doors-105-x-57-x-200",
"VIKHAMMER|Bedside table, 40 × 39 cm": "vikhammer-bedside-table-40-x-39",
+ "VILHATTEN|Wardrobe with 2 doors and 2 drawers, 98 × 57 × 190 cm": "vilhatten-wardrobe-2-doors-and-2-drawers-98-x-57",
"VILTO|Shelving unit, 46 × 150 cm": "vilto-shelving-unit-46-x-150",
"VILTO|Step stool": "vilto-step-stool",
"VIMLE|2-seat sofa": "vimle-2-seat-sofa",
diff --git a/src/data/ikea-items.ts b/src/data/ikea-items.ts
index 25c555c..81fe386 100644
--- a/src/data/ikea-items.ts
+++ b/src/data/ikea-items.ts
@@ -331,6 +331,7 @@ hemnes-chest-8-drawers|10239280
hemnes-day-bed-frame-3-drawers-80-x-200|90349326 80622892 60372276
hemnes-day-bed-w-3-drawers-2-mattresses-80-x-200|49521503 79610220 59521499 49521485 19428120 19390952 59610235
hemnes-desk-155-x-65|20535044
+hemnes-glass-door-cabinet-3-drawers-90-x-197|50452297 00596161 50413507
hemnes-nightstand-2-drawers|50610739
hemnes-sideboard-157-x-88|70476259 80628667
hemnes-tv-bench-148-x-57|50413526
@@ -363,6 +364,7 @@ idanas-coffee-table-107-x-55|20487873 80487870
idanas-coffee-table-80-x-80|40500005 10500002
idanas-console-table-104-x-32-x-95|90487879
idanas-desk-152-x-70|10514155 60514153
+idanas-high-cabinet-w-gls-drs-and-1-drawer-81-x|10487840
idanas-open-wardrobe-59-x-211|80458839 20458842
idanas-side-table-46-x-36|00496048 60496045
idanas-sideboard-124-x-50-x-95|80496025
@@ -617,6 +619,10 @@ metod-high-cabinet-60-x-60-x-200|60212565 90212559 90212564 70212560 10212558 50
metod-high-cabinet-shelves-2-doors-60-x-60-x-220|09507311 29507310 19468936 69538753 99457241 79456817 49457597
metod-high-cabinet-shelves-40-x-37-x-200|89507312 89507307 69507313 39461991 69538965 49487467 39455669
metod-high-cabinet-shelves-60-x-60-x-140|79507317 29467658 19509418 59465002 09466259 99628219 99586484
+metod-knivshult-base-cabinet-drawer-2-doors-80-x|89586960 59588244 99587068 89589529 79588021 69588168 59589007
+metod-knivshult-base-cabinet-drawer-door-40-x-60|59589470 99588845 99588789 79589681 79587955 29589396 29587199
+metod-maximera-base-cabinet-drawer-2-doors-80-x|79506997 79473317 59507021 09517414 99486979 79565680 79509298
+metod-maximera-base-cabinet-drawer-door-60-x-60|59473295 89504083 89473307 59539395 99556571 89507005 89486687
metod-top-cabinet-40-x-40|99518027 99456251 59539197 49464201 39507296 39473611 99587940
metod-top-cabinet-40-x-60-x-40|60224078 10591733
metod-wall-cabinet-2-doors-80-x-40|79507261 99473463 29611929 39469398 19518045 09588703 39587165
@@ -1119,6 +1125,7 @@ vihals-tv-bench-146-x-37-x-50|20483295 00543672
vihals-tv-bench-176-x-37-x-50|80542857
vihals-wardrobe-2-doors-105-x-57-x-200|60483255
vikhammer-bedside-table-40-x-39|20388972 00381764
+vilhatten-wardrobe-2-doors-and-2-drawers-98-x-57|70530609
vilto-shelving-unit-46-x-150|90344456
vilto-step-stool|60344453
vimle-2-seat-sofa|09634663 99634692 89631383 19634667 59634689 79398974 09398977 79400547 79400566 59501646 49400544 99501395 89503093 19306294
diff --git a/src/data/ikea-rows.ts b/src/data/ikea-rows.ts
index c964140..e4c7684 100644
--- a/src/data/ikea-rows.ts
+++ b/src/data/ikea-rows.ts
@@ -299,6 +299,7 @@ HAVSTEN|sofa|2-seat sofa, outdoor, 179 × 92 × 76 cm|179|76|92|seats=2|outdoor
HEMNES|daybed|Day-bed frame with 3 drawers, 80 × 200 cm|210|83|91|rows=3,knobs=knob,m=80,under=pullout
HEMNES|daybed|Day-bed w 3 drawers/2 mattresses, 80 × 200 cm|210|83|91|rows=3,knobs=knob,m=80,under=pullout,mats=2
HEMNES|desk|Desk, 155 × 65 cm|155|74|65
+HEMNES|mixed|Glass-door cabinet with 3 drawers, 90 × 197 cm|90|197|37|rows=3,knobs=knob
HERRÅKRA|armchair|Armchair|75|90|80
HÖGVED|chair|Chair|44|88|50
HOL|side|Side table, 50 × 50 cm|50|50|50
@@ -325,6 +326,7 @@ IDANÄS|coffee|Coffee table, 80 × 80 cm|80|45|80
IDANÄS|coffee|Coffee table, 107 × 55 cm|107|45|55
IDANÄS|console|Console table, 104 × 32 × 95 cm|104|95|32
IDANÄS|desk|Desk, 152 × 70 cm|152|74|70
+IDANÄS|mixed|High cabinet w gls-drs and 1 drawer, 81 × 39 × 211 cm|81|211|39|rows=1
IDANÄS|nightstand|Bedside table, 47 × 40 cm|47|55|40|rows=1,knobs=bar
IDANÄS|side|Side table, 46 × 36 cm|46|50|36
IDANÄS|sideboard|Sideboard, 124 × 50 × 95 cm|124|95|50
@@ -563,6 +565,10 @@ METOD|wallcab|Wall cabinet with shelves, 60 × 80 cm|60|80|35|doors=0
METOD|wallcab|Wall cabinet with 2 doors, 80 × 40 cm|80|40|35
METOD|wallcab|Wall cabinet with 2 glass doors, 80 × 40 cm|80|40|35
METOD|wallcab|Wall cabinet with shelves/2 doors, 80 × 80 cm|80|80|35
+METOD / KNIVSHULT|mixed|Base cabinet with drawer/door, 40 × 60 cm|40|80|60|rows=1,doors=1,dtop=1
+METOD / KNIVSHULT|mixed|Base cabinet with drawer/2 doors, 80 × 60 cm|80|80|60|rows=1,doors=2,dtop=1
+METOD / MAXIMERA|mixed|Base cabinet with drawer/door, 60 × 60 cm|60|80|60|rows=1,doors=1,dtop=1
+METOD / MAXIMERA|mixed|Base cabinet with drawer/2 doors, 80 × 60 cm|80|80|60|rows=1,doors=2,dtop=1
MICKE|desk|Desk, 73 × 50 cm|73|75|50|legs=square,attach=apron
MICKE|desk|Desk, 142 × 50 cm|142|75|50|legs=square,attach=apron
MILLBERGET|office|Swivel chair|60|105|64|arms=none
@@ -1032,6 +1038,7 @@ VIHALS|tv|TV bench, 146 × 37 × 50 cm|146|50|37
VIHALS|tv|TV bench, 176 × 37 × 50 cm|176|50|37
VIHALS|wardrobe|Wardrobe with 2 doors, 105 × 57 × 200 cm|105|200|57|doors=2
VIKHAMMER|nightstand|Bedside table, 40 × 39 cm|40|55|39|rows=1
+VILHATTEN|mixed|Wardrobe with 2 doors and 2 drawers, 98 × 57 × 190 cm|98|190|57|rows=2,doors=2,rail=1
VILTO|open|Shelving unit, 46 × 150 cm|46|150|35
VILTO|stool|Step stool|35|50|35
VIMLE|armchair|Armchair|75|90|80
diff --git a/src/lib/ikea.ts b/src/lib/ikea.ts
index 6fd76c9..f301485 100644
--- a/src/lib/ikea.ts
+++ b/src/lib/ikea.ts
@@ -23,8 +23,8 @@ 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"] as const;
-const FLAGS = new Set<string>(["plinth", "shelf", "round", "open", "drawer"]);
+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"] as const;
+const FLAGS = new Set<string>(["plinth", "shelf", "round", "open", "drawer", "dtop", "rail"]);
const WORDS = new Set<string>(["knobs", "arms", "legs", "attach", "chaise", "corner", "under"]);
export function encodeX(x: X): string {
diff --git a/src/lib/plan/cabinet.ts b/src/lib/plan/cabinet.ts
index d07922d..e8e21d2 100644
--- a/src/lib/plan/cabinet.ts
+++ b/src/lib/plan/cabinet.ts
@@ -2,6 +2,7 @@ import type { CabinetParams, ProductSpec, Vec3 } from "../types";
import { HW, PlanBuilder, type FitOpts } from "./builder";
import { FrameKit } from "./frame";
import { clamp } from "./math";
+import { buildMixed } from "./mixed";
export function defaultsCabinet(s: ProductSpec): CabinetParams {
const p = s.cabinet ?? {};
@@ -19,6 +20,7 @@ export function defaultsCabinet(s: ProductSpec): CabinetParams {
}
export function buildCabinet(b: PlanBuilder, s: ProductSpec) {
+ if (s.cabinet?.drawers) return buildMixed(b, s);
const p = defaultsCabinet(s);
if (p.fronts === "tilt") return tiltCabinet(b, s, p);
const W = s.size.w * 10, H = s.size.h * 10, D = s.size.d * 10;
diff --git a/src/lib/plan/mixed.ts b/src/lib/plan/mixed.ts
new file mode 100644
index 0000000..b9af19b
--- /dev/null
+++ b/src/lib/plan/mixed.ts
@@ -0,0 +1,311 @@
+import type { ProductSpec, Vec3 } from "../types";
+import { HW, PlanBuilder, type FitOpts } from "./builder";
+import { FrameKit } from "./frame";
+import { clamp } from "./math";
+
+/**
+ * Cabinets with doors and drawers: a carcass split by a fixed shelf, with full-width drawers under the doors
+ * (HEMNES, IDANÄS, VILHATTEN) or one drawer above them (a kitchen base cabinet).
+ * Built like a cabinet: runners onto the sides while they lie flat, the carcass, the back, then the shelves
+ * behind the doors, the doors, the drawers and last the knobs.
+ */
+export function buildMixed(b: PlanBuilder, s: ProductSpec) {
+ const c = s.cabinet ?? {};
+ const p = {
+ doors: c.doors === 1 ? 1 : 2,
+ shelves: clamp(Math.round(c.shelves ?? 1), 0, 4),
+ rail: !!c.rail,
+ plinth: c.plinth ?? s.size.h > 100,
+ handles: c.handles ?? "knob",
+ thickness: clamp(c.thickness ?? 18, 12, 25),
+ };
+ const n = clamp(Math.round(c.drawers ?? 1), 1, 4);
+ const top = c.drawerAt === "top";
+ const W = s.size.w * 10, H = s.size.h * 10, D = s.size.d * 10;
+ const t = p.thickness;
+ const base = p.plinth ? 70 : 0;
+ const lying = H > 1100;
+ const dh = top && H < 1000 ? 200 : clamp(H * 0.11, 150, 220); // one drawer, front to front
+ const Hd = n * dh; // the drawers' opening
+ const yDiv = top ? H - t - Hd - t / 2 : base + t + Hd + t / 2; // the fixed shelf between drawers and doors
+ const f = new FrameKit(b, { W, H, D, t, base, plinth: p.plinth, fixed: [yDiv], back: true, pinRows: false, lying, names: { fixed: "Middle shelf" } });
+
+ // the drawers' opening and the doors' opening, inside the carcass
+ const dLo = top ? yDiv + t / 2 : base + t;
+ const oLo = top ? base + t : yDiv + t / 2, oHi = top ? yDiv - t / 2 : H - t;
+ const slotH = Hd / n;
+
+ /* ---------- drawers ---------- */
+ const runLen = Math.round((D - 60) / 10) * 10;
+ const runner = { kind: "runner" as const, len: runLen, dia: 20 };
+ const fz = D / 2 + t / 2; // fronts sit on the front edge of the carcass
+ const frontLo = top ? yDiv : base, frontHi = top ? H : yDiv;
+ const fh = (frontHi - frontLo) / n - 4, fw = W - 4;
+ const bw = W - 2 * t - 26;
+ const sh = Math.min(slotH - 46, 170);
+ const dd = D - 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;
+ ys: number;
+ }
+ const drawers: Drawer[] = [];
+ for (let r = 0; r < n; r++) {
+ const ys = dLo + r * slotH; // bottom of its slot
+ const sy = ys + 24 + sh / 2;
+ const zBox = D / 2 - dd / 2;
+ drawers.push({
+ ys,
+ front: b.place(frT, [0, frontLo + 2 + r * (fh + 4) + fh / 2, fz]),
+ sides: [b.place(dsT, [-bw / 2 + 6, sy, zBox]), b.place(dsT, [bw / 2 - 6, sy, zBox])],
+ back: b.place(dbT, [0, ys + 24 + 22 + (sh - 22) / 2, D / 2 - dd + 6]),
+ bottom: b.place(dbtT, [0, ys + 24 + 9, zBox - 2]),
+ });
+ }
+
+ /* ---------- steps: the carcass ---------- */
+ f.prepSides();
+ b.step(
+ {
+ title: n > 1 ? "Screw the drawer runners onto the sides" : "Screw the drawer runner onto each side",
+ detail: "The open end of each runner points to the front.",
+ tools: ["screwdriver"],
+ scene: "prep",
+ kind: "runners",
+ warnings: ["face"],
+ },
+ () => {
+ const list: FitOpts[] = [];
+ const screws: FitOpts[] = [];
+ f.sides.forEach((side, i) => {
+ const xi = i === 0 ? -W / 2 + t : W / 2 - t;
+ const into: Vec3 = [i === 0 ? -1 : 1, 0, 0];
+ for (const d of drawers) {
+ const y = d.ys + 14;
+ list.push({ on: side, at: [xi, y, D / 2 - runLen / 2 - 8], dir: into, hole: false });
+ for (const dz of [-runLen / 2 + 30, runLen / 2 - 30]) screws.push({ on: side, at: [xi + (i === 0 ? 12 : -12), y, D / 2 - runLen / 2 - 8 + dz], dir: into, hole: false });
+ }
+ });
+ b.fits(runner, list, 0.12);
+ b.then(0.1);
+ b.fits(HW.screwS, screws, 0.04);
+ },
+ );
+ f.join();
+ f.otherSide();
+ f.cams();
+ f.plinthStep();
+ f.backSteps();
+ f.standUp();
+
+ /* ---------- shelves and clothes rail behind the doors ---------- */
+ const inner = W - 2 * t;
+ if (p.rail) {
+ // a wardrobe: one shelf up high, the rail under it
+ const shY = oHi - 320;
+ shelfStep([shY], "Add the shelf pins and the top shelf");
+ const rT = b.part("Clothes rail", [24, inner - 2, 24], { shape: "cyl", material: "metal" });
+ const ry = shY - 80;
+ const rail = b.place(rT, [0, ry, 0], [0, 0, Math.PI / 2]);
+ b.step(
+ {
+ title: "Fit the clothes rail",
+ detail: "Clip the holders on first, 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]);
+ },
+ );
+ } else if (p.shelves > 0) {
+ const ys = Array.from({ length: p.shelves }, (_, i) => Math.round((oLo + ((oHi - oLo) * (i + 1)) / (p.shelves + 1)) / 32) * 32);
+ shelfStep(ys, p.shelves > 1 ? "Add the shelf pins and shelves" : "Add the shelf pins and the shelf");
+ }
+
+ function shelfStep(ys: number[], title: string) {
+ const shT = b.part("Shelf", [inner - 3, t, D - 26]);
+ const shelves = ys.map((y) => b.place(shT, [0, y + 3 + t / 2, 11]));
+ // a row of holes above and below, so the shelf can move
+ 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);
+ }
+ b.step(
+ {
+ title,
+ detail: "Pick any height you like. 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 ---------- */
+ const nd = p.doors;
+ const doorLo = top ? base : yDiv, doorHi = top ? yDiv : H;
+ const dwid = nd === 2 ? W / 2 - 3 : W - 4;
+ const dht = doorHi - doorLo - 4;
+ const dy = doorLo + 2 + dht / 2;
+ const doorT = b.part("Door", [dwid, dht, t]);
+ const doors = Array.from({ length: nd }, (_, i) => b.place(doorT, [nd === 2 ? (i === 0 ? -1 : 1) * (W / 4) : 0, dy, fz]));
+ const hn = dht > 1500 ? 4 : dht > 900 ? 3 : 2;
+ const hingeYs = Array.from({ length: hn }, (_, i) => doorLo + 110 + (i * (dht - 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) * (dwid + 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.",
+ kind: "doors",
+ people: dht > 1500 ? 2 : 1,
+ warnings: dht > 1500 ? ["two"] : [],
+ },
+ () => {
+ b.stagger(0.35);
+ doors.forEach((d) => b.add(d, [0, 0, 380]));
+ },
+ );
+ b.step(
+ {
+ title: "Line up the doors",
+ detail: "Turn the hinge screws a little until the gaps look even.",
+ tools: ["screwdriver"],
+ kind: "doors",
+ },
+ () => {},
+ );
+
+ /* ---------- steps: the drawers ---------- */
+ const d0 = drawers[0];
+ const c0: Vec3 = [0, d0.ys + slotH / 2, D / 2 - 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((dy2) => ({ on: sd, at: [xo, bp[1] + dy2, 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.5 * 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.22);
+ }
+ },
+ );
+
+ /* ---------- knobs or handles on every front ---------- */
+ if (p.handles !== "none") {
+ const bar = p.handles === "bar";
+ const def = bar ? HW.handle : HW.knob;
+ b.step(
+ {
+ title: bar ? "Screw on the handles" : "Screw on the knobs",
+ detail: "Screw from the inside of each door and drawer. Snug is enough.",
+ tools: ["screwdriver"],
+ kind: "screws",
+ },
+ () => {
+ const list: FitOpts[] = doors.map((d, i) => {
+ const { sgn } = hingeX(i);
+ const x = at(d)[0] - sgn * (dwid / 2 - 40);
+ const y = top ? doorHi - 80 : Math.min(dy, Math.max(doorLo + 150, 1050));
+ return { on: d, at: [x, y, D / 2 + t], dir: [0, 0, -1], hole: false, twist: bar ? Math.PI / 2 : 0 };
+ });
+ for (const d of drawers) list.push({ on: d.front, at: [0, at(d.front)[1], D / 2 + t], dir: [0, 0, -1], hole: false });
+ b.fits(def, list, 0.1);
+ },
+ );
+ }
+
+ if (H >= 800) f.anchor();
+}
diff --git a/src/lib/products.ts b/src/lib/products.ts
index e4e6a8b..8ce11ed 100644
--- a/src/lib/products.ts
+++ b/src/lib/products.ts
@@ -42,7 +42,8 @@ export type Kind =
| "bunk"
| "loft"
| "dropleaf"
- | "daybed";
+ | "daybed"
+ | "mixed";
export type X = {
rows?: number;
@@ -72,6 +73,8 @@ export type X = {
leaf?: number;
under?: "pullout" | "trundle" | "boxes";
mats?: number;
+ dtop?: boolean;
+ rail?: boolean;
};
export type Row = [name: string, kind: Kind, variant: string, w: number, h: number, d: number, x?: X, keywords?: string];
@@ -245,7 +248,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, dropleaf: 40, daybed: 60,
+ office: 20, chaise: 55, corner: 70, cot: 35, bunk: 90, loft: 75, dropleaf: 40, daybed: 60, mixed: 50,
};
const CATEGORY: Record<Kind, string> = {
@@ -254,7 +257,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", dropleaf: "Drop-leaf table", daybed: "Day-bed",
+ office: "Office chair", chaise: "Sofa with chaise longue", corner: "Corner sofa", cot: "Cot", bunk: "Bunk bed", loft: "Loft bed", dropleaf: "Drop-leaf table", daybed: "Day-bed", mixed: "Cabinet with doors and drawers",
};
export const KIND_ARCH: Record<Kind, Archetype> = {
@@ -262,7 +265,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", dropleaf: "table", daybed: "bed",
+ office: "seat", chaise: "sofa", corner: "sofa", cot: "bed", bunk: "bed", loft: "bed", dropleaf: "table", daybed: "bed", mixed: "cabinet",
};
const round = (x: X) => (x.round ? { round: true } : {});
@@ -358,6 +361,13 @@ export function specFor(kind: Kind, name: string, variant: string, w: number, h:
const under = x.under ? { under: x.under } : {};
return { ...base, minutes, people: 2, difficulty: x.under ? 3 : 2, bed: { type: "daybed", mattressW: x.m ?? 80, mattressL: x.l ?? 200, headH: h, footH: h, slats: 13, centerBeam: false, ...under, ...(drawers ? { drawers, knobs: x.knobs ?? "none" } : {}), ...(x.mats ? { mattresses: x.mats } : {}) } };
}
+ case "mixed": {
+ // x.rows: drawers, under the doors unless x.dtop (a kitchen base cabinet); x.rail: a wardrobe
+ const rows = x.rows ?? 1;
+ const category = x.rail ? "Wardrobe with drawers" : CATEGORY.mixed;
+ const at = x.dtop ? { drawerAt: "top" as const } : {};
+ return { ...base, category, minutes: x.min ?? MIN.mixed + 20 * rows + (h > 150 ? 30 : 0), people: h > 150 ? 2 : 1, difficulty: 3, cabinet: { doors: x.doors ?? (w > 50 ? 2 : 1), shelves: x.shelves ?? (h > 150 ? 2 : 1), rail: !!x.rail, plinth: x.plinth ?? (h > 100 || !!x.dtop), handles: x.knobs ?? (x.dtop ? "bar" : "knob"), thickness: 18, drawers: rows, ...at } };
+ }
}
}
@@ -388,5 +398,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: [226, 85, 160], corner: [233, 85, 171], cot: [130, 84, 68], bunk: [211, 160, 100], loft: [211, 195, 100], dropleaf: [134, 75, 80], daybed: [207, 83, 91],
+ office: [64, 105, 64], chaise: [226, 85, 160], corner: [233, 85, 171], cot: [130, 84, 68], bunk: [211, 160, 100], loft: [211, 195, 100], dropleaf: [134, 75, 80], daybed: [207, 83, 91], mixed: [80, 120, 40],
};
diff --git a/src/lib/search.ts b/src/lib/search.ts
index f80112e..c4ed0f0 100644
--- a/src/lib/search.ts
+++ b/src/lib/search.ts
@@ -18,6 +18,7 @@ const CATEGORY_WORDS: [Kind, string[]][] = [
["office", ["office chair", "desk chair", "swivel chair", "gaming chair", "computer chair"]],
["shoe", ["shoe", "shoes", "shoe cabinet", "shoe rack"]],
["nightstand", ["nightstand", "bedside", "night stand"]],
+ ["mixed", ["doors and drawers", "cabinet with drawers", "cupboard with drawers", "wardrobe with drawers", "armoire with drawers"]],
["chest", ["drawer", "drawers", "chest", "dresser"]],
["cube", ["cube", "cubes"]],
["wallshelf", ["wall shelf", "wall shelves", "wall shelf unit"]],
diff --git a/src/lib/types.ts b/src/lib/types.ts
index da8469e..d24bb11 100644
--- a/src/lib/types.ts
+++ b/src/lib/types.ts
@@ -59,6 +59,8 @@ export interface CabinetParams {
handles: "knob" | "bar" | "none";
thickness: number;
wall?: boolean; // hangs on the wall instead of standing on the floor
+ drawers?: number; // drawers as well as doors: full-width drawers, split from the doors by a fixed shelf
+ drawerAt?: "top" | "bottom"; // where the drawers are; under the doors unless it says top
}
export interface SeatParams {