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 rows of identical frames

Youssefd145cb8b0438
diff --git a/scripts/ikea/build.ts b/scripts/ikea/build.ts
index aa8ac55..c12b400 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", "mixed", "sliding", "slidecab"]);
+const LATER_KINDS = new Set<Kind>(["office", "chaise", "corner", "cot", "bunk", "loft", "dropleaf", "daybed", "mixed", "sliding", "slidecab", "bookrow", "cabrow"]);
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 d3ac8da..f50fb23 100644
--- a/scripts/ikea/check.ts
+++ b/scripts/ikea/check.ts
@@ -109,6 +109,9 @@ async function main() {
// sliding doors only when the query says so
expect("hauga sliding wardrobe", "hauga-wardrobe-sliding-doors-118-x-55-x-199");
expect("hauga wardrobe", "hauga-wardrobe-70-x-199");
+ // a row of frames when asked for, the single frame otherwise
+ expect("billy bookcase combination", "billy-bookcase-160-x-28-x-202");
+ expect("pax bergsbo", "pax-bergsbo-wardrobe");
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 318322d..78417ca 100644
--- a/scripts/ikea/classify.ts
+++ b/scripts/ikea/classify.ts
@@ -80,6 +80,8 @@ const FLAT = new Set<Kind>(["desk", "coffee", "side", "dining", "bar", "console"
const OFFICE_ARMS = new Set(["MARKUS", "ALEFJÄLL"]);
/** Office chairs with a tall back and a headrest. */
const OFFICE_TALL = new Set(["MARKUS"]);
+/** The frame a family's combinations are rows of, in cm: two BILLY 80s, two BESTÅ 120s, two PAX 100s. */
+const ROW_UNITS: Record<string, number> = { BILLY: 80, BESTÅ: 120, IVAR: 80, PAX: 100 };
/** Day-beds' outer size (w, h, d) from IKEA's product pages: IKEA's measure is only the mattress size. */
const DAYBED_SIZE: Record<string, [number, number, number]> = { HEMNES: [210, 83, 91], BRIMNES: [205, 58, 87], FLEKKE: [207, 86, 91], VIHALS: [206, 75, 86] };
@@ -402,12 +404,25 @@ export function classify(f: Fact, hints: Hints): Verdict {
if (shape.cols === 2) x.cols = 2;
if (hint?.x.plinth) x.plinth = true;
}
- if ((kind === "wardrobe" || kind === "sliding") && multi && w > 100) return { skip: "several wardrobe frames" };
if (kind === "wardrobe" && x.doors === 0 && hint?.x.shelves) x.shelves = hint.x.shelves;
- if ((kind === "cabinet" || kind === "bookcase") && multi && w > 100) return { skip: "several units side by side" };
- // a combination this wide is more than one frame, which one carcass can't show
- if (f.spr && w > 125 && ["bookcase", "open", "cabinet", "wardrobe", "shoe", "wallcab", "wallshelf", "kitchen", "sliding", "slidecab"].includes(kind)) return { skip: "several units side by side" };
- if (kind === "tv" && f.spr && w > 200) return { skip: "several units side by side" };
+ // a combination this wide is more than one frame, which one carcass can't show: a row of them when the frames are all alike
+ const several =
+ (kind === "wardrobe" || kind === "sliding") && multi && w > 100
+ ? "several wardrobe frames"
+ : ((kind === "cabinet" || kind === "bookcase") && multi && w > 100) ||
+ (f.spr && w > 125 && ["bookcase", "open", "cabinet", "wardrobe", "shoe", "wallcab", "wallshelf", "kitchen", "sliding", "slidecab"].includes(kind)) ||
+ (kind === "tv" && f.spr && w > 200)
+ ? "several units side by side"
+ : null;
+ if (several) {
+ const unit = ROW_UNITS[family];
+ const n = unit ? Math.round(w / unit) : 0;
+ if (!unit || n < 2 || n > 4 || n * unit !== w || !["bookcase", "cabinet", "tv", "wardrobe", "wallcab"].includes(kind)) return { skip: several };
+ if (kind === "wardrobe" && d > 62) return { skip: "PAX with sliding doors across its frames" };
+ x.n = n;
+ x.of = kind as NonNullable<X["of"]>;
+ return finish(kind === "bookcase" ? "bookrow" : "cabrow");
+ }
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" };
diff --git a/scripts/ikea/slugs.json b/scripts/ikea/slugs.json
index 2ae04e6..15e40e2 100644
--- a/scripts/ikea/slugs.json
+++ b/scripts/ikea/slugs.json
@@ -55,6 +55,9 @@
"BESTÅ|Shelving unit, 60 × 40 × 193 cm": "besta-shelving-unit-60-x-40-x-193",
"BESTÅ|TV bench with doors, 120 × 42 × 48 cm": "besta-tv-bench-doors-120-x-42-x-48",
"BESTÅ|TV bench with doors, 120 × 42 × 74 cm": "besta-tv-bench-doors-120-x-42-x-74",
+ "BESTÅ|TV bench with doors, 240 × 42 × 38 cm": "besta-tv-bench-doors-240-x-42-x-38",
+ "BESTÅ|TV bench with doors, 240 × 42 × 40 cm": "besta-tv-bench-doors-240-x-42-x-40",
+ "BESTÅ|TV bench with doors, 240 × 42 × 76 cm": "besta-tv-bench-doors-240-x-42-x-76",
"BESTÅ|TV bench, 120 × 40 × 48 cm": "besta-tv-bench-120-x-40-x-48",
"BESTÅ|TV bench, 180 × 40 × 64 cm": "besta-tv-bench-180-x-40-x-64",
"BETESHÄST|Desk, 120 × 60 cm": "beteshast-desk-120-x-60",
@@ -76,11 +79,14 @@
"BILLY / OXBERG|Bookcase with glass-doors, 80 × 41 × 202 cm": "billy-oxberg-bookcase-glass-doors-80-x-41-x-202",
"BILLY / OXBERG|Bookcase with panel/glass door, 40 × 30 × 202 cm": "billy-oxberg-bookcase-panel-glass-door-40-x-30-x",
"BILLY / OXBERG|Bookcase with panel/glass door, 40 × 41 × 202 cm": "billy-oxberg-bookcase-panel-glass-door-40-x-41-x",
+ "BILLY / OXBERG|Bookcase with panel/glass doors, 160 × 30 × 202 cm": "billy-oxberg-bookcase-panel-glass-doors-160-x-30",
"BILLY / OXBERG|Bookcase with panel/glass doors, 80 × 30 × 202 cm": "billy-oxberg-bookcase-panel-glass-doors-80-x-30",
"BILLY / OXBERG|Bookcase with panel/glass doors, 80 × 41 × 202 cm": "billy-oxberg-bookcase-panel-glass-doors-80-x-41",
"BILLY / OXBERG|Bookcase, 80 × 30 × 202 cm": "billy-oxberg-bookcase-80-x-30-x-202",
"BILLY / OXBERG|Bookcase, 80 × 30 × 237 cm": "billy-oxberg-bookcase-80-x-30-x-237",
"BILLY|Bookcase, 120 × 28 × 237 cm": "billy-bookcase-120-x-28-x-237",
+ "BILLY|Bookcase, 160 × 28 × 202 cm": "billy-bookcase-160-x-28-x-202",
+ "BILLY|Bookcase, 240 × 28 × 106 cm": "billy-bookcase-240-x-28-x-106",
"BILLY|Bookcase, 40 × 28 × 106 cm": "billy-bookcase-40-x-28-x-106",
"BILLY|Bookcase, 40 × 28 × 237 cm": "billy-bookcase-40-x-28-x-237",
"BILLY|Bookcase, 40 × 39 × 202 cm": "billy-bookcase-40-x-39-x-202",
@@ -353,6 +359,7 @@
"IKEA PS|Cabinet, 119 × 63 cm": "ikea-ps-cabinet-119-x-63",
"INVALLNING|Trolley, 68 × 39 cm": "invallning-trolley-68-x-39",
"ISMANTORP|Armchair": "ismantorp-armchair",
+ "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",
"IVAR|Shelving unit with doors, 89 × 30 × 124 cm": "ivar-shelving-unit-doors-89-x-30-x-124",
@@ -363,6 +370,7 @@
"IVAR|Shelving unit, 89 × 30 × 226 cm": "ivar-shelving-unit-89-x-30-x-226",
"IVAR|Shelving unit, 89 × 50 × 179 cm": "ivar-shelving-unit-89-x-50-x-179",
"IVAR|Shelving unit, 89 × 50 × 226 cm": "ivar-shelving-unit-89-x-50-x-226",
+ "IVAR|Wall cabinet with doors, 160 × 30 × 83 cm": "ivar-wall-cabinet-doors-160-x-30-x-83",
"IVÖSJÖN|Cabinet with doors, 33 × 34 × 99 cm": "ivosjon-cabinet-doors-33-x-34-x-99",
"JAKOBSFORS|Coffee table, 80 cm": "jakobsfors-coffee-table-80",
"JÄRVFJÄLLET|Office chair with armrests": "jarvfjallet-office-chair-armrests",
@@ -680,9 +688,13 @@
"PÅHL|Desk, 96 × 58 cm": "pahl-desk-96-x-58",
"PAX / BERGSBO|Wardrobe": "pax-bergsbo-wardrobe",
"PAX / BERGSBO|Wardrobe, 100 × 60 × 201 cm": "pax-bergsbo-wardrobe-100-x-60-x-201",
+ "PAX / BERGSBO|Wardrobe, 200 × 60 × 201 cm": "pax-bergsbo-wardrobe-200-x-60-x-201",
+ "PAX / BERGSBO|Wardrobe, 200 × 60 × 236 cm": "pax-bergsbo-wardrobe-200-x-60-x-236",
"PAX / FLISBERGET|Wardrobe, 100 × 60 × 201 cm": "pax-flisberget-wardrobe-100-x-60-x-201",
+ "PAX / FLISBERGET|Wardrobe, 200 × 60 × 201 cm": "pax-flisberget-wardrobe-200-x-60-x-201",
"PAX / FORSAND|Wardrobe, 100 × 60 × 201 cm": "pax-forsand-wardrobe-100-x-60-x-201",
"PAX / FORSAND|Wardrobe, 100 × 60 × 236 cm": "pax-forsand-wardrobe-100-x-60-x-236",
+ "PAX / FORSAND|Wardrobe, 200 × 60 × 201 cm": "pax-forsand-wardrobe-200-x-60-x-201",
"PAX / GRIMO|Wardrobe, 100 × 60 × 201 cm": "pax-grimo-wardrobe-100-x-60-x-201",
"PAX|Wardrobe frame, 50 × 58 × 201 cm": "pax-wardrobe-frame-50-x-58-x-201",
"PAX|Wardrobe frame, 75 × 58 × 201 cm": "pax-wardrobe-frame-75-x-58-x-201",
diff --git a/src/data/ikea-items.ts b/src/data/ikea-items.ts
index d39c9dd..2515a1b 100644
--- a/src/data/ikea-items.ts
+++ b/src/data/ikea-items.ts
@@ -65,11 +65,16 @@ besta-tv-bench-180-x-38|69597380 29622904 59622912 39622908 89330691 09612171 79
besta-tv-bench-180-x-40-x-64|00538618 70299879 70299884 80299874 00474070 40299885 60474072
besta-tv-bench-doors-120-x-42-x-48|29419436 69612106 69419439 39612103 39419624 09419442 09419437
besta-tv-bench-doors-120-x-42-x-74|39068334 09506095 99420506 99420479 79420480 69068337 59506093
+besta-tv-bench-doors-240-x-42-x-38|09603572 39612155 59603579 19603581 99603624 89603573 59612159
+besta-tv-bench-doors-240-x-42-x-40|29623135 49623144 49623139 29623140 89623137 69623143 19623145
+besta-tv-bench-doors-240-x-42-x-76|89622958 39622965 59622969 99622967 59622974 89622963 79622968
beteshast-desk-120-x-60|80619804
billy-40x202|50263838 60477382 80508641 70477334 40594928
billy-80x106|30263844 90477385 30508648 00477337
billy-80x202|00263850 10508932 40477340 50508652
billy-bookcase-120-x-28-x-237|39017839
+billy-bookcase-160-x-28-x-202|79017837
+billy-bookcase-240-x-28-x-106|09017826
billy-bookcase-40-x-28-x-106|80263832 30477331 20477379 10508625
billy-bookcase-40-x-28-x-237|49217734
billy-bookcase-40-x-39-x-202|10401931
@@ -95,6 +100,7 @@ billy-oxberg-bookcase-glass-doors-80-x-30-x-237|09581909 69581911
billy-oxberg-bookcase-glass-doors-80-x-41-x-202|79398832
billy-oxberg-bookcase-panel-glass-door-40-x-30-x|39287421 39483337 79483340 19483338
billy-oxberg-bookcase-panel-glass-door-40-x-41-x|89398841
+billy-oxberg-bookcase-panel-glass-doors-160-x-30|79581859 39581861 79280738 79280724 49581865 19581862
billy-oxberg-bookcase-panel-glass-doors-80-x-30|69281776 69483326 29483328 89483325
billy-oxberg-bookcase-panel-glass-doors-80-x-41|69398837
bingsta-armchair|10455655
@@ -394,6 +400,7 @@ ikea-ps-2026-trolley-89-x-48|50621078 40621074
ikea-ps-cabinet-119-x-63|10251451
invallning-trolley-68-x-39|10569398
ismantorp-armchair|60598218 10598225
+ivar-cabinet-doors-160-x-30-x-83|89508118 99508108
ivar-cabinet-doors-80-x-83|50531252 00531240 40033763 70033766
ivar-cabinet-doors-89-x-30-x-124|69508162 49508158
ivar-cabinet-sliding-doors-80-x-30-x-60|00494394
@@ -406,6 +413,7 @@ ivar-shelving-unit-89-x-50-x-179|39407070 89404578
ivar-shelving-unit-89-x-50-x-226|09631216
ivar-shelving-unit-doors-89-x-30-x-124|39403473 89507883 59508087 09507858
ivar-shelving-unit-doors-89-x-30-x-179|89403461 19403474
+ivar-wall-cabinet-doors-160-x-30-x-83|09417382
ivosjon-cabinet-doors-33-x-34-x-99|30569095 90609871
jakobsfors-coffee-table-80|90500121 50515167
janinge-chair|70246089
@@ -753,9 +761,13 @@ ovning-trolley-54-x-33|00517003
pahl-desk-96-x-58|49619340
pax-bergsbo-wardrobe|59502716
pax-bergsbo-wardrobe-100-x-60-x-201|09503011 59502655 89503012 39502656
+pax-bergsbo-wardrobe-200-x-60-x-201|89502545 19502544
+pax-bergsbo-wardrobe-200-x-60-x-236|79502635
pax-flisberget-wardrobe-100-x-60-x-201|49503014 19502662 99503016 79502664
+pax-flisberget-wardrobe-200-x-60-x-201|09502634 29502633 69625156 49625162
pax-forsand-wardrobe-100-x-60-x-201|79503017 09502667
pax-forsand-wardrobe-100-x-60-x-236|49502665
+pax-forsand-wardrobe-200-x-60-x-201|89503173 69503174
pax-frame|70458203 80458207 90458202 50458204 00458206 60458208 10458201
pax-grimo-wardrobe-100-x-60-x-201|19503020 89502668
pax-wardrobe-frame-50-x-58-x-201|70458217 90458221 90458216 10458215 50458218 10458220 70458222
diff --git a/src/data/ikea-rows.ts b/src/data/ikea-rows.ts
index dfcab81..063fbdf 100644
--- a/src/data/ikea-rows.ts
+++ b/src/data/ikea-rows.ts
@@ -52,6 +52,9 @@ BESTÅ|cabinet|Frame, 60 × 40 × 192 cm|60|192|40|knobs=none,doors=0
BESTÅ|cabinet|Shelf unit with doors, 60 × 42 × 193 cm|60|193|42|knobs=none
BESTÅ|cabinet|Frame, 120 × 40 × 64 cm|120|64|40|knobs=none,doors=0
BESTÅ|cabinet|Shelf unit with doors, 120 × 42 × 64 cm|120|64|42|knobs=none
+BESTÅ|cabrow|TV bench with doors, 240 × 42 × 38 cm|240|38|42|knobs=none,n=2,of=tv
+BESTÅ|cabrow|TV bench with doors, 240 × 42 × 40 cm|240|40|42|knobs=none,n=2,of=tv
+BESTÅ|cabrow|TV bench with doors, 240 × 42 × 76 cm|240|76|42|knobs=none,n=2,of=tv
BESTÅ|open|Shelving unit, 60 × 40 × 193 cm|60|193|40
BESTÅ|tv|TV bench, 120 × 40 × 48 cm|120|48|40|knobs=none,doors=0
BESTÅ|tv|TV bench with doors, 120 × 42 × 48 cm|120|48|42|knobs=none
@@ -65,6 +68,8 @@ BILLY|bookcase|Bookcase, 40 × 28 × 237 cm|40|237|28
BILLY|bookcase|Bookcase, 80 × 39 × 202 cm|80|202|39
BILLY|bookcase|Bookcase, 80 × 28 × 237 cm|80|237|28
BILLY|bookcase|Bookcase, 120 × 28 × 237 cm|120|237|28
+BILLY|bookrow|Bookcase, 160 × 28 × 202 cm|160|202|28|n=2,of=bookcase
+BILLY|bookrow|Bookcase, 240 × 28 × 106 cm|240|106|28|n=3,of=bookcase
BILLY / HÖGADAL|cabinet|Bookcase with door, 40 × 30 × 106 cm|40|106|30|doors=1
BILLY / HÖGADAL|cabinet|Bookcase with door, 40 × 30 × 202 cm|40|202|30|doors=1
BILLY / HÖGADAL|cabinet|Bookcase with doors, 80 × 30 × 106 cm|80|106|30
@@ -87,6 +92,7 @@ BILLY / OXBERG|cabinet|Bookcase with doors, 80 × 41 × 202 cm|80|202|41
BILLY / OXBERG|cabinet|Bookcase with glass-doors, 80 × 41 × 202 cm|80|202|41
BILLY / OXBERG|cabinet|Bookcase with panel/glass doors, 80 × 41 × 202 cm|80|202|41
BILLY / OXBERG|cabinet|Bookcase with glass doors, 80 × 30 × 237 cm|80|237|30
+BILLY / OXBERG|cabrow|Bookcase with panel/glass doors, 160 × 30 × 202 cm|160|202|30|n=2,of=cabinet
BINGSTA|armchair|Armchair|75|90|80
BJÖRKBERGET|office|Swivel chair|60|105|64|arms=none
BJÖRKSNÄS|bed|Bed frame, Standard King, 150 × 200 cm|166|100|209|m=150
@@ -357,6 +363,8 @@ ISMANTORP|armchair|Armchair|75|90|80
IVAR|cabinet|Cabinet with doors, 89 × 30 × 124 cm|89|124|30
IVAR|cabinet|Shelving unit with doors, 89 × 30 × 124 cm|89|124|30
IVAR|cabinet|Shelving unit with doors, 89 × 30 × 179 cm|89|179|30
+IVAR|cabrow|Cabinet with doors, 160 × 30 × 83 cm|160|83|30|n=2,of=cabinet
+IVAR|cabrow|Wall cabinet with doors, 160 × 30 × 83 cm|160|83|30|n=2,of=wallcab
IVAR|open|Shelving unit, 80 × 30 × 83 cm|80|83|30
IVAR|open|Shelving unit, 80 × 30 × 166 cm|80|166|30
IVAR|open|Shelving unit, 89 × 30 × 124 cm|89|124|30
@@ -681,9 +689,13 @@ OSKARSHAMN|armchair|Wing chair|75|104|80
PÅHL|desk|Desk, 96 × 58 cm|96|74|58||kids children
PAX|wardrobe|Wardrobe frame, 50 × 58 × 201 cm|50|201|58|doors=0,shelves=2
PAX|wardrobe|Wardrobe frame, 75 × 58 × 201 cm|75|201|58|doors=0,shelves=2
+PAX / BERGSBO|cabrow|Wardrobe, 200 × 60 × 201 cm|200|201|60|n=2,of=wardrobe
+PAX / BERGSBO|cabrow|Wardrobe, 200 × 60 × 236 cm|200|236|60|n=2,of=wardrobe
PAX / BERGSBO|wardrobe|Wardrobe|50|236|58
PAX / BERGSBO|wardrobe|Wardrobe, 100 × 60 × 201 cm|100|201|60
+PAX / FLISBERGET|cabrow|Wardrobe, 200 × 60 × 201 cm|200|201|60|n=2,of=wardrobe
PAX / FLISBERGET|wardrobe|Wardrobe, 100 × 60 × 201 cm|100|201|60
+PAX / FORSAND|cabrow|Wardrobe, 200 × 60 × 201 cm|200|201|60|n=2,of=wardrobe
PAX / FORSAND|wardrobe|Wardrobe, 100 × 60 × 201 cm|100|201|60
PAX / FORSAND|wardrobe|Wardrobe, 100 × 60 × 236 cm|100|236|60
PAX / GRIMO|wardrobe|Wardrobe, 100 × 60 × 201 cm|100|201|60
diff --git a/src/lib/ikea.ts b/src/lib/ikea.ts
index e557608..e9cb643 100644
--- a/src/lib/ikea.ts
+++ b/src/lib/ikea.ts
@@ -23,9 +23,9 @@ 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"] 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"] 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"]);
+const WORDS = new Set<string>(["knobs", "arms", "legs", "attach", "chaise", "corner", "under", "of"]);
export function encodeX(x: X): string {
const out: string[] = [];
diff --git a/src/lib/plan/index.ts b/src/lib/plan/index.ts
index 1f95c49..47343bc 100644
--- a/src/lib/plan/index.ts
+++ b/src/lib/plan/index.ts
@@ -8,6 +8,7 @@ import { buildCabinet } from "./cabinet";
import { buildSeat } from "./seat";
import { buildSofa } from "./sofa";
import { buildCustom } from "./custom";
+import { buildRow } from "./row";
const cache = new Map<string, Plan>();
@@ -16,33 +17,30 @@ export function buildPlan(spec: ProductSpec): Plan {
const hit = cache.get(key);
if (hit) return hit;
const b = new PlanBuilder(spec);
+ if (spec.row) buildRow(b, spec, buildOne);
+ else buildOne(b, spec);
+ const plan = b.build();
+ cache.set(key, plan);
+ return plan;
+}
+
+function buildOne(b: PlanBuilder, spec: ProductSpec) {
switch (spec.archetype) {
case "shelf":
- buildShelf(b, spec);
- break;
+ return buildShelf(b, spec);
case "drawers":
- buildDrawers(b, spec);
- break;
+ return buildDrawers(b, spec);
case "table":
- buildTable(b, spec);
- break;
+ return buildTable(b, spec);
case "bed":
- buildBed(b, spec);
- break;
+ return buildBed(b, spec);
case "cabinet":
- buildCabinet(b, spec);
- break;
+ return buildCabinet(b, spec);
case "seat":
- buildSeat(b, spec);
- break;
+ return buildSeat(b, spec);
case "sofa":
- buildSofa(b, spec);
- break;
+ return buildSofa(b, spec);
case "custom":
- buildCustom(b, spec);
- break;
+ return buildCustom(b, spec);
}
- const plan = b.build();
- cache.set(key, plan);
- return plan;
}
diff --git a/src/lib/plan/row.ts b/src/lib/plan/row.ts
new file mode 100644
index 0000000..77299a0
--- /dev/null
+++ b/src/lib/plan/row.ts
@@ -0,0 +1,155 @@
+import type { HwItem, PartItem, ProductSpec, Step, Vec3 } from "../types";
+import { HW, PlanBuilder, type FitOpts } from "./builder";
+import { clamp, rotate, toWorld } from "./math";
+
+const UNIT: Record<string, [string, string]> = {
+ bookcase: ["bookcase", "bookcases"],
+ tv: ["TV bench", "TV benches"],
+ wardrobe: ["wardrobe", "wardrobes"],
+ wallcab: ["wall cabinet", "wall cabinets"],
+ cabinet: ["cabinet", "cabinets"],
+};
+const COUNT = ["", "", "two", "three", "four"];
+
+/**
+ * Several identical frames side by side (two BILLY bookcases, two BESTÅ TV benches, a row of PAX wardrobes).
+ * The first is built step by step exactly as its own guide does, the others the same way off to the side;
+ * then they're pushed together (and screwed to each other through their sides when IKEA joins them),
+ * and fixed to the wall last, every one of them.
+ */
+export function buildRow(b: PlanBuilder, s: ProductSpec, one: (b: PlanBuilder, s: ProductSpec) => void) {
+ const n = clamp(Math.round(s.row?.n ?? 2), 2, 4);
+ const join = !!s.row?.join;
+ const W = s.size.w * 10, H = s.size.h * 10, D = s.size.d * 10;
+ const uw = W / n;
+ const { row, ...rest } = s;
+ void row;
+ const unit: ProductSpec = { ...rest, size: { ...s.size, w: s.size.w / n } };
+ one(b, unit);
+ const [what, whats] = UNIT[s.row?.of ?? (s.archetype === "shelf" ? "bookcase" : "cabinet")] ?? ["one", "others"];
+
+ // the first one's wall fixing waits until they all stand together
+ let anchor: { def: Step; items: HwItem[] } | undefined;
+ const lastStep = b.steps[b.steps.length - 1];
+ if (lastStep?.kind === "anchor") {
+ const items = b.items.filter((it): it is HwItem => it.kind === "hw" && it.step === lastStep.n);
+ b.items = b.items.filter((it) => !(it.kind === "hw" && it.step === lastStep.n));
+ for (const it of items) b.map.delete(it.key);
+ b.steps.pop();
+ anchor = { def: lastStep, items };
+ }
+
+ // the first one stands at the left end of the row
+ const dx0 = -W / 2 + uw / 2;
+ const shift = (p: Vec3, dx: number): Vec3 => [p[0] + dx, p[1], p[2]];
+ const parts = b.items.filter((it): it is PartItem => it.kind === "part");
+ for (const it of parts) {
+ const old = it.final.pos;
+ it.final = { pos: shift(old, dx0), rot: it.final.rot };
+ for (const st of it.states) if (st.scene === "main") st.pos = st.pos === old ? it.final.pos : shift(st.pos, dx0);
+ }
+ for (const it of b.items) if (it.kind === "hw" && !it.parent && it.scene === "main") it.pos = shift(it.pos, dx0);
+ const fitted = b.items.filter((it): it is HwItem => it.kind === "hw" && !!it.parent);
+
+ // how long the first one took, to weigh the others by
+ const own = b.steps.reduce((sum, st) => sum + weightOf(b, st), 0);
+
+ /* ---------- the others, built the same way ---------- */
+ const copies = new Map<string, string[]>(parts.map((it) => [it.key, []]));
+ const gap = 160;
+ b.step(
+ {
+ title: n > 2 ? `Build the other ${COUNT[n - 1]} ${whats} the same way` : `Build the second ${what} the same way`,
+ detail: n > 2 ? "Every step as for the first one. Stand each one next to the last." : "Every step as for the first one. Stand it next to the first.",
+ kind: "general",
+ people: s.people,
+ weight: own * (n - 1) * 0.85,
+ },
+ () => {
+ for (let k = 1; k < n; k++) {
+ b.stagger(0);
+ for (const it of parts) {
+ const pos = shift(it.final.pos, k * uw);
+ const key = b.place(it.ref, pos, it.final.rot);
+ b.partItem(key).holes = it.holes.map((h) => ({ p: [...h.p] as Vec3, n: [...h.n] as Vec3, r: h.r }));
+ copies.get(it.key)!.push(key);
+ b.stage(key, shift(pos, k * gap), it.final.rot, [520, 0, 0]);
+ }
+ // its fittings are in already
+ for (const h of fitted) {
+ const ht = b.hw.get(h.ref)!;
+ const key = copies.get(h.parent!)![k - 1];
+ const f = b.partItem(key).final;
+ const k2 = b.preset({ kind: ht.kind, len: ht.len, dia: ht.dia, notIncluded: ht.notIncluded }, { on: key, at: toWorld(h.pos, f.pos, f.rot), dir: rotate(h.dir, f.rot), twist: h.twist, scale: h.scale, hole: false });
+ const c = b.map.get(k2) as HwItem;
+ c.spin = h.spin;
+ c.turn = h.turn;
+ }
+ b.wait(0.35);
+ }
+ },
+ );
+
+ /* ---------- pushed together ---------- */
+ const frameOf = (orig: string, k: number) => (k === 0 ? orig : copies.get(orig)![k - 1]);
+ const sides = parts.filter((it) => b.parts.find((p) => p.id === it.ref)?.name === "Side panel");
+ const left = sides.reduce<PartItem | undefined>((a, it) => (!a || it.final.pos[0] < a.final.pos[0] ? it : a), undefined);
+ const right = sides.reduce<PartItem | undefined>((a, it) => (!a || it.final.pos[0] > a.final.pos[0] ? it : a), undefined);
+ const screws = join && left && right && left !== right;
+ b.step(
+ {
+ title: screws ? "Push them together and screw them to each other" : "Push them together",
+ detail: screws ? "Line up the fronts and the tops, then screw through the sides." : "Line up the fronts and the tops, side by side against the wall.",
+ tools: screws ? ["screwdriver"] : [],
+ people: 2,
+ kind: "join",
+ warnings: ["two"],
+ weight: screws ? 1.2 + 0.4 * (n - 1) : 1,
+ },
+ () => {
+ b.stagger(0);
+ for (const list of copies.values()) for (const key of list) b.add(key);
+ if (!screws) return;
+ b.then(0.15);
+ const t = b.parts.find((p) => p.id === right.ref)!.size[0];
+ const ys = (H > 1500 ? [0.12, 0.38, 0.62, 0.88] : H > 700 ? [0.2, 0.5, 0.8] : [0.3, 0.7]).map((f) => Math.round(H * f));
+ const list: FitOpts[] = [];
+ for (let k = 0; k < n - 1; k++) {
+ const x = -W / 2 + (k + 1) * uw - t;
+ for (const y of ys) list.push({ on: frameOf(right.key, k), at: [x, y, D / 2 - 60], dir: [1, 0, 0], mate: frameOf(left.key, k + 1) });
+ }
+ b.fits(HW.screwM, list, 0.08);
+ },
+ );
+
+ /* ---------- every one fixed to the wall ---------- */
+ if (anchor) {
+ const a = anchor;
+ b.step(
+ { title: a.def.title.replace(/\bit\b/, "them"), detail: a.def.detail, tools: a.def.tools, people: a.def.people, kind: a.def.kind, warnings: a.def.warnings, wall: a.def.wall },
+ () => {
+ b.stagger(0.12);
+ for (const h of a.items) {
+ const ht = b.hw.get(h.ref)!;
+ const def = { kind: ht.kind, len: ht.len, dia: ht.dia, notIncluded: ht.notIncluded };
+ for (let k = 0; k < n; k++) {
+ if (h.parent) {
+ const key = frameOf(h.parent, k);
+ const f = b.partItem(key).final;
+ b.fit(def, { on: key, at: toWorld(h.pos, f.pos, f.rot), dir: rotate(h.dir, f.rot), travel: h.travel, spin: h.spin, twist: h.twist, hole: false });
+ } else b.fit(def, { at: shift(h.pos, dx0 + k * uw), dir: h.dir, travel: h.travel, spin: h.spin, twist: h.twist });
+ }
+ }
+ },
+ );
+ }
+}
+
+/** The builder's own estimate of a step's work, before minutes are shared out. */
+function weightOf(b: PlanBuilder, s: Step) {
+ if (s.minutes) return s.minutes;
+ if (s.quiet) return 1.6;
+ const parts = b.items.filter((i) => i.kind === "part" && i.states[0]?.step === s.n).length + b.items.filter((i) => i.kind === "part" && i.states.length > 1 && i.states.some((x, k) => k > 0 && x.step === s.n)).length * 0.5;
+ const hws = b.items.filter((i) => i.kind === "hw" && i.step === s.n && !i.preset).length;
+ return (0.8 + parts * 0.6 + hws * 0.12) * (s.repeat ?? 1);
+}
diff --git a/src/lib/products.ts b/src/lib/products.ts
index cd14436..d8d3cd3 100644
--- a/src/lib/products.ts
+++ b/src/lib/products.ts
@@ -45,7 +45,9 @@ export type Kind =
| "daybed"
| "mixed"
| "sliding"
- | "slidecab";
+ | "slidecab"
+ | "bookrow"
+ | "cabrow";
export type X = {
rows?: number;
@@ -78,6 +80,8 @@ export type X = {
dtop?: boolean;
rail?: boolean;
slides?: number;
+ n?: number;
+ of?: "bookcase" | "cabinet" | "tv" | "wardrobe" | "wallcab";
};
export type Row = [name: string, kind: Kind, variant: string, w: number, h: number, d: number, x?: X, keywords?: string];
@@ -251,7 +255,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, mixed: 50, sliding: 110, slidecab: 60,
+ office: 20, chaise: 55, corner: 70, cot: 35, bunk: 90, loft: 75, dropleaf: 40, daybed: 60, mixed: 50, sliding: 110, slidecab: 60, bookrow: 120, cabrow: 120,
};
const CATEGORY: Record<Kind, string> = {
@@ -260,7 +264,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", mixed: "Cabinet with doors and drawers", sliding: "Wardrobe with sliding doors", slidecab: "Cabinet with sliding doors",
+ 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", sliding: "Wardrobe with sliding doors", slidecab: "Cabinet with sliding doors", bookrow: "Bookcase combination", cabrow: "Storage combination",
};
export const KIND_ARCH: Record<Kind, Archetype> = {
@@ -268,11 +272,19 @@ 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", mixed: "cabinet", sliding: "cabinet", slidecab: "cabinet",
+ office: "seat", chaise: "sofa", corner: "sofa", cot: "bed", bunk: "bed", loft: "bed", dropleaf: "table", daybed: "bed", mixed: "cabinet", sliding: "cabinet", slidecab: "cabinet", bookrow: "shelf", cabrow: "cabinet",
};
const round = (x: X) => (x.round ? { round: true } : {});
+const ROW_CATEGORY: Record<NonNullable<X["of"]>, string> = {
+ bookcase: "Bookcase combination",
+ cabinet: "Cabinet combination",
+ tv: "TV bench combination",
+ wardrobe: "Wardrobe combination",
+ wallcab: "Wall cabinet combination",
+};
+
/** Turn a kind and a size into a full product spec. */
export function specFor(kind: Kind, name: string, variant: string, w: number, h: number, d: number, x: X = {}): Omit<ProductSpec, "source"> {
const big = h > 150 || w > 150;
@@ -377,6 +389,17 @@ export function specFor(kind: Kind, name: string, variant: string, w: number, h:
const robe = kind === "sliding";
return { ...base, people: robe || h > 150 ? 2 : 1, difficulty: robe ? 3 : 2, cabinet: { fronts: "sliding", slides: x.slides ?? 2, doors: 0, shelves: x.shelves ?? (robe ? 1 : h > 150 ? 3 : h > 100 ? 2 : 1), rail: robe, plinth: x.plinth ?? h > 120, handles: "none", thickness: robe ? 18 : 16 } };
}
+ case "bookrow":
+ case "cabrow": {
+ // x.n units of kind x.of side by side, each drawn as its own guide would draw it
+ const n = x.n ?? 2;
+ const of = x.of ?? (kind === "bookrow" ? "bookcase" : "cabinet");
+ const inner: X = { ...x };
+ delete inner.n;
+ delete inner.of;
+ const one = specFor(of, name, variant, Math.round((w / n) * 10) / 10, h, d, inner);
+ return { ...one, category: ROW_CATEGORY[of], size: { w, h, d }, minutes: x.min ?? one.minutes * n + 15, people: 2, row: { n, of, join: of !== "bookcase" } };
+ }
}
}
@@ -407,5 +430,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], mixed: [80, 120, 40], sliding: [118, 200, 60], slidecab: [80, 110, 45],
+ 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], sliding: [118, 200, 60], slidecab: [80, 110, 45], bookrow: [160, 202, 28], cabrow: [240, 48, 42],
};
diff --git a/src/lib/search.ts b/src/lib/search.ts
index 47235b3..94a25b3 100644
--- a/src/lib/search.ts
+++ b/src/lib/search.ts
@@ -16,6 +16,8 @@ export function slugify(s: string) {
const CATEGORY_WORDS: [Kind, string[]][] = [
["office", ["office chair", "desk chair", "swivel chair", "gaming chair", "computer chair"]],
+ ["bookrow", ["bookcase combination", "bookshelf combination"]],
+ ["cabrow", ["tv bench combination", "tv unit combination", "media unit combination", "cabinet combination", "wardrobe combination", "closet combination", "wall cabinet combination"]],
["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"]],
@@ -151,6 +153,8 @@ export function searchCatalog(q: string, limit = 8): Hit[] {
if (!ns && ((first.length >= 3 && r.words.some((w) => w.startsWith(first))) || (firstIsKind && kwHit))) score += 20;
for (const t of tokens.slice(1)) if (t.length && r.words.some((w) => w.startsWith(t) || (t.length > 2 && w.includes(t)))) score += 12;
if (kw) score += kwHit ? 14 : -30;
+ // several units side by side come after the single one, unless the query asks for a combination
+ if ((e.kind === "bookrow" || e.kind === "cabrow") && kind !== e.kind) score -= 1;
if (e.checked) score += 3;
if (e.featured) score += 2;
if (score > 15) hits.push({ entry: e, score, exact: ns >= 80 });
diff --git a/src/lib/types.ts b/src/lib/types.ts
index 90617f2..d0d6c9c 100644
--- a/src/lib/types.ts
+++ b/src/lib/types.ts
@@ -157,6 +157,7 @@ export interface ProductSpec {
slug?: string;
variants?: { label: string; slug: string }[];
siblings?: { label: string; slug: string }[];
+ row?: { n: number; join?: boolean; of?: string }; // several identical units side by side, built one after another
}
/* ---------- generated plan ---------- */