IKEA assembly, step by step: animated, manual-style 3D guides. Scan any paper manual with Together AI.
TypeScript
Draw cots
Youssef74cea1249ce5
diff --git a/scripts/ikea/build.ts b/scripts/ikea/build.tsindex cd073e8..356958a 100644--- a/scripts/ikea/build.ts+++ b/scripts/ikea/build.ts@@ -59,6 +59,8 @@ function hints(family: string, kind: Kind): Hint | undefined {/* ---------- matching against hand made entries ---------- */+const LATER_KINDS = new Set<Kind>(["office", "chaise", "corner", "cot"]);+function baseMatch(name: string, draw: Draw): CatalogEntry | undefined {const fam = fold(name);const spec = specFor(draw.kind, name, "", draw.w, draw.h, draw.d, draw.x);@@ -66,6 +68,8 @@ function baseMatch(name: string, draw: Draw): CatalogEntry | undefined {for (const e of BASE) {if (fold(e.name) !== fam) continue;if (e.archetype !== spec.archetype && e.category !== spec.category) continue;+ // the newer kinds draw a different shape from anything hand made in their archetype+ if (LATER_KINDS.has(draw.kind) && e.category !== spec.category) continue;if (draw.kind === "bed") {if (e.bed?.mattressW === draw.x.m && (e.bed?.mattressL ?? 200) === (draw.x.l ?? 200)) return e;continue;diff --git a/scripts/ikea/classify.ts b/scripts/ikea/classify.tsindex 24d6b2e..d83f4aa 100644--- a/scripts/ikea/classify.ts+++ b/scripts/ikea/classify.ts@@ -139,7 +139,8 @@ const RULES: Rule[] = [[/corner|chaise|u-shaped|crnr/, () => "corner or chaise longue sofa"],[/section|add-on|armrest|backrest for|seat sec|modular (easy chair|chaise)/, () => "sofa or storage section"],[/\b(bunk|loft)\b/, () => "bunk or loft bed"],- [/\b(cot|crib)\b|cradle/, () => "cot"],+ [/^cot( with drawer)?$/, (m) => ({ kind: "cot", x: m[1] ? { drawer: true } : {} })],+ [/\b(cot|crib)\b|cradle/, () => "cot bedding, mattress or cradle"],[/day-?bed|divan/, () => "day-bed or divan"],[/sliding/, () => "sliding doors"],[/sink|wash-?basin|wash-?st|hob\b|oven|fridge|freezer|dishwasher|microwave|extractor|appliances|kitchenette|outdoor kitchen/, () => "appliance or sink unit"],@@ -276,6 +277,12 @@ export function classify(f: Fact, hints: Hints): Verdict {} else if (hint?.kind === kind) set(hint.w, hint.h, hint.d);else if (kind !== "bench") return { skip: "no size given" };if (guessed.h && hint?.kind === kind) h = hint.h;+ } else if (kind === "cot") {+ // IKEA gives the mattress size: a cot is a little longer and wider, about 85 cm high+ if (v.length !== 2 || v[1] < 100 || v[1] > 150) return { skip: "cot without a mattress size" };+ [x.m, x.l] = [v[0], v[1]];+ set(v[1] + 10, undefined, v[0] + 8);+ h = v[1] >= 140 ? 86 : 82;} else if (kind === "chaise" || kind === "corner") {// IKEA gives no size: seat width, depth and height from a straight sofa of the same family, else a typical oneconst sofa = hints(family, "sofa");diff --git a/scripts/ikea/slugs.json b/scripts/ikea/slugs.jsonindex 9d0a77d..44a1249 100644--- a/scripts/ikea/slugs.json+++ b/scripts/ikea/slugs.json@@ -13,6 +13,7 @@"ÅLHULT|Extendable table, 120/170 × 80 cm": "alhult-extendable-table-120-170-x-80","ÅLHULT|Extendable table, 170/220 × 80 cm": "alhult-extendable-table-170-220-x-80","ÅLHULT|Table, 120 × 80 cm": "alhult-table-120-x-80",+ "ÄLSKVÄRD|Cot, 70 × 140 cm": "alskvard-cot-70-x-140","ÄLVDALEN|3-seat sofa-bed": "alvdalen-3-seat-sofa-bed","ÄLVDALEN|3-seat sofa-bed with chaise longue": "alvdalen-3-seat-sofa-bed-chaise-longue","ÄMMARYD|Coffee table, 98 × 59 cm": "ammaryd-coffee-table-98-x-59",@@ -222,6 +223,7 @@"GLOSTAD|3-seat sofa": "glostad-3-seat-sofa","GLOSTAD|3-seat sofa with chaise longue": "glostad-3-seat-sofa-chaise-longue","GODISHUS|Chest of 3 drawers, 60 × 40 × 60 cm": "godishus-chest-3-drawers-60-x-40-x-60",+ "GONATT|Cot with drawer, 70 × 140 cm": "gonatt-cot-drawer-70-x-140","GRÅFJÄLLET|Bedside table, 45 × 36 × 59 cm": "grafjallet-bedside-table-45-x-36-x-59","GRÅFJÄLLET|Dressing table, 100 × 42 cm": "grafjallet-dressing-table-100-x-42","GREJSIMOJS|Children's stool": "grejsimojs-children-s-stool",@@ -250,6 +252,7 @@"GULLABERG|Shoe cabinet with 2 compartments, 88 × 30 × 122 cm": "gullaberg-shoe-cabinet-2-compartments-88-x-30-x","GULLABERG|Shoe cabinet with 4 compartments, 105 × 22 × 107 cm": "gullaberg-shoe-cabinet-4-compartments-105-x-22-x","GULLABERG|Wardrobe, 128 × 64 × 201 cm": "gullaberg-wardrobe-128-x-64-x-201",+ "GULLIVER|Cot, 60 × 120 cm": "gulliver-cot-60-x-120","GULLVALLA|2-seat sofa": "gullvalla-2-seat-sofa","GULLVALLA|3-seat sofa": "gullvalla-3-seat-sofa","GULTARP|Stool": "gultarp-stool",@@ -381,6 +384,7 @@"KARSKÄR|Extendable table, 160/220 × 90 cm": "karskar-extendable-table-160-220-x-90","KARSKÄR|Extendable table, 240/300 × 100 cm": "karskar-extendable-table-240-300-x-100","KÄTTIL|Chair": "kattil-chair",+ "KATTUNGE|Cot, 70 × 140 cm": "kattunge-cot-70-x-140","KESNACKEN|Bar stool, 66 cm": "kesnacken-bar-stool-66","KILBERGET|Chest of 3 drawers, 86 × 78 cm": "kilberget-chest-3-drawers-86-x-78","KILBERGET|Chest of 5 drawers, 76 × 102 cm": "kilberget-chest-5-drawers-76-x-102",@@ -571,6 +575,7 @@"MULLSJÖ|Swivel chair": "mullsjo-swivel-chair","MUSKAN|Bench, 58 × 38 cm": "muskan-bench-58-x-38","MUSKAN|Shelving unit, 37 × 140 cm": "muskan-shelving-unit-37-x-140",+ "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ÄMMARÖ|2-seat sofa, 126 cm": "nammaro-2-seat-sofa-126","NÄMMARÖ|2-seat sofa, 147 cm": "nammaro-2-seat-sofa-147",@@ -774,6 +779,7 @@"SLATORP|4-seat sofa with chaise longues": "slatorp-4-seat-sofa-chaise-longues","SLATTUM|Upholstered bed frame, Standard Double, 135 × 190 cm": "slattum-upholstered-bed-frame-standard-double-13","SLATTUM|Upholstered bed frame, Standard Single, 90 × 190 cm": "slattum-upholstered-bed-frame-standard-single-90",+ "SMÅGÖRA|Cot, 70 × 140 cm": "smagora-cot-70-x-140","SMÅGÖRA|Desk, 93 × 51 cm": "smagora-desk-93-x-51","SMÅGÖRA|Shelf unit, 29 × 88 cm": "smagora-shelf-unit-29-x-88","SMÅGÖRA|Wardrobe, 80 × 50 × 187 cm": "smagora-wardrobe-80-x-50-x-187",@@ -797,6 +803,7 @@"SMYGA|Bed frame, 90 × 200 cm": "smyga-bed-frame-90-x-200","SMYGA|Desk, 122 × 60 cm": "smyga-desk-122-x-60","SNIGLAR|Bed frame with slatted bed base, 70 × 160 cm": "sniglar-bed-frame-slatted-bed-base-70-x-160",+ "SNIGLAR|Cot, 60 × 120 cm": "sniglar-cot-60-x-120","SÖDERHAMN|2-seat sofa": "soderhamn-2-seat-sofa","SÖDERHAMN|4-seat sofa with chaise longue": "soderhamn-4-seat-sofa-chaise-longue","SÖDERHAMN|4-seat sofa-bed": "soderhamn-4-seat-sofa-bed",@@ -855,6 +862,7 @@"SUNDSÖ|Table, 65 cm": "sundso-table-65","SUNDVIK|Children's chair": "sundvik-children-s-chair","SUNDVIK|Children's table, 76 × 50 cm": "sundvik-children-s-table-76-x-50",+ "SUNDVIK|Cot, 70 × 140 cm": "sundvik-cot-70-x-140","SUNDVIK|Rocking-chair": "sundvik-rocking-chair","SUNDVIK|Wardrobe, 80 × 50 × 171 cm": "sundvik-wardrobe-80-x-50-x-171","SUNNERSTA|Storage unit, 56 × 38 cm": "sunnersta-storage-unit-56-x-38",diff --git a/src/data/ikea-items.ts b/src/data/ikea-items.tsindex 3c42d34..b11e28d 100644--- a/src/data/ikea-items.ts+++ b/src/data/ikea-items.ts@@ -15,6 +15,7 @@ alhult-chair|50600801 40600774alhult-extendable-table-120-170-x-80|60597921 20600789alhult-extendable-table-170-220-x-80|50600783 40597922alhult-table-120-x-80|40600793 00597919+alskvard-cot-70-x-140|40466704alvdalen-3-seat-sofa-bed|10530650 10530645alvdalen-3-seat-sofa-bed-chaise-longue|70530666 70530671ammaryd-coffee-table-98-x-59|00609125 40609128@@ -247,6 +248,7 @@ glostad-2-seat-sofa|90489010glostad-3-seat-sofa|80595940glostad-3-seat-sofa-chaise-longue|89578601godishus-chest-3-drawers-60-x-40-x-60|80598095+gonatt-cot-drawer-70-x-140|90467089grafjallet-bedside-table-45-x-36-x-59|20570221grafjallet-dressing-table-100-x-42|30570225grejsimojs-children-s-stool|60598973 50598959@@ -275,6 +277,7 @@ gullaberg-desk-155-x-65-x-75|50601669gullaberg-shoe-cabinet-2-compartments-88-x-30-x|50587692 40587697gullaberg-shoe-cabinet-4-compartments-105-x-22-x|10587707 50587710gullaberg-wardrobe-128-x-64-x-201|00609903 80609904+gulliver-cot-60-x-120|20589503 10248519gullvalla-2-seat-sofa|80618507 20618510gullvalla-3-seat-sofa|60618513 50618504gultarp-stool|80614585@@ -430,6 +433,7 @@ karskar-chair|00611251karskar-extendable-table-160-220-x-90|50611263karskar-extendable-table-240-300-x-100|00611265kattil-chair|00500347 30500341+kattunge-cot-70-x-140|30598291kesnacken-bar-stool-66|10614999kilberget-chest-3-drawers-86-x-78|70609914kilberget-chest-5-drawers-76-x-102|40609915@@ -641,6 +645,7 @@ mullsjo-desk-135-x-70|30553240mullsjo-swivel-chair|70576584muskan-bench-58-x-38|50345957muskan-shelving-unit-37-x-140|50424327+myllra-cot-drawer-70-x-140|80597048 60483590nackanas-table-140-x-76|40511056nammaro-2-seat-sofa-126|59610240 39611170 19579307 49607511 09621509 09575423nammaro-2-seat-sofa-147|99579308 59611174 89610248 09607513 69621511 19575427@@ -852,6 +857,7 @@ slatorp-3-seat-sofa-chaise-longue|59577580 79577598 39577576slatorp-4-seat-sofa-chaise-longues|59577603slattum-upholstered-bed-frame-standard-double-13|50571257 30571258slattum-upholstered-bed-frame-standard-single-90|90578737+smagora-cot-70-x-140|20461236smagora-desk-93-x-51|90489883smagora-shelf-unit-29-x-88|30465489smagora-wardrobe-80-x-50-x-187|10460888@@ -875,6 +881,7 @@ smyga-bed-frame-90-x-200|60480780smyga-bed-frame-storage-90-x-200|59444142smyga-desk-122-x-60|40480781sniglar-bed-frame-slatted-bed-base-70-x-160|19185433+sniglar-cot-60-x-120|30248537soderhamn-2-seat-sofa|29305755soderhamn-3-seat-sofa|39621635 09621632 69621629 79621638 09305704 29449693 39305694 19449698 59452108 69622110 39622102 29622107 09622113 19618672 49580069 99580062 39621386 79621389 19621392soderhamn-4-seat-sofa-bed|89616448 69621375 49621381 49616247 39621372 29618676 69618679 69621361 69616270 39621367 09621364 09616428@@ -938,6 +945,7 @@ sundso-table-65|80575895 40575897sundso-table-65-x-65|60582585 10582583 90575507 50582581 80575560 30582577 90582579sundvik-children-s-chair|70628314 60196358 10494020sundvik-children-s-table-76-x-50|20628316 10201673+sundvik-cot-70-x-140|60497587sundvik-extendable-bed-80-x-200|49046068 49421508sundvik-rocking-chair|80201740sundvik-wardrobe-80-x-50-x-171|10269696diff --git a/src/data/ikea-rows.ts b/src/data/ikea-rows.tsindex 32a96ab..9675e9c 100644--- a/src/data/ikea-rows.ts+++ b/src/data/ikea-rows.ts@@ -14,6 +14,7 @@ ALEX|open|Storage unit, 36 × 70 cm|36|70|35ÅLHULT|dining|Extendable table, 120/170 × 80 cm|120|74|80ÅLHULT|dining|Table, 120 × 80 cm|120|74|80ÅLHULT|dining|Extendable table, 170/220 × 80 cm|170|74|80+ÄLSKVÄRD|cot|Cot, 70 × 140 cm|150|86|78|m=70,l=140ÄLVDALEN|chaise|3-seat sofa-bed with chaise longue|226|85|160|seats=3,arms=wide,chaise=right,sd=92ÄLVDALEN|sofa|3-seat sofa-bed|230|85|92|seats=3ÄMMARYD|coffee|Coffee table, 98 × 59 cm|98|45|59@@ -223,6 +224,7 @@ GLENN|stool|Bar stool, 66 cm|35|66|35GLOSTAD|chaise|3-seat sofa with chaise longue|201|78|150|seats=3,arms=wide,chaise=right,sd=82GLOSTAD|sofa|3-seat sofa|230|85|92|seats=3GODISHUS|chest|Chest of 3 drawers, 60 × 40 × 60 cm|60|60|40|rows=3+GONATT|cot|Cot with drawer, 70 × 140 cm|150|86|78|m=70,l=140,drawer=1GRÅFJÄLLET|desk|Dressing table, 100 × 42 cm|100|74|42GRÅFJÄLLET|nightstand|Bedside table, 45 × 36 × 59 cm|45|59|36|rows=1GREJSIMOJS|kidstable|Children's table, 84 × 42 cm|84|48|42||kids@@ -251,6 +253,7 @@ GULLABERG|nightstand|Bedside table, 53 × 43 × 69 cm|53|69|43|rows=2GULLABERG|shoe|Shoe cabinet with 2 compartments, 88 × 30 × 122 cm|88|122|30|c=2GULLABERG|shoe|Shoe cabinet with 4 compartments, 105 × 22 × 107 cm|105|107|22|c=4GULLABERG|wardrobe|Wardrobe, 128 × 64 × 201 cm|128|201|64+GULLIVER|cot|Cot, 60 × 120 cm|130|82|68|m=60,l=120GULLVALLA|sofa|2-seat sofa|170|85|92|seats=2GULLVALLA|sofa|3-seat sofa|230|85|92|seats=3GULTARP|stool|Stool|35|45|35@@ -382,6 +385,7 @@ KARSKÄR|chair|Chair|44|88|50KARSKÄR|dining|Extendable table, 160/220 × 90 cm|160|74|90KARSKÄR|dining|Extendable table, 240/300 × 100 cm|240|74|100KÄTTIL|chair|Chair|44|88|50+KATTUNGE|cot|Cot, 70 × 140 cm|150|86|78|m=70,l=140KESNACKEN|stool|Bar stool, 66 cm|35|66|35KILBERGET|chest|Chest of 5 drawers, 76 × 102 cm|76|102|48|rows=5KILBERGET|chest|Chest of 3 drawers, 86 × 78 cm|86|78|48|rows=3@@ -572,6 +576,7 @@ MULLSJÖ|desk|Desk, 135 × 70 cm|135|74|70MULLSJÖ|office|Swivel chair|60|105|64|arms=noneMUSKAN|bench|Bench, 58 × 38 cm|58|45|38MUSKAN|open|Shelving unit, 37 × 140 cm|37|140|35+MYLLRA|cot|Cot with drawer, 70 × 140 cm|150|86|78|m=70,l=140,drawer=1NACKANÄS|dining|Table, 140 × 76 cm|140|74|76NÄMMARÖ|bar|Bar table, outdoor, 120 × 40 cm|120|105|40||outdoor gardenNÄMMARÖ|bench|Bench, outdoor, 120 cm|120|45|38||outdoor garden@@ -775,6 +780,7 @@ SLATORP|sofa|2-seat sofa|170|85|92|seats=2SLATORP|sofa|3-seat sofa|230|85|92|seats=3SLATTUM|bed|Upholstered bed frame, Standard Single, 90 × 190 cm|106|85|199|m=90,l=190,f=30SLATTUM|bed|Upholstered bed frame, Standard Double, 135 × 190 cm|151|85|199|m=135,l=190,f=30+SMÅGÖRA|cot|Cot, 70 × 140 cm|150|86|78|m=70,l=140SMÅGÖRA|desk|Desk, 93 × 51 cm|93|74|51||kids childrenSMÅGÖRA|open|Shelf unit, 29 × 88 cm|29|88|35||kids childrenSMÅGÖRA|wardrobe|Wardrobe, 80 × 50 × 187 cm|80|187|50@@ -798,6 +804,7 @@ SMYGA|bed|Bed frame with storage, 90 × 200 cm|106|100|209|m=90SMYGA|bed|Bed frame, 90 × 200 cm|106|100|209|m=90SMYGA|desk|Desk, 122 × 60 cm|122|74|60||kids childrenSNIGLAR|bed|Bed frame with slatted bed base, 70 × 160 cm|86|64|169|m=70,l=160,f=50+SNIGLAR|cot|Cot, 60 × 120 cm|130|82|68|m=60,l=120SÖDERHAMN|chaise|4-seat sofa with chaise longue|259|69|167|seats=4,arms=slim,chaise=right,sd=99SÖDERHAMN|corner|Corner sofa, 4-seat|228|69|168|seats=4,arms=slim,corner=left,sd=99SÖDERHAMN|corner|Corner sofa-bed, 6-seat|289|69|228|seats=6,arms=slim,corner=left,sd=99@@ -855,6 +862,7 @@ SUNDSÖ|chair|Folding chair|44|88|50||outdoor gardenSUNDSÖ|dining|Table, 65 × 65 cm|65|74|65||outdoor gardenSUNDSÖ|dining|Table, 65 cm|65|74|65|round=1|outdoor gardenSUNDVIK|armchair|Rocking-chair|75|90|80+SUNDVIK|cot|Cot, 70 × 140 cm|150|86|78|m=70,l=140SUNDVIK|kidschair|Children's chair|34|60|34||kidsSUNDVIK|kidstable|Children's table, 76 × 50 cm|76|48|50||kidsSUNDVIK|wardrobe|Wardrobe, 80 × 50 × 171 cm|80|171|50diff --git a/src/lib/ikea.ts b/src/lib/ikea.tsindex 7f6a7cd..7620ab6 100644--- a/src/lib/ikea.ts+++ b/src/lib/ikea.ts@@ -23,8 +23,8 @@ export interface IkeaRow {slug?: string;}-const X_KEYS = ["rows", "cols", "knobs", "plinth", "doors", "shelves", "c", "m", "l", "f", "seats", "arms", "legs", "attach", "shelf", "min", "round", "seatH", "chaise", "corner", "open", "sd"] as const;-const FLAGS = new Set<string>(["plinth", "shelf", "round", "open"]);+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"] as const;+const FLAGS = new Set<string>(["plinth", "shelf", "round", "open", "drawer"]);const WORDS = new Set<string>(["knobs", "arms", "legs", "attach", "chaise", "corner"]);export function encodeX(x: X): string {diff --git a/src/lib/plan/bed.ts b/src/lib/plan/bed.tsindex 1d11f43..a437eb9 100644--- a/src/lib/plan/bed.ts+++ b/src/lib/plan/bed.ts@@ -1,6 +1,7 @@import type { BedParams, ProductSpec } from "../types";import { HW, PlanBuilder, type FitOpts } from "./builder";import { clamp } from "./math";+import { buildCot } from "./cot";export function defaultsBed(s: ProductSpec): BedParams {const p = s.bed ?? {};@@ -16,6 +17,7 @@ export function defaultsBed(s: ProductSpec): BedParams {}export function buildBed(b: PlanBuilder, s: ProductSpec) {+ if (s.bed?.type === "cot") return buildCot(b, s);const p = defaultsBed(s);const Wm = p.mattressW * 10, Lm = p.mattressL * 10;const t = 22;diff --git a/src/lib/plan/cot.ts b/src/lib/plan/cot.tsnew file mode 100644index 0000000..e7d9ec9--- /dev/null+++ b/src/lib/plan/cot.ts@@ -0,0 +1,151 @@+import type { PartPiece, ProductSpec, Vec3 } from "../types";+import { HW, PlanBuilder, type FitOpts } from "./builder";+import { clamp } from "./math";++/**+ * A cot: two ends, two barred sides and a slatted base that bolts in at one of two heights.+ * It stands lengthways across the view (x), so the front side faces the camera.+ * Built like IKEA's: one side between the ends, the base at the top height, then the front side.+ */+export function buildCot(b: PlanBuilder, s: ProductSpec) {+ const p = s.bed ?? {};+ const Ml = clamp((p.mattressL ?? 120) * 10, 1000, 1500), Mm = clamp((p.mattressW ?? 60) * 10, 500, 800);+ const H = clamp(s.size.h * 10, 700, 1000);+ const post = 45;+ const L = Ml + 2 * post + 10; // outside length+ const D = Mm + 83; // outside width+ const inner = D - 73; // between the sides+ const ex = L / 2 - post / 2; // centre of each end+ const sz = D / 2 - post / 2; // plane of each side+ const sideT = 28;++ /* ---------- ends: two posts, two rails and a panel ---------- */+ const endPieces = (x: number): PartPiece[] => [+ ...[-1, 1].map((k): PartPiece => ({ shape: "box", size: [post, H, post], pos: [x, H / 2, k * sz] })),+ { shape: "box", size: [36, 60, D - 2 * post], pos: [x, H - 30, 0] },+ { shape: "box", size: [36, 60, D - 2 * post], pos: [x, 130, 0] },+ { shape: "box", size: [12, H - 220, D - 2 * post], pos: [x, (H + 100) / 2, 0], material: "board" },+ ];+ const endC = b.compound("End", endPieces(-ex), { material: "wood" });+ const ends = [b.place(endC.type, endC.mid), b.place(endC.type, [-endC.mid[0], endC.mid[1], endC.mid[2]], [0, Math.PI, 0])];++ /* ---------- sides: two rails with bars between ---------- */+ const Ls = L - 2 * post;+ const railLo = 190, railHi = H - 40;+ const bars = Math.max(8, Math.round(Ls / 75));+ const pitch = Ls / bars;+ const sidePieces: PartPiece[] = [+ { shape: "box", size: [Ls, 40, sideT], pos: [0, railHi, 0] },+ { shape: "box", size: [Ls, 40, sideT], pos: [0, railLo, 0] },+ ];+ const barLen = railHi - railLo - 40;+ for (let i = 1; i < bars; i++) sidePieces.push({ shape: "cyl", size: [22, barLen, 22], pos: [-Ls / 2 + i * pitch, (railHi + railLo) / 2, 0] });+ const sideC = b.compound("Side", sidePieces, { material: "wood" });+ const backSide = b.place(sideC.type, [0, sideC.mid[1], -sz]);+ const frontSide = b.place(sideC.type, [0, sideC.mid[1], sz], [0, Math.PI, 0]);++ /* ---------- slatted base ---------- */+ const topY = clamp(H - 380, 380, 520); // top of the slats, top position+ const lowY = 230; // the lower position, for when the baby can sit up+ const baseL = L - 2 * post;+ const rz = inner / 2 - 40;+ const basePieces: PartPiece[] = [-1, 1].map((k) => ({ shape: "box", size: [baseL, 50, 24], pos: [0, topY - 12 - 25, k * rz] }));+ const slats = Math.round(Ml / 130);+ for (let i = 0; i < slats; i++) basePieces.push({ shape: "box", size: [70, 12, 2 * rz + 24], pos: [-Ml / 2 + 60 + (i * (Ml - 120)) / (slats - 1), topY - 6, 0] });+ const baseC = b.compound("Bed base", basePieces, { material: "wood" });+ const base = b.place(baseC.type, baseC.mid);++ /* ---------- drawer ---------- */+ let drawer: string | undefined;+ if (p.drawer) {+ const dw = Ls - 40, dd = inner - 30;+ const dC = b.compound(+ "Drawer",+ [+ { shape: "box", size: [dw - 40, 120, dd - 30], pos: [0, 30 + 60, -10] },+ { shape: "box", size: [dw, 140, 18], pos: [0, 30 + 70, dd / 2 - 9] },+ ],+ { material: "board" },+ );+ drawer = b.place(dC.type, dC.mid);+ }++ /* ---------- steps ---------- */+ const railYs = [railLo, railHi];+ const sideBolts = (side: string, z: number): FitOpts[] =>+ ends.flatMap((e, i) => railYs.map((y) => ({ on: e, at: [(i === 0 ? -1 : 1) * (L / 2), y, z] as Vec3, dir: [i === 0 ? 1 : -1, 0, 0] as Vec3, mate: side })));++ b.step(+ {+ title: "Bolt one side between the ends",+ detail: "Hand tight for now, so the rest lines up easily.",+ tools: ["allen"],+ kind: "bolts",+ warnings: ["loose"],+ },+ () => {+ b.stagger(0.3);+ ends.forEach((e, i) => b.add(e, [(i === 0 ? -1 : 1) * 300, 0, 0]));+ b.then(0.05);+ b.add(backSide, [0, 0, -320]);+ b.then(0.1);+ b.fits(HW.boltL, sideBolts(backSide, -sz), 0.1);+ },+ );++ b.step(+ {+ title: "Bolt the base in at the top height",+ detail: "The top holes are for a newborn. Move the base down once your baby can sit up.",+ tools: ["allen"],+ kind: "bolts",+ },+ () => {+ // the holes for the lower height, for later+ ends.forEach((e, i) => {+ const sgn = i === 0 ? -1 : 1;+ for (const z of [-rz, rz]) b.hole(e, [sgn * (L / 2 - 16.5), lowY - 37, z], [sgn, 0, 0], 3.5);+ });+ b.add(base, [0, 320, 0]);+ b.then(0.1);+ const bolts: FitOpts[] = ends.flatMap((e, i) => [-rz, rz].map((z) => ({ on: e, at: [(i === 0 ? -1 : 1) * (L / 2 - 16.5), topY - 37, z] as Vec3, dir: [i === 0 ? 1 : -1, 0, 0] as Vec3, mate: base })));+ b.fits(HW.boltL, bolts, 0.1);+ },+ );++ b.step(+ {+ title: "Add the other side",+ detail: "Then tighten every bolt firmly. Check none stick out on the inside.",+ tools: ["allen"],+ kind: "bolts",+ },+ () => {+ b.add(frontSide, [0, 0, 320]);+ b.then(0.1);+ b.fits(HW.boltL, sideBolts(frontSide, sz), 0.1);+ },+ );++ if (drawer) {+ b.step(+ {+ title: "Slide the drawer in underneath",+ detail: "It sits under the base and pulls out from the front.",+ kind: "drawer",+ },+ () => b.add(drawer!, [0, 0, 420]),+ );+ }++ const mT = b.part("Your mattress", [Ml, 100, Mm], { material: "soft", extra: true });+ const m = b.place(mT, [0, topY + 50, 0]);+ b.step(+ {+ title: "Add your mattress",+ detail: "It should fit snugly, with no gap at the sides.",+ kind: "general",+ },+ () => b.add(m, [0, 420, 0]),+ );+}diff --git a/src/lib/products.ts b/src/lib/products.tsindex 15f62dc..68dc722 100644--- a/src/lib/products.ts+++ b/src/lib/products.ts@@ -37,7 +37,8 @@ export type Kind =// added later: new shapes of an existing archetype| "office"| "chaise"- | "corner";+ | "corner"+ | "cot";export type X = {rows?: number;@@ -62,6 +63,7 @@ export type X = {corner?: "left" | "right";open?: boolean;sd?: number;+ drawer?: boolean;};export type Row = [name: string, kind: Kind, variant: string, w: number, h: number, d: number, x?: X, keywords?: string];@@ -235,7 +237,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,+ office: 20, chaise: 55, corner: 70, cot: 35,};const CATEGORY: Record<Kind, string> = {@@ -244,7 +246,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",+ office: "Office chair", chaise: "Sofa with chaise longue", corner: "Corner sofa", cot: "Cot",};export const KIND_ARCH: Record<Kind, Archetype> = {@@ -252,7 +254,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",+ office: "seat", chaise: "sofa", corner: "sofa", cot: "bed",};const round = (x: X) => (x.round ? { round: true } : {});@@ -334,6 +336,8 @@ export function specFor(kind: Kind, name: string, variant: string, w: number, h:const shape = kind === "corner" ? { corner: x.corner ?? "left", ...(x.open ? { open: true } : {}) } : { chaise: x.chaise ?? "right" };return { ...base, people: 2, sofa: { ...sofa, ...shape } };}+ case "cot":+ return { ...base, people: 1, bed: { type: "cot", mattressW: x.m ?? 60, mattressL: x.l ?? 120, headH: h, footH: h, slats: 9, centerBeam: false, ...(x.drawer ? { drawer: true } : {}) } };}}@@ -362,5 +366,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: [250, 85, 160], corner: [250, 85, 220],+ office: [64, 105, 64], chaise: [250, 85, 160], corner: [250, 85, 220], cot: [130, 84, 68],};diff --git a/src/lib/types.ts b/src/lib/types.tsindex 893a93f..f091faf 100644--- a/src/lib/types.ts+++ b/src/lib/types.ts@@ -39,6 +39,8 @@ export interface BedParams {footH: number; // cm, 0 for noneslats: number;centerBeam: boolean;+ type?: "cot" | "bunk" | "loft"; // a cot with barred sides, two beds stacked on posts, or one bed up high+ drawer?: boolean; // a cot with a drawer under the base}export interface CabinetParams {