@kruschdev/pascal-plugin-plumbing 0.0.0-stage → 0.3.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.
@@ -0,0 +1,322 @@
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 isFiniteVec3Pt(p: unknown): p is Vec3 {
137
+ return (
138
+ Array.isArray(p) &&
139
+ p.length >= 3 &&
140
+ typeof p[0] === 'number' &&
141
+ typeof p[1] === 'number' &&
142
+ typeof p[2] === 'number' &&
143
+ Number.isFinite(p[0]) &&
144
+ Number.isFinite(p[1]) &&
145
+ Number.isFinite(p[2])
146
+ )
147
+ }
148
+
149
+ function safeQuatFromUp(dir: Vector3): Quaternion {
150
+ if (dir.y < -0.99999) {
151
+ return new Quaternion().setFromAxisAngle(X_AXIS, Math.PI)
152
+ }
153
+ return new Quaternion().setFromUnitVectors(UP, dir)
154
+ }
155
+
156
+ /**
157
+ * Build a swept 3D cylindrical pipe run with smooth corner joints, coupling hubs,
158
+ * periodic hangers, and system color coding.
159
+ */
160
+ export function buildPipeRunCad(params: {
161
+ id: string
162
+ path: ReadonlyArray<Vec3>
163
+ system: PlumbingSystem
164
+ material: PipeMaterial
165
+ nominalSize: PipeNominalSize
166
+ hasCleanout?: boolean
167
+ penetrations?: ReadonlyArray<{
168
+ position: Vec3
169
+ pipeDirection: Vec3
170
+ wallNormal?: readonly [number, number]
171
+ studDepthM?: number
172
+ holeSawIn: number
173
+ needsNailPlate: boolean
174
+ codeCompliant: boolean
175
+ memberKind: 'stud' | 'sole-plate' | 'top-plate' | 'floor-joist'
176
+ }>
177
+ }): Group {
178
+ const { id, path, system, material, nominalSize, hasCleanout = false, penetrations = [] } = params
179
+ const pool = createPlumbingMaterialPool()
180
+ const g = new Group()
181
+ g.name = `plumbing-pipe-run-${id}`
182
+
183
+ const validPath = path.filter(isFiniteVec3Pt)
184
+ if (validPath.length < 2) return g
185
+
186
+ const mat = pipeRunMaterialForSystem(pool, system, material)
187
+ const odM = getPipeOuterDiameterM(nominalSize, material)
188
+ const radius = Math.max(0.009, odM / 2)
189
+ const hubRadius = radius * 1.18
190
+ const isRigid = material !== 'pex-a' && material !== 'pex-b' && material !== 'csst'
191
+
192
+ // Shared unit geometries lazily allocated and reused across segments, elbows, collars, and nail plates in this run
193
+ let unitSegGeo: CylinderGeometry | null = null
194
+ let jointGeo: SphereGeometry | null = null
195
+ let collarGeo: CylinderGeometry | null = null
196
+ let studNailPlateGeo: BoxGeometry | null = null
197
+ let plateNailPlateGeo: BoxGeometry | null = null
198
+ let firstValidSeg: { start: Vector3; dir: Vector3; len: number } | null = null
199
+
200
+ for (let i = 1; i < validPath.length; i++) {
201
+ const a = new Vector3(validPath[i - 1]![0], validPath[i - 1]![1], validPath[i - 1]![2])
202
+ const b = new Vector3(validPath[i]![0], validPath[i]![1], validPath[i]![2])
203
+ const delta = new Vector3().subVectors(b, a)
204
+ const len = delta.length()
205
+ if (!Number.isFinite(len) || len < 0.005) continue
206
+
207
+ const dir = delta.clone().normalize()
208
+ if (!firstValidSeg) {
209
+ firstValidSeg = { start: a.clone(), dir: dir.clone(), len }
210
+ }
211
+ const quat = safeQuatFromUp(dir)
212
+ const mid = new Vector3().addVectors(a, b).multiplyScalar(0.5)
213
+
214
+ unitSegGeo ??= new CylinderGeometry(radius, radius, 1, 12)
215
+ const seg = new Mesh(unitSegGeo, mat)
216
+ seg.position.copy(mid)
217
+ seg.quaternion.copy(quat)
218
+ seg.scale.set(1, len, 1)
219
+ seg.castShadow = true
220
+ seg.receiveShadow = true
221
+ g.add(seg)
222
+
223
+ // Smooth elbow/wye joint sphere at vertices
224
+ if (i < validPath.length - 1) {
225
+ jointGeo ??= new SphereGeometry(isRigid ? hubRadius : radius * 1.06, 12, 10)
226
+ const joint = new Mesh(jointGeo, mat)
227
+ joint.position.copy(b)
228
+ g.add(joint)
229
+ }
230
+
231
+ // Coupling hubs every ~3.05 m (10 ft) on rigid pipe
232
+ if (isRigid && len > 3.2) {
233
+ collarGeo ??= new CylinderGeometry(hubRadius, hubRadius, 0.055, 12)
234
+ const hubs = Math.floor(len / 3.05)
235
+ for (let h = 1; h <= hubs; h++) {
236
+ const pt = a.clone().addScaledVector(dir, h * 3.05)
237
+ const collar = new Mesh(collarGeo, mat)
238
+ collar.position.copy(pt)
239
+ collar.quaternion.copy(quat)
240
+ g.add(collar)
241
+ }
242
+ }
243
+ }
244
+
245
+ // Optional cleanout plug boss oriented perpendicular to the first valid pipe segment
246
+ if (hasCleanout && firstValidSeg) {
247
+ const { start, dir, len } = firstValidSeg
248
+ const horizLen = Math.hypot(dir.x, dir.z)
249
+ const perp =
250
+ horizLen > 1e-4
251
+ ? new Vector3(-dir.z / horizLen, 0, dir.x / horizLen)
252
+ : new Vector3(0, 0, 1)
253
+ const plug = new Mesh(new CylinderGeometry(hubRadius * 1.15, hubRadius * 1.15, 0.08, 14), pool.brass)
254
+ plug.position
255
+ .copy(start)
256
+ .addScaledVector(dir, Math.min(0.06, len * 0.5))
257
+ .addScaledVector(perp, hubRadius)
258
+ plug.quaternion.copy(safeQuatFromUp(perp))
259
+ g.add(plug)
260
+ }
261
+
262
+ // Framing Penetration 3D Bore Sleeves & IRC R602.6 / IPC 305.6 Nail Plates (oriented to wall normal on both faces)
263
+ const sleeveGeoCache = new Map<string, CylinderGeometry>()
264
+ for (const pen of penetrations) {
265
+ if (!isFiniteVec3Pt(pen.position)) continue
266
+ const holeSawIn = Number.isFinite(pen.holeSawIn) && pen.holeSawIn > 0 ? pen.holeSawIn : 1
267
+ const boreR = Math.max(radius * 1.15, (holeSawIn * 0.0254) / 2)
268
+ const rawDir = isFiniteVec3Pt(pen.pipeDirection)
269
+ ? new Vector3(pen.pipeDirection[0], pen.pipeDirection[1], pen.pipeDirection[2])
270
+ : UP.clone()
271
+ const pDir = rawDir.lengthSq() < 1e-8 ? UP.clone() : rawDir.normalize()
272
+ const quat = safeQuatFromUp(pDir)
273
+ const sleeveMat = pen.codeCompliant ? pool.darkRubber : pool.pexHotRed
274
+ const sleeveLen = pen.memberKind === 'top-plate' ? 0.082 : 0.044 // Proud of 1.5" stud or 3" double top plate by ~3 mm
275
+ const sleeveKey = `${boreR.toFixed(4)}|${sleeveLen}`
276
+ let sleeveGeo = sleeveGeoCache.get(sleeveKey)
277
+ if (!sleeveGeo) {
278
+ sleeveGeo = new CylinderGeometry(boreR, boreR, sleeveLen, 16, 1, true)
279
+ sleeveGeoCache.set(sleeveKey, sleeveGeo)
280
+ }
281
+ const sleeve = new Mesh(sleeveGeo, sleeveMat)
282
+ sleeve.position.set(pen.position[0], pen.position[1], pen.position[2])
283
+ sleeve.quaternion.copy(quat)
284
+ g.add(sleeve)
285
+
286
+ // Protective steel nail plates on both framing faces when edge clearance < 1-1/4" (studs and bored plates)
287
+ if (
288
+ pen.needsNailPlate &&
289
+ (pen.memberKind === 'stud' || pen.memberKind === 'sole-plate' || pen.memberKind === 'top-plate')
290
+ ) {
291
+ const isPlate = pen.memberKind !== 'stud'
292
+ let activePlateGeo: BoxGeometry
293
+ if (isPlate) {
294
+ plateNailPlateGeo ??= new BoxGeometry(0.127, 0.042, 0.005)
295
+ activePlateGeo = plateNailPlateGeo
296
+ } else {
297
+ studNailPlateGeo ??= new BoxGeometry(0.042, 0.127, 0.005)
298
+ activePlateGeo = studNailPlateGeo
299
+ }
300
+ const rawNx = pen.wallNormal?.[0] ?? 0
301
+ const rawNz = pen.wallNormal?.[1] ?? 1
302
+ const nLen = Math.hypot(rawNx, rawNz)
303
+ const nx = nLen > 1e-5 ? rawNx / nLen : 0
304
+ const nz = nLen > 1e-5 ? rawNz / nLen : 1
305
+ const studHalfDepth = (pen.studDepthM ?? 0.0889) / 2
306
+ const faceOffset = studHalfDepth + 0.003
307
+ const yaw = Math.atan2(nx, nz)
308
+ for (const side of [1, -1] as const) {
309
+ const plate = new Mesh(activePlateGeo, pool.galvanizedSteel)
310
+ plate.position.set(
311
+ pen.position[0] + nx * side * faceOffset,
312
+ pen.position[1],
313
+ pen.position[2] + nz * side * faceOffset,
314
+ )
315
+ plate.rotation.y = yaw
316
+ g.add(plate)
317
+ }
318
+ }
319
+ }
320
+
321
+ return g
322
+ }
@@ -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'