IKEA assembly, step by step: animated, manual-style 3D guides. Scan any paper manual with Together AI.
TypeScript
Draw PAX corner wardrobes
Youssefb809e9cd5768
diff --git a/scripts/ikea/build.ts b/scripts/ikea/build.tsindex 84f0a8d..bdd8fba 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", "bookrow", "cabrow", "section", "gateleg", "washstand", "sinkcab", "appliance", "shoerack", "clothesrack", "changing", "divider", "backbench", "junior", "lounge", "highchair", "cornercab"]);+const LATER_KINDS = new Set<Kind>(["office", "chaise", "corner", "cot", "bunk", "loft", "dropleaf", "daybed", "mixed", "sliding", "slidecab", "bookrow", "cabrow", "section", "gateleg", "washstand", "sinkcab", "appliance", "shoerack", "clothesrack", "changing", "divider", "backbench", "junior", "lounge", "highchair", "cornercab", "cornerrobe"]);function baseMatch(name: string, draw: Draw): CatalogEntry | undefined {const fam = fold(name);diff --git a/scripts/ikea/check.ts b/scripts/ikea/check.tsindex 3158276..8f92848 100644--- a/scripts/ikea/check.ts+++ b/scripts/ikea/check.ts@@ -112,6 +112,9 @@ async function main() {// a row of frames when asked for, the single frame otherwiseexpect("billy bookcase combination", "billy-bookcase-160-x-28-x-202");expect("pax bergsbo", "pax-bergsbo-wardrobe");+ // a corner wardrobe when asked for, the frame otherwise+ expect("pax corner wardrobe", "pax-corner-wardrobe-161-188-x-201");+ expect("pax wardrobe", "pax-frame");expect("vihals gateleg table", "vihals-gateleg-table-39-95-151-x-90");// a wash-stand when asked for, US words too, without taking the family's cabinetsexpect("hemnes wash-stand", "hemnes-wash-stand-2-drawers-60-x-47-x-83");diff --git a/scripts/ikea/classify.ts b/scripts/ikea/classify.tsindex 9bda9ea..ba6b20a 100644--- a/scripts/ikea/classify.ts+++ b/scripts/ikea/classify.ts@@ -87,6 +87,41 @@ const GATE_STORAGE = new Set(["VIHALS"]);const ROW_UNITS: Record<string, number> = { BILLY: 80, BESTÅ: 120, IVAR: 80, PAX: 100 };/** 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. */+const FRAME_SIZES: Record<string, number[]> = { PAX: [100, 75, 50] };++/** Frames for one leg of a corner wardrobe: the frames that come closest to `len` cm, and how far off they are. */+function legFrames(len: number, sizes: number[], least: number): [number[], number] {+ let best: [number[], number] = [[], Infinity];+ const walk = (left: number[], from: number) => {+ const off = Math.abs(left.reduce((a, v) => a + v, 0) - len);+ if (left.length >= least && off < best[1]) best = [[...left], off];+ if (left.length === 3) return;+ for (let i = from; i < sizes.length; i++) walk([...left, sizes[i]], i);+ };+ walk([], 0);+ return best;+}++/**+ * How a PAX corner wardrobe of these two legs (cm) is laid out: frames along the back wall, an add-on corner unit 53 cm wide+ * with its back to the side wall, tucked in beside the first frame, and frames along the side wall after it. The corner unit+ * comes 35 or 58 cm deep. Picks the layout whose frames come closest to IKEA's legs, either way round.+ */+function cornerLayout(a: number, c: number, sizes: number[]) {+ let best: { back: number; side: number; u: number[]; v: number[]; cu: number; off: number } | undefined;+ for (const [back, side] of [[a, c], [c, a]])+ for (const cu of [35, 58]) {+ const [u, offU] = legFrames(back - cu - 0.5, sizes, 1);+ const [v, offV] = legFrames(side - cu - 0.5 - 52.5, sizes, 0);+ const start = back - u.reduce((s, x) => s + x, 0), zc = side - v.reduce((s, x) => s + x, 0) - 53;+ // the corner unit must not run into the first frame along the back wall+ if (zc < 0 || (start < cu - 1 && zc < 57)) continue;+ const off = offU + offV;+ if (!best || off < best.off - 0.01) best = { back, side, u, v, cu, off };+ }+ return best && best.off <= 8 ? best : undefined;+}/** Wash-stands' own height in cm, to tell how thick a basin from the same box is; and the ones that stand on the floor. */const WASH_H: Record<string, number> = { HAVBÄCK: 63, ÄNGSJÖN: 63, TÄNNFORSEN: 63, HEMNES: 83, ENHET: 60, NYSJÖN: 65 };const WASH_FLOOR = new Set(["HEMNES", "NYSJÖN"]);@@ -235,6 +270,10 @@ const RULES: Rule[] = [}],// a chaise longue sold alone as a section of a modular sofa: a one-seat section as long as a chaise[/^(chaise longue section|chaise longue module(?:, (?:left|right))?|chaise longue, add-on unit|modular chaise longue)$/, () => ({ kind: "section", x: { seats: 1, chaise: "right" } })],+ // corner wardrobes: frames along both walls around an add-on corner unit, with doors when a door's name comes with them+ [/^corner wardrobe$/, (_m, c) => ({ kind: "cornerrobe", x: c.multi ? {} : { doors: 0 } })],+ // the add-on corner unit sold on its own: a cabinet of shelves+ [/^add-on corner unit with (\d) shelves$/, (m) => ({ kind: "cabinet", x: { doors: 0, shelves: Number(m[1]) } })],[/corner|chaise|u-shaped|crnr/, () => "corner or chaise longue sofa"],// a straight sofa section sold alone: a seat frame with legs, a backrest and cushions, no armrests[/^(\d)-seat section( for modular sofa)?$/, (m) => ({ kind: "section", x: { seats: Number(m[1]) } })],@@ -562,6 +601,16 @@ export function classify(f: Fact, hints: Hints): Verdict {d = Math.min(175, Math.max(140, d + 68));delete x.chaise;}+ } else if (kind === "cornerrobe") {+ // IKEA gives the two legs and the height: "211/161x201 cm"+ const legs = f.size.replace(/\s+/g, "").match(/^(\d+(?:\.\d+)?)\/(\d+(?:\.\d+)?)x(\d+(?:\.\d+)?)cm$/);+ if (!legs) return { skip: "corner wardrobe with a size we can't read" };+ const lay = cornerLayout(Number(legs[1]), Number(legs[2]), FRAME_SIZES[family] ?? FRAME_SIZES.PAX);+ if (!lay) return { skip: "corner wardrobe we can't split into frames" };+ set(lay.back, Number(legs[3]), lay.side);+ Object.assign(x, { u: lay.u.join("+"), ...(lay.v.length ? { v: lay.v.join("+") } : {}), ...(lay.cu !== 35 ? { cu: lay.cu } : {}) });+ const robe = hints(family, "wardrobe");+ if (robe?.x.shelves) x.shelves = robe.x.shelves;} else if (kind === "cornercab") {// an L is measured leg by leg ("88x88"), or as a frame with its leg's depth ("88x60x80"); a blind corner wide by deep;// a wall cabinet wide by high; some families wide by high with the worktop on topdiff --git a/scripts/ikea/slugs.json b/scripts/ikea/slugs.jsonindex bf87d8f..5531c13 100644--- a/scripts/ikea/slugs.json+++ b/scripts/ikea/slugs.json@@ -922,18 +922,30 @@"PÄRONHOLMEN|Bench with backrest, outdoor": "paronholmen-bench-backrest-outdoor","PAX / AULI|Wardrobe with sliding doors, 150 × 43 × 201 cm": "pax-auli-wardrobe-sliding-doors-150-x-43-x-201","PAX / AULI|Wardrobe with sliding doors, 150 × 66 × 201 cm": "pax-auli-wardrobe-sliding-doors-150-x-66-x-201",+ "PAX / BERGSBO/ÅHEIM|Corner wardrobe, 211/161 × 236 cm": "pax-bergsbo-aheim-corner-wardrobe-211-161-x-236",+ "PAX / BERGSBO|Corner wardrobe, 111/88 × 201 cm": "pax-bergsbo-corner-wardrobe-111-88-x-201","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 / FARDAL/ÅHEIM|Corner wardrobe, 111/88 × 201 cm": "pax-fardal-aheim-corner-wardrobe-111-88-x-201",+ "PAX / FLISBERGET|Corner wardrobe, 111/88 × 201 cm": "pax-flisberget-corner-wardrobe-111-88-x-201",+ "PAX / FLISBERGET|Corner wardrobe, 161/111 × 201 cm": "pax-flisberget-corner-wardrobe-161-111-x-201",+ "PAX / FLISBERGET|Corner wardrobe, 161/88 × 201 cm": "pax-flisberget-corner-wardrobe-161-88-x-201","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|Corner wardrobe, 111/88 × 201 cm": "pax-forsand-corner-wardrobe-111-88-x-201",+ "PAX / FORSAND|Corner wardrobe, 111/88 × 236 cm": "pax-forsand-corner-wardrobe-111-88-x-236","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 / FYRUDDEN|Corner wardrobe, 161/111 × 236 cm": "pax-fyrudden-corner-wardrobe-161-111-x-236",+ "PAX / GRIMO/ÅHEIM|Corner wardrobe, 211/161 × 201 cm": "pax-grimo-aheim-corner-wardrobe-211-161-x-201",+ "PAX / GRIMO|Corner wardrobe, 110/110 × 201 cm": "pax-grimo-corner-wardrobe-110-110-x-201","PAX / GRIMO|Wardrobe with sliding doors, 150 × 43 × 201 cm": "pax-grimo-wardrobe-sliding-doors-150-x-43-x-201","PAX / GRIMO|Wardrobe, 100 × 60 × 201 cm": "pax-grimo-wardrobe-100-x-60-x-201","PAX / GRIMO|Wardrobe, 150 × 66 × 201 cm": "pax-grimo-wardrobe-150-x-66-x-201",+ "PAX / GULLABERG|Corner wardrobe, 161/111 × 201 cm": "pax-gullaberg-corner-wardrobe-161-111-x-201","PAX / HASVIK|Wardrobe with sliding doors, 150 × 43 × 201 cm": "pax-hasvik-wardrobe-sliding-doors-150-x-43-x-201","PAX / HASVIK|Wardrobe, 150 × 66 × 201 cm": "pax-hasvik-wardrobe-150-x-66-x-201","PAX / HASVIK|Wardrobe, 200 × 66 × 201 cm": "pax-hasvik-wardrobe-200-x-66-x-201",@@ -952,6 +964,15 @@"PAX / MEHAMN|Wardrobe with sliding doors, 200 × 66 × 236 cm": "pax-mehamn-wardrobe-sliding-doors-200-x-66-x-236","PAX / MEHAMN|Wardrobe, 150 × 66 × 201 cm": "pax-mehamn-wardrobe-150-x-66-x-201","PAX / MEHAMN|Wardrobe, 200 × 66 × 201 cm": "pax-mehamn-wardrobe-200-x-66-x-201",+ "PAX / TONSTAD|Corner wardrobe, 211/161 × 201 cm": "pax-tonstad-corner-wardrobe-211-161-x-201",+ "PAX / TONSTAD|Corner wardrobe, 231/161 × 236 cm": "pax-tonstad-corner-wardrobe-231-161-x-236",+ "PAX / TYSSEDAL|Corner wardrobe, 161/111 × 236 cm": "pax-tyssedal-corner-wardrobe-161-111-x-236",+ "PAX|Add-on corner unit with 4 shelves, 53 × 35 × 236 cm": "pax-add-on-corner-unit-4-shelves-53-x-35-x-236",+ "PAX|Add-on corner unit with 4 shelves, 53 × 58 × 201 cm": "pax-add-on-corner-unit-4-shelves-53-x-58-x-201",+ "PAX|Corner wardrobe, 161/188 × 201 cm": "pax-corner-wardrobe-161-188-x-201",+ "PAX|Corner wardrobe, 210/180 × 236 cm": "pax-corner-wardrobe-210-180-x-236",+ "PAX|Corner wardrobe, 211/161 × 201 cm": "pax-corner-wardrobe-211-161-x-201",+ "PAX|Corner wardrobe, 211/213 × 236 cm": "pax-corner-wardrobe-211-213-x-236","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","PERSBOL|Armchair": "persbol-armchair",diff --git a/src/data/ikea-guard.ts b/src/data/ikea-guard.tsindex c7e9e66..1b26913 100644--- a/src/data/ikea-guard.ts+++ b/src/data/ikea-guard.ts@@ -1,3 +1,3 @@// Generated by scripts/ikea/build.ts from IKEA product data. Do not edit by hand.// Real IKEA names we can't draw that look like a typo of one we can (folded, no spaces)-export const IKEA_GUARD = "abrotten afjall alsken alvsta ananas angskorn arsjon asphult aspinge bagganas basingen batskar bengta blanda blaser boholmen bolmso borrby branas brogrund brunsta bullig burfjord byholma cissan dalskar duvholmen eklatera ekorre fagelon falskar fardal farvik fiskbo florsjon forneby forsa forvaltare fossta frakta fridfull frihult frojda froson frost fyllen gamman gansjon gatebo gillstad godis gresla gronmes grossjon grusnarv grytas gubbarp hackas hallnas hallspar halved hammaron hamnskar hanga hassjon havsdun havsen havskal havsmal hejsta helgeo hilver hogvind holmared holmeja horred hultarp hutten ikeaps2002 ikeaps2014 ikeaps2017 isjakt jagmastare jallby jattestor kalken kallarp kallboda kallror kallsjon kallsup kasker klamtare klipplax knalla knixhult knoppang kolsjon konstruera kroksjon kvalmso kvittera laktare larkar latsas lersta lill lilla lillabo lillhult lindasen lohals lova lubban lyckad macksjon majsjon mala maleras manalg martorp melodi molnas moppa morkulla navlinge nereby nissedal nogsta norden nydala opparyd ordning orskar piggal pinnarp pipranka plats plockar rahult ramsnas ramsta ranarp ransberg revskar ringsta rissla rockan runnen runskar saljen sandmott seglaro sidsjo sindal sindvik sjalso skalryta skarig skedstor skogsa skogskorn skogsnas skogsror smaata smalom smarra smaska smycka sonhult spantad sparka stelna stensta stensund stjarnhov storslinga strala strandad svalka svallet svansele svartho svartra sy tackan tacknan tallsparv tasjon terrsjo tisken tittebo tolken torared torkad tossig trogen troskning tvarfot tysnes uddarp undvika uppfora upplaga upplid uppvind utaker vagdal vagomrade vagsjon vallasan vasskar vathult vedbak veddinge vedhamn viggbo vilsta vindas voxtorp vresjon";+export const IKEA_GUARD = "abrotten afjall alsken alvsta ananas angskorn arsjon asphult aspinge bagganas basingen batskar bengta blanda blaser boholmen bolmso borrby branas brogrund brunsta bullig burfjord byholma cissan dalskar duvholmen eklatera ekorre fagelon falskar farvik fiskbo florsjon forneby forsa forvaltare fossta frakta fridfull frihult frojda froson frost fyllen gamman gansjon gatebo gillstad godis gresla gronmes grossjon grusnarv grytas gubbarp hackas hallnas hallspar halved hammaron hamnskar hanga hassjon havsdun havsen havskal havsmal hejsta helgeo hilver hogvind holmared holmeja horred hultarp hutten ikeaps2002 ikeaps2014 ikeaps2017 isjakt jagmastare jallby jattestor kalken kallarp kallboda kallror kallsjon kallsup kasker klamtare klipplax knalla knixhult knoppang kolsjon konstruera kroksjon kvalmso kvittera laktare larkar latsas lersta lill lilla lillabo lillhult lindasen lohals lova lubban lyckad macksjon majsjon mala maleras manalg martorp melodi molnas moppa morkulla navlinge nereby nissedal nogsta norden nydala opparyd ordning orskar piggal pinnarp pipranka plats plockar rahult ramsnas ramsta ranarp ransberg revskar ringsta rissla rockan runnen runskar saljen sandmott seglaro sidsjo sindal sindvik sjalso skalryta skarig skedstor skogsa skogskorn skogsnas skogsror smaata smalom smarra smaska smycka sonhult spantad sparka stelna stensta stensund stjarnhov storslinga strala strandad svalka svallet svansele svartho svartra sy tackan tacknan tallsparv tasjon terrsjo tisken tittebo tolken torared torkad tossig trogen troskning tvarfot tysnes uddarp undvika uppfora upplaga upplid uppvind utaker vagdal vagomrade vagsjon vallasan vasskar vathult vedbak veddinge vedhamn viggbo vilsta vindas voxtorp vresjon";diff --git a/src/data/ikea-items.ts b/src/data/ikea-items.tsindex 3eb57f0..2ba4480 100644--- a/src/data/ikea-items.ts+++ b/src/data/ikea-items.ts@@ -993,21 +993,39 @@ oskarshamn-wing-chair|90523622 30521678 50521663ovning-trolley-54-x-33|00517003pahl-desk-96-x-58|49619340paronholmen-bench-backrest-outdoor|90503799+pax-add-on-corner-unit-4-shelves-53-x-35-x-236|00346964 20346958 80346960 60346956+pax-add-on-corner-unit-4-shelves-53-x-58-x-201|70346932 50515110 10515112 30346934 60515119 20515121 80346941pax-auli-wardrobe-sliding-doors-150-x-43-x-201|29561335 89561342 59561329 79561333 59561334 09561336pax-auli-wardrobe-sliding-doors-150-x-66-x-201|99561351 59561305 79561314 09561317+pax-bergsbo-aheim-corner-wardrobe-211-161-x-236|99600041 59600038+pax-bergsbo-corner-wardrobe-111-88-x-201|89600046 69600047pax-bergsbo-wardrobe|59502716pax-bergsbo-wardrobe-100-x-60-x-201|09503011 59502655 89503012 39502656pax-bergsbo-wardrobe-200-x-60-x-201|89502545 19502544pax-bergsbo-wardrobe-200-x-60-x-236|79502635+pax-corner-wardrobe-161-188-x-201|69502315 09502318 99502314 29502317+pax-corner-wardrobe-210-180-x-236|19607126 09607122 99600036 19600035+pax-corner-wardrobe-211-161-x-201|69502985 49502986 99590730 99590725 89590721 89590735+pax-corner-wardrobe-211-213-x-236|99503139+pax-fardal-aheim-corner-wardrobe-111-88-x-201|19502657 99502658+pax-flisberget-corner-wardrobe-111-88-x-201|69626151 79626160+pax-flisberget-corner-wardrobe-161-111-x-201|19600021 29600025+pax-flisberget-corner-wardrobe-161-88-x-201|89502649 49502651pax-flisberget-wardrobe-100-x-60-x-201|49503014 19502662 99503016 79502664pax-flisberget-wardrobe-200-x-60-x-201|09502634 29502633 69625156 49625162+pax-forsand-corner-wardrobe-111-88-x-201|39600044+pax-forsand-corner-wardrobe-111-88-x-236|29600030 49600029pax-forsand-wardrobe-100-x-60-x-201|79503017 09502667pax-forsand-wardrobe-100-x-60-x-236|49502665pax-forsand-wardrobe-200-x-60-x-201|89503173 69503174pax-frame|70458203 80458207 90458202 50458204 00458206 60458208 10458201+pax-fyrudden-corner-wardrobe-161-111-x-236|59581756 29581753+pax-grimo-aheim-corner-wardrobe-211-161-x-201|29502987 09502988+pax-grimo-corner-wardrobe-110-110-x-201|29502652 89502654pax-grimo-wardrobe-100-x-60-x-201|19503020 89502668pax-grimo-wardrobe-150-x-66-x-201|89502791 29500295 09502648 29502647pax-grimo-wardrobe-sliding-doors-150-x-43-x-201|39590139 79590142+pax-gullaberg-corner-wardrobe-161-111-x-201|59600019 39600020pax-hasvik-wardrobe-150-x-66-x-201|29502794 79502796 79502800 59502797 19502803 09500296pax-hasvik-wardrobe-200-x-66-x-201|49502547 69502546 29503152 39503156 39503161 99503158 19503162 89503154pax-hasvik-wardrobe-sliding-doors-150-x-43-x-201|69626556 29626539 39626548 29626563@@ -1026,6 +1044,9 @@ pax-mehamn-wardrobe-sliding-doors-150-x-66-x-201|19608748 89608759 39608752 0960pax-mehamn-wardrobe-sliding-doors-150-x-66-x-236|49608822 29608818 29608559 09608555 89562247 29562245 49608817 39608813pax-mehamn-wardrobe-sliding-doors-200-x-66-x-201|49608860 99608867 89608863 79608651 09608659 39608648 39608667 89551748 99551738 79551758 49551745 19551742pax-mehamn-wardrobe-sliding-doors-200-x-66-x-236|69608779 49608775+pax-tonstad-corner-wardrobe-211-161-x-201|79600037 19600040+pax-tonstad-corner-wardrobe-231-161-x-236|59612060 39612056+pax-tyssedal-corner-wardrobe-161-111-x-236|29603397 39603392pax-wardrobe-frame-50-x-58-x-201|70458217 90458221 90458216 10458215 50458218 10458220 70458222pax-wardrobe-frame-75-x-58-x-201|80458231 90458235 60458232 00458230 70458236 20458229 20458234persbol-armchair|50525915 90525923 70525924diff --git a/src/data/ikea-rows.ts b/src/data/ikea-rows.tsindex 59bfb7c..eeb58f6 100644--- a/src/data/ikea-rows.ts+++ b/src/data/ikea-rows.ts@@ -921,22 +921,40 @@ OSKARSHAMN|armchair|Wing chair|75|104|80ÖVNING|trolley|Trolley, 54 × 33 cm|54|80|33||kids childrenPÅHL|desk|Desk, 96 × 58 cm|96|74|58||kids childrenPÄRONHOLMEN|backbench|Bench with backrest, outdoor|120|86|60||outdoor garden+PAX|cabinet|Add-on corner unit with 4 shelves, 53 × 58 × 201 cm|53|201|58|doors=0,shelves=4+PAX|cabinet|Add-on corner unit with 4 shelves, 53 × 35 × 236 cm|53|236|35|doors=0,shelves=4+PAX|cornerrobe|Corner wardrobe, 161/188 × 201 cm|161|201|188|doors=0,shelves=2,u=75+50,v=100+PAX|cornerrobe|Corner wardrobe, 210/180 × 236 cm|180|236|210|doors=0,shelves=2,u=75+50,v=100,cu=58+PAX|cornerrobe|Corner wardrobe, 211/161 × 201 cm|211|201|161|doors=0,shelves=2,u=100+75,v=75+PAX|cornerrobe|Corner wardrobe, 211/213 × 236 cm|211|236|213|doors=0,shelves=2,u=100+75,v=75+50PAX|wardrobe|Wardrobe frame, 50 × 58 × 201 cm|50|201|58|doors=0,shelves=2PAX|wardrobe|Wardrobe frame, 75 × 58 × 201 cm|75|201|58|doors=0,shelves=2PAX / AULI|cabrow|Wardrobe with sliding doors, 150 × 43 × 201 cm|150|201|43|shelves=2,slides=2,n=2,of=wardrobePAX / AULI|cabrow|Wardrobe with sliding doors, 150 × 66 × 201 cm|150|201|66|shelves=2,slides=2,n=2,of=wardrobePAX / BERGSBO|cabrow|Wardrobe, 200 × 60 × 201 cm|200|201|60|n=2,of=wardrobePAX / BERGSBO|cabrow|Wardrobe, 200 × 60 × 236 cm|200|236|60|n=2,of=wardrobe+PAX / BERGSBO|cornerrobe|Corner wardrobe, 111/88 × 201 cm|111|201|88|shelves=2,u=75PAX / BERGSBO|wardrobe|Wardrobe|50|236|58PAX / BERGSBO|wardrobe|Wardrobe, 100 × 60 × 201 cm|100|201|60+PAX / BERGSBO/ÅHEIM|cornerrobe|Corner wardrobe, 211/161 × 236 cm|211|236|161|shelves=2,u=100+75,v=75+PAX / FARDAL/ÅHEIM|cornerrobe|Corner wardrobe, 111/88 × 201 cm|111|201|88|shelves=2,u=75PAX / FLISBERGET|cabrow|Wardrobe, 200 × 60 × 201 cm|200|201|60|n=2,of=wardrobe+PAX / FLISBERGET|cornerrobe|Corner wardrobe, 111/88 × 201 cm|111|201|88|shelves=2,u=75+PAX / FLISBERGET|cornerrobe|Corner wardrobe, 161/88 × 201 cm|161|201|88|shelves=2,u=75+50+PAX / FLISBERGET|cornerrobe|Corner wardrobe, 161/111 × 201 cm|161|201|111|shelves=2,u=100,cu=58PAX / FLISBERGET|wardrobe|Wardrobe, 100 × 60 × 201 cm|100|201|60PAX / FORSAND|cabrow|Wardrobe, 200 × 60 × 201 cm|200|201|60|n=2,of=wardrobe+PAX / FORSAND|cornerrobe|Corner wardrobe, 111/88 × 201 cm|111|201|88|shelves=2,u=75+PAX / FORSAND|cornerrobe|Corner wardrobe, 111/88 × 236 cm|111|236|88|shelves=2,u=75PAX / FORSAND|wardrobe|Wardrobe, 100 × 60 × 201 cm|100|201|60PAX / FORSAND|wardrobe|Wardrobe, 100 × 60 × 236 cm|100|236|60+PAX / FYRUDDEN|cornerrobe|Corner wardrobe, 161/111 × 236 cm|161|236|111|shelves=2,u=100,cu=58PAX / GRIMO|cabrow|Wardrobe with sliding doors, 150 × 43 × 201 cm|150|201|43|shelves=2,slides=2,n=2,of=wardrobePAX / GRIMO|cabrow|Wardrobe, 150 × 66 × 201 cm|150|201|66|shelves=2,slides=2,n=2,of=wardrobe+PAX / GRIMO|cornerrobe|Corner wardrobe, 110/110 × 201 cm|110|201|110|shelves=2,u=50,cu=58PAX / GRIMO|wardrobe|Wardrobe, 100 × 60 × 201 cm|100|201|60+PAX / GRIMO/ÅHEIM|cornerrobe|Corner wardrobe, 211/161 × 201 cm|211|201|161|shelves=2,u=100+75,v=75+PAX / GULLABERG|cornerrobe|Corner wardrobe, 161/111 × 201 cm|161|201|111|shelves=2,u=100,cu=58PAX / HASVIK|cabrow|Wardrobe with sliding doors, 150 × 43 × 201 cm|150|201|43|shelves=2,slides=2,n=2,of=wardrobePAX / HASVIK|cabrow|Wardrobe, 150 × 66 × 201 cm|150|201|66|shelves=2,slides=2,n=2,of=wardrobePAX / HASVIK|cabrow|Wardrobe, 200 × 66 × 201 cm|200|201|66|shelves=2,slides=2,n=2,of=wardrobe@@ -955,6 +973,9 @@ PAX / MEHAMN/AULI|cabrow|Wardrobe with sliding doors, 150 × 43 × 201 cm|150|20PAX / MEHAMN/AULI|cabrow|Wardrobe with sliding doors, 150 × 66 × 201 cm|150|201|66|shelves=2,slides=2,n=2,of=wardrobePAX / MEHAMN/AULI|cabrow|Wardrobe with sliding doors, 150 × 66 × 236 cm|150|236|66|shelves=2,slides=2,n=2,of=wardrobe||pax-mehamn-auli-wardrobe-sliding-doors-150-x-66-2PAX / MEHAMN/AULI|cabrow|Wardrobe with sliding doors, 200 × 66 × 236 cm|200|236|66|shelves=2,slides=2,n=2,of=wardrobe+PAX / TONSTAD|cornerrobe|Corner wardrobe, 211/161 × 201 cm|211|201|161|shelves=2,u=100+75,v=75+PAX / TONSTAD|cornerrobe|Corner wardrobe, 231/161 × 236 cm|231|236|161|shelves=2,u=100+75,v=50,cu=58+PAX / TYSSEDAL|cornerrobe|Corner wardrobe, 161/111 × 236 cm|161|236|111|shelves=2,u=100,cu=58PERSBOL|armchair|Armchair|75|90|80PINNTORP|chair|Chair|44|88|50PINNTORP|dining|Table, 85 cm|85|74|85|round=1diff --git a/src/lib/catalog.ts b/src/lib/catalog.tsindex 61d7077..8cada28 100644--- a/src/lib/catalog.ts+++ b/src/lib/catalog.ts@@ -481,8 +481,8 @@ export function catalogSpec(slug: string): ProductSpec | null {function sizeLabel(x: Entry, same: Entry[]) {const head = x.variant.split(",")[0];if (x.shelf?.style === "grid" && x.shelf.cols && x.shelf.rows) return `${head}, ${x.shelf.cols} × ${x.shelf.rows}`;- // a corner cabinet goes by IKEA's own measure, leg by leg- if (x.cabinet?.corner) return x.variant;+ // a corner cabinet or wardrobe goes by IKEA's own measure, leg by leg+ if (x.cabinet?.corner || x.kind === "cornerrobe") return x.variant;if ((x.archetype === "shelf" || x.archetype === "cabinet") && /\d+ × \d+/.test(x.variant)) {const twin = same.some((o) => o !== x && o.size.w === x.size.w && o.size.h === x.size.h);return `${head}, ${x.size.w} × ${x.size.h} cm${twin ? `, ${x.size.d} deep` : ""}`;diff --git a/src/lib/ikea.ts b/src/lib/ikea.tsindex 5b8b073..5749f98 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", "n", "of", "hinge", "use", "z", "basin", "hung", "uf", "ins", "blind", "inner"] as const;+const X_KEYS = ["rows", "cols", "knobs", "plinth", "doors", "shelves", "c", "m", "l", "f", "seats", "arms", "legs", "attach", "shelf", "min", "round", "seatH", "chaise", "corner", "open", "sd", "drawer", "leaves", "leaf", "under", "mats", "dtop", "rail", "slides", "n", "of", "hinge", "use", "z", "basin", "hung", "uf", "ins", "blind", "inner", "u", "v", "cu"] as const;const FLAGS = new Set<string>(["plinth", "shelf", "round", "open", "drawer", "dtop", "rail", "hinge", "hung"]);-const WORDS = new Set<string>(["knobs", "arms", "legs", "attach", "chaise", "corner", "under", "of", "use", "z", "inner"]);+const WORDS = new Set<string>(["knobs", "arms", "legs", "attach", "chaise", "corner", "under", "of", "use", "z", "inner", "u", "v"]);export function encodeX(x: X): string {const out: string[] = [];diff --git a/src/lib/plan/builder.ts b/src/lib/plan/builder.tsindex 4af2391..4cab18f 100644--- a/src/lib/plan/builder.ts+++ b/src/lib/plan/builder.ts@@ -363,11 +363,16 @@ export class PlanBuilder {const used = this.parts.filter((p) => counts.has(p.id));used.sort((a, b) => (firstStep.get(a.id)! - firstStep.get(b.id)!) || this.parts.indexOf(a) - this.parts.indexOf(b));let li = 0;+ // past Z the letters double up (AA, AB...), and those parts keep the order they were lettered in+ const late = new Map<string, number>();for (const p of used) {p.qty = counts.get(p.id)!;- p.label = p.extra ? "" : p.label || LETTERS[li++ % LETTERS.length];+ if (!p.extra && !p.label && li >= LETTERS.length) late.set(p.id, li);+ p.label = p.extra ? "" : p.label || (li < LETTERS.length ? LETTERS[li++] : LETTERS[Math.floor(li / LETTERS.length) - 1] + LETTERS[li++ % LETTERS.length]);}- used.sort((a, b) => (a.extra ? 1 : 0) - (b.extra ? 1 : 0) || a.label.localeCompare(b.label, undefined, { numeric: true }));+ const byLabel = (a: PartType, b: PartType) =>+ late.has(a.id) || late.has(b.id) ? (late.get(a.id) ?? -1) - (late.get(b.id) ?? -1) : a.label.localeCompare(b.label, undefined, { numeric: true });+ used.sort((a, b) => (a.extra ? 1 : 0) - (b.extra ? 1 : 0) || byLabel(a, b));// step weights -> minutesconst weights = this.steps.map((s) => {diff --git a/src/lib/plan/index.ts b/src/lib/plan/index.tsindex 47343bc..fa010b1 100644--- a/src/lib/plan/index.ts+++ b/src/lib/plan/index.ts@@ -9,6 +9,7 @@ import { buildSeat } from "./seat";import { buildSofa } from "./sofa";import { buildCustom } from "./custom";import { buildRow } from "./row";+import { buildUnits } from "./units";const cache = new Map<string, Plan>();@@ -17,7 +18,8 @@ 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);+ if (spec.row?.units) buildUnits(b, spec, buildOne);+ else if (spec.row) buildRow(b, spec, buildOne);else buildOne(b, spec);const plan = b.build();cache.set(key, plan);diff --git a/src/lib/plan/units.ts b/src/lib/plan/units.tsnew file mode 100644index 0000000..11270ac--- /dev/null+++ b/src/lib/plan/units.ts@@ -0,0 +1,338 @@+import type { HwItem, HwType, PartItem, PartType, ProductSpec, RowUnit, Step, Vec3 } from "../types";+import { HW, PlanBuilder, type FitOpts } from "./builder";+import { rotate, toLocal, toWorld } from "./math";+import { slidingDoors } from "./sliding";++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"],+ open: ["shelving unit", "shelving units"],+};+const COUNT = ["", "", "two", "three", "four"];+const SIZE = [[], [""], ["narrow", "wide"], ["narrow", "medium", "wide"], ["narrowest", "narrow", "wide", "widest"]];++/** Where a frame stands: the middle of its footprint, and how far it is turned about the vertical. */+interface Place {+ pos: Vec3;+ a: number;+}++const ry = (v: Vec3, a: number): Vec3 => (a ? [v[0] * Math.cos(a) + v[2] * Math.sin(a), v[1], -v[0] * Math.sin(a) + v[2] * Math.cos(a)] : v);+const at = (p: Place, v: Vec3): Vec3 => {+ const r = ry(v, p.a);+ return [r[0] + p.pos[0], r[1] + p.pos[1], r[2] + p.pos[2]];+};++/** An XYZ Euler turned about the world vertical first: the Euler of Ry(a) times R(e), as three.js reads it. */+function turnY(e: Vec3, a: number): Vec3 {+ if (!a) return e;+ const X = ry(rotate([1, 0, 0], e), a), Y = ry(rotate([0, 1, 0], e), a), Z = ry(rotate([0, 0, 1], e), a);+ const y = Math.asin(Math.max(-1, Math.min(1, Z[0])));+ if (Math.abs(Z[0]) < 0.9999999) return [Math.atan2(-Z[1], Z[2]), y, Math.atan2(-Y[0], X[0])];+ return [Math.atan2(Y[2], Y[1]), y, 0];+}++/** 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);+}++/** A frame's guide, built on its own: what it is made of, its fittings, and its wall fixing kept apart. */+interface Built {+ parts: PartItem[];+ types: PartType[];+ fitted: HwItem[];+ hw: Map<string, HwType>;+ anchor?: { def: Step; items: HwItem[] };+ weight: number;+}++/** Takes the last step off when it fixes the frame to the wall: that waits until every frame stands in place. */+function takeAnchor(b: PlanBuilder): Built["anchor"] {+ const last = b.steps[b.steps.length - 1];+ if (last?.kind !== "anchor") return undefined;+ const items = b.items.filter((it): it is HwItem => it.kind === "hw" && it.step === last.n);+ b.items = b.items.filter((it) => !(it.kind === "hw" && it.step === last.n));+ for (const it of items) b.map.delete(it.key);+ b.steps.pop();+ return { def: last, items };+}++/**+ * Frames that aren't all alike, side by side (a wide BILLY and a narrow one, PAX frames of 100 and 50 cm),+ * or standing in a corner around an add-on corner unit. The commonest frame is built step by step exactly+ * as its own guide does; each of the others is built the same way off to the side, one step per size.+ * Then they're pushed together (screwed to each other through their sides when IKEA joins them),+ * sliding doors go across when there are any, and every frame is fixed to the wall last.+ */+export function buildUnits(b: PlanBuilder, s: ProductSpec, one: (b: PlanBuilder, s: ProductSpec) => void) {+ const row = s.row!;+ const units: RowUnit[] = row.units!;+ const W = s.size.w * 10, D = s.size.d * 10, H = s.size.h * 10;+ const join = !!row.join;+ const slide = row.slide;+ const of = row.of ?? (s.archetype === "shelf" ? "bookcase" : "cabinet");+ const [what, whats] = UNIT[of] ?? ["one", "others"];+ const { row: r0, cabinet: c0, shelf: s0, ...rest } = s;+ void r0;+ void c0;+ void s0;+ const specOf = (u: RowUnit): ProductSpec => ({+ ...rest,+ size: { w: u.w, h: s.size.h, d: u.d ?? (slide ? s.size.d - 8 : s.size.d) },+ ...(u.cabinet ? { cabinet: u.cabinet } : {}),+ ...(u.shelf ? { shelf: u.shelf } : {}),+ });+ const keyOf = (u: RowUnit) => JSON.stringify(specOf(u));++ // side by side from the left with their backs in line, unless the row says where each one stands+ let x0 = -W / 2;+ const places: Place[] = units.map((u) => {+ const uw = u.w * 10, ud = (u.d ?? (slide ? s.size.d - 8 : s.size.d)) * 10;+ if (u.at) return { pos: [u.at[0] * 10, 0, u.at[1] * 10], a: u.turn ? Math.PI / 2 : 0 };+ const p: Place = { pos: [x0 + uw / 2, 0, -D / 2 + ud / 2], a: 0 };+ x0 += uw;+ return p;+ });++ // the commonest frame first (the widest of those, when it's a tie), never the corner unit or one that is turned+ const groups = new Map<string, number[]>();+ units.forEach((u, i) => groups.set(keyOf(u), [...(groups.get(keyOf(u)) ?? []), i]));+ const first = [...groups.values()]+ .filter((g) => !units[g[0]].corner && !units[g[0]].turn)+ .sort((a, c) => c.length - a.length || units[c[0]].w - units[a[0]].w)[0][0];++ /* ---------- the first frame, step by step ---------- */+ one(b, specOf(units[first]));+ const firstAnchor = takeAnchor(b);+ const p0 = places[first];+ const ownParts = b.items.filter((it): it is PartItem => it.kind === "part");+ for (const it of ownParts) {+ const old = it.final.pos;+ it.final = { pos: at(p0, old), rot: turnY(it.final.rot, p0.a) };+ for (const st of it.states)+ if (st.scene === "main") {+ st.pos = st.pos === old ? it.final.pos : at(p0, st.pos);+ st.rot = turnY(st.rot, p0.a);+ }+ }+ for (const it of b.items) if (it.kind === "hw" && !it.parent && it.scene === "main") it.pos = at(p0, it.pos);+ const own: Built = {+ parts: ownParts,+ types: b.parts,+ fitted: b.items.filter((it): it is HwItem => it.kind === "hw" && !!it.parent),+ hw: b.hw,+ anchor: firstAnchor,+ weight: b.steps.reduce((sum, st) => sum + weightOf(b, st), 0),+ };+ // the first frame's parts now stand where it goes: in its own frame of reference for copying+ const ownLocal = new Map(own.parts.map((it) => [it.key, { pos: toLocal(it.final.pos, p0.pos, [0, p0.a, 0]), rot: turnY(it.final.rot, -p0.a) }]));++ /* ---------- every other size, built on its own to copy from ---------- */+ const builtFor = new Map<string, Built>();+ const builtOf = (u: RowUnit): Built => {+ const k = keyOf(u);+ if (k === keyOf(units[first])) return own;+ let got = builtFor.get(k);+ if (!got) {+ const sb = new PlanBuilder(specOf(u));+ one(sb, specOf(u));+ const anchor = takeAnchor(sb);+ got = {+ parts: sb.items.filter((it): it is PartItem => it.kind === "part"),+ types: sb.parts,+ fitted: sb.items.filter((it): it is HwItem => it.kind === "hw" && !!it.parent),+ hw: sb.hw,+ anchor,+ weight: sb.steps.reduce((sum, st) => sum + weightOf(sb, st), 0),+ };+ builtFor.set(k, got);+ }+ return got;+ };++ // parts of the same name, size and shape are one part, whichever frame they come from+ const typeKey = (p: PartType) => JSON.stringify([p.name, p.size, p.shape, p.material, p.extra ?? false, p.pieces ?? null]);+ const typeIds = new Map<string, string>();+ for (const p of b.parts) if (!typeIds.has(typeKey(p))) typeIds.set(typeKey(p), p.id);+ const typeFor = (p: PartType) => {+ const k = typeKey(p);+ let id = typeIds.get(k);+ if (!id) {+ id = b.part(p.name, p.size, { shape: p.shape, material: p.material, extra: p.extra });+ if (p.pieces) b.parts[b.parts.length - 1].pieces = p.pieces;+ typeIds.set(k, id);+ }+ return id;+ };++ /** Each frame's parts in the finished product, by the key of the part it copies. */+ const frameParts: Map<string, string>[] = units.map(() => new Map());+ own.parts.forEach((it) => frameParts[first].set(it.key, it.key));+ const added: string[][] = units.map(() => []);++ /** Places a copy of a frame where it stands, its fittings already in. */+ const copy = (i: number) => {+ const u = units[i], p = places[i];+ const src = builtOf(u);+ const local = (it: PartItem) => (src === own ? ownLocal.get(it.key)! : it.final);+ for (const it of src.parts) {+ const type = src.types.find((t) => t.id === it.ref)!;+ const l = local(it);+ const key = b.place(typeFor(type), at(p, l.pos), turnY(l.rot, p.a));+ b.partItem(key).holes = it.holes.map((h) => ({ p: [...h.p] as Vec3, n: [...h.n] as Vec3, r: h.r }));+ frameParts[i].set(it.key, key);+ added[i].push(key);+ }+ for (const h of src.fitted) {+ const ht = src.hw.get(h.ref)!;+ const key = frameParts[i].get(h.parent!);+ if (!key) continue;+ 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;+ }+ };++ /* ---------- the others, one step per size ---------- */+ const sized = [...new Set(units.filter((u) => !u.corner).map((u) => u.w))].sort((a, c) => a - c);+ const adj = (u: RowUnit) => (sized.length > 1 ? SIZE[Math.min(4, sized.length)][sized.indexOf(u.w)] + " " : "");+ // where each one waits while it is built: out to the side, or out into the room for a frame on the side wall+ const waitOff = (i: number): Vec3 => (units[i].turn || units[i].corner ? [0, 0, 320] : [(places[i].pos[0] - places[first].pos[0]) * 0.25 + 220, 0, 0]);+ const order = [...groups.values()].sort((g1, g2) => (g1.includes(first) ? -1 : g2.includes(first) ? 1 : 0));+ for (const g of order) {+ const others = g.filter((i) => i !== first);+ if (!others.length) continue;+ const u = units[others[0]];+ const k = others.length;+ let title: string, detail: string;+ if (u.corner) {+ title = "Build the corner unit";+ detail = `The same way as a ${what}, without a clothes rail. Its shelves go on pins.`;+ } else if (g.includes(first)) {+ title = k > 1 ? `Build ${COUNT[k]} more ${adj(u)}${whats} the same way` : `Build another ${adj(u)}${what} the same way`;+ detail = k > 1 ? "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.";+ } else {+ title = k > 1 ? `Build the ${COUNT[k]} ${adj(u)}${whats} the same way` : `Build the ${adj(u)}${what} the same way`;+ detail = `Every step as for the first one, ${u.w < units[first].w ? "just narrower" : "just wider"}.`;+ }+ b.step({ title, detail, kind: "general", people: s.people, weight: builtOf(u).weight * k * 0.85 }, () => {+ for (const i of others) {+ b.stagger(0);+ copy(i);+ const off = waitOff(i);+ for (const key of added[i]) {+ const f = b.partItem(key).final;+ b.stage(key, [f.pos[0] + off[0], f.pos[1] + off[1], f.pos[2] + off[2]], f.rot, [off[0] > 0 ? 520 : 0, 0, off[2] > 0 ? 520 : 0]);+ }+ b.wait(0.35);+ }+ });+ }++ /* ---------- pushed together ---------- */+ const partName = (key: string) => b.parts.find((p) => p.id === b.partItem(key).ref)?.name;+ const sidesOf = (i: number) => [...frameParts[i].values()].filter((key) => partName(key) === "Side panel");+ const extreme = (i: number, axis: 0 | 2, max: boolean) =>+ sidesOf(i).reduce<string | undefined>((a, key) => (!a || (max ? b.partItem(key).final.pos[axis] > b.partItem(a).final.pos[axis] : b.partItem(key).final.pos[axis] < b.partItem(a).final.pos[axis]) ? key : a), undefined);+ const corner = units.some((u) => u.turn || u.corner);+ 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 tOf = (key: string) => Math.min(...b.parts.find((p) => p.id === b.partItem(key).ref)!.size);+ const screws: FitOpts[] = [];+ if (join) {+ const backRun = units.map((u, i) => i).filter((i) => !units[i].turn && !units[i].corner).sort((a, c) => places[a].pos[0] - places[c].pos[0]);+ const sideRun = units.map((u, i) => i).filter((i) => units[i].turn && !units[i].corner).sort((a, c) => places[a].pos[2] - places[c].pos[2]);+ const depth = (i: number) => (units[i].d ?? s.size.d) * 10;+ for (let k = 0; k + 1 < backRun.length; k++) {+ const [l, r] = [backRun[k], backRun[k + 1]];+ const a = extreme(l, 0, true), c = extreme(r, 0, false);+ if (!a || !c) continue;+ const xj = places[l].pos[0] + (units[l].w * 10) / 2 - tOf(a);+ const zf = -D / 2 + Math.min(depth(l), depth(r)) - 60;+ for (const y of ys) screws.push({ on: a, at: [xj, y, zf], dir: [1, 0, 0], mate: c });+ }+ for (let k = 0; k + 1 < sideRun.length; k++) {+ const [l, r] = [sideRun[k], sideRun[k + 1]];+ const a = extreme(l, 2, true), c = extreme(r, 2, false);+ if (!a || !c) continue;+ const zj = places[l].pos[2] + (units[l].w * 10) / 2 - tOf(a);+ const xf = -W / 2 + Math.min(depth(l), depth(r)) - 60;+ for (const y of ys) screws.push({ on: a, at: [xf, y, zj], dir: [0, 0, 1], mate: c });+ }+ // the corner unit: screwed to the side of the first frame along the back wall, and to the first one on the side wall+ const cu = units.findIndex((u) => u.corner);+ if (cu >= 0) {+ const cz0 = places[cu].pos[2] - (units[cu].w * 10) / 2, cz1 = cz0 + units[cu].w * 10;+ const cx1 = -W / 2 + depth(cu);+ const b0 = backRun[0];+ const bl = b0 !== undefined ? extreme(b0, 0, false) : undefined;+ const zb1 = -D / 2 + (b0 !== undefined ? depth(b0) : 0);+ if (bl && zb1 - cz0 > 80) for (const y of ys) screws.push({ on: bl, at: [b.partItem(bl).final.pos[0] + tOf(bl) / 2, y, (cz0 + zb1) / 2], dir: [-1, 0, 0], hole: false });+ const s0 = sideRun[0];+ const cs = extreme(cu, 2, true), fs = s0 !== undefined ? extreme(s0, 2, false) : undefined;+ if (cs && fs) for (const y of ys) screws.push({ on: cs, at: [Math.min(cx1, -W / 2 + depth(s0)) - 60, y, cz1 - tOf(cs)], dir: [0, 0, 1], mate: fs });+ }+ }+ const glue = screws.length > 0;+ b.step(+ {+ title: corner ? (glue ? "Stand them in the corner and screw them together" : "Stand them in the corner") : glue ? "Push them together and screw them to each other" : "Push them together",+ detail: glue ? "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: glue ? ["screwdriver"] : [],+ people: 2,+ kind: "join",+ warnings: ["two"],+ weight: glue ? 1.2 + 0.4 * (units.length - 1) : 1,+ },+ () => {+ b.stagger(0);+ for (const list of added) for (const key of list) b.add(key);+ if (!glue) return;+ b.then(0.15);+ b.fits(HW.screwM, screws, 0.08);+ },+ );++ /* ---------- sliding doors across the whole row ---------- */+ if (slide) slidingDoors(b, { span: W, n: slide, topY: H, botY: 0, zFront: -D / 2 + (s.size.d - 8) * 10, front: true });++ /* ---------- every frame fixed to the wall ---------- */+ const fixings: { def: HwType; o: FitOpts }[] = [];+ units.forEach((u, i) => {+ const src = builtOf(u);+ if (!src.anchor) return;+ for (const h of src.anchor.items) {+ const ht = src.hw.get(h.ref)!;+ const def = { kind: ht.kind, len: ht.len, dia: ht.dia, notIncluded: ht.notIncluded };+ if (h.parent) {+ // fittings sit on their part, wherever the part now stands+ const key = frameParts[i].get(h.parent);+ if (!key) continue;+ const f = b.partItem(key).final;+ fixings.push({ def: def as HwType, o: { 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 {+ // the plugs and screws in the wall were placed where the frame stood when it was built+ fixings.push({ def: def as HwType, o: { at: at(places[i], h.pos), dir: ry(h.dir, places[i].a), travel: h.travel, spin: h.spin, twist: h.twist } });+ }+ }+ });+ const a = own.anchor ?? [...builtFor.values()].find((x) => x.anchor)?.anchor;+ if (a && fixings.length) {+ 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 f of fixings) b.fit({ kind: f.def.kind, len: f.def.len, dia: f.def.dia, notIncluded: f.def.notIncluded }, f.o);+ },+ );+ }+}diff --git a/src/lib/products.ts b/src/lib/products.tsindex 698e140..02c8477 100644--- a/src/lib/products.ts+++ b/src/lib/products.ts@@ -1,4 +1,4 @@-import type { Archetype, CornerCab, FitUse, FitZone, ProductSpec } from "./types";+import type { Archetype, CornerCab, FitUse, FitZone, ProductSpec, RowUnit } from "./types";/*** A wide offline index of real IKEA product names. Each row is a kind plus outer size (cm);@@ -62,7 +62,8 @@ export type Kind =| "lounge"| "highchair"// the last hard shapes: corners- | "cornercab";+ | "cornercab"+ | "cornerrobe";export type X = {rows?: number;@@ -96,7 +97,7 @@ export type X = {rail?: boolean;slides?: number;n?: number;- of?: "bookcase" | "cabinet" | "tv" | "wardrobe" | "wallcab";+ of?: "bookcase" | "cabinet" | "tv" | "wardrobe" | "wallcab" | "open";hinge?: boolean;use?: FitUse;z?: string;@@ -105,6 +106,9 @@ export type X = {uf?: number;ins?: number;blind?: number;+ u?: string;+ v?: string;+ cu?: number;inner?: "shelf" | "carousel" | "pullout";};@@ -279,7 +283,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, bookrow: 120, cabrow: 120, section: 25, gateleg: 50, washstand: 35, sinkcab: 45, appliance: 50, shoerack: 25, clothesrack: 20, changing: 50, divider: 20, backbench: 35, junior: 25, lounge: 30, highchair: 15, cornercab: 45,+ 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, section: 25, gateleg: 50, washstand: 35, sinkcab: 45, appliance: 50, shoerack: 25, clothesrack: 20, changing: 50, divider: 20, backbench: 35, junior: 25, lounge: 30, highchair: 15, cornercab: 45, cornerrobe: 150,};const CATEGORY: Record<Kind, string> = {@@ -288,7 +292,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", bookrow: "Bookcase combination", cabrow: "Storage combination", section: "Sofa section", gateleg: "Gateleg table", washstand: "Wash-stand", sinkcab: "Sink cabinet", appliance: "Appliance cabinet", shoerack: "Shoe rack", clothesrack: "Clothes rack", changing: "Changing table", divider: "Room divider", backbench: "Bench with backrest", junior: "Junior chair", lounge: "Lounge chair", highchair: "Highchair", cornercab: "Corner base cabinet",+ 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", section: "Sofa section", gateleg: "Gateleg table", washstand: "Wash-stand", sinkcab: "Sink cabinet", appliance: "Appliance cabinet", shoerack: "Shoe rack", clothesrack: "Clothes rack", changing: "Changing table", divider: "Room divider", backbench: "Bench with backrest", junior: "Junior chair", lounge: "Lounge chair", highchair: "Highchair", cornercab: "Corner base cabinet", cornerrobe: "Corner wardrobe",};export const KIND_ARCH: Record<Kind, Archetype> = {@@ -296,7 +300,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", mixed: "cabinet", sliding: "cabinet", slidecab: "cabinet", bookrow: "shelf", cabrow: "cabinet", section: "sofa", gateleg: "table", washstand: "cabinet", sinkcab: "cabinet", appliance: "cabinet", shoerack: "shelf", clothesrack: "shelf", changing: "drawers", divider: "shelf", backbench: "seat", junior: "seat", lounge: "seat", highchair: "seat", cornercab: "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", section: "sofa", gateleg: "table", washstand: "cabinet", sinkcab: "cabinet", appliance: "cabinet", shoerack: "shelf", clothesrack: "shelf", changing: "drawers", divider: "shelf", backbench: "seat", junior: "seat", lounge: "seat", highchair: "seat", cornercab: "cabinet", cornerrobe: "cabinet",};const round = (x: X) => (x.round ? { round: true } : {});@@ -307,6 +311,7 @@ const ROW_CATEGORY: Record<NonNullable<X["of"]>, string> = {tv: "TV bench combination",wardrobe: "Wardrobe combination",wallcab: "Wall cabinet combination",+ open: "Shelving combination",};const ZONE_KIND = { r: "drawers", d: "doors", f: "front", g: "gap", o: "open", a: "apron" } as const;@@ -533,6 +538,31 @@ export function specFor(kind: Kind, name: string, variant: string, w: number, h:const minutes = x.min ?? MIN.cornercab + (door ? 15 : 0) + (x.inner ? 15 : 0) + (x.rows ? 30 : 0) + 5 * (x.shelves ?? 0);return { ...base, category: hung ? "Corner wall cabinet" : CATEGORY.cornercab, minutes, people: w > 100 ? 2 : 1, difficulty: x.rows ? 3 : 2, cabinet: { doors: door ? 1 : 0, shelves: x.shelves ?? 0, rail: false, plinth: !hung, handles: x.knobs ?? "bar", thickness: 18, ...(hung ? { wall: true } : {}), corner } };}+ case "cornerrobe": {+ // an L of wardrobe frames: x.u along the back wall, ending at its far end, x.v along the left-hand wall, ending at its+ // front, and between them an add-on corner unit x.cu deep with its back to the left-hand wall (cm, "100+50")+ const fd = 58, cuw = 53, cud = x.cu ?? 35;+ const list = (s?: string) => (s ?? "").split("+").filter(Boolean).map(Number);+ const back = list(x.u), side = list(x.v);+ const sum = (l: number[]) => l.reduce((a, v) => a + v, 0);+ const frame = (fw: number) => specFor("wardrobe", name, variant, fw, h, fd, { doors: x.doors, shelves: x.shelves, knobs: x.knobs });+ const r1 = (n: number) => Math.round(n * 10) / 10;+ const units: RowUnit[] = [];+ let bx = -w / 2 + (w - sum(back));+ for (const fw of back) {+ units.push({ w: fw, d: fd, at: [r1(bx + fw / 2), r1(-d / 2 + fd / 2)], cabinet: frame(fw).cabinet });+ bx += fw;+ }+ let sz = d / 2 - sum(side);+ const corner = specFor("cabinet", name, variant, cuw, h, cud, { doors: 0, shelves: 4 });+ units.push({ w: cuw, d: cud, at: [r1(-w / 2 + cud / 2), r1(sz - cuw / 2)], turn: true, corner: true, cabinet: { ...corner.cabinet, plinth: true } });+ for (const fw of side) {+ units.push({ w: fw, d: fd, at: [r1(-w / 2 + fd / 2), r1(sz + fw / 2)], turn: true, cabinet: frame(fw).cabinet });+ sz += fw;+ }+ const minutes = x.min ?? [...back, ...side].reduce((a, fw) => a + frame(fw).minutes, 0) + 50;+ return { ...frame(back[0] ?? 100), category: CATEGORY.cornerrobe, size: { w, h, d }, minutes, people: 2, difficulty: 3, row: { n: units.length, of: "wardrobe", join: true, units } };+ }case "bookrow":case "cabrow": {// x.n units of kind x.of side by side, each drawn as its own guide would draw it@@ -544,6 +574,18 @@ export function specFor(kind: Kind, name: string, variant: string, w: number, h:// with x.slides, a pair of sliding doors runs in front of all the frames, which have no doors of their ownconst slide = x.slides ? { slide: x.slides } : {};if (x.slides) Object.assign(inner, { doors: 0, slides: undefined });+ if (x.u) {+ // frames that aren't all alike, x.u wide from the left ("80+40" cm); IVAR's sections share a post, so the row+ // can be a little narrower than its frames added up, and each frame gives up its share+ delete inner.u;+ const ws = x.u.split("+").map(Number);+ const scale = w / ws.reduce((a, v) => a + v, 0);+ const each = ws.map((uw) => specFor(of, name, variant, Math.round(uw * scale * 10) / 10, h, x.slides ? d - 8 : d, inner));+ const units = each.map((o) => ({ w: o.size.w, ...(o.cabinet ? { cabinet: o.cabinet } : {}), ...(o.shelf ? { shelf: o.shelf } : {}) }));+ const category = x.slides ? CATEGORY.sliding : ROW_CATEGORY[of];+ const minutes = x.min ?? each.reduce((a, o) => a + o.minutes, 0) + 15 + (x.slides ? 40 : 0);+ return { ...each[0], category, size: { w, h, d }, minutes, people: 2, row: { n: ws.length, of, join: of !== "bookcase" && of !== "open", ...slide, units } };+ }const one = specFor(of, name, variant, Math.round((w / n) * 10) / 10, h, x.slides ? d - 8 : d, inner);const category = x.slides ? CATEGORY.sliding : ROW_CATEGORY[of];return { ...one, category, size: { w, h, d }, minutes: x.min ?? one.minutes * n + 15 + (x.slides ? 40 : 0), people: 2, row: { n, of, join: of !== "bookcase", ...slide } };@@ -578,5 +620,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], bookrow: [160, 202, 28], cabrow: [240, 48, 42], section: [192, 83, 92], gateleg: [151, 75, 90], washstand: [60, 83, 47], sinkcab: [60, 80, 60], appliance: [60, 200, 60], shoerack: [80, 40, 32], clothesrack: [100, 160, 46], changing: [80, 100, 55], divider: [150, 170, 25], backbench: [120, 86, 60], junior: [43, 91, 52], lounge: [72, 88, 80], highchair: [58, 90, 62], cornercab: [88, 80, 88],+ 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], section: [192, 83, 92], gateleg: [151, 75, 90], washstand: [60, 83, 47], sinkcab: [60, 80, 60], appliance: [60, 200, 60], shoerack: [80, 40, 32], clothesrack: [100, 160, 46], changing: [80, 100, 55], divider: [150, 170, 25], backbench: [120, 86, 60], junior: [43, 91, 52], lounge: [72, 88, 80], highchair: [58, 90, 62], cornercab: [88, 80, 88], cornerrobe: [161, 201, 111],};diff --git a/src/lib/search.ts b/src/lib/search.tsindex 601ff27..a6c5a38 100644--- a/src/lib/search.ts+++ b/src/lib/search.ts@@ -21,6 +21,7 @@ const CATEGORY_WORDS: [Kind, string[]][] = [["washstand", ["wash stand", "washstand", "vanity", "vanity unit", "bathroom vanity", "basin unit", "basin cabinet", "wash basin cabinet", "washbasin cabinet", "bathroom cabinet", "sink vanity"]],["sinkcab", ["sink cabinet", "sink base", "sink base cabinet", "sink unit", "kitchen sink cabinet", "under sink cabinet", "cabinet for sink", "sink cupboard"]],["appliance", ["appliance cabinet", "oven cabinet", "oven housing", "oven unit", "tall oven unit", "wall oven cabinet", "cabinet for oven", "fridge cabinet", "fridge housing", "refrigerator cabinet", "freezer cabinet", "cabinet for fridge", "microwave cabinet", "hob cabinet", "hob unit", "cooktop cabinet", "hood cabinet", "extractor hood cabinet"]],+ ["cornerrobe", ["corner wardrobe", "corner closet", "corner armoire", "l shaped wardrobe", "l shaped closet", "corner wardrobe unit"]],["cornercab", ["corner cabinet", "corner base cabinet", "corner wall cabinet", "corner cupboard", "corner base unit", "corner wall unit", "corner kitchen cabinet", "corner kitchen unit", "blind corner", "blind corner cabinet", "lazy susan", "lazy susan cabinet", "carousel unit", "carousel cabinet"]],["divider", ["room divider", "room dividers", "folding screen", "privacy screen", "partition screen", "room screen"]],["changing", ["changing table", "changing unit", "baby changing table", "changing station", "diaper changing table", "nappy changing table"]],@@ -71,7 +72,7 @@ const CATEGORY_WORDS: [Kind, string[]][] = [];const KIND_WORDS = new Map(CATEGORY_WORDS);// rows, sections, and kinds drawn later than a family's other pieces, which only come first when asked for-const LESSER = new Set<Kind>(["bookrow", "cabrow", "section", "sinkcab", "appliance", "washstand", "shoerack", "clothesrack", "changing", "divider", "backbench", "junior", "lounge", "highchair", "cornercab"]);+const LESSER = new Set<Kind>(["bookrow", "cabrow", "section", "sinkcab", "appliance", "washstand", "shoerack", "clothesrack", "changing", "divider", "backbench", "junior", "lounge", "highchair", "cornercab", "cornerrobe"]);export function kindOf(q: string): Kind | null {const f = " " + fold(q) + " ";diff --git a/src/lib/types.ts b/src/lib/types.tsindex 6811ee2..22e8573 100644--- a/src/lib/types.ts+++ b/src/lib/types.ts@@ -201,7 +201,18 @@ export interface ProductSpec {slug?: string;variants?: { label: string; slug: string }[];siblings?: { label: string; slug: string }[];- row?: { n: number; join?: boolean; of?: string; slide?: number }; // several identical units side by side, built one after another, with sliding doors across them all+ row?: { n: number; join?: boolean; of?: string; slide?: number; units?: RowUnit[] }; // several identical units side by side, built one after another, with sliding doors across them all+}++/** One frame of a row whose frames aren't all alike, or of a corner: its own size and parameters, and where it stands. */+export interface RowUnit {+ w: number; // cm+ d?: number; // cm, when it isn't as deep as the row+ at?: [number, number]; // cm, the middle of its footprint (x, z); otherwise side by side from the left, backs in line+ turn?: boolean; // stands with its back to the left-hand wall+ corner?: boolean; // the add-on unit that fills the corner+ cabinet?: Partial<CabinetParams>;+ shelf?: Partial<ShelfParams>;}/* ---------- generated plan ---------- */