@bitbybit-dev/create-app 1.4.1 → 1.5.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/README.md +1 -0
  2. package/dist/index.js +20 -13
  3. package/dist/index.js.map +1 -1
  4. package/dist/scaffold.d.ts.map +1 -1
  5. package/dist/scaffold.js +16 -8
  6. package/dist/scaffold.js.map +1 -1
  7. package/package.json +1 -1
  8. package/src/index.test.ts +47 -11
  9. package/src/index.ts +28 -14
  10. package/src/scaffold.ts +23 -8
  11. package/templates/apps/drone-assembly/package.json +3 -3
  12. package/templates/apps/drone-assembly/scripts/smoke.ts +3 -3
  13. package/templates/apps/drone-assembly/src/parts.ts +3 -3
  14. package/templates/apps/ifc-house/AGENTS.section.md +19 -0
  15. package/templates/apps/ifc-house/README.md +36 -0
  16. package/templates/apps/ifc-house/eslint.config.js +47 -0
  17. package/templates/apps/ifc-house/index.html +22 -0
  18. package/templates/apps/ifc-house/package.json +36 -0
  19. package/templates/apps/ifc-house/public/favicon.ico +0 -0
  20. package/templates/apps/ifc-house/public/logo.png +0 -0
  21. package/templates/apps/ifc-house/scripts/smoke.ts +118 -0
  22. package/templates/apps/ifc-house/src/export/step-export.ts +29 -0
  23. package/templates/apps/ifc-house/src/house/build-house.ts +194 -0
  24. package/templates/apps/ifc-house/src/house/details.ts +393 -0
  25. package/templates/apps/ifc-house/src/house/house-plan.ts +400 -0
  26. package/templates/apps/ifc-house/src/house/house-types.ts +192 -0
  27. package/templates/apps/ifc-house/src/main.ts +138 -0
  28. package/templates/apps/ifc-house/src/scene/draw-house.ts +92 -0
  29. package/templates/apps/ifc-house/src/scene/scene-types.ts +30 -0
  30. package/templates/apps/ifc-house/src/scene/stage.ts +64 -0
  31. package/templates/apps/ifc-house/src/style.css +347 -0
  32. package/templates/apps/ifc-house/src/ui/panel.ts +144 -0
  33. package/templates/apps/ifc-house/src/ui/room-labels.ts +75 -0
  34. package/templates/apps/ifc-house/src/ui/ui-types.ts +14 -0
  35. package/templates/apps/ifc-house/src/vite-env.d.ts +1 -0
  36. package/templates/apps/ifc-house/src/workers/ifc.worker.ts +7 -0
  37. package/templates/apps/ifc-house/src/workers/manifold.worker.ts +16 -0
  38. package/templates/apps/ifc-house/src/workers/occt.worker.ts +17 -0
  39. package/templates/apps/ifc-house/tsconfig.json +29 -0
  40. package/templates/apps/laser-cut-box/package.json +2 -2
  41. package/templates/apps/laser-cut-box/scripts/smoke.ts +2 -1
  42. package/templates/apps/laser-cut-box/src/panels.ts +2 -0
  43. package/templates/apps/product-configurator/package.json +2 -2
  44. package/templates/apps/product-configurator/scripts/smoke.ts +4 -3
  45. package/templates/apps/sheet-metal-unfold/backend/package.json +1 -1
  46. package/templates/apps/sheet-metal-unfold/frontend/package.json +2 -2
  47. package/templates/apps/sheet-metal-unfold/frontend/scripts/smoke.ts +4 -3
  48. package/templates/apps/step-to-gltf-cli/package.json +2 -2
  49. package/templates/apps/step-to-gltf-cli/src/convert.ts +7 -2
  50. package/templates/cloud/backends/hono-rest/package.json +1 -1
  51. package/templates/cloud/backends/hono-sdk/package.json +2 -2
  52. package/templates/cloud/backends/nodejs-rest/package.json +1 -1
  53. package/templates/cloud/backends/nodejs-sdk/package.json +2 -2
  54. package/templates/cloud/frontend/package.json +1 -1
  55. package/templates/vite/babylonjs/typescript/AGENTS.section.md +1 -1
  56. package/templates/vite/babylonjs/typescript/package.json +2 -2
  57. package/templates/vite/babylonjs/typescript/scripts/smoke.ts +4 -3
  58. package/templates/vite/playcanvas/typescript/AGENTS.section.md +1 -1
  59. package/templates/vite/playcanvas/typescript/package.json +2 -2
  60. package/templates/vite/playcanvas/typescript/scripts/smoke.ts +4 -3
  61. package/templates/vite/threejs/typescript/AGENTS.section.md +1 -1
  62. package/templates/vite/threejs/typescript/package.json +2 -2
  63. package/templates/vite/threejs/typescript/scripts/smoke.ts +4 -3
@@ -0,0 +1,393 @@
1
+ import { IFC, type Base } from "@bitbybit-dev/ifc/lib/api/inputs";
2
+ import {
3
+ BOARD, CANTILEVER_DRIP, CARPORT, CARPORT_DECK_BOTTOM, CAVITY, COPING, DECK_TOP, GLASS_RAIL, RAILS, STUDY_GLAZING, DOOR_TYPES, DOORS, FACADE_DEPTH, FIRST_FLOOR_ELEVATION, FIRST_FLOOR_EAST_FACE, FIRST_FLOOR_WALL_TOP, FIRST_INTERIOR,
4
+ GROUND_INTERIOR, PARAPET_INSET, PARAPET_TOP, ROOF_DEPTH, SILLED_WINDOWS, SLAB_DEPTH, STAIR, SURROUNDED_WINDOWS, TIMBER_WALL, WALL_RUNS, WINDOW_TYPES, WINDOWS, railLine, thicknessOf,
5
+ } from "./house-plan";
6
+ import type { AssemblySpec, DetailSpec, FacadeLine, FacadeOpening, FacadeSide, FillingSpec, WallSide } from "./house-types";
7
+
8
+ const { memberPredefinedTypeEnum } = IFC;
9
+ const BOARD_PLANE = TIMBER_WALL + CAVITY + BOARD.thickness / 2;
10
+ const FLASHING = { height: 0.06, projection: 0.03 };
11
+ const ABOVE_FLASHING = -SLAB_DEPTH + FLASHING.height;
12
+ const SURROUND = { thickness: 0.03, projection: 0.15 };
13
+ const SILL = { thickness: 0.03, drip: 0.04 };
14
+ const FRAME_DEPTH = 0.09;
15
+ const MIN_PIECE = 0.02;
16
+ const CORNER_BOARD_LIMIT = FIRST_INTERIOR.y0 - TIMBER_WALL - CAVITY;
17
+ const ROOF_TOP = FIRST_FLOOR_WALL_TOP + ROOF_DEPTH;
18
+ const SOLAR = { width: 1.13, length: 1.72, thickness: 0.04, lift: 0.15, tilt: 10, gap: 0.05, rows: [-1.2, 1.6], columns: 7, firstColumn: 1.2 };
19
+ const SOLAR_RAIL = { width: 0.06, inset: 0.1, clearance: 0.003 };
20
+ const STRINGER = { thickness: 0.012, depth: 0.22, below: 0.08, past: 0.03 };
21
+ const HANDRAIL = { radius: 0.021, height: 0.9, wallGap: 0.02 };
22
+ const BALUSTER = { radius: 0.008, below: 0.05, underRail: 0.015 };
23
+ const DOWNPIPE = { radius: 0.05, standoff: 0.09, positions: [0.45, 10.5] };
24
+ const HOPPER = { height: 0.25, width: 0.22, depth: 0.17, belowCoping: 0.51 };
25
+ const CANOPY = {
26
+ from: 5.75, to: 8.35, projection: 1.4, underside: 2.75, cover: 0.02, upstand: 0.02,
27
+ fascia: { thickness: 0.03, depth: 0.14 },
28
+ slat: { width: 0.06, gap: 0.02, depth: 0.03, above: 0.03 },
29
+ lights: [6.665, 7.915], light: { radius: 0.035, depth: 0.01, out: 0.7 },
30
+ };
31
+
32
+ const SOLAR_ARRAY = "solar-array";
33
+
34
+ const FIRST_SIDES: FacadeSide[] = [
35
+ { wall: "ff-south", along: "x", line: FIRST_INTERIOR.y0, outward: -1, from: -FACADE_DEPTH, to: FIRST_INTERIOR.x1 + FACADE_DEPTH, start: FIRST_INTERIOR.x0, direction: 1 },
36
+ { wall: "ff-north", along: "x", line: FIRST_INTERIOR.y1, outward: 1, from: -FACADE_DEPTH, to: FIRST_INTERIOR.x1 + FACADE_DEPTH, start: FIRST_INTERIOR.x1, direction: -1 },
37
+ { wall: "ff-west", along: "y", line: FIRST_INTERIOR.x0, outward: -1, from: CORNER_BOARD_LIMIT, to: FIRST_INTERIOR.y1 + TIMBER_WALL + CAVITY, start: FIRST_INTERIOR.y1, direction: -1 },
38
+ { wall: "ff-east", along: "y", line: FIRST_INTERIOR.x1, outward: 1, from: CORNER_BOARD_LIMIT, to: FIRST_INTERIOR.y1 + TIMBER_WALL + CAVITY, start: FIRST_INTERIOR.y0, direction: 1 },
39
+ ];
40
+
41
+ function sideOfWall(wall: string): WallSide {
42
+ const run = WALL_RUNS.find((candidate) => candidate.walls.some((spec) => spec.id === wall));
43
+ const spec = run?.walls.find((candidate) => candidate.id === wall);
44
+ if (!run || !spec) {
45
+ throw new Error(`The plan has no wall '${wall}'`);
46
+ }
47
+ const along = spec.start[1] === spec.end[1] ? "x" : "y";
48
+ const axis = along === "x" ? 0 : 1;
49
+ const across = along === "x" ? 1 : 0;
50
+ const direction = spec.end[axis] > spec.start[axis] ? 1 : -1;
51
+ const outward = along === "x" ? -direction as 1 | -1 : direction;
52
+ const thickness = run.layerSet === "Timber frame wall" ? TIMBER_WALL : FACADE_DEPTH;
53
+ return { wall, along, line: spec.start[across], outward, start: spec.start[axis], direction, thickness, baseOffset: run.baseOffset };
54
+ }
55
+
56
+ function sizeOf(filling: FillingSpec): { width: number; height: number } {
57
+ const type = WINDOW_TYPES.find((candidate) => candidate.id === filling.type) ?? DOOR_TYPES.find((candidate) => candidate.id === filling.type);
58
+ if (!type) {
59
+ throw new Error(`The plan has no type '${filling.type}'`);
60
+ }
61
+ return type;
62
+ }
63
+
64
+ function openingOf(filling: FillingSpec, side: FacadeLine & { baseOffset?: number }): FacadeOpening {
65
+ const { width, height } = sizeOf(filling);
66
+ const from = side.direction > 0 ? side.start + filling.offset : side.start - filling.offset - width;
67
+ const bottom = filling.sill + (side.baseOffset ?? -SLAB_DEPTH);
68
+ return { id: filling.id, from, to: from + width, bottom, top: bottom + height };
69
+ }
70
+
71
+ function point(side: FacadeLine, u: number, depth: number, z: number): Base.Point3 {
72
+ const across = side.line + side.outward * depth;
73
+ return side.along === "x" ? [u, across, z] : [across, u, z];
74
+ }
75
+
76
+ function boardBottom(side: FacadeSide, to: number): number {
77
+ if (side.wall === "ff-south") {
78
+ return CANTILEVER_DRIP;
79
+ }
80
+ if (side.wall === "ff-north") {
81
+ return to > FIRST_FLOOR_EAST_FACE ? DECK_TOP : ABOVE_FLASHING;
82
+ }
83
+ if (to <= -FACADE_DEPTH) {
84
+ return CANTILEVER_DRIP;
85
+ }
86
+ return side.wall === "ff-west" ? ABOVE_FLASHING : DECK_TOP;
87
+ }
88
+
89
+ function cutAround(bottom: number, top: number, from: number, to: number, openings: readonly FacadeOpening[]): [number, number][] {
90
+ let pieces: [number, number][] = [[bottom, top]];
91
+ for (const opening of openings) {
92
+ if (to <= opening.from || from >= opening.to) {
93
+ continue;
94
+ }
95
+ pieces = pieces.flatMap(([low, high]): [number, number][] => {
96
+ if (high <= opening.bottom || low >= opening.top) {
97
+ return [[low, high]];
98
+ }
99
+ const below: [number, number] = [low, Math.min(high, opening.bottom)];
100
+ const above: [number, number] = [Math.max(low, opening.top), high];
101
+ return [below, above].filter(([a, b]) => b - a > MIN_PIECE);
102
+ });
103
+ }
104
+ return pieces;
105
+ }
106
+
107
+ function facadeOpenings(side: FacadeSide): FacadeOpening[] {
108
+ return [...WINDOWS, ...DOORS].filter((filling) => filling.wall === side.wall).map((filling) => openingOf(filling, side));
109
+ }
110
+
111
+ function claddingOf(side: FacadeSide): string {
112
+ return `${side.wall}-cladding`;
113
+ }
114
+
115
+ function facingOf(side: FacadeSide): string {
116
+ const facing = side.wall.replace(/^ff-/, "");
117
+ return facing.charAt(0).toUpperCase() + facing.slice(1);
118
+ }
119
+
120
+ function claddingBoards(): DetailSpec[] {
121
+ const boards: DetailSpec[] = [];
122
+ const pitch = BOARD.width + BOARD.gap;
123
+ for (const side of FIRST_SIDES) {
124
+ const openings = facadeOpenings(side);
125
+ const count = Math.floor((side.to - side.from + BOARD.gap) / pitch);
126
+ const first = side.from + (side.to - side.from - (count * pitch - BOARD.gap)) / 2;
127
+ for (let index = 0; index < count; index++) {
128
+ const from = first + index * pitch;
129
+ const to = from + BOARD.width;
130
+ const middle = (from + to) / 2;
131
+ cutAround(boardBottom(side, to), PARAPET_TOP, from, to, openings).forEach(([bottom, top], piece) => {
132
+ boards.push({
133
+ id: `${side.wall}-board-${index}-${piece}`, name: "Cladding board", storey: "first", layer: "first", material: "Charred larch", assembly: claddingOf(side),
134
+ start: point(side, middle, BOARD_PLANE, bottom), end: point(side, middle, BOARD_PLANE, top),
135
+ width: BOARD.width, depth: BOARD.thickness, rotation: side.along === "y" ? 90 : 0, kind: memberPredefinedTypeEnum.plate,
136
+ });
137
+ });
138
+ }
139
+ }
140
+ return boards;
141
+ }
142
+
143
+ function flashings(): DetailSpec[] {
144
+ const outer = FACADE_DEPTH + FLASHING.projection;
145
+ const middle = (TIMBER_WALL + outer) / 2;
146
+ const width = outer - TIMBER_WALL;
147
+ const z = -SLAB_DEPTH + FLASHING.height / 2;
148
+ const [, north, west] = FIRST_SIDES as [FacadeSide, FacadeSide, FacadeSide, FacadeSide];
149
+ const flashing = (id: string, start: Base.Point3, end: Base.Point3): DetailSpec => ({
150
+ id, name: "Floor line flashing", storey: "first", layer: "first", material: "Anthracite aluminium", start, end, width, depth: FLASHING.height,
151
+ });
152
+ return [
153
+ flashing("flashing-north", point(north, -outer, middle, z), point(north, FIRST_FLOOR_EAST_FACE, middle, z)),
154
+ flashing("flashing-west", point(west, -FACADE_DEPTH, middle, z), point(west, FIRST_INTERIOR.y1 + TIMBER_WALL, middle, z)),
155
+ ];
156
+ }
157
+
158
+ function windowSurrounds(): DetailSpec[] {
159
+ const t = SURROUND.thickness;
160
+ const inner = TIMBER_WALL / 2 + FRAME_DEPTH / 2;
161
+ const outer = FACADE_DEPTH + SURROUND.projection;
162
+ const middle = (inner + outer) / 2;
163
+ const width = outer - inner;
164
+ const [side] = FIRST_SIDES as [FacadeSide];
165
+ return WINDOWS.filter((window) => SURROUNDED_WINDOWS.includes(window.id)).flatMap((window) => {
166
+ const opening = openingOf(window, side);
167
+ const plate = (suffix: string, start: Base.Point3, end: Base.Point3, horizontal: boolean): DetailSpec => ({
168
+ id: `${window.id}-surround-${suffix}`, name: "Window surround", storey: "first", layer: "first", material: "Anthracite aluminium",
169
+ start, end, width: horizontal ? width : t, depth: horizontal ? t : width,
170
+ });
171
+ return [
172
+ plate("head", point(side, opening.from, middle, opening.top - t / 2), point(side, opening.to, middle, opening.top - t / 2), true),
173
+ plate("sill", point(side, opening.from, middle, opening.bottom + t / 2), point(side, opening.to, middle, opening.bottom + t / 2), true),
174
+ plate("left", point(side, opening.from + t / 2, middle, opening.bottom + t), point(side, opening.from + t / 2, middle, opening.top - t), false),
175
+ plate("right", point(side, opening.to - t / 2, middle, opening.bottom + t), point(side, opening.to - t / 2, middle, opening.top - t), false),
176
+ ];
177
+ });
178
+ }
179
+
180
+ function windowSills(): DetailSpec[] {
181
+ return WINDOWS.filter((window) => SILLED_WINDOWS.includes(window.id)).map((window): DetailSpec => {
182
+ const side = sideOfWall(window.wall);
183
+ const opening = openingOf(window, side);
184
+ const inner = side.thickness / 2 + FRAME_DEPTH / 2;
185
+ const outer = FACADE_DEPTH + SILL.drip;
186
+ const z = opening.bottom + SILL.thickness / 2;
187
+ const storey = window.wall.startsWith("ff") ? "first" : "ground";
188
+ return {
189
+ id: `${window.id}-sill`, name: "Window sill", storey, layer: storey, material: "Anthracite aluminium",
190
+ start: point(side, opening.from, (inner + outer) / 2, z), end: point(side, opening.to, (inner + outer) / 2, z), width: outer - inner, depth: SILL.thickness,
191
+ };
192
+ });
193
+ }
194
+
195
+ function copings(): DetailSpec[] {
196
+ const inner = PARAPET_INSET - COPING.drip;
197
+ const outer = FACADE_DEPTH + COPING.drip;
198
+ const middle = (inner + outer) / 2;
199
+ const z = PARAPET_TOP + COPING.thickness / 2;
200
+ return FIRST_SIDES.map((side): DetailSpec => {
201
+ const [from, to] = side.along === "x" ? [-outer, FIRST_INTERIOR.x1 + outer] : [FIRST_INTERIOR.y0 - inner, FIRST_INTERIOR.y1 + inner];
202
+ return {
203
+ id: `${side.wall}-coping`, name: "Parapet coping", storey: "first", layer: "first", material: "Anthracite aluminium",
204
+ start: point(side, from, middle, z), end: point(side, to, middle, z), width: outer - inner, depth: COPING.thickness,
205
+ };
206
+ });
207
+ }
208
+
209
+ function solarArray(): DetailSpec[] {
210
+ const tilt = SOLAR.tilt * Math.PI / 180;
211
+ const slope = Math.tan(tilt);
212
+ const run = SOLAR.length * Math.cos(tilt);
213
+ const base = ROOF_TOP + SOLAR.lift;
214
+ const halfDepth = SOLAR.thickness / 2 / Math.cos(tilt);
215
+ const left = SOLAR.firstColumn - SOLAR.width / 2;
216
+ const right = SOLAR.firstColumn + (SOLAR.columns - 1) * (SOLAR.width + SOLAR.gap) + SOLAR.width / 2;
217
+ return SOLAR.rows.flatMap((y, row) => {
218
+ const rail = (id: string, near: number): DetailSpec => {
219
+ const top = base + (near - y) * slope - halfDepth - SOLAR_RAIL.clearance;
220
+ const middle = near + SOLAR_RAIL.width / 2;
221
+ return {
222
+ id, name: "Mounting rail", storey: "first", layer: "roof", material: "Anthracite aluminium", assembly: SOLAR_ARRAY,
223
+ start: [left, middle, (ROOF_TOP + top) / 2], end: [right, middle, (ROOF_TOP + top) / 2], width: SOLAR_RAIL.width, depth: top - ROOF_TOP,
224
+ };
225
+ };
226
+ const panels = Array.from({ length: SOLAR.columns }, (_, column): DetailSpec => {
227
+ const x = SOLAR.firstColumn + column * (SOLAR.width + SOLAR.gap);
228
+ return {
229
+ id: `solar-panel-${row}-${column}`, name: "Solar panel", storey: "first", layer: "roof", material: "Solar module", assembly: SOLAR_ARRAY,
230
+ start: [x, y, base], end: [x, y + run, base + run * slope], width: SOLAR.width, depth: SOLAR.thickness, kind: memberPredefinedTypeEnum.plate,
231
+ };
232
+ });
233
+ return [...panels, rail(`solar-rail-front-${row}`, y + SOLAR_RAIL.inset), rail(`solar-rail-back-${row}`, y + run - SOLAR_RAIL.inset - SOLAR_RAIL.width)];
234
+ });
235
+ }
236
+
237
+ function stairParts(): DetailSpec[] {
238
+ const [near, far] = STAIR.sides;
239
+ const slope = STAIR.riser / STAIR.going;
240
+ const nosing = (x: number): number => STAIR.riser + (STAIR.bottomEdge - x) * slope;
241
+ const treadMiddle = (step: number): number => STAIR.bottomEdge - (step - 0.5) * STAIR.going;
242
+ const steps = Array.from({ length: STAIR.risers - 1 }, (_, index) => index + 1);
243
+ const top = STAIR.voidEdge + 0.07;
244
+ const bottom = STAIR.bottomEdge + STRINGER.past;
245
+ const railBottom = STAIR.bottomEdge;
246
+ const railY = far + STRINGER.thickness + BALUSTER.radius;
247
+ const stringerY = far + STRINGER.thickness / 2;
248
+ const steel = { storey: "ground", layer: "ground", material: "Blackened steel" } as const;
249
+ return [
250
+ ...steps.map((step): DetailSpec => ({
251
+ id: `stair-tread-${step}`, name: `Tread ${step}`, storey: "ground", layer: "ground", material: "Oak",
252
+ start: [treadMiddle(step), near, step * STAIR.riser - STAIR.treadThickness / 2], end: [treadMiddle(step), far, step * STAIR.riser - STAIR.treadThickness / 2],
253
+ width: STAIR.treadDepth, depth: STAIR.treadThickness,
254
+ })),
255
+ {
256
+ ...steel, id: "stair-stringer", name: "Stair stringer", kind: memberPredefinedTypeEnum.stringer, width: STRINGER.thickness, depth: STRINGER.depth,
257
+ start: [bottom, stringerY, nosing(bottom) - STRINGER.below], end: [top, stringerY, nosing(top) - STRINGER.below],
258
+ },
259
+ ...([["stair-handrail-wall", near + HANDRAIL.wallGap], ["stair-handrail-open", railY]] as const).map(([id, y]): DetailSpec => ({
260
+ ...steel, id, name: "Handrail", radius: HANDRAIL.radius,
261
+ start: [railBottom, y, nosing(railBottom) + HANDRAIL.height], end: [top, y, nosing(top) + HANDRAIL.height],
262
+ })),
263
+ ...steps.map((step): DetailSpec => ({
264
+ ...steel, id: `stair-baluster-${step}`, name: "Baluster", radius: BALUSTER.radius, kind: memberPredefinedTypeEnum.post,
265
+ start: [treadMiddle(step), railY, step * STAIR.riser - BALUSTER.below],
266
+ end: [treadMiddle(step), railY, nosing(treadMiddle(step)) + HANDRAIL.height - HANDRAIL.radius - BALUSTER.underRail],
267
+ })),
268
+ ];
269
+ }
270
+
271
+ function rainwater(): DetailSpec[] {
272
+ const y = GROUND_INTERIOR.y1 + FACADE_DEPTH + DOWNPIPE.standoff;
273
+ const hopperBottom = FIRST_FLOOR_ELEVATION + PARAPET_TOP - HOPPER.belowCoping;
274
+ const aluminium = { storey: "ground", layer: "ground", material: "Anthracite aluminium" } as const;
275
+ return DOWNPIPE.positions.flatMap((x, index): DetailSpec[] => [
276
+ { ...aluminium, id: `downpipe-${index}`, name: "Downpipe", radius: DOWNPIPE.radius, start: [x, y, 0], end: [x, y, hopperBottom] },
277
+ { ...aluminium, id: `rainwater-hopper-${index}`, name: "Rainwater hopper", start: [x, y, hopperBottom], end: [x, y, hopperBottom + HOPPER.height], width: HOPPER.width, depth: HOPPER.depth },
278
+ ]);
279
+ }
280
+
281
+ function entranceCanopy(): DetailSpec[] {
282
+ const { from, to, fascia, slat, light } = CANOPY;
283
+ const wall = GROUND_INTERIOR.y1 + FACADE_DEPTH;
284
+ const front = wall + CANOPY.projection;
285
+ const t = fascia.thickness;
286
+ const fasciaZ = CANOPY.underside + fascia.depth / 2;
287
+ const coverZ = CANOPY.underside + fascia.depth - CANOPY.upstand - CANOPY.cover / 2;
288
+ const slatZ = CANOPY.underside + slat.above + slat.depth / 2;
289
+ const inner = { from: from + t, to: to - t, front: front - t };
290
+ const pitch = slat.width + slat.gap;
291
+ const count = Math.floor((inner.to - inner.from + slat.gap) / pitch);
292
+ const first = inner.from + (inner.to - inner.from - (count * pitch - slat.gap)) / 2 + slat.width / 2;
293
+ const metal = { storey: "ground", layer: "ground", material: "Anthracite aluminium" } as const;
294
+ return [
295
+ { ...metal, id: "canopy-fascia-front", name: "Canopy fascia", start: [from, front - t / 2, fasciaZ], end: [to, front - t / 2, fasciaZ], width: t, depth: fascia.depth, beam: true },
296
+ { ...metal, id: "canopy-fascia-left", name: "Canopy fascia", start: [from + t / 2, wall, fasciaZ], end: [from + t / 2, inner.front, fasciaZ], width: t, depth: fascia.depth, beam: true },
297
+ { ...metal, id: "canopy-fascia-right", name: "Canopy fascia", start: [to - t / 2, wall, fasciaZ], end: [to - t / 2, inner.front, fasciaZ], width: t, depth: fascia.depth, beam: true },
298
+ {
299
+ ...metal, id: "canopy-cover", name: "Canopy cover", kind: memberPredefinedTypeEnum.plate,
300
+ start: [inner.from, (wall + inner.front) / 2, coverZ], end: [inner.to, (wall + inner.front) / 2, coverZ], width: inner.front - wall, depth: CANOPY.cover,
301
+ },
302
+ ...Array.from({ length: count }, (_, index): DetailSpec => ({
303
+ id: `canopy-slat-${index}`, name: "Canopy soffit slat", storey: "ground", layer: "ground", material: "Smoked oak",
304
+ start: [first + index * pitch, wall, slatZ], end: [first + index * pitch, inner.front, slatZ], width: slat.width, depth: slat.depth,
305
+ })),
306
+ ...CANOPY.lights.map((x, index): DetailSpec => ({
307
+ id: `canopy-light-${index}`, name: "Downlight", storey: "ground", layer: "ground", material: "Brushed stainless steel", radius: light.radius,
308
+ start: [x, wall + light.out, CANOPY.underside + slat.above - light.depth], end: [x, wall + light.out, CANOPY.underside + slat.above],
309
+ })),
310
+ ];
311
+ }
312
+
313
+ function carportFrame(): DetailSpec[] {
314
+ const { x0, x1, y0, y1, beam, joist } = CARPORT;
315
+ const beamZ = CARPORT.clearance + beam.depth / 2;
316
+ const joistZ = CARPORT_DECK_BOTTOM - joist.depth / 2;
317
+ const inner = { x0: x0 + beam.width, y0: y0 + beam.width, y1: y1 - beam.width };
318
+ const ledgerX = x1 - CARPORT.ledger / 2;
319
+ const spacing = (inner.y1 - inner.y0) / (joist.count + 1);
320
+ const steel = { storey: "ground", layer: "garden", material: "Blackened steel", beam: true } as const;
321
+ return [
322
+ { ...steel, id: "carport-beam-outer", name: "Carport edge beam", start: [x0 + beam.width / 2, y0, beamZ], end: [x0 + beam.width / 2, y1, beamZ], width: beam.width, depth: beam.depth },
323
+ { ...steel, id: "carport-beam-south", name: "Carport edge beam", start: [inner.x0, y0 + beam.width / 2, beamZ], end: [x1, y0 + beam.width / 2, beamZ], width: beam.width, depth: beam.depth },
324
+ { ...steel, id: "carport-beam-north", name: "Carport edge beam", start: [inner.x0, y1 - beam.width / 2, beamZ], end: [x1, y1 - beam.width / 2, beamZ], width: beam.width, depth: beam.depth },
325
+ { ...steel, id: "carport-ledger", name: "Carport wall ledger", start: [ledgerX, inner.y0, joistZ], end: [ledgerX, inner.y1, joistZ], width: CARPORT.ledger, depth: joist.depth },
326
+ ...Array.from({ length: joist.count }, (_, index): DetailSpec => ({
327
+ id: `carport-joist-${index}`, name: "Carport joist", storey: "ground", layer: "garden", material: "Glulam spruce", beam: true,
328
+ start: [inner.x0, inner.y0 + (index + 1) * spacing, joistZ], end: [x1 - CARPORT.ledger, inner.y0 + (index + 1) * spacing, joistZ], width: joist.width, depth: joist.depth,
329
+ })),
330
+ ];
331
+ }
332
+
333
+ function glassRails(): DetailSpec[] {
334
+ const { shoe, cap, glass } = GLASS_RAIL;
335
+ return RAILS.flatMap((rail) => rail.runs.flatMap((run): DetailSpec[] => {
336
+ const [shoeStart, shoeEnd] = railLine(run, shoe.width);
337
+ const [capStart, capEnd] = railLine(run, cap.width);
338
+ const shoeZ = rail.base + shoe.depth / 2;
339
+ const capZ = rail.base + shoe.depth + glass + cap.depth / 2;
340
+ return [
341
+ {
342
+ id: `${rail.id}-shoe-${run.id}`, name: "Balustrade base shoe", storey: "first", layer: "first", material: "Anthracite aluminium",
343
+ start: [...shoeStart, shoeZ], end: [...shoeEnd, shoeZ], width: shoe.width, depth: shoe.depth,
344
+ },
345
+ {
346
+ id: `${rail.id}-cap-${run.id}`, name: "Balustrade handrail", storey: "first", layer: "first", material: "Brushed stainless steel",
347
+ start: [...capStart, capZ], end: [...capEnd, capZ], width: cap.width, depth: cap.depth,
348
+ },
349
+ ];
350
+ }));
351
+ }
352
+
353
+ function studyGlazing(): DetailSpec[] {
354
+ const { wall, line, x0, panes, frame } = STUDY_GLAZING;
355
+ const w = frame.width;
356
+ const studyDoor = DOORS.find((filling) => filling.wall === wall);
357
+ if (!studyDoor) {
358
+ throw new Error(`The plan has no door in '${wall}'`);
359
+ }
360
+ const door = openingOf(studyDoor, { wall, along: "x", line, outward: 1, start: x0, direction: 1, baseOffset: 0 });
361
+ const pane = (door.from - w - (x0 + w) - (panes - 1) * w) / panes;
362
+ const mullions = Array.from({ length: panes - 1 }, (_, index) => x0 + w + (index + 1) * pane + index * w);
363
+ const verticals = [x0, ...mullions, door.from - w, door.to];
364
+ const bays = verticals.flatMap((left, index) => {
365
+ const right = verticals[index + 1];
366
+ return right === undefined ? [] : [{ from: left + w, to: right, door: left + w === door.from }];
367
+ });
368
+ const faces = [line - thicknessOf("Glass partition") / 2 - frame.depth / 2, line + thicknessOf("Glass partition") / 2 + frame.depth / 2];
369
+ const steel = { storey: "first", layer: "first", material: "Blackened steel" } as const;
370
+ return faces.flatMap((y, face): DetailSpec[] => [
371
+ ...verticals.map((left, index): DetailSpec => ({
372
+ ...steel, id: `study-mullion-${face}-${index}`, name: "Glazing mullion", kind: memberPredefinedTypeEnum.mullion,
373
+ start: [left + w / 2, y, 0], end: [left + w / 2, y, FIRST_FLOOR_WALL_TOP], width: w, depth: frame.depth,
374
+ })),
375
+ ...bays.flatMap((bay, index): DetailSpec[] => {
376
+ const rails: [string, number][] = [["transom", door.top + w / 2], ["head", FIRST_FLOOR_WALL_TOP - w / 2], ...(bay.door ? [] : [["sill", w / 2] as [string, number]])];
377
+ return rails.map(([kind, z]): DetailSpec => ({
378
+ ...steel, id: `study-${kind}-${face}-${index}`, name: "Glazing rail", start: [bay.from, y, z], end: [bay.to, y, z], width: frame.depth, depth: w,
379
+ }));
380
+ }),
381
+ ]);
382
+ }
383
+
384
+ export function houseAssemblies(): AssemblySpec[] {
385
+ return [
386
+ ...FIRST_SIDES.map((side) => ({ id: claddingOf(side), name: `${facingOf(side)} cladding`, objectType: "Cladding" })),
387
+ { id: SOLAR_ARRAY, name: "Solar array", objectType: "Solar array" },
388
+ ];
389
+ }
390
+
391
+ export function houseDetails(): DetailSpec[] {
392
+ return [...claddingBoards(), ...flashings(), ...windowSurrounds(), ...windowSills(), ...copings(), ...solarArray(), ...stairParts(), ...rainwater(), ...entranceCanopy(), ...carportFrame(), ...glassRails(), ...studyGlazing()];
393
+ }