@kruschdev/pascal-plugin-plumbing 0.0.0-stage → 0.2.1

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.
@@ -0,0 +1,304 @@
1
+ /**
2
+ * 12 Clean-Room MIT Procedural 3D CAD Builders for Plumbing Fittings & Valves
3
+ * plus the Swept 3D Sloped Pipe-Run Builder (`buildPipeRunCad`).
4
+ * Zero React or `@pascal-app/editor` imports.
5
+ */
6
+
7
+ import {
8
+ BoxGeometry,
9
+ CylinderGeometry,
10
+ Group,
11
+ Mesh,
12
+ Quaternion,
13
+ SphereGeometry,
14
+ TorusGeometry,
15
+ Vector3,
16
+ } from 'three'
17
+ import type { Vec3 } from '../ipc/framing-interop'
18
+ import {
19
+ type PipeMaterial,
20
+ type PipeNominalSize,
21
+ type PlumbingSystem,
22
+ getPipeOuterDiameterM,
23
+ } from '../ipc/tables'
24
+ import { createPlumbingMaterialPool, pipeRunMaterialForSystem } from './materials'
25
+
26
+ export type FittingCadKind =
27
+ | 'p-trap'
28
+ | 'sanitary-tee'
29
+ | 'wye-combo'
30
+ | 'long-sweep-90'
31
+ | 'cleanout-tee'
32
+ | 'roof-vent-flashing'
33
+ | 'aav-studor'
34
+ | 'ball-valve'
35
+ | 'angle-stop'
36
+ | 'mixing-valve'
37
+ | 'gas-drip-leg'
38
+ | 'pipe-hanger-clevis'
39
+
40
+ export function buildFittingCad(kind: FittingCadKind): Group {
41
+ const pool = createPlumbingMaterialPool()
42
+ const g = new Group()
43
+ g.name = `plumbing-fitting-${kind}`
44
+
45
+ const add = (mesh: Mesh, x: number, y: number, z: number) => {
46
+ mesh.position.set(x, y, z)
47
+ mesh.castShadow = true
48
+ mesh.receiveShadow = true
49
+ g.add(mesh)
50
+ return mesh
51
+ }
52
+
53
+ switch (kind) {
54
+ case 'p-trap': {
55
+ add(new Mesh(new CylinderGeometry(0.025, 0.025, 0.12, 16), pool.pvcWhite), -0.055, 0.06, 0)
56
+ add(new Mesh(new TorusGeometry(0.055, 0.025, 12, 20, Math.PI), pool.pvcWhite), 0, 0, 0).rotation.x = Math.PI
57
+ add(new Mesh(new CylinderGeometry(0.025, 0.025, 0.09, 16), pool.pvcWhite), 0.055, 0.045, 0)
58
+ add(new Mesh(new CylinderGeometry(0.025, 0.025, 0.14, 16), pool.pvcWhite), 0.11, 0.09, 0).rotation.z = Math.PI / 2
59
+ break
60
+ }
61
+ case 'sanitary-tee': {
62
+ add(new Mesh(new CylinderGeometry(0.046, 0.046, 0.24, 18), pool.pvcWhite), 0, 0, 0)
63
+ add(new Mesh(new CylinderGeometry(0.036, 0.036, 0.12, 16), pool.pvcWhite), 0.07, 0.01, 0).rotation.z = Math.PI / 2
64
+ break
65
+ }
66
+ case 'wye-combo': {
67
+ add(new Mesh(new CylinderGeometry(0.046, 0.046, 0.28, 18), pool.pvcWhite), 0, 0, 0)
68
+ add(new Mesh(new CylinderGeometry(0.036, 0.036, 0.16, 16), pool.pvcWhite), 0.07, 0.05, 0).rotation.z = -Math.PI / 4
69
+ break
70
+ }
71
+ case 'long-sweep-90': {
72
+ add(new Mesh(new TorusGeometry(0.09, 0.038, 14, 24, Math.PI / 2), pool.pvcWhite), 0, 0, 0)
73
+ break
74
+ }
75
+ case 'cleanout-tee': {
76
+ add(new Mesh(new CylinderGeometry(0.052, 0.052, 0.24, 18), pool.pvcWhite), 0, 0, 0)
77
+ add(new Mesh(new CylinderGeometry(0.056, 0.056, 0.07, 18), pool.pvcWhite), 0.06, 0, 0).rotation.z = Math.PI / 2
78
+ add(new Mesh(new BoxGeometry(0.04, 0.04, 0.04), pool.brass), 0.11, 0, 0)
79
+ break
80
+ }
81
+ case 'roof-vent-flashing': {
82
+ add(new Mesh(new BoxGeometry(0.36, 0.012, 0.42), pool.galvanizedSteel), 0, 0, 0)
83
+ add(new Mesh(new CylinderGeometry(0.05, 0.085, 0.16, 18), pool.darkRubber), 0, 0.08, 0)
84
+ add(new Mesh(new CylinderGeometry(0.045, 0.045, 0.34, 16), pool.ventGreen), 0, 0.18, 0)
85
+ break
86
+ }
87
+ case 'aav-studor': {
88
+ add(new Mesh(new CylinderGeometry(0.025, 0.025, 0.09, 14), pool.pvcWhite), 0, 0, 0)
89
+ add(new Mesh(new CylinderGeometry(0.042, 0.038, 0.07, 18), pool.pvcWhite), 0, 0.075, 0)
90
+ break
91
+ }
92
+ case 'ball-valve': {
93
+ add(new Mesh(new CylinderGeometry(0.022, 0.022, 0.10, 16), pool.brass), 0, 0, 0).rotation.z = Math.PI / 2
94
+ add(new Mesh(new SphereGeometry(0.028, 16, 12), pool.brass), 0, 0, 0)
95
+ // Vertical brass stem connecting ball-valve body solidly to quarter-turn lever handle
96
+ add(new Mesh(new CylinderGeometry(0.007, 0.007, 0.028, 12), pool.brass), 0, 0.032, 0)
97
+ add(new Mesh(new BoxGeometry(0.11, 0.012, 0.02), pool.pexColdBlue), 0.04, 0.045, 0)
98
+ break
99
+ }
100
+ case 'angle-stop': {
101
+ add(new Mesh(new CylinderGeometry(0.014, 0.014, 0.06, 14), pool.chrome), 0, 0, 0).rotation.x = Math.PI / 2
102
+ add(new Mesh(new CylinderGeometry(0.012, 0.012, 0.05, 14), pool.chrome), 0, 0.025, 0.02)
103
+ // Stem connecting stop body solidly to oval quarter-turn handle
104
+ add(new Mesh(new CylinderGeometry(0.006, 0.006, 0.024, 12), pool.chrome), 0, 0, 0.034).rotation.x = Math.PI / 2
105
+ add(new Mesh(new CylinderGeometry(0.022, 0.018, 0.015, 14), pool.chrome), 0, 0, 0.045).rotation.x = Math.PI / 2
106
+ break
107
+ }
108
+ case 'mixing-valve': {
109
+ add(new Mesh(new CylinderGeometry(0.024, 0.024, 0.12, 16), pool.brass), 0, 0, 0).rotation.z = Math.PI / 2
110
+ add(new Mesh(new CylinderGeometry(0.022, 0.022, 0.09, 16), pool.brass), 0, 0.04, 0)
111
+ add(new Mesh(new CylinderGeometry(0.028, 0.028, 0.04, 16), pool.darkRubber), 0, 0.10, 0)
112
+ break
113
+ }
114
+ case 'gas-drip-leg': {
115
+ // IFGC 408.4 tee + vertical 4" sediment trap nipple + cap + yellow shutoff valve & handle
116
+ add(new Mesh(new CylinderGeometry(0.018, 0.018, 0.24, 14), pool.blackIron), 0, 0, 0)
117
+ add(new Mesh(new CylinderGeometry(0.024, 0.024, 0.03, 14), pool.blackIron), 0, -0.13, 0)
118
+ add(new Mesh(new CylinderGeometry(0.018, 0.018, 0.14, 14), pool.blackIron), 0.07, 0.03, 0).rotation.z = Math.PI / 2
119
+ add(new Mesh(new CylinderGeometry(0.023, 0.023, 0.045, 14), pool.brass), 0, 0.08, 0)
120
+ add(new Mesh(new BoxGeometry(0.08, 0.014, 0.02), pool.csstYellow), -0.02, 0.08, 0.026)
121
+ break
122
+ }
123
+ case 'pipe-hanger-clevis': {
124
+ add(new Mesh(new TorusGeometry(0.042, 0.006, 8, 18), pool.galvanizedSteel), 0, 0, 0)
125
+ add(new Mesh(new CylinderGeometry(0.005, 0.005, 0.18, 8), pool.galvanizedSteel), 0, 0.13, 0)
126
+ break
127
+ }
128
+ }
129
+
130
+ return g
131
+ }
132
+
133
+ const UP = new Vector3(0, 1, 0)
134
+ const X_AXIS = new Vector3(1, 0, 0)
135
+
136
+ function safeQuatFromUp(dir: Vector3): Quaternion {
137
+ if (dir.y < -0.99999) {
138
+ return new Quaternion().setFromAxisAngle(X_AXIS, Math.PI)
139
+ }
140
+ return new Quaternion().setFromUnitVectors(UP, dir)
141
+ }
142
+
143
+ /**
144
+ * Build a swept 3D cylindrical pipe run with smooth corner joints, coupling hubs,
145
+ * periodic hangers, and system color coding.
146
+ */
147
+ export function buildPipeRunCad(params: {
148
+ id: string
149
+ path: ReadonlyArray<Vec3>
150
+ system: PlumbingSystem
151
+ material: PipeMaterial
152
+ nominalSize: PipeNominalSize
153
+ hasCleanout?: boolean
154
+ penetrations?: ReadonlyArray<{
155
+ position: Vec3
156
+ pipeDirection: Vec3
157
+ wallNormal?: readonly [number, number]
158
+ studDepthM?: number
159
+ holeSawIn: number
160
+ needsNailPlate: boolean
161
+ codeCompliant: boolean
162
+ memberKind: 'stud' | 'sole-plate' | 'top-plate' | 'floor-joist'
163
+ }>
164
+ }): Group {
165
+ const { id, path, system, material, nominalSize, hasCleanout = false, penetrations = [] } = params
166
+ const pool = createPlumbingMaterialPool()
167
+ const g = new Group()
168
+ g.name = `plumbing-pipe-run-${id}`
169
+
170
+ if (path.length < 2) return g
171
+
172
+ const mat = pipeRunMaterialForSystem(pool, system, material)
173
+ const odM = getPipeOuterDiameterM(nominalSize, material)
174
+ const radius = Math.max(0.009, odM / 2)
175
+ const hubRadius = radius * 1.18
176
+ const isRigid = material !== 'pex-a' && material !== 'pex-b' && material !== 'csst'
177
+
178
+ // Shared unit geometries lazily allocated and reused across segments, elbows, collars, and nail plates in this run
179
+ let unitSegGeo: CylinderGeometry | null = null
180
+ let jointGeo: SphereGeometry | null = null
181
+ let collarGeo: CylinderGeometry | null = null
182
+ let studNailPlateGeo: BoxGeometry | null = null
183
+ let plateNailPlateGeo: BoxGeometry | null = null
184
+ let firstValidSeg: { start: Vector3; dir: Vector3; len: number } | null = null
185
+
186
+ for (let i = 1; i < path.length; i++) {
187
+ const a = new Vector3(path[i - 1]![0], path[i - 1]![1], path[i - 1]![2])
188
+ const b = new Vector3(path[i]![0], path[i]![1], path[i]![2])
189
+ const delta = new Vector3().subVectors(b, a)
190
+ const len = delta.length()
191
+ if (len < 0.005) continue
192
+
193
+ const dir = delta.clone().normalize()
194
+ if (!firstValidSeg) {
195
+ firstValidSeg = { start: a.clone(), dir: dir.clone(), len }
196
+ }
197
+ const quat = safeQuatFromUp(dir)
198
+ const mid = new Vector3().addVectors(a, b).multiplyScalar(0.5)
199
+
200
+ unitSegGeo ??= new CylinderGeometry(radius, radius, 1, 12)
201
+ const seg = new Mesh(unitSegGeo, mat)
202
+ seg.position.copy(mid)
203
+ seg.quaternion.copy(quat)
204
+ seg.scale.set(1, len, 1)
205
+ seg.castShadow = true
206
+ seg.receiveShadow = true
207
+ g.add(seg)
208
+
209
+ // Smooth elbow/wye joint sphere at vertices
210
+ if (i < path.length - 1) {
211
+ jointGeo ??= new SphereGeometry(isRigid ? hubRadius : radius * 1.06, 12, 10)
212
+ const joint = new Mesh(jointGeo, mat)
213
+ joint.position.copy(b)
214
+ g.add(joint)
215
+ }
216
+
217
+ // Coupling hubs every ~3.05 m (10 ft) on rigid pipe
218
+ if (isRigid && len > 3.2) {
219
+ collarGeo ??= new CylinderGeometry(hubRadius, hubRadius, 0.055, 12)
220
+ const hubs = Math.floor(len / 3.05)
221
+ for (let h = 1; h <= hubs; h++) {
222
+ const pt = a.clone().addScaledVector(dir, h * 3.05)
223
+ const collar = new Mesh(collarGeo, mat)
224
+ collar.position.copy(pt)
225
+ collar.quaternion.copy(quat)
226
+ g.add(collar)
227
+ }
228
+ }
229
+ }
230
+
231
+ // Optional cleanout plug boss oriented perpendicular to the first valid pipe segment
232
+ if (hasCleanout && firstValidSeg) {
233
+ const { start, dir, len } = firstValidSeg
234
+ const horizLen = Math.hypot(dir.x, dir.z)
235
+ const perp =
236
+ horizLen > 1e-4
237
+ ? new Vector3(-dir.z / horizLen, 0, dir.x / horizLen)
238
+ : new Vector3(0, 0, 1)
239
+ const plug = new Mesh(new CylinderGeometry(hubRadius * 1.15, hubRadius * 1.15, 0.08, 14), pool.brass)
240
+ plug.position
241
+ .copy(start)
242
+ .addScaledVector(dir, Math.min(0.06, len * 0.5))
243
+ .addScaledVector(perp, hubRadius)
244
+ plug.quaternion.copy(safeQuatFromUp(perp))
245
+ g.add(plug)
246
+ }
247
+
248
+ // Framing Penetration 3D Bore Sleeves & IRC R602.6 / IPC 305.6 Nail Plates (oriented to wall normal on both faces)
249
+ const sleeveGeoCache = new Map<string, CylinderGeometry>()
250
+ for (const pen of penetrations) {
251
+ const boreR = Math.max(radius * 1.15, (pen.holeSawIn * 0.0254) / 2)
252
+ const rawDir = new Vector3(pen.pipeDirection[0], pen.pipeDirection[1], pen.pipeDirection[2])
253
+ const pDir = rawDir.lengthSq() < 1e-8 ? UP.clone() : rawDir.normalize()
254
+ const quat = safeQuatFromUp(pDir)
255
+ const sleeveMat = pen.codeCompliant ? pool.darkRubber : pool.pexHotRed
256
+ const sleeveLen = pen.memberKind === 'top-plate' ? 0.082 : 0.044 // Proud of 1.5" stud or 3" double top plate by ~3 mm
257
+ const sleeveKey = `${boreR.toFixed(4)}|${sleeveLen}`
258
+ let sleeveGeo = sleeveGeoCache.get(sleeveKey)
259
+ if (!sleeveGeo) {
260
+ sleeveGeo = new CylinderGeometry(boreR, boreR, sleeveLen, 16, 1, true)
261
+ sleeveGeoCache.set(sleeveKey, sleeveGeo)
262
+ }
263
+ const sleeve = new Mesh(sleeveGeo, sleeveMat)
264
+ sleeve.position.set(pen.position[0], pen.position[1], pen.position[2])
265
+ sleeve.quaternion.copy(quat)
266
+ g.add(sleeve)
267
+
268
+ // Protective steel nail plates on both framing faces when edge clearance < 1-1/4" (studs and bored plates)
269
+ if (
270
+ pen.needsNailPlate &&
271
+ (pen.memberKind === 'stud' || pen.memberKind === 'sole-plate' || pen.memberKind === 'top-plate')
272
+ ) {
273
+ const isPlate = pen.memberKind !== 'stud'
274
+ let activePlateGeo: BoxGeometry
275
+ if (isPlate) {
276
+ plateNailPlateGeo ??= new BoxGeometry(0.127, 0.042, 0.005)
277
+ activePlateGeo = plateNailPlateGeo
278
+ } else {
279
+ studNailPlateGeo ??= new BoxGeometry(0.042, 0.127, 0.005)
280
+ activePlateGeo = studNailPlateGeo
281
+ }
282
+ const rawNx = pen.wallNormal?.[0] ?? 0
283
+ const rawNz = pen.wallNormal?.[1] ?? 1
284
+ const nLen = Math.hypot(rawNx, rawNz)
285
+ const nx = nLen > 1e-5 ? rawNx / nLen : 0
286
+ const nz = nLen > 1e-5 ? rawNz / nLen : 1
287
+ const studHalfDepth = (pen.studDepthM ?? 0.0889) / 2
288
+ const faceOffset = studHalfDepth + 0.003
289
+ const yaw = Math.atan2(nx, nz)
290
+ for (const side of [1, -1] as const) {
291
+ const plate = new Mesh(activePlateGeo, pool.galvanizedSteel)
292
+ plate.position.set(
293
+ pen.position[0] + nx * side * faceOffset,
294
+ pen.position[1],
295
+ pen.position[2] + nz * side * faceOffset,
296
+ )
297
+ plate.rotation.y = yaw
298
+ g.add(plate)
299
+ }
300
+ }
301
+ }
302
+
303
+ return g
304
+ }
@@ -0,0 +1,255 @@
1
+ /**
2
+ * 18 Clean-Room MIT Procedural 3D CAD Builders for Residential & Commercial Plumbing Fixtures.
3
+ * Zero React or `@pascal-app/editor` imports.
4
+ */
5
+
6
+ import { BoxGeometry, CylinderGeometry, Group, Mesh, SphereGeometry, TorusGeometry } from 'three'
7
+ import type { FixtureKind } from '../ipc/tables'
8
+ import { createPlumbingMaterialPool } from './materials'
9
+
10
+ export function buildFixtureCad(params: { fixtureKind: FixtureKind; roughInOnly?: boolean }): Group {
11
+ const { fixtureKind, roughInOnly = false } = params
12
+ const pool = createPlumbingMaterialPool()
13
+ const g = new Group()
14
+ g.name = roughInOnly ? `plumbing-roughin-${fixtureKind}` : `plumbing-fixture-${fixtureKind}`
15
+
16
+ const add = (mesh: Mesh, x: number, y: number, z: number) => {
17
+ mesh.position.set(x, y, z)
18
+ mesh.castShadow = true
19
+ mesh.receiveShadow = true
20
+ g.add(mesh)
21
+ return mesh
22
+ }
23
+
24
+ // Compact rough-in stub-out mode when linked to a placed real-world catalog SKU / furnishing
25
+ // so zero duplicate porcelain/cabinet/tub meshes Z-fight with the real fixture.
26
+ if (roughInOnly && fixtureKind !== 'clothes-washer' && fixtureKind !== 'hose-bibb' && fixtureKind !== 'garbage-disposal') {
27
+ const addAngleStop = (x: number, y: number, z: number, mat: typeof pool.pexColdBlue) => {
28
+ // Wall escutcheon flange + quarter-turn chrome stop body + colored PEX stub-out
29
+ add(new Mesh(new CylinderGeometry(0.026, 0.026, 0.008, 14), pool.chrome), x, y, z - 0.04).rotation.x = Math.PI / 2
30
+ add(new Mesh(new CylinderGeometry(0.011, 0.011, 0.075, 10), mat), x, y, z - 0.01).rotation.x = Math.PI / 2
31
+ add(new Mesh(new CylinderGeometry(0.014, 0.014, 0.032, 12), pool.chrome), x, y + 0.012, z + 0.02)
32
+ add(new Mesh(new BoxGeometry(0.036, 0.008, 0.014), pool.chrome), x, y + 0.028, z + 0.028)
33
+ }
34
+
35
+ switch (fixtureKind) {
36
+ case 'water-closet': {
37
+ // 3" PVC closet flange on floor + rear-left 1/2" cold-water angle stop (no hot water!)
38
+ add(new Mesh(new CylinderGeometry(0.088, 0.088, 0.016, 20), pool.pvcWhite), 0, 0.008, 0)
39
+ add(new Mesh(new CylinderGeometry(0.045, 0.045, 0.14, 16), pool.pvcWhite), 0, 0.07, 0)
40
+ addAngleStop(-0.14, 0.15, -0.22, pool.pexColdBlue)
41
+ return g
42
+ }
43
+ case 'lavatory':
44
+ case 'bar-sink':
45
+ case 'kitchen-sink':
46
+ case 'laundry-sink':
47
+ case 'mop-sink': {
48
+ const stubY = fixtureKind === 'lavatory' ? 0.53 : fixtureKind === 'mop-sink' ? 0.28 : 0.46
49
+ const wallZ = fixtureKind === 'kitchen-sink' || fixtureKind === 'laundry-sink' ? -0.20 : -0.18
50
+ // Rear DWV stub-out + hot (left) and cold (right) quarter-turn angle stops
51
+ add(new Mesh(new CylinderGeometry(0.024, 0.024, 0.14, 14), pool.pvcWhite), 0, stubY - 0.04, wallZ + 0.04).rotation.x = Math.PI / 2
52
+ add(new Mesh(new CylinderGeometry(0.036, 0.036, 0.01, 14), pool.chrome), 0, stubY - 0.04, wallZ - 0.02).rotation.x = Math.PI / 2
53
+ addAngleStop(-0.08, stubY, wallZ, pool.pexHotRed)
54
+ addAngleStop(0.08, stubY, wallZ, pool.pexColdBlue)
55
+ return g
56
+ }
57
+ case 'bathtub':
58
+ case 'shower':
59
+ case 'tub-shower-combo': {
60
+ // Floor drain waste hub + concealed brass pressure-balance rough-in valve body w/ hot & cold drops
61
+ add(new Mesh(new CylinderGeometry(0.042, 0.042, 0.10, 16), pool.pvcWhite), 0, 0.05, 0)
62
+ add(new Mesh(new CylinderGeometry(0.055, 0.055, 0.014, 16), pool.chrome), 0, 0.012, 0)
63
+ const valveY = fixtureKind === 'shower' ? 1.12 : 0.84
64
+ const valveZ = fixtureKind === 'shower' ? -0.40 : -0.32
65
+ add(new Mesh(new BoxGeometry(0.11, 0.08, 0.05), pool.brass), 0, valveY, valveZ)
66
+ add(new Mesh(new CylinderGeometry(0.009, 0.009, valveY - 0.1, 10), pool.pexHotRed), -0.08, (valveY + 0.1) / 2, valveZ)
67
+ add(new Mesh(new CylinderGeometry(0.009, 0.009, valveY - 0.1, 10), pool.pexColdBlue), 0.08, (valveY + 0.1) / 2, valveZ)
68
+ return g
69
+ }
70
+ case 'dishwasher': {
71
+ // Hot-water-only angle stop + indirect drain barb stub-out
72
+ addAngleStop(-0.08, 0.40, -0.20, pool.pexHotRed)
73
+ add(new Mesh(new CylinderGeometry(0.018, 0.018, 0.10, 12), pool.pvcWhite), 0.06, 0.36, -0.18).rotation.x = Math.PI / 2
74
+ return g
75
+ }
76
+ case 'bidet': {
77
+ add(new Mesh(new CylinderGeometry(0.036, 0.036, 0.10, 14), pool.pvcWhite), 0, 0.05, 0)
78
+ addAngleStop(-0.08, 0.20, -0.20, pool.pexHotRed)
79
+ addAngleStop(0.08, 0.20, -0.20, pool.pexColdBlue)
80
+ return g
81
+ }
82
+ case 'urinal': {
83
+ add(new Mesh(new CylinderGeometry(0.030, 0.030, 0.12, 14), pool.pvcWhite), 0, 0.46, -0.10).rotation.x = Math.PI / 2
84
+ addAngleStop(0, 0.96, -0.10, pool.pexColdBlue)
85
+ return g
86
+ }
87
+ case 'drinking-fountain': {
88
+ add(new Mesh(new CylinderGeometry(0.022, 0.022, 0.10, 12), pool.pvcWhite), 0, 0.48, -0.12).rotation.x = Math.PI / 2
89
+ addAngleStop(0.06, 0.56, -0.12, pool.pexColdBlue)
90
+ return g
91
+ }
92
+ case 'floor-drain':
93
+ case 'grease-interceptor':
94
+ break
95
+ }
96
+ }
97
+
98
+ switch (fixtureKind) {
99
+ case 'water-closet': {
100
+ // Base pedestal, elongated bowl, rear bowl-to-tank deck bridge, tank, chrome flush lever, cold supply riser
101
+ add(new Mesh(new CylinderGeometry(0.14, 0.17, 0.36, 20), pool.porcelain), 0, 0.18, 0.06)
102
+ add(new Mesh(new CylinderGeometry(0.19, 0.15, 0.12, 22), pool.porcelain), 0, 0.38, 0.12)
103
+ add(new Mesh(new BoxGeometry(0.24, 0.10, 0.18), pool.porcelain), 0, 0.38, -0.08)
104
+ add(new Mesh(new BoxGeometry(0.40, 0.38, 0.19), pool.porcelain), 0, 0.56, -0.18)
105
+ add(new Mesh(new BoxGeometry(0.42, 0.03, 0.21), pool.porcelain), 0, 0.76, -0.18)
106
+ add(new Mesh(new BoxGeometry(0.06, 0.015, 0.02), pool.chrome), -0.15, 0.68, -0.075)
107
+ add(new Mesh(new CylinderGeometry(0.010, 0.010, 0.29, 10), pool.chrome), -0.14, 0.245, -0.21)
108
+ break
109
+ }
110
+
111
+ case 'lavatory':
112
+ case 'bar-sink': {
113
+ const w = fixtureKind === 'bar-sink' ? 0.46 : 0.60
114
+ const d = fixtureKind === 'bar-sink' ? 0.44 : 0.48
115
+ // Counter/basin deck + faucet + chrome P-trap & dual supply risers connected solidly to underside
116
+ add(new Mesh(new BoxGeometry(w, 0.08, d), pool.porcelain), 0, 0.80, 0)
117
+ add(new Mesh(new CylinderGeometry(0.14, 0.10, 0.16, 20), pool.porcelain), 0, 0.70, 0.02)
118
+ add(new Mesh(new CylinderGeometry(0.016, 0.018, 0.14, 12), pool.chrome), 0, 0.89, -d * 0.34)
119
+ add(new Mesh(new CylinderGeometry(0.012, 0.012, 0.12, 12), pool.chrome), 0, 0.94, -d * 0.22).rotation.x = Math.PI / 2
120
+ // Under-sink drain tailpiece, oriented YZ P-trap U-bend, trap arm, and H/C supply risers up to counter deck
121
+ add(new Mesh(new CylinderGeometry(0.020, 0.020, 0.26, 12), pool.pvcWhite), 0, 0.50, 0)
122
+ const pTrap = add(new Mesh(new TorusGeometry(0.045, 0.019, 10, 16, Math.PI), pool.pvcWhite), 0, 0.37, -0.045)
123
+ pTrap.rotation.set(Math.PI, Math.PI / 2, 0)
124
+ add(new Mesh(new CylinderGeometry(0.019, 0.019, 0.10, 12), pool.pvcWhite), 0, 0.37, -0.14).rotation.x = Math.PI / 2
125
+ add(new Mesh(new CylinderGeometry(0.009, 0.009, 0.40, 8), pool.pexHotRed), -0.10, 0.59, -0.14)
126
+ add(new Mesh(new CylinderGeometry(0.009, 0.009, 0.40, 8), pool.pexColdBlue), 0.10, 0.59, -0.14)
127
+ break
128
+ }
129
+
130
+ case 'kitchen-sink':
131
+ case 'laundry-sink': {
132
+ const isKitchen = fixtureKind === 'kitchen-sink'
133
+ const w = isKitchen ? 0.84 : 0.62
134
+ add(new Mesh(new BoxGeometry(w, 0.05, 0.54), pool.chrome), 0, 0.88, 0)
135
+ add(new Mesh(new BoxGeometry(w - 0.08, 0.22, 0.44), pool.galvanizedSteel), 0, 0.75, 0)
136
+ // High-arc gooseneck faucet
137
+ add(new Mesh(new CylinderGeometry(0.018, 0.022, 0.24, 14), pool.chrome), 0, 1.01, -0.21)
138
+ add(new Mesh(new TorusGeometry(0.08, 0.014, 10, 18, Math.PI), pool.chrome), 0, 1.13, -0.13).rotation.y = Math.PI / 2
139
+ // Drain tailpiece & H/C supply risers
140
+ add(new Mesh(new CylinderGeometry(0.024, 0.024, 0.28, 12), pool.pvcWhite), 0, 0.52, 0)
141
+ add(new Mesh(new CylinderGeometry(0.010, 0.010, 0.36, 8), pool.pexHotRed), -0.12, 0.58, -0.16)
142
+ add(new Mesh(new CylinderGeometry(0.010, 0.010, 0.36, 8), pool.pexColdBlue), 0.12, 0.58, -0.16)
143
+ break
144
+ }
145
+
146
+ case 'bathtub':
147
+ case 'tub-shower-combo': {
148
+ add(new Mesh(new BoxGeometry(1.52, 0.46, 0.76), pool.porcelain), 0, 0.23, 0)
149
+ add(new Mesh(new BoxGeometry(1.36, 0.34, 0.60), pool.enamelSteel), 0, 0.31, 0)
150
+ // Continuous vertical copper rough-in riser tying tub deck -> tub spout -> mixing valve (-> shower arm)
151
+ if (fixtureKind === 'tub-shower-combo') {
152
+ add(new Mesh(new CylinderGeometry(0.012, 0.012, 1.76, 10), pool.copper), -0.75, 1.12, 0)
153
+ } else {
154
+ add(new Mesh(new CylinderGeometry(0.012, 0.012, 0.66, 10), pool.copper), -0.75, 0.57, 0)
155
+ }
156
+ // Mixing valve trim & tub spout at head end
157
+ add(new Mesh(new CylinderGeometry(0.055, 0.055, 0.025, 16), pool.chrome), -0.74, 0.86, 0).rotation.z = Math.PI / 2
158
+ add(new Mesh(new CylinderGeometry(0.018, 0.018, 0.14, 12), pool.chrome), -0.69, 0.62, 0).rotation.z = Math.PI / 2
159
+ if (fixtureKind === 'tub-shower-combo') {
160
+ // Horizontal chrome shower arm + angled shower head
161
+ add(new Mesh(new CylinderGeometry(0.011, 0.011, 0.15, 10), pool.chrome), -0.69, 1.98, 0).rotation.z = Math.PI / 2
162
+ add(new Mesh(new CylinderGeometry(0.045, 0.025, 0.06, 16), pool.chrome), -0.63, 1.96, 0).rotation.z = -Math.PI / 4
163
+ }
164
+ break
165
+ }
166
+
167
+ case 'shower': {
168
+ add(new Mesh(new BoxGeometry(0.96, 0.10, 0.96), pool.porcelain), 0, 0.05, 0)
169
+ add(new Mesh(new CylinderGeometry(0.055, 0.055, 0.02, 16), pool.chrome), 0, 0.105, 0)
170
+ // Full-height rough-in riser from shower base up to shower arm & head
171
+ add(new Mesh(new CylinderGeometry(0.014, 0.014, 1.94, 12), pool.copper), 0, 1.03, -0.45)
172
+ add(new Mesh(new CylinderGeometry(0.06, 0.06, 0.025, 18), pool.chrome), 0, 1.15, -0.43).rotation.x = Math.PI / 2
173
+ add(new Mesh(new CylinderGeometry(0.011, 0.011, 0.14, 10), pool.chrome), 0, 1.99, -0.39).rotation.x = Math.PI / 2
174
+ add(new Mesh(new CylinderGeometry(0.055, 0.024, 0.06, 16), pool.chrome), 0, 1.97, -0.33).rotation.x = Math.PI / 4
175
+ break
176
+ }
177
+
178
+ case 'clothes-washer': {
179
+ // Recessed washer outlet box + red/blue quarter-turn ball valves + 2" standpipe
180
+ add(new Mesh(new BoxGeometry(0.24, 0.22, 0.10), pool.pvcWhite), 0, 0, 0)
181
+ add(new Mesh(new CylinderGeometry(0.018, 0.018, 0.06, 10), pool.pexHotRed), -0.06, 0.02, 0.03)
182
+ add(new Mesh(new CylinderGeometry(0.018, 0.018, 0.06, 10), pool.pexColdBlue), 0.06, 0.02, 0.03)
183
+ add(new Mesh(new CylinderGeometry(0.029, 0.029, 0.65, 14), pool.pvcWhite), 0, -0.42, 0)
184
+ break
185
+ }
186
+
187
+ case 'dishwasher': {
188
+ add(new Mesh(new BoxGeometry(0.58, 0.82, 0.56), pool.galvanizedSteel), 0, 0.41, 0)
189
+ add(new Mesh(new BoxGeometry(0.46, 0.04, 0.03), pool.chrome), 0, 0.74, 0.29)
190
+ break
191
+ }
192
+
193
+ case 'garbage-disposal': {
194
+ add(new Mesh(new CylinderGeometry(0.095, 0.085, 0.30, 18), pool.absBlack), 0, 0, 0)
195
+ add(new Mesh(new CylinderGeometry(0.048, 0.048, 0.05, 16), pool.chrome), 0, 0.17, 0)
196
+ add(new Mesh(new CylinderGeometry(0.020, 0.020, 0.10, 12), pool.pvcWhite), 0.11, 0.02, 0).rotation.z = Math.PI / 2
197
+ break
198
+ }
199
+
200
+ case 'hose-bibb': {
201
+ // Frost-proof 12" stem + brass flange + angled sillcock + vacuum breaker cap
202
+ add(new Mesh(new CylinderGeometry(0.014, 0.014, 0.30, 12), pool.copper), 0, 0, -0.12).rotation.x = Math.PI / 2
203
+ add(new Mesh(new CylinderGeometry(0.038, 0.038, 0.016, 16), pool.brass), 0, 0, 0.02).rotation.x = Math.PI / 2
204
+ add(new Mesh(new CylinderGeometry(0.018, 0.018, 0.09, 12), pool.brass), 0, -0.02, 0.07).rotation.x = Math.PI / 3
205
+ add(new Mesh(new CylinderGeometry(0.022, 0.022, 0.03, 14), pool.chrome), 0, 0.035, 0.05) // Anti-siphon vacuum breaker
206
+ add(new Mesh(new TorusGeometry(0.032, 0.008, 8, 16), pool.pexColdBlue), 0, 0.01, 0.11) // Handwheel
207
+ break
208
+ }
209
+
210
+ case 'floor-drain': {
211
+ add(new Mesh(new CylinderGeometry(0.08, 0.08, 0.02, 20), pool.chrome), 0, 0.01, 0)
212
+ add(new Mesh(new CylinderGeometry(0.032, 0.032, 0.22, 16), pool.castIron), 0, -0.11, 0)
213
+ break
214
+ }
215
+
216
+ case 'bidet': {
217
+ add(new Mesh(new CylinderGeometry(0.14, 0.15, 0.36, 20), pool.porcelain), 0, 0.18, 0)
218
+ add(new Mesh(new SphereGeometry(0.18, 18, 12), pool.porcelain), 0, 0.34, 0.04)
219
+ add(new Mesh(new CylinderGeometry(0.014, 0.014, 0.08, 12), pool.chrome), 0, 0.42, -0.15)
220
+ break
221
+ }
222
+
223
+ case 'urinal': {
224
+ add(new Mesh(new BoxGeometry(0.36, 0.56, 0.28), pool.porcelain), 0, 0.65, 0)
225
+ add(new Mesh(new CylinderGeometry(0.025, 0.025, 0.24, 14), pool.chrome), 0, 1.05, -0.08)
226
+ add(new Mesh(new BoxGeometry(0.10, 0.02, 0.02), pool.chrome), 0.06, 1.08, -0.08)
227
+ break
228
+ }
229
+
230
+ case 'mop-sink': {
231
+ add(new Mesh(new BoxGeometry(0.61, 0.28, 0.61), pool.porcelain), 0, 0.14, 0)
232
+ add(new Mesh(new CylinderGeometry(0.045, 0.045, 0.02, 14), pool.chrome), 0, 0.05, 0)
233
+ // Stainless wall guard backing connecting basin rim up to service faucet body
234
+ add(new Mesh(new BoxGeometry(0.32, 0.48, 0.02), pool.galvanizedSteel), 0, 0.50, -0.30)
235
+ add(new Mesh(new BoxGeometry(0.22, 0.06, 0.08), pool.chrome), 0, 0.68, -0.28)
236
+ break
237
+ }
238
+
239
+ case 'drinking-fountain': {
240
+ add(new Mesh(new BoxGeometry(0.46, 0.48, 0.42), pool.galvanizedSteel), 0, 0.72, 0)
241
+ add(new Mesh(new CylinderGeometry(0.014, 0.014, 0.09, 10), pool.chrome), 0.10, 0.99, 0.08)
242
+ break
243
+ }
244
+
245
+ case 'grease-interceptor': {
246
+ add(new Mesh(new BoxGeometry(0.84, 0.46, 0.56), pool.enamelBlue), 0, 0.23, 0)
247
+ add(new Mesh(new BoxGeometry(0.86, 0.04, 0.58), pool.castIron), 0, 0.48, 0)
248
+ add(new Mesh(new CylinderGeometry(0.042, 0.042, 0.14, 14), pool.castIron), -0.48, 0.30, 0).rotation.z = Math.PI / 2
249
+ add(new Mesh(new CylinderGeometry(0.042, 0.042, 0.14, 14), pool.castIron), 0.48, 0.26, 0).rotation.z = Math.PI / 2
250
+ break
251
+ }
252
+ }
253
+
254
+ return g
255
+ }
@@ -0,0 +1,6 @@
1
+ export * from './materials'
2
+ export * from './equipment'
3
+ export * from './fixtures'
4
+ export * from './fittings'
5
+ export * from './manifold-interior'
6
+ export * from './catalog'