@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.
- package/LICENSE +21 -0
- package/README.md +123 -2
- package/docs/AGENT-TOOLS.md +12 -0
- package/docs/ARCHITECTURE.md +15 -0
- package/docs/CAD-CATALOG.md +10 -0
- package/docs/IPC-REFERENCE.md +17 -0
- package/package.json +89 -4
- package/src/agent-operations.ts +854 -0
- package/src/agent-tools.ts +258 -0
- package/src/cad/catalog.ts +151 -0
- package/src/cad/equipment.ts +172 -0
- package/src/cad/fittings.ts +322 -0
- package/src/cad/fixtures.ts +255 -0
- package/src/cad/index.ts +6 -0
- package/src/cad/manifold-interior.ts +248 -0
- package/src/cad/materials.ts +122 -0
- package/src/index.ts +156 -0
- package/src/ipc/audit.ts +927 -0
- package/src/ipc/autopopulate.ts +5071 -0
- package/src/ipc/framing-interop.ts +843 -0
- package/src/ipc/index.ts +9 -0
- package/src/ipc/pricing.ts +571 -0
- package/src/ipc/routing.ts +2410 -0
- package/src/ipc/rules.ts +271 -0
- package/src/ipc/schedule.ts +653 -0
- package/src/ipc/sizing.ts +663 -0
- package/src/ipc/tables.ts +780 -0
- package/src/nodes/equipment.ts +330 -0
- package/src/nodes/fixture.ts +245 -0
- package/src/nodes/manifold.ts +194 -0
- package/src/nodes/parametrics.ts +170 -0
- package/src/nodes/pipe-run.ts +393 -0
- package/src/render.ts +64 -0
- package/src/ui/chat-card.tsx +209 -0
- package/src/ui/inspector-card.tsx +243 -0
- package/src/ui/manifold-cutaway-view.tsx +297 -0
- package/src/ui/plumbing-panel.tsx +812 -0
- package/src/ui/schedule-view.tsx +523 -0
- package/src/ui/store.ts +98 -0
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 4 Clean-Room MIT Procedural 3D CAD Builders for Plumbing Manifolds +
|
|
3
|
+
* Interactive 3D PEX Manifold & Wet-Wall Cutaway View Builder (`buildWiredManifoldCutawayCad`).
|
|
4
|
+
*
|
|
5
|
+
* Plumbing's signature interactive 3D showcase parallel to Electrical's Cover-Off Panel Interior View.
|
|
6
|
+
* Zero React or `@pascal-app/editor` imports.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { BoxGeometry, CylinderGeometry, Group, Mesh } from 'three'
|
|
10
|
+
import type { ManifoldKind } from '../ipc/tables'
|
|
11
|
+
import { createPlumbingMaterialPool } from './materials'
|
|
12
|
+
|
|
13
|
+
export type ManifoldPortAssignment = {
|
|
14
|
+
portIndex: number
|
|
15
|
+
side: 'hot' | 'cold' | 'gas'
|
|
16
|
+
label: string
|
|
17
|
+
pipeSize: string
|
|
18
|
+
active: boolean
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export type ManifoldCutawayViewMode = 'open-manifold' | 'enclosure-closed' | 'wet-wall-cutaway'
|
|
22
|
+
|
|
23
|
+
export function buildManifoldCad(params: {
|
|
24
|
+
manifoldKind: ManifoldKind
|
|
25
|
+
portCount?: number
|
|
26
|
+
coverRemoved?: boolean
|
|
27
|
+
roughInOnly?: boolean
|
|
28
|
+
}): Group {
|
|
29
|
+
const { manifoldKind, portCount = 12, coverRemoved = false, roughInOnly = false } = params
|
|
30
|
+
if (roughInOnly) {
|
|
31
|
+
// Compact stub-out union & supply inlet nipples only (avoids 3D Z-fighting over a placed real-world manifold SKU)
|
|
32
|
+
const pool = createPlumbingMaterialPool()
|
|
33
|
+
const g = new Group()
|
|
34
|
+
g.name = `plumbing-manifold-${manifoldKind}-rough-in`
|
|
35
|
+
const stubMat = manifoldKind === 'gas-csst' ? pool.csstYellow : pool.brass
|
|
36
|
+
const collarGeo = new CylinderGeometry(0.018, 0.018, 0.05, 12)
|
|
37
|
+
if (manifoldKind === 'gas-csst') {
|
|
38
|
+
const m = new Mesh(collarGeo, stubMat)
|
|
39
|
+
m.position.set(0, -0.18, 0.02)
|
|
40
|
+
g.add(m)
|
|
41
|
+
} else {
|
|
42
|
+
const hotStub = new Mesh(collarGeo, pool.pexHotRed)
|
|
43
|
+
hotStub.position.set(-0.085, -0.18, 0.02)
|
|
44
|
+
const coldStub = new Mesh(collarGeo, pool.pexColdBlue)
|
|
45
|
+
coldStub.position.set(0.085, -0.18, 0.02)
|
|
46
|
+
const bracket = new Mesh(new BoxGeometry(0.22, 0.02, 0.016), pool.galvanizedSteel)
|
|
47
|
+
bracket.position.set(0, -0.18, 0.01)
|
|
48
|
+
g.add(hotStub, coldStub, bracket)
|
|
49
|
+
}
|
|
50
|
+
return g
|
|
51
|
+
}
|
|
52
|
+
return buildWiredManifoldCutawayCad({
|
|
53
|
+
manifoldKind,
|
|
54
|
+
portCount,
|
|
55
|
+
viewMode: coverRemoved ? 'open-manifold' : 'enclosure-closed',
|
|
56
|
+
})
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Build a detailed 3D PEX Home-Run Manifold, Copper Header, or CSST Gas Manifold,
|
|
61
|
+
* optionally mounted inside an exposed 2x6 wet-wall framing cutaway with active hot/cold
|
|
62
|
+
* home-run PEX loops, brass quarter-turn ball valves, nail plates, and adjacent 3" PVC stack.
|
|
63
|
+
*/
|
|
64
|
+
export function buildWiredManifoldCutawayCad(options: {
|
|
65
|
+
manifoldKind: ManifoldKind
|
|
66
|
+
portCount?: number
|
|
67
|
+
viewMode?: ManifoldCutawayViewMode
|
|
68
|
+
ports?: ReadonlyArray<ManifoldPortAssignment>
|
|
69
|
+
}): Group {
|
|
70
|
+
const {
|
|
71
|
+
manifoldKind,
|
|
72
|
+
portCount = 12,
|
|
73
|
+
viewMode = 'open-manifold',
|
|
74
|
+
} = options
|
|
75
|
+
const ports = options?.ports ?? []
|
|
76
|
+
const pool = createPlumbingMaterialPool()
|
|
77
|
+
const g = new Group()
|
|
78
|
+
g.name = `plumbing-manifold-${manifoldKind}-${viewMode}`
|
|
79
|
+
|
|
80
|
+
const add = (mesh: Mesh, x: number, y: number, z: number) => {
|
|
81
|
+
mesh.position.set(x, y, z)
|
|
82
|
+
mesh.castShadow = true
|
|
83
|
+
mesh.receiveShadow = true
|
|
84
|
+
g.add(mesh)
|
|
85
|
+
return mesh
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const perSide = Math.max(4, Math.min(18, Math.ceil(portCount / 2)))
|
|
89
|
+
const cabinetW = manifoldKind === 'gas-csst' ? 0.36 : 0.44
|
|
90
|
+
const cabinetH =
|
|
91
|
+
manifoldKind === 'gas-csst'
|
|
92
|
+
? Math.max(0.56, 0.24 + Math.min(8, portCount) * 0.052)
|
|
93
|
+
: Math.max(0.56, 0.22 + perSide * 0.048)
|
|
94
|
+
const cabinetD = 0.11
|
|
95
|
+
|
|
96
|
+
// Optional 2x6 Wet-Wall Framing Cutaway Surround
|
|
97
|
+
if (viewMode === 'wet-wall-cutaway') {
|
|
98
|
+
const bayW = 0.72
|
|
99
|
+
const wallH = Math.max(1.35, cabinetH + 0.55)
|
|
100
|
+
// Left, center, and right 2x6 wood studs (1.5" x 5.5" = 0.0381 x 0.1397 m)
|
|
101
|
+
const studGeo = new BoxGeometry(0.038, wallH, 0.14)
|
|
102
|
+
add(new Mesh(studGeo, pool.woodStud), -bayW / 2, 0, -0.02)
|
|
103
|
+
add(new Mesh(studGeo, pool.woodStud), bayW / 2, 0, -0.02)
|
|
104
|
+
add(new Mesh(studGeo, pool.woodStud), bayW / 2 + 0.406, 0, -0.02)
|
|
105
|
+
// Top & bottom horizontal wood blocking cleats anchoring the recessed manifold box to the 2x6 studs
|
|
106
|
+
const cleatGeo = new BoxGeometry(bayW - 0.02, 0.038, 0.11)
|
|
107
|
+
add(new Mesh(cleatGeo, pool.woodStud), 0, cabinetH / 2 + 0.018, -0.01)
|
|
108
|
+
add(new Mesh(cleatGeo, pool.woodStud), 0, -cabinetH / 2 - 0.018, -0.01)
|
|
109
|
+
// Bottom sole plate + double top plate
|
|
110
|
+
add(new Mesh(new BoxGeometry(bayW + 0.50, 0.038, 0.14), pool.woodStud), 0.20, -wallH / 2, -0.02)
|
|
111
|
+
add(new Mesh(new BoxGeometry(bayW + 0.50, 0.076, 0.14), pool.woodStud), 0.20, wallH / 2, -0.02)
|
|
112
|
+
// Galvanized steel nail plates (IRC R602.6 protection, seated flush on stud front face)
|
|
113
|
+
const nailPlateGeo = new BoxGeometry(0.042, 0.13, 0.004)
|
|
114
|
+
add(new Mesh(nailPlateGeo, pool.galvanizedSteel), -bayW / 2, -0.18, 0.051)
|
|
115
|
+
add(new Mesh(nailPlateGeo, pool.galvanizedSteel), bayW / 2, -0.18, 0.051)
|
|
116
|
+
// Adjacent 3" PVC DWV Soil/Vent Stack in neighboring 2x6 bay
|
|
117
|
+
add(new Mesh(new CylinderGeometry(0.044, 0.044, wallH + 0.12, 20), pool.pvcWhite), bayW / 2 + 0.20, 0, -0.02)
|
|
118
|
+
add(new Mesh(new CylinderGeometry(0.052, 0.052, 0.10, 20), pool.pvcWhite), bayW / 2 + 0.20, -0.25, -0.02)
|
|
119
|
+
// Drywall backing sheet flush against stud rear face
|
|
120
|
+
add(new Mesh(new BoxGeometry(bayW + 0.52, wallH, 0.012), pool.drywallWhite), 0.20, 0, -0.095)
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// Open-front recessed steel manifold backbox (thin backplate + 4 side flanges so headers & valves are 100% visible!)
|
|
124
|
+
const wallT = 0.012
|
|
125
|
+
const horizFlangeGeo = new BoxGeometry(cabinetW, wallT, cabinetD)
|
|
126
|
+
const vertFlangeGeo = new BoxGeometry(wallT, cabinetH, cabinetD)
|
|
127
|
+
add(new Mesh(new BoxGeometry(cabinetW, cabinetH, wallT), pool.galvanizedSteel), 0, 0, -cabinetD / 2)
|
|
128
|
+
add(new Mesh(horizFlangeGeo, pool.galvanizedSteel), 0, cabinetH / 2, 0)
|
|
129
|
+
add(new Mesh(horizFlangeGeo, pool.galvanizedSteel), 0, -cabinetH / 2, 0)
|
|
130
|
+
add(new Mesh(vertFlangeGeo, pool.galvanizedSteel), -cabinetW / 2, 0, 0)
|
|
131
|
+
add(new Mesh(vertFlangeGeo, pool.galvanizedSteel), cabinetW / 2, 0, 0)
|
|
132
|
+
|
|
133
|
+
const hasExplicitPorts = options?.ports !== undefined
|
|
134
|
+
|
|
135
|
+
if (manifoldKind === 'gas-csst') {
|
|
136
|
+
const activeGasIndices = new Set(
|
|
137
|
+
ports.filter((p) => p.side === 'gas' && p.active).map((p) => p.portIndex),
|
|
138
|
+
)
|
|
139
|
+
// Brass CSST gas distribution block with mounting standoffs, continuous black-iron inlet, & yellow shutoffs
|
|
140
|
+
add(new Mesh(new BoxGeometry(0.06, cabinetH - 0.16, 0.05), pool.brass), 0, 0, 0.02)
|
|
141
|
+
const standoffGeo = new BoxGeometry(0.04, 0.04, 0.055)
|
|
142
|
+
add(new Mesh(standoffGeo, pool.galvanizedSteel), 0, cabinetH * 0.22, -0.025)
|
|
143
|
+
add(new Mesh(standoffGeo, pool.galvanizedSteel), 0, -cabinetH * 0.22, -0.025)
|
|
144
|
+
add(new Mesh(new CylinderGeometry(0.016, 0.016, 0.22, 12), pool.blackIron), 0, -cabinetH / 2 - 0.01, 0.02)
|
|
145
|
+
const gasCount = Math.min(8, portCount)
|
|
146
|
+
let gasPortGeo: CylinderGeometry | null = null
|
|
147
|
+
let gasStubGeo: CylinderGeometry | null = null
|
|
148
|
+
let gasPlugGeo: CylinderGeometry | null = null
|
|
149
|
+
for (let i = 0; i < gasCount; i++) {
|
|
150
|
+
const y = cabinetH / 2 - 0.12 - i * 0.052
|
|
151
|
+
const side = i % 2 === 0 ? -1 : 1
|
|
152
|
+
const isActive = !hasExplicitPorts || activeGasIndices.has(i)
|
|
153
|
+
gasPortGeo ??= new CylinderGeometry(0.010, 0.010, 0.10, 10)
|
|
154
|
+
add(new Mesh(gasPortGeo, pool.brass), side * 0.065, y, 0.02).rotation.z =
|
|
155
|
+
Math.PI / 2
|
|
156
|
+
if (isActive) {
|
|
157
|
+
if (viewMode !== 'enclosure-closed') {
|
|
158
|
+
gasStubGeo ??= new CylinderGeometry(0.009, 0.009, 0.16, 10)
|
|
159
|
+
add(new Mesh(gasStubGeo, pool.csstYellow), side * 0.11, y - 0.075, 0.02)
|
|
160
|
+
}
|
|
161
|
+
} else {
|
|
162
|
+
// Capped spare port (dark plug)
|
|
163
|
+
gasPlugGeo ??= new CylinderGeometry(0.011, 0.011, 0.018, 10)
|
|
164
|
+
add(new Mesh(gasPlugGeo, pool.darkRubber), side * 0.112, y, 0.02).rotation.z =
|
|
165
|
+
Math.PI / 2
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
} else {
|
|
169
|
+
// Hot (Red, left) & Cold (Blue, right) vertical distribution trunks
|
|
170
|
+
const headerH = cabinetH - 0.10
|
|
171
|
+
const hotMat = manifoldKind === 'copper-header' ? pool.copper : pool.pexHotRed
|
|
172
|
+
const coldMat = manifoldKind === 'copper-header' ? pool.copper : pool.pexColdBlue
|
|
173
|
+
|
|
174
|
+
const headerGeo = new CylinderGeometry(0.022, 0.022, headerH, 16)
|
|
175
|
+
add(new Mesh(headerGeo, hotMat), -0.085, 0, 0.02)
|
|
176
|
+
add(new Mesh(headerGeo, coldMat), 0.085, 0, 0.02)
|
|
177
|
+
// Header mounting brackets to backplate
|
|
178
|
+
const bracketGeo = new BoxGeometry(0.22, 0.024, 0.065)
|
|
179
|
+
add(new Mesh(bracketGeo, pool.galvanizedSteel), 0, headerH * 0.36, -0.02)
|
|
180
|
+
add(new Mesh(bracketGeo, pool.galvanizedSteel), 0, -headerH * 0.36, -0.02)
|
|
181
|
+
|
|
182
|
+
// Bottom 3/4" main feed risers + main brass isolation ball valves seated directly into header bases
|
|
183
|
+
const mainRiserGeo = new CylinderGeometry(0.015, 0.015, 0.20, 12)
|
|
184
|
+
const mainValveGeo = new CylinderGeometry(0.023, 0.023, 0.06, 12)
|
|
185
|
+
add(new Mesh(mainRiserGeo, pool.pexHotRed), -0.085, -cabinetH / 2 - 0.04, 0.02)
|
|
186
|
+
add(new Mesh(mainRiserGeo, pool.pexColdBlue), 0.085, -cabinetH / 2 - 0.04, 0.02)
|
|
187
|
+
add(new Mesh(mainValveGeo, pool.brass), -0.085, -cabinetH / 2 + 0.04, 0.02)
|
|
188
|
+
add(new Mesh(mainValveGeo, pool.brass), 0.085, -cabinetH / 2 + 0.04, 0.02)
|
|
189
|
+
|
|
190
|
+
// Per-port quarter-turn ball valves + color-coded PEX home-run stubs (active open vs inactive closed)
|
|
191
|
+
const activeHotIndices = new Set(
|
|
192
|
+
ports.filter((p) => p.side === 'hot' && p.active).map((p) => p.portIndex),
|
|
193
|
+
)
|
|
194
|
+
const activeColdIndices = new Set(
|
|
195
|
+
ports.filter((p) => p.side === 'cold' && p.active).map((p) => p.portIndex),
|
|
196
|
+
)
|
|
197
|
+
const hotPortCount = Math.max(perSide, ports.filter((p) => p.side === 'hot').length)
|
|
198
|
+
const coldPortCount = Math.max(perSide, ports.filter((p) => p.side === 'cold').length)
|
|
199
|
+
const rows = Math.min(18, Math.max(hotPortCount, coldPortCount))
|
|
200
|
+
|
|
201
|
+
const valveBodyGeo = new CylinderGeometry(0.009, 0.009, 0.075, 10)
|
|
202
|
+
const valveHandleGeo = new BoxGeometry(0.026, 0.009, 0.012)
|
|
203
|
+
let pexStubGeo: CylinderGeometry | null = null
|
|
204
|
+
|
|
205
|
+
for (let i = 0; i < rows; i++) {
|
|
206
|
+
const y = headerH / 2 - 0.05 - i * ((headerH - 0.10) / Math.max(1, rows - 1))
|
|
207
|
+
const hotActive = !hasExplicitPorts || activeHotIndices.has(i)
|
|
208
|
+
const coldActive = !hasExplicitPorts || activeColdIndices.has(i)
|
|
209
|
+
|
|
210
|
+
// Hot side port (left): brass valve + seated handle (parallel=open/red when active, perpendicular=closed/dark when spare)
|
|
211
|
+
add(new Mesh(valveBodyGeo, pool.brass), -0.13, y, 0.02).rotation.z = Math.PI / 2
|
|
212
|
+
const hotHandle = add(
|
|
213
|
+
new Mesh(valveHandleGeo, hotActive ? pool.pexHotRed : pool.darkRubber),
|
|
214
|
+
-0.13,
|
|
215
|
+
y + 0.009,
|
|
216
|
+
0.026,
|
|
217
|
+
)
|
|
218
|
+
if (!hotActive) hotHandle.rotation.z = Math.PI / 2
|
|
219
|
+
if (viewMode !== 'enclosure-closed' && hotActive) {
|
|
220
|
+
pexStubGeo ??= new CylinderGeometry(0.008, 0.008, 0.14, 8)
|
|
221
|
+
add(new Mesh(pexStubGeo, pool.pexHotRed), -0.162, y - 0.065, 0.02)
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// Cold side port (right): brass valve + seated handle
|
|
225
|
+
add(new Mesh(valveBodyGeo, pool.brass), 0.13, y, 0.02).rotation.z = Math.PI / 2
|
|
226
|
+
const coldHandle = add(
|
|
227
|
+
new Mesh(valveHandleGeo, coldActive ? pool.pexColdBlue : pool.darkRubber),
|
|
228
|
+
0.13,
|
|
229
|
+
y + 0.009,
|
|
230
|
+
0.026,
|
|
231
|
+
)
|
|
232
|
+
if (!coldActive) coldHandle.rotation.z = Math.PI / 2
|
|
233
|
+
if (viewMode !== 'enclosure-closed' && coldActive) {
|
|
234
|
+
pexStubGeo ??= new CylinderGeometry(0.008, 0.008, 0.14, 8)
|
|
235
|
+
add(new Mesh(pexStubGeo, pool.pexColdBlue), 0.162, y - 0.065, 0.02)
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
// Hinged steel access door when closed
|
|
241
|
+
if (viewMode === 'enclosure-closed') {
|
|
242
|
+
add(new Mesh(new BoxGeometry(cabinetW + 0.02, cabinetH + 0.02, 0.016), pool.enamelSteel), 0, 0, 0.055)
|
|
243
|
+
add(new Mesh(new BoxGeometry(0.16, 0.04, 0.005), pool.enamelBlue), 0, cabinetH * 0.34, 0.065)
|
|
244
|
+
add(new Mesh(new BoxGeometry(0.018, 0.06, 0.018), pool.chrome), cabinetW * 0.42, 0, 0.068)
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
return g
|
|
248
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fresh per-build PBR material factory for clean-room MIT plumbing 3D CAD models.
|
|
3
|
+
* Editor-free and React-free: zero React or `@pascal-app/*` imports.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { MeshStandardMaterial } from 'three'
|
|
7
|
+
import { PLUMBING_SYSTEM_COLORS, type PipeMaterial, type PlumbingSystem } from '../ipc/tables'
|
|
8
|
+
|
|
9
|
+
export type PlumbingMaterialPool = {
|
|
10
|
+
pvcWhite: MeshStandardMaterial
|
|
11
|
+
absBlack: MeshStandardMaterial
|
|
12
|
+
castIron: MeshStandardMaterial
|
|
13
|
+
copper: MeshStandardMaterial
|
|
14
|
+
brass: MeshStandardMaterial
|
|
15
|
+
chrome: MeshStandardMaterial
|
|
16
|
+
porcelain: MeshStandardMaterial
|
|
17
|
+
enamelSteel: MeshStandardMaterial
|
|
18
|
+
enamelBlue: MeshStandardMaterial
|
|
19
|
+
galvanizedSteel: MeshStandardMaterial
|
|
20
|
+
blackIron: MeshStandardMaterial
|
|
21
|
+
csstYellow: MeshStandardMaterial
|
|
22
|
+
pexColdBlue: MeshStandardMaterial
|
|
23
|
+
pexHotRed: MeshStandardMaterial
|
|
24
|
+
pexRecircOrange: MeshStandardMaterial
|
|
25
|
+
ventGreen: MeshStandardMaterial
|
|
26
|
+
condensateCyan: MeshStandardMaterial
|
|
27
|
+
darkRubber: MeshStandardMaterial
|
|
28
|
+
woodStud: MeshStandardMaterial
|
|
29
|
+
drywallWhite: MeshStandardMaterial
|
|
30
|
+
aluminumRigid: MeshStandardMaterial
|
|
31
|
+
dispose: () => void
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const MATERIAL_SPECS = {
|
|
35
|
+
pvcWhite: { color: 0xf1f5f9, roughness: 0.42, metalness: 0.04 },
|
|
36
|
+
absBlack: { color: 0x1e293b, roughness: 0.48, metalness: 0.06 },
|
|
37
|
+
castIron: { color: 0x27272a, roughness: 0.72, metalness: 0.55 },
|
|
38
|
+
copper: { color: 0xc87544, roughness: 0.28, metalness: 0.88 },
|
|
39
|
+
brass: { color: 0xd4a024, roughness: 0.30, metalness: 0.86 },
|
|
40
|
+
chrome: { color: 0xe2e8f0, roughness: 0.16, metalness: 0.94 },
|
|
41
|
+
porcelain: { color: 0xffffff, roughness: 0.14, metalness: 0.05 },
|
|
42
|
+
enamelSteel: { color: 0xdbeafe, roughness: 0.35, metalness: 0.35 },
|
|
43
|
+
enamelBlue: { color: 0x1d4ed8, roughness: 0.38, metalness: 0.30 },
|
|
44
|
+
galvanizedSteel: { color: 0x94a3b8, roughness: 0.44, metalness: 0.72 },
|
|
45
|
+
blackIron: { color: 0x334155, roughness: 0.62, metalness: 0.68 },
|
|
46
|
+
csstYellow: { color: 0xeab308, roughness: 0.40, metalness: 0.12 },
|
|
47
|
+
pexColdBlue: { color: 0x2563eb, roughness: 0.45, metalness: 0.05 },
|
|
48
|
+
pexHotRed: { color: 0xdc2626, roughness: 0.45, metalness: 0.05 },
|
|
49
|
+
pexRecircOrange: { color: 0xf97316, roughness: 0.45, metalness: 0.05 },
|
|
50
|
+
ventGreen: { color: 0x16a34a, roughness: 0.46, metalness: 0.05 },
|
|
51
|
+
condensateCyan: { color: 0x06b6d4, roughness: 0.42, metalness: 0.06 },
|
|
52
|
+
darkRubber: { color: 0x18181b, roughness: 0.82, metalness: 0.05 },
|
|
53
|
+
woodStud: { color: 0xd4a373, roughness: 0.78, metalness: 0.02 },
|
|
54
|
+
drywallWhite: { color: 0xe5e7eb, roughness: 0.88, metalness: 0.0 },
|
|
55
|
+
aluminumRigid: { color: 0xcbd5e1, roughness: 0.32, metalness: 0.82 },
|
|
56
|
+
} as const
|
|
57
|
+
|
|
58
|
+
type MaterialKey = keyof typeof MATERIAL_SPECS
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Lazy per-build PBR material pool: instantiates each `MeshStandardMaterial` only on first
|
|
62
|
+
* property access so simple pipe runs allocate 1-3 GPU materials instead of all 21.
|
|
63
|
+
*/
|
|
64
|
+
export function createPlumbingMaterialPool(): PlumbingMaterialPool {
|
|
65
|
+
const cache = new Map<MaterialKey, MeshStandardMaterial>()
|
|
66
|
+
const get = (key: MaterialKey): MeshStandardMaterial => {
|
|
67
|
+
let m = cache.get(key)
|
|
68
|
+
if (!m) {
|
|
69
|
+
m = new MeshStandardMaterial(MATERIAL_SPECS[key])
|
|
70
|
+
cache.set(key, m)
|
|
71
|
+
}
|
|
72
|
+
return m
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const pool = {
|
|
76
|
+
dispose: () => {
|
|
77
|
+
for (const m of cache.values()) m.dispose()
|
|
78
|
+
cache.clear()
|
|
79
|
+
},
|
|
80
|
+
} as PlumbingMaterialPool
|
|
81
|
+
|
|
82
|
+
for (const key of Object.keys(MATERIAL_SPECS) as MaterialKey[]) {
|
|
83
|
+
Object.defineProperty(pool, key, {
|
|
84
|
+
enumerable: true,
|
|
85
|
+
get: () => get(key),
|
|
86
|
+
})
|
|
87
|
+
}
|
|
88
|
+
return pool
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export function pipeRunMaterialForSystem(
|
|
92
|
+
pool: PlumbingMaterialPool,
|
|
93
|
+
system: PlumbingSystem,
|
|
94
|
+
material: PipeMaterial,
|
|
95
|
+
): MeshStandardMaterial {
|
|
96
|
+
switch (system) {
|
|
97
|
+
case 'cold-water':
|
|
98
|
+
return material === 'copper-l' || material === 'copper-m' ? pool.copper : pool.pexColdBlue
|
|
99
|
+
case 'hot-water':
|
|
100
|
+
return material === 'copper-l' || material === 'copper-m' ? pool.copper : pool.pexHotRed
|
|
101
|
+
case 'hot-recirc':
|
|
102
|
+
return pool.pexRecircOrange
|
|
103
|
+
case 'dwv-drain':
|
|
104
|
+
return material === 'abs-dwv'
|
|
105
|
+
? pool.absBlack
|
|
106
|
+
: material === 'cast-iron'
|
|
107
|
+
? pool.castIron
|
|
108
|
+
: pool.pvcWhite
|
|
109
|
+
case 'dwv-vent':
|
|
110
|
+
return pool.ventGreen
|
|
111
|
+
case 'fuel-gas':
|
|
112
|
+
return material === 'csst' ? pool.csstYellow : pool.blackIron
|
|
113
|
+
case 'condensate':
|
|
114
|
+
return pool.condensateCyan
|
|
115
|
+
case 'dryer-vent':
|
|
116
|
+
return pool.aluminumRigid
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export function systemColorMeta(system: PlumbingSystem) {
|
|
121
|
+
return PLUMBING_SYSTEM_COLORS[system]
|
|
122
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Main browser entry (`@kruschdev/pascal-plugin-plumbing`).
|
|
3
|
+
*
|
|
4
|
+
* Exports the full Pascal Plugin API v1 surface:
|
|
5
|
+
* - `plumbingPlugin`: Core `Plugin` manifest (`apiVersion: 1`, 4 `plumbing:*` node kinds + InspectorExtension)
|
|
6
|
+
* - `plumbingHostPanel`: Left-rail `EditorHostPanel`
|
|
7
|
+
* - `plumbingScheduleView`: Full-pane `EditorHostView` (Fixtures, Loads & Power, IPC Audit, Drill List, BOM, 3D Manifold Cutaway)
|
|
8
|
+
* - `plumbingChatExtension`: `PluginChatExtension` (`/` actions + lazy tool result cards)
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import type { AnyNodeDefinition, InspectorExtension, Plugin } from '@pascal-app/core'
|
|
12
|
+
import type { EditorHostPanel, EditorHostView, PluginChatExtension } from '@pascal-app/editor'
|
|
13
|
+
import { plumbingEquipmentRenderDefinition } from './nodes/equipment'
|
|
14
|
+
import { plumbingFixtureRenderDefinition } from './nodes/fixture'
|
|
15
|
+
import { plumbingManifoldRenderDefinition } from './nodes/manifold'
|
|
16
|
+
import {
|
|
17
|
+
plumbingEquipmentParametrics,
|
|
18
|
+
plumbingFixtureParametrics,
|
|
19
|
+
plumbingManifoldParametrics,
|
|
20
|
+
plumbingPipeRunParametrics,
|
|
21
|
+
} from './nodes/parametrics'
|
|
22
|
+
import { plumbingPipeRunRenderDefinition } from './nodes/pipe-run'
|
|
23
|
+
import { PLUMBING_PLUGIN_ID, PLUMBING_SCHEDULE_VIEW_ID, plumbingRenderPlugin } from './render'
|
|
24
|
+
|
|
25
|
+
export const plumbingInspectorExtensions: InspectorExtension[] = [
|
|
26
|
+
{
|
|
27
|
+
id: `${PLUMBING_PLUGIN_ID}:ipc-diagnostics`,
|
|
28
|
+
pluginId: PLUMBING_PLUGIN_ID,
|
|
29
|
+
kinds: [
|
|
30
|
+
'plumbing:equipment',
|
|
31
|
+
'plumbing:manifold',
|
|
32
|
+
'plumbing:fixture',
|
|
33
|
+
'plumbing:pipe-run',
|
|
34
|
+
],
|
|
35
|
+
icon: { kind: 'iconify', name: 'lucide:droplets' },
|
|
36
|
+
title: 'IPC / IFGC Engineering',
|
|
37
|
+
component: () => import('./ui/inspector-card'),
|
|
38
|
+
},
|
|
39
|
+
]
|
|
40
|
+
|
|
41
|
+
export const plumbingEquipmentDefinition: AnyNodeDefinition = {
|
|
42
|
+
...plumbingEquipmentRenderDefinition,
|
|
43
|
+
snapProfile: 'item' as const,
|
|
44
|
+
parametrics: plumbingEquipmentParametrics,
|
|
45
|
+
} as unknown as AnyNodeDefinition
|
|
46
|
+
|
|
47
|
+
export const plumbingManifoldDefinition: AnyNodeDefinition = {
|
|
48
|
+
...plumbingManifoldRenderDefinition,
|
|
49
|
+
snapProfile: 'item' as const,
|
|
50
|
+
parametrics: plumbingManifoldParametrics,
|
|
51
|
+
} as unknown as AnyNodeDefinition
|
|
52
|
+
|
|
53
|
+
export const plumbingFixtureDefinition: AnyNodeDefinition = {
|
|
54
|
+
...plumbingFixtureRenderDefinition,
|
|
55
|
+
snapProfile: 'item' as const,
|
|
56
|
+
parametrics: plumbingFixtureParametrics,
|
|
57
|
+
} as unknown as AnyNodeDefinition
|
|
58
|
+
|
|
59
|
+
export const plumbingPipeRunDefinition: AnyNodeDefinition = {
|
|
60
|
+
...plumbingPipeRunRenderDefinition,
|
|
61
|
+
snapProfile: 'structural' as const,
|
|
62
|
+
parametrics: plumbingPipeRunParametrics,
|
|
63
|
+
} as unknown as AnyNodeDefinition
|
|
64
|
+
|
|
65
|
+
export const plumbingPlugin: Plugin = {
|
|
66
|
+
...plumbingRenderPlugin,
|
|
67
|
+
nodes: [
|
|
68
|
+
plumbingEquipmentDefinition,
|
|
69
|
+
plumbingManifoldDefinition,
|
|
70
|
+
plumbingFixtureDefinition,
|
|
71
|
+
plumbingPipeRunDefinition,
|
|
72
|
+
],
|
|
73
|
+
inspectorExtensions: plumbingInspectorExtensions,
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export const plumbingHostPanel: EditorHostPanel = {
|
|
77
|
+
id: `${PLUMBING_PLUGIN_ID}:panel`,
|
|
78
|
+
pluginId: PLUMBING_PLUGIN_ID,
|
|
79
|
+
label: 'Plumbing',
|
|
80
|
+
summary: 'Residential & Light-Commercial IPC/UPC/IFGC DWV, supply, PEX manifolds, fuel gas, and framing bore coordination.',
|
|
81
|
+
description:
|
|
82
|
+
'Author editable residential and light-commercial plumbing systems with IPC/UPC DFU drain sizing, Hunter-curve WSFU peak demand and Hazen-Williams hydraulics, gravity-sloped 3D DWV routing, PEX home-run manifolds, IFGC fuel gas, IRC dryer vents, Bones framing penetration drill schedules, and automatic Electrical panel power coordination.',
|
|
83
|
+
category: 'MEP & Engineering',
|
|
84
|
+
creator: {
|
|
85
|
+
name: 'Kevin Ruschman (@kruschdev)',
|
|
86
|
+
url: 'https://github.com/kruschdev',
|
|
87
|
+
},
|
|
88
|
+
pluginUrl: 'https://github.com/kruschdev/pascal-plugin-plumbing',
|
|
89
|
+
icon: { kind: 'iconify', name: 'lucide:droplets' },
|
|
90
|
+
component: () => import('./ui/plumbing-panel'),
|
|
91
|
+
defaultInstalled: false,
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export const plumbingScheduleView: EditorHostView = {
|
|
95
|
+
id: PLUMBING_SCHEDULE_VIEW_ID,
|
|
96
|
+
pluginId: PLUMBING_PLUGIN_ID,
|
|
97
|
+
label: 'Plumbing Schedule',
|
|
98
|
+
description:
|
|
99
|
+
'Fixture schedule, DFU/WSFU/Gas loads, cross-trade electrical coordination, IPC/IFGC audit, framing drill list, priced BOM, and 3D PEX manifold cutaway.',
|
|
100
|
+
icon: { kind: 'iconify', name: 'lucide:table' },
|
|
101
|
+
component: () => import('./ui/schedule-view'),
|
|
102
|
+
workspaces: ['edit'],
|
|
103
|
+
defaultPinned: false,
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export const plumbingChatExtension: PluginChatExtension = {
|
|
107
|
+
pluginId: PLUMBING_PLUGIN_ID,
|
|
108
|
+
cards: {
|
|
109
|
+
plumbing_place_equipment: () => import('./ui/chat-card'),
|
|
110
|
+
plumbing_place_manifold: () => import('./ui/chat-card'),
|
|
111
|
+
plumbing_place_fixture: () => import('./ui/chat-card'),
|
|
112
|
+
plumbing_audit_ipc: () => import('./ui/chat-card'),
|
|
113
|
+
plumbing_generate_schedule: () => import('./ui/chat-card'),
|
|
114
|
+
plumbing_route_pipe: () => import('./ui/chat-card'),
|
|
115
|
+
plumbing_calculate_loads: () => import('./ui/chat-card'),
|
|
116
|
+
plumbing_autopopulate: () => import('./ui/chat-card'),
|
|
117
|
+
},
|
|
118
|
+
actions: [
|
|
119
|
+
{
|
|
120
|
+
id: 'ipc-audit',
|
|
121
|
+
label: 'IPC & Framing Audit',
|
|
122
|
+
hint: 'Check DWV slope, 2x6 wet walls, trap arms, gas drip legs & NEC 110.26(E)',
|
|
123
|
+
prompt: 'Run plumbing_audit_ipc on this scene and summarize any code, framing bore, or electrical coordination issues.',
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
id: 'plumbing-schedule',
|
|
127
|
+
label: 'Fixture Schedule & BOM',
|
|
128
|
+
hint: 'Generate DFU/WSFU schedule, framing drill list, electrical handoff, and priced BOM',
|
|
129
|
+
prompt: 'Run plumbing_generate_schedule and open the plumbing schedule view.',
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
id: 'plumbing-loads',
|
|
133
|
+
label: 'DFU / WSFU / Gas Calc',
|
|
134
|
+
hint: 'Calculate building drain size, Hunter-curve peak GPM, water heater & IFGC gas sizing',
|
|
135
|
+
prompt: 'Run plumbing_calculate_loads for this building and summarize drain, supply, and water heater sizing.',
|
|
136
|
+
},
|
|
137
|
+
],
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export {
|
|
141
|
+
PLUMBING_PLUGIN_ID,
|
|
142
|
+
PLUMBING_SCHEDULE_VIEW_ID,
|
|
143
|
+
plumbingRenderPlugin,
|
|
144
|
+
PlumbingEquipmentNode,
|
|
145
|
+
EquipmentKindEnum,
|
|
146
|
+
ElectricalDemandSchema,
|
|
147
|
+
PlumbingManifoldNode,
|
|
148
|
+
ManifoldKindEnum,
|
|
149
|
+
PlumbingFixtureNode,
|
|
150
|
+
FixtureKindEnum,
|
|
151
|
+
PipeNominalSizeEnum,
|
|
152
|
+
PlumbingPipeRunNode,
|
|
153
|
+
PlumbingSystemEnum,
|
|
154
|
+
PipeMaterialEnum,
|
|
155
|
+
} from './render'
|
|
156
|
+
export * from './ipc'
|