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 drawer units and cabinets on castors

Youssef1a5d3c3880a2
diff --git a/scripts/ikea/classify.ts b/scripts/ikea/classify.ts
index 5cecf5b..19ded23 100644
--- a/scripts/ikea/classify.ts
+++ b/scripts/ikea/classify.ts
@@ -157,6 +157,7 @@ const CORNER_WH: Record<string, number> = { KNOXHULT: 61 };
/** Pieces IKEA gives no size for, by type: typical ones (w, h, d). */
const TYPICAL: Record<string, [number, number, number]> = {
"trolley table with storage": [50, 52, 50],
+ "drawer unit w 3 drawers on castors": [42, 61, 51],
};
/** Boxes with a lid IKEA gives no size for, or only part of one (w, h, d): typical ones of each kind. */
const LIDBOX_SIZE: Record<string, [number, number, number]> = {
@@ -415,6 +416,11 @@ const RULES: Rule[] = [
[/^three-seat sofa$/, () => ({ kind: "sofa", x: { seats: 3 } })],
[/^(modular )?chest of (\d+) drawers$/, (m) => ({ kind: "chest", x: { rows: Number(m[2]) } })],
[/^(drawer unit|drawer unit on castors|chest of drawers|dresser)$/, () => ({ kind: "chest" })],
+ // drawer units, cabinets and open storage on castors (castors drawn on the ones that say so in their name)
+ [/^drawer unit w(?:ith)? (\d+) drawers( on castors)?$/, (m) => ({ kind: "chest", x: { rows: Number(m[1]), ...(m[2] ? { cast: true } : {}) } })],
+ [/^cabinet on castors$/, () => ({ kind: "cabinet", x: { cast: true, cat: "Cabinet on castors" } })],
+ [/^storage unit on castors$/, (_m, c) => ({ kind: "cabinet", x: { doors: 0, shelves: (c.sz.n[1] ?? 60) > 80 ? 2 : 1, cast: true, cat: "Storage unit on castors" } })],
+ [/^cabinet with drawers$/, () => ({ kind: "chest", x: { rows: 4 } })],
[/^(bedside table|nightstand|bedside table with (\d) drawers?)$/, (m) => ({ kind: "nightstand", x: m[2] ? { rows: Number(m[2]) } : {} })],
[/^(wardrobe frame|open wardrobe|open clothes hanging unit)$/, () => ({ kind: "wardrobe", x: { doors: 0 } })],
// PLATSA wardrobes are a row of identical frames: one or two doors on each, as many frames as that takes
@@ -504,7 +510,8 @@ const RULES: Rule[] = [
/** Drawers in one or two columns, each between 7 and 42 cm tall (taller means open sections we can't show). */
function chestShape(total: number, w: number, h: number): { rows: number; cols: 1 | 2 } | null {
- const ok = (rows: number) => rows <= 6 && h / rows >= 7 && h / rows <= 42;
+ // a narrow drawer unit can hold up to ten shallow drawers (ALEX)
+ const ok = (rows: number) => (rows <= 6 || (rows <= 10 && w <= 50)) && h / rows >= 7 && h / rows <= 42;
if (total % 2 === 0 && w >= 100 && ok(total / 2)) return { rows: total / 2, cols: 2 };
return ok(total) ? { rows: total, cols: 1 } : null;
}
@@ -571,6 +578,7 @@ export function classify(f: Fact, hints: Hints): Verdict {
} else if (v.length === 1) return { skip: "upright piece with one size" };
else if (hint?.kind === kind) set(hint.w, hint.h, hint.d);
else if (kind === "clothesrack" && RACK_SIZE[family]) set(...RACK_SIZE[family]);
+ else if (TYPICAL[t]) [w, h, d] = TYPICAL[t];
else return { skip: "no size given" };
if (kind === "clothesrack" && h < 100) return { skip: "clothes rack measured in a way we can't read" };
// a mini chest measured from the front only is a small, shallow box
diff --git a/scripts/ikea/slugs.json b/scripts/ikea/slugs.json
index 1eb2292..21fdd20 100644
--- a/scripts/ikea/slugs.json
+++ b/scripts/ikea/slugs.json
@@ -8,6 +8,7 @@
"ALEX|Drawer unit on castors, 36 × 50 cm": "alex-drawer-unit-on-castors-36-x-50",
"ALEX|Drawer unit on castors, 36 × 76 cm": "alex-drawer-unit-on-castors-36-x-76",
"ALEX|Drawer unit on castors, 67 × 66 cm": "alex-drawer-unit-on-castors-67-x-66",
+ "ALEX|Drawer unit with 9 drawers, 36 × 116 cm": "alex-drawer-unit-9-drawers-36-x-116",
"ALEX|Storage unit, 36 × 70 cm": "alex-storage-unit-36-x-70",
"ÄLGANÄS|Clothes rack with shoe storage, 46 × 39 × 166 cm": "alganas-clothes-rack-shoe-storage-46-x-39-x-166",
"ÄLGANÄS|Shoe rack, 76 × 24 × 59 cm": "alganas-shoe-rack-76-x-24-x-59",
@@ -56,6 +57,7 @@
"BÅRSLÖV|3-seat sofa-bed": "barslov-3-seat-sofa-bed",
"BÅRSLÖV|3-seat sofa-bed with chaise longue": "barslov-3-seat-sofa-bed-chaise-longue",
"BÄSTBOLL|Gaming chair": "bastboll-gaming-chair",
+ "BEKANT|Storage unit on castors, 41 × 101 cm": "bekant-storage-unit-on-castors-41-x-101",
"BEKVÄM|Kitchen trolley, 58 × 50 cm": "bekvam-kitchen-trolley-58-x-50",
"BEKVÄM|Step stool, 63 cm": "bekvam-step-stool-63",
"BERGSHYTTAN|Bench, 210 × 38 cm": "bergshyttan-bench-210-x-38",
@@ -281,6 +283,7 @@
"FRYKSÅS|Armchair with cushion": "fryksas-armchair-cushion",
"FRYKSÅS|Cabinet, 81 × 124 cm": "fryksas-cabinet-81-x-124",
"FRYKSÅS|Desk, 110 × 54 cm": "fryksas-desk-110-x-54",
+ "FRYKSÅS|Storage unit on castors, 37 × 53 cm": "fryksas-storage-unit-on-castors-37-x-53",
"FRYKSÅS|TV bench, 157 × 41 × 49 cm": "fryksas-tv-bench-157-x-41-x-49",
"GALANT|Cabinet with doors, 80 × 120 cm": "galant-cabinet-doors-80-x-120",
"GALANT|Cabinet with sliding doors, 160 × 120 cm": "galant-cabinet-sliding-doors-160-x-120",
@@ -304,6 +307,7 @@
"GRÅFJÄLLET|Dressing table, 100 × 42 cm": "grafjallet-dressing-table-100-x-42",
"GRÅFJÄLLET|Room divider, 150 × 175 cm": "grafjallet-room-divider-150-x-175",
"GRÅFJÄLLET|Wall-mounted bedside table, 42 × 29 × 31 cm": "grafjallet-wall-mounted-bedside-table-42-x-29-x",
+ "GREÅKER|Cabinet with drawers, 84 × 101 cm": "greaker-cabinet-drawers-84-x-101",
"GREJSIMOJS|Children's stool": "grejsimojs-children-s-stool",
"GREJSIMOJS|Children's table, 84 × 42 cm": "grejsimojs-children-s-table-84-x-42",
"GREJSIMOJS|Pouffe with storage": "grejsimojs-pouffe-storage",
@@ -881,6 +885,7 @@
"MYLLRA|Changing table with drawers, 85 × 79 × 97 cm": "myllra-changing-table-drawers-85-x-79-x-97",
"MYLLRA|Cot with drawer, 70 × 140 cm": "myllra-cot-drawer-70-x-140",
"NACKANÄS|Table, 140 × 76 cm": "nackanas-table-140-x-76",
+ "NÅLMAKARE|Cabinet on castors, 79 × 44 × 88 cm": "nalmakare-cabinet-on-castors-79-x-44-x-88",
"NÄMMARÖ|2-seat sofa, 126 cm": "nammaro-2-seat-sofa-126",
"NÄMMARÖ|2-seat sofa, 147 cm": "nammaro-2-seat-sofa-147",
"NÄMMARÖ|3-seat sofa, 264 cm": "nammaro-3-seat-sofa-264",
@@ -1392,6 +1397,7 @@
"TROTTEN|Cabinet with sliding doors, 80 × 55 × 75 cm": "trotten-cabinet-sliding-doors-80-x-55-x-75",
"TROTTEN|Desk sit/stand, 160 × 80 cm": "trotten-desk-sit-stand-160-x-80",
"TROTTEN|Desk, 160 × 80 cm": "trotten-desk-160-x-80",
+ "TROTTEN|Drawer unit w 3 drawers on castors": "trotten-drawer-unit-w-3-drawers-on-castors",
"TROTTEN|Drawer unit, 34 × 56 cm": "trotten-drawer-unit-34-x-56",
"TUFFING|Bunk bed frame, 90 × 200 cm": "tuffing-bunk-bed-frame-90-x-200",
"TUFFING|Loft bed frame, 90 × 200 cm": "tuffing-loft-bed-frame-90-x-200",
diff --git a/src/data/ikea-guard.ts b/src/data/ikea-guard.ts
index ac86e93..acb4140 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 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 larkar latsas lersta lill lilla lillabo lillhult lindasen lohals lova 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 ladmakare larkar latsas lersta lill lilla lillabo lillhult lindasen lohals lova 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.ts
index d283864..2a245fd 100644
--- a/src/data/ikea-items.ts
+++ b/src/data/ikea-items.ts
@@ -7,6 +7,7 @@ alefjall-office-chair|90320224 00419984
alex-desk-100-x-48|10473555 50473558 40588885
alex-desk-132-x-58|80483438 60473529 80588888
alex-drawer-unit|00473546 80473547 60588894
+alex-drawer-unit-9-drawers-36-x-116|90486139
alex-drawer-unit-on-castors-36-x-50|09582664 59582671 59582666
alex-drawer-unit-on-castors-36-x-76|59422220 69582680 39422221 29628029
alex-drawer-unit-on-castors-67-x-66|80485423 50473544 20588891
@@ -59,6 +60,7 @@ baggebo-sideboard-78-x-92|40553616
barslov-3-seat-sofa-bed|90541584 40541591
barslov-3-seat-sofa-bed-chaise-longue|30541596 10541578
bastboll-gaming-chair|50586254
+bekant-storage-unit-on-castors-41-x-101|20591370 60591373
bekvam-kitchen-trolley-58-x-50|70240351
bekvam-step-stool|70569545 10225589 40178888 40463852
bekvam-step-stool-63|90190411 90219829
@@ -305,6 +307,7 @@ fryksas-armchair|80540033
fryksas-armchair-cushion|09563156
fryksas-cabinet-81-x-124|40574096
fryksas-desk-110-x-54|60574104
+fryksas-storage-unit-on-castors-37-x-53|90574174
fryksas-tv-bench-157-x-41-x-49|80574099
galant-cabinet-doors-80-x-120|10365141 50365139
galant-cabinet-sliding-doors-160-x-120|30365135 20365131
@@ -329,6 +332,7 @@ grafjallet-clothes-rack-shoe-storage-90-x-36-x-1|00570222
grafjallet-dressing-table-100-x-42|30570225
grafjallet-room-divider-150-x-175|10570226
grafjallet-wall-mounted-bedside-table-42-x-29-x|00603114
+greaker-cabinet-drawers-84-x-101|50501071
grejsimojs-children-s-stool|60598973 50598959
grejsimojs-children-s-table-84-x-42|70598963
grejsimojs-pouffe-storage|60603644
@@ -951,6 +955,7 @@ mydal-bunk-bed-frame-90-x-200|20467629 00102452
myllra-changing-table-drawers-85-x-79-x-97|40595744
myllra-cot-drawer-70-x-140|80597048 60483590
nackanas-table-140-x-76|40511056
+nalmakare-cabinet-on-castors-79-x-44-x-88|80595761
nammaro-2-seat-sofa-126|59610240 39611170 19579307 49607511 09621509 09575423
nammaro-2-seat-sofa-147|99579308 59611174 89610248 09607513 69621511 19575427
nammaro-3-seat-sofa-264|79649114 59576024 39579311 19610440 09649688 09643605
@@ -1481,6 +1486,7 @@ trotten-desk-120-x-70|49621885 09621873 59621917 19621919
trotten-desk-160-x-80|79621921
trotten-desk-sit-stand-160-x-80|59621899
trotten-drawer-unit-34-x-56|20474762 40474841
+trotten-drawer-unit-w-3-drawers-on-castors|70485094 80485098 10619671
tuffing-bunk-bed-frame-90-x-200|00239233
tuffing-loft-bed-frame-90-x-200|90299449
tufjord-upholstered-bed-frame-standard-king-150|29555358 69555356 19555330 99555331 89555317 69555318 49555357
diff --git a/src/data/ikea-rows.ts b/src/data/ikea-rows.ts
index a08e010..d41be9b 100644
--- a/src/data/ikea-rows.ts
+++ b/src/data/ikea-rows.ts
@@ -6,6 +6,7 @@ AGEN|chair|Chair|44|88|50
ALEFJÄLL|office|Office chair|64|105|64|arms=slim
ALEX|chest|Drawer unit on castors, 36 × 50 cm|36|50|58|rows=4,knobs=none
ALEX|chest|Drawer unit on castors, 36 × 76 cm|36|76|58|rows=5,knobs=none
+ALEX|chest|Drawer unit with 9 drawers, 36 × 116 cm|36|116|58|rows=9,knobs=none
ALEX|chest|Drawer unit on castors, 67 × 66 cm|67|66|58|rows=5,knobs=none
ALEX|desk|Desk, 100 × 48 cm|100|74|48
ALEX|desk|Desk, 132 × 58 cm|132|74|58
@@ -57,6 +58,7 @@ BAGGEBO|sideboard|Sideboard, 78 × 92 cm|78|92|45
BÅRSLÖV|chaise|3-seat sofa-bed with chaise longue|226|85|160|seats=3,arms=wide,chaise=right,sd=92
BÅRSLÖV|sofa|3-seat sofa-bed|230|85|92|seats=3
BÄSTBOLL|office|Gaming chair|64|128|64|arms=slim,seatH=50
+BEKANT|cabinet|Storage unit on castors, 41 × 101 cm|41|101|40|doors=0,shelves=2,cat=Storage unit on castors,cast=1
BEKVÄM|stool|Step stool, 63 cm|35|63|35
BEKVÄM|trolley|Kitchen trolley, 58 × 50 cm|58|80|50
BERGSHYTTAN|bench|Bench, 210 × 38 cm|210|45|38
@@ -280,6 +282,7 @@ FRÖTORP|coffee|Coffee table, 88 cm|88|45|88|round=1
FRÖTORP|side|Side table, 48 cm|48|50|48|round=1
FRYKSÅS|armchair|Armchair|75|90|80
FRYKSÅS|armchair|Armchair with cushion|75|90|80
+FRYKSÅS|cabinet|Storage unit on castors, 37 × 53 cm|37|53|40|doors=0,shelves=1,cat=Storage unit on castors,cast=1
FRYKSÅS|cabinet|Cabinet, 81 × 124 cm|81|124|40
FRYKSÅS|desk|Desk, 110 × 54 cm|110|74|54
FRYKSÅS|tv|TV bench, 157 × 41 × 49 cm|157|49|41
@@ -305,6 +308,7 @@ GRÅFJÄLLET|desk|Dressing table, 100 × 42 cm|100|74|42
GRÅFJÄLLET|divider|Room divider, 150 × 175 cm|150|175|25
GRÅFJÄLLET|nightstand|Bedside table, 45 × 36 × 59 cm|45|59|36|rows=1
GRÅFJÄLLET|wallshelf|Wall-mounted bedside table, 42 × 29 × 31 cm|42|31|29
+GREÅKER|chest|Cabinet with drawers, 84 × 101 cm|84|101|48|rows=4
GREJSIMOJS|kidstable|Children's table, 84 × 42 cm|84|48|42||kids
GREJSIMOJS|lidbox|Pouffe with storage|38|38|38|cat=Pouffe with storage
GREJSIMOJS|stool|Children's stool|35|30|35||kids
@@ -882,6 +886,7 @@ MYDAL|bunk|Bunk bed frame, 90 × 200 cm|211|160|100|m=90
MYLLRA|changing|Changing table with drawers, 85 × 79 × 97 cm|85|97|79|rows=3|kids children
MYLLRA|cot|Cot with drawer, 70 × 140 cm|150|86|78|m=70,l=140,drawer=1
NACKANÄS|dining|Table, 140 × 76 cm|140|74|76
+NÅLMAKARE|cabinet|Cabinet on castors, 79 × 44 × 88 cm|79|88|44|cat=Cabinet on castors,cast=1
NÄMMARÖ|backbench|Bench with backrest, outdoor|120|86|60||outdoor garden
NÄMMARÖ|bar|Bar table, outdoor, 120 × 40 cm|120|105|40||outdoor garden
NÄMMARÖ|bench|Bench, outdoor, 120 cm|120|45|38||outdoor garden
@@ -1389,6 +1394,7 @@ TROFAST|wallshelf|Wall storage, 99 × 30 cm|99|30|22||kids children
TROTTEN|cabinet|Cabinet with doors, 70 × 35 × 110 cm|70|110|35
TROTTEN|cabinet|Cabinet with doors, 70 × 35 × 173 cm|70|173|35
TROTTEN|chest|Drawer unit, 34 × 56 cm|34|56|48|rows=4
+TROTTEN|chest|Drawer unit w 3 drawers on castors|42|61|51|rows=3,cast=1
TROTTEN|desk|Desk sit/stand, 160 × 80 cm|160|75|80|legs=square,attach=apron
TROTTEN|desk|Desk, 160 × 80 cm|160|75|80|legs=square,attach=apron
TROTTEN|slidecab|Cabinet with sliding doors, 80 × 55 × 75 cm|80|75|55|slides=2
diff --git a/src/lib/plan/cabinet.ts b/src/lib/plan/cabinet.ts
index 8f601d6..af8de68 100644
--- a/src/lib/plan/cabinet.ts
+++ b/src/lib/plan/cabinet.ts
@@ -7,6 +7,7 @@ import { buildMixed } from "./mixed";
import { buildSliding } from "./sliding";
import { buildCornerCabinet } from "./cornercab";
import { buildLidBox } from "./lidbox";
+import { CASTOR_H, castorStep, liftOntoCastors } from "./castors";
export function defaultsCabinet(s: ProductSpec): CabinetParams {
const p = s.cabinet ?? {};
@@ -31,10 +32,12 @@ export function buildCabinet(b: PlanBuilder, s: ProductSpec) {
if (s.cabinet?.fronts === "sliding") return buildSliding(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;
+ // on castors: the carcass is built on the floor, then lifted onto them
+ const ch = s.cabinet?.castors ? CASTOR_H : 0;
+ const W = s.size.w * 10, H = s.size.h * 10 - ch, D = s.size.d * 10;
const t = p.thickness;
const wall = !!s.cabinet?.wall;
- if (wall) p.plinth = false;
+ if (wall || ch) p.plinth = false;
const base = p.plinth ? 70 : 0;
const lying = H > 1100;
const f = new FrameKit(b, {
@@ -52,6 +55,7 @@ export function buildCabinet(b: PlanBuilder, s: ProductSpec) {
f.cams();
f.plinthStep();
f.backSteps();
+ if (ch) castorStep(b, { bottom: f.bottom, W, D, y: base, big: H > 1000 });
f.standUp();
// shelves sit lower when there is a rail
@@ -170,7 +174,9 @@ export function buildCabinet(b: PlanBuilder, s: ProductSpec) {
}
}
- if (wall) f.hang();
+ // a cabinet on castors rolls about: nothing to fix to the wall
+ if (ch) liftOntoCastors(b);
+ else if (wall) f.hang();
else if (H >= 800) f.anchor();
}
diff --git a/src/lib/plan/castors.ts b/src/lib/plan/castors.ts
new file mode 100644
index 0000000..326bd55
--- /dev/null
+++ b/src/lib/plan/castors.ts
@@ -0,0 +1,40 @@
+import type { Vec3 } from "../types";
+import { HW, PlanBuilder, type FitOpts } from "./builder";
+
+/** How far castors lift whatever stands on them, in mm. */
+export const CASTOR_H = HW.castor.len;
+
+/**
+ * Castors under the bottom panel of a carcass that lies on its front: turned upside down, one castor pushed into each
+ * corner. The carcass is built with its bottom at zero; liftOntoCastors raises it onto them once every step is in.
+ */
+export function castorStep(b: PlanBuilder, o: { bottom: string; W: number; D: number; y: number; big?: boolean }) {
+ const xs = [-o.W / 2 + 50, o.W / 2 - 50], zs = [-o.D / 2 + 50, o.D / 2 - 50];
+ b.step(
+ {
+ title: "Fit a castor under each corner",
+ detail: "Turn it upside down on the flattened box. Push each castor into its hole until it clicks.",
+ pose: "-y",
+ kind: "legs",
+ people: o.big ? 2 : 1,
+ warnings: o.big ? ["two", "floor"] : ["floor"],
+ },
+ () => {
+ const list: FitOpts[] = [];
+ for (const x of xs) for (const z of zs) list.push({ on: o.bottom, at: [x, o.y, z] as Vec3, dir: [0, 1, 0] as Vec3, travel: 70, hole: false });
+ b.fits(HW.castor, list, 0.12);
+ },
+ );
+}
+
+/** Raises everything built in the main scene by the castors' height, so it stands on them. */
+export function liftOntoCastors(b: PlanBuilder) {
+ const U = CASTOR_H;
+ for (const it of b.items) {
+ if (it.kind === "part") {
+ const old = it.final.pos;
+ it.final = { pos: [old[0], old[1] + U, old[2]], rot: it.final.rot };
+ for (const st of it.states) if (st.scene === "main") st.pos = st.pos === old ? it.final.pos : [st.pos[0], st.pos[1] + U, st.pos[2]];
+ } else if (!it.parent && it.scene === "main") it.pos = [it.pos[0], it.pos[1] + U, it.pos[2]];
+ }
+}
diff --git a/src/lib/plan/drawers.ts b/src/lib/plan/drawers.ts
index ef66775..bacc563 100644
--- a/src/lib/plan/drawers.ts
+++ b/src/lib/plan/drawers.ts
@@ -3,12 +3,13 @@ import { HW, PlanBuilder, type FitOpts } from "./builder";
import { FrameKit } from "./frame";
import { clamp } from "./math";
import { buildChanging } from "./changing";
+import { CASTOR_H, castorStep, liftOntoCastors } from "./castors";
export function defaultsDrawers(s: ProductSpec): DrawersParams {
const p = s.drawers ?? {};
return {
cols: p.cols === 2 ? 2 : 1,
- rows: clamp(Math.round(p.rows ?? 3), 1, 6),
+ rows: clamp(Math.round(p.rows ?? 3), 1, 10),
knobs: p.knobs ?? "none",
plinth: p.plinth ?? false,
thickness: clamp(p.thickness ?? 16, 12, 24),
@@ -18,7 +19,9 @@ export function defaultsDrawers(s: ProductSpec): DrawersParams {
export function buildDrawers(b: PlanBuilder, s: ProductSpec) {
if (s.drawers?.changing) return buildChanging(b, s, buildDrawers);
const p = defaultsDrawers(s);
- const W = s.size.w * 10, H = s.size.h * 10, D = s.size.d * 10;
+ // on castors: the carcass is built on the floor, then lifted onto them
+ const ch = s.drawers?.castors ? CASTOR_H : 0;
+ const W = s.size.w * 10, H = s.size.h * 10 - ch, D = s.size.d * 10;
const t = p.thickness;
const base = p.plinth ? 70 : 0;
const f = new FrameKit(b, { W, H, D, t, base, plinth: p.plinth, fixed: [], back: true, pinRows: false, lying: false });
@@ -136,6 +139,7 @@ export function buildDrawers(b: PlanBuilder, s: ProductSpec) {
f.cams();
f.plinthStep();
f.backSteps();
+ if (ch) castorStep(b, { bottom: f.bottom, W, D, y: base, big: H > 1000 });
f.standUp();
// build the first drawer in its own scene, front face down
@@ -269,6 +273,8 @@ export function buildDrawers(b: PlanBuilder, s: ProductSpec) {
);
}
+ // a drawer unit on castors rolls about: nothing to fix to the wall
+ if (ch) return liftOntoCastors(b);
f.anchor(f.top, H);
const last = b.steps[b.steps.length - 1];
last.detail = "Chests of drawers can tip over if they're not fixed. Wall screws aren't included: pick ones made for your wall.";
diff --git a/src/lib/products.ts b/src/lib/products.ts
index c067bd2..ef5f1cf 100644
--- a/src/lib/products.ts
+++ b/src/lib/products.ts
@@ -476,8 +476,11 @@ function specOf(kind: Kind, name: string, variant: string, w: number, h: number,
// an open rack: a fixed shelf in the middle, and one more on pins when it's tall enough for three rows of shoes
return { ...base, difficulty: 1, people: 1, shelf: { style: "bookcase", shelves: x.shelves ?? (h >= 55 ? 1 : 0), fixedShelf: true, back: false, plinth: false, outer: 18 } };
case "chest":
- case "nightstand":
- return { ...base, minutes: x.min ?? (kind === "nightstand" ? 30 + 15 * (x.rows ?? 2) : 30 + 20 * (x.rows ?? 3) * (x.cols ?? 1)), drawers: { cols: x.cols ?? 1, rows: x.rows ?? (kind === "nightstand" ? 2 : 3), knobs: x.knobs ?? "knob", plinth: x.plinth ?? false, thickness: 16 } };
+ case "nightstand": {
+ // x.cast: a drawer unit on castors
+ const cast = x.cast ? { castors: true } : {};
+ return { ...base, minutes: x.min ?? (kind === "nightstand" ? 30 + 15 * (x.rows ?? 2) : 30 + 20 * (x.rows ?? 3) * (x.cols ?? 1)) + (x.cast ? 5 : 0), drawers: { cols: x.cols ?? 1, rows: x.rows ?? (kind === "nightstand" ? 2 : 3), knobs: x.knobs ?? "knob", plinth: x.plinth ?? false, thickness: 16, ...cast } };
+ }
case "desk":
return { ...base, table: { attach: x.attach ?? "plate", legs: x.legs ?? "round", legSize: x.legs === "square" ? 45 : 34, topThickness: 28, shelf: false } };
case "coffee":
@@ -491,6 +494,8 @@ function specOf(kind: Kind, name: string, variant: string, w: number, h: number,
case "wardrobe":
return { ...base, people: 2, cabinet: { doors: x.doors ?? (w >= 60 ? 2 : 1), shelves: x.shelves ?? 1, rail: true, plinth: true, handles: x.knobs ?? "knob", thickness: 18 } };
case "cabinet":
+ // x.cast: on castors, so no plinth
+ if (x.cast) return { ...base, minutes: x.min ?? MIN.cabinet + 5, cabinet: { doors: x.doors ?? (w > 50 ? 2 : 1), shelves: x.shelves ?? (h > 100 ? 2 : 1), rail: false, plinth: false, handles: x.knobs ?? "knob", thickness: 18, castors: true } };
return { ...base, cabinet: { doors: x.doors ?? (w > 50 ? 2 : 1), shelves: x.shelves ?? (h > 100 ? 2 : 1), rail: false, plinth: h > 100, handles: x.knobs ?? "knob", thickness: 18 } };
case "sideboard":
return { ...base, cabinet: { doors: 2, shelves: 1, rail: false, plinth: true, handles: x.knobs ?? "knob", thickness: 18 } };
diff --git a/src/lib/types.ts b/src/lib/types.ts
index 03afc68..d9ec1bf 100644
--- a/src/lib/types.ts
+++ b/src/lib/types.ts
@@ -26,6 +26,7 @@ export interface DrawersParams {
plinth: boolean;
thickness: number;
changing?: boolean; // a changing table: a changing top goes on last (size.h and size.d take it in)
+ castors?: boolean; // stands on castors (size.h takes them in)
}
export interface TableParams {
@@ -75,6 +76,7 @@ export interface CabinetParams {
fit?: FitParams; // built around a basin, a sink or an appliance that is fitted afterwards
corner?: CornerCab; // a kitchen corner cabinet
lid?: { soft?: boolean }; // a box with a lid on hinges instead (storage benches); a padded lid on a footstool
+ castors?: boolean; // stands on castors (size.h takes them in)
}
/**