@2112-lab/central-plant 0.2.8 → 0.2.12

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.
@@ -35,7 +35,7 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
35
35
  * Initialize the CentralPlant manager
36
36
  *
37
37
  * @constructor
38
- * @version 0.2.8
38
+ * @version 0.2.12
39
39
  * @updated 2025-10-22
40
40
  *
41
41
  * @description Creates a new CentralPlant instance and initializes internal managers and utilities.
@@ -18,6 +18,7 @@ var sceneInitializationManager = require('../managers/scene/sceneInitializationM
18
18
  var environmentManager = require('../managers/environment/environmentManager.js');
19
19
  var keyboardControlsManager = require('../managers/controls/keyboardControlsManager.js');
20
20
  var pathfindingManager = require('../managers/pathfinding/pathfindingManager.js');
21
+ var PathFlowManager = require('../managers/pathfinding/PathFlowManager.js');
21
22
  var BehaviorManager = require('../managers/behaviors/BehaviorManager.js');
22
23
  var sceneOperationsManager = require('../managers/scene/sceneOperationsManager.js');
23
24
  var animationManager = require('../managers/scene/animationManager.js');
@@ -164,6 +165,7 @@ var CentralPlantInternals = /*#__PURE__*/function () {
164
165
  this.centralPlant.managers.environmentManager = new environmentManager.EnvironmentManager(this.centralPlant.sceneViewer);
165
166
  this.centralPlant.managers.keyboardControlsManager = new keyboardControlsManager.KeyboardControlsManager(this.centralPlant.sceneViewer);
166
167
  this.centralPlant.managers.pathfindingManager = new pathfindingManager.PathfindingManager(this.centralPlant.sceneViewer);
168
+ this.centralPlant.managers.pathFlowManager = new PathFlowManager.PathFlowManager(this.centralPlant.sceneViewer);
167
169
  this.centralPlant.managers.behaviorManager = new BehaviorManager.BehaviorManager(this.centralPlant.sceneViewer);
168
170
  this.centralPlant.managers.sceneOperationsManager = new sceneOperationsManager.SceneOperationsManager(this.centralPlant.sceneViewer);
169
171
  this.centralPlant.managers.animationManager = new animationManager.AnimationManager(this.centralPlant.sceneViewer);
@@ -68,10 +68,19 @@ function createPathfindingRequest(startConnector, endConnector) {
68
68
  };
69
69
  }
70
70
 
71
+ /**
72
+ * The official set of flow-related attribute keys that can be set on a path.
73
+ * These attributes belong to the full path and are inherited by all segments.
74
+ *
75
+ * @type {string[]}
76
+ */
77
+ var FLOW_ATTRIBUTE_KEYS = ['flowDirection', 'flowSpeed', 'flowTemperature', 'flowMaterial'];
78
+
71
79
  /**
72
80
  * Data structure for storing path information with segments.
73
81
  * Tracks both computed and declared (manually edited) segments.
74
- *
82
+ * Also stores path-level flow attributes shared by all segments.
83
+ *
75
84
  * Business logic layer - stores coordinate data without Three.js dependencies.
76
85
  */
77
86
  var PathData = /*#__PURE__*/function () {
@@ -91,16 +100,60 @@ var PathData = /*#__PURE__*/function () {
91
100
  * @type {Array<{start: {x, y, z}, end: {x, y, z}, isDeclared: boolean, modifiedAt: number|null}>}
92
101
  */
93
102
  this.segments = [];
103
+
104
+ /**
105
+ * Path-level flow attributes shared by all segments within this path.
106
+ * Keys must come from FLOW_ATTRIBUTE_KEYS. Values are application-defined.
107
+ * @type {Record<string, any>}
108
+ */
109
+ this.flowAttributes = {};
94
110
  this.createdAt = Date.now();
95
111
  }
96
112
 
97
113
  /**
98
- * Add a computed segment (from pathfinding algorithm)
99
- *
100
- * @param {{x: number, y: number, z: number}} start - Start coordinate
101
- * @param {{x: number, y: number, z: number}} end - End coordinate
114
+ * Set a flow attribute on this path.
115
+ * All segments within this path inherit the value.
116
+ *
117
+ * @param {string} key - Attribute key (should be one of FLOW_ATTRIBUTE_KEYS)
118
+ * @param {any} value - Attribute value
102
119
  */
103
120
  return _rollupPluginBabelHelpers.createClass(PathData, [{
121
+ key: "setFlowAttribute",
122
+ value: function setFlowAttribute(key, value) {
123
+ this.flowAttributes[key] = value;
124
+ }
125
+
126
+ /**
127
+ * Get the declared value of a flow attribute.
128
+ * Returns null if the attribute has not been set.
129
+ *
130
+ * @param {string} key - Attribute key
131
+ * @returns {any|null}
132
+ */
133
+ }, {
134
+ key: "getFlowAttribute",
135
+ value: function getFlowAttribute(key) {
136
+ return Object.prototype.hasOwnProperty.call(this.flowAttributes, key) ? this.flowAttributes[key] : null;
137
+ }
138
+
139
+ /**
140
+ * Get a shallow copy of all declared flow attributes.
141
+ *
142
+ * @returns {Record<string, any>}
143
+ */
144
+ }, {
145
+ key: "getAllFlowAttributes",
146
+ value: function getAllFlowAttributes() {
147
+ return _rollupPluginBabelHelpers.objectSpread2({}, this.flowAttributes);
148
+ }
149
+
150
+ /**
151
+ * Add a computed segment (from pathfinding algorithm)
152
+ *
153
+ * @param {{x: number, y: number, z: number}} start - Start coordinate
154
+ * @param {{x: number, y: number, z: number}} end - End coordinate
155
+ */
156
+ }, {
104
157
  key: "addSegment",
105
158
  value: function addSegment(start, end) {
106
159
  this.segments.push({
@@ -177,6 +230,7 @@ var PathData = /*#__PURE__*/function () {
177
230
  segments: this.segments.map(function (seg) {
178
231
  return _rollupPluginBabelHelpers.objectSpread2({}, seg);
179
232
  }),
233
+ flowAttributes: _rollupPluginBabelHelpers.objectSpread2({}, this.flowAttributes),
180
234
  createdAt: this.createdAt
181
235
  };
182
236
  }
@@ -237,11 +291,13 @@ var PathData = /*#__PURE__*/function () {
237
291
  pathData.segments = json.segments.map(function (seg) {
238
292
  return _rollupPluginBabelHelpers.objectSpread2({}, seg);
239
293
  });
294
+ pathData.flowAttributes = json.flowAttributes ? _rollupPluginBabelHelpers.objectSpread2({}, json.flowAttributes) : {};
240
295
  pathData.createdAt = json.createdAt || Date.now();
241
296
  return pathData;
242
297
  }
243
298
  }]);
244
299
  }();
245
300
 
301
+ exports.FLOW_ATTRIBUTE_KEYS = FLOW_ATTRIBUTE_KEYS;
246
302
  exports.PathData = PathData;
247
303
  exports.createPathfindingRequest = createPathfindingRequest;
@@ -102,7 +102,7 @@ var sceneViewer = /*#__PURE__*/function (_BaseDisposable) {
102
102
  this.centralPlant.attachToComponent();
103
103
 
104
104
  // Sync our managers tracking object after attachment
105
- managerKeys = ['threeJSResourceManager', 'performanceMonitorManager', 'settingsManager', 'sceneExportManager', 'componentManager', 'sceneInitializationManager', 'environmentManager', 'keyboardControlsManager', 'pathfindingManager', 'behaviorManager', 'sceneOperationsManager', 'animationManager', 'cameraControlsManager', 'componentDragManager', 'tooltipsManager', 'componentTooltipManager']; // Populate our managers tracking object
105
+ managerKeys = ['threeJSResourceManager', 'performanceMonitorManager', 'settingsManager', 'sceneExportManager', 'componentManager', 'sceneInitializationManager', 'environmentManager', 'keyboardControlsManager', 'pathfindingManager', 'pathFlowManager', 'behaviorManager', 'sceneOperationsManager', 'animationManager', 'cameraControlsManager', 'componentDragManager', 'tooltipsManager', 'componentTooltipManager']; // Populate our managers tracking object
106
106
  managerKeys.forEach(function (key) {
107
107
  if (_this2[key]) {
108
108
  _this2.managers[key] = _this2[key];
@@ -17,6 +17,7 @@ var BehaviorManager = require('./managers/behaviors/BehaviorManager.js');
17
17
  var componentManager = require('./managers/components/componentManager.js');
18
18
  var animationManager = require('./managers/scene/animationManager.js');
19
19
  var pathfindingManager = require('./managers/pathfinding/pathfindingManager.js');
20
+ var PathFlowManager = require('./managers/pathfinding/PathFlowManager.js');
20
21
  var SnapshotManager = require('./managers/pathfinding/SnapshotManager.js');
21
22
  var componentDataManager = require('./managers/components/componentDataManager.js');
22
23
  var transformControlsManager = require('./managers/controls/transformControlsManager.js');
@@ -42,6 +43,7 @@ exports.findObjectByHardcodedUuid = nameUtils.findObjectByHardcodedUuid;
42
43
  exports.generateUniqueComponentId = nameUtils.generateUniqueComponentId;
43
44
  exports.generateUuidFromName = nameUtils.generateUuidFromName;
44
45
  exports.getHardcodedUuid = nameUtils.getHardcodedUuid;
46
+ exports.FLOW_ATTRIBUTE_KEYS = pathfindingData.FLOW_ATTRIBUTE_KEYS;
45
47
  exports.PathData = pathfindingData.PathData;
46
48
  exports.createPathfindingRequest = pathfindingData.createPathfindingRequest;
47
49
  exports.getObjectTypeName = objectTypes.getObjectTypeName;
@@ -66,6 +68,7 @@ exports.BehaviorManager = BehaviorManager.BehaviorManager;
66
68
  exports.ComponentManager = componentManager.ComponentManager;
67
69
  exports.AnimationManager = animationManager.AnimationManager;
68
70
  exports.PathfindingManager = pathfindingManager.PathfindingManager;
71
+ exports.PathFlowManager = PathFlowManager.PathFlowManager;
69
72
  exports.SnapshotManager = SnapshotManager.SnapshotManager;
70
73
  exports.ComponentDataManager = componentDataManager.ComponentDataManager;
71
74
  exports.createTransformControls = transformControlsManager.createTransformControls;
@@ -0,0 +1,265 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var _rollupPluginBabelHelpers = require('../../../_virtual/_rollupPluginBabelHelpers.js');
6
+ var baseDisposable = require('../../core/baseDisposable.js');
7
+ var pathfindingData = require('../../core/pathfindingData.js');
8
+
9
+ // ── Temperature visualisation constants ────────────────────────────────────
10
+
11
+ /** Minimum temperature in the colour ramp (maps to pure blue). */
12
+ var TEMP_MIN = 0;
13
+
14
+ /** Maximum temperature in the colour ramp (maps to pure red). */
15
+ var TEMP_MAX = 100;
16
+
17
+ /**
18
+ * Convert a temperature value to a CSS hex colour string using a blue→red HSL
19
+ * ramp. Values are clamped to [TEMP_MIN, TEMP_MAX].
20
+ *
21
+ * • TEMP_MIN → hsl(240, 80%, 50%) — blue
22
+ * • TEMP_MAX → hsl(0, 80%, 50%) — red
23
+ *
24
+ * @param {number} temp
25
+ * @returns {string} CSS hex colour string e.g. '#2255cc'
26
+ */
27
+ function temperatureToColor(temp) {
28
+ var clamped = Math.max(TEMP_MIN, Math.min(TEMP_MAX, temp));
29
+ var t = (clamped - TEMP_MIN) / (TEMP_MAX - TEMP_MIN); // 0 (cold) → 1 (hot)
30
+ // Map t=0 → hue 240 (blue), t=1 → hue 0 (red)
31
+ var hue = Math.round(240 - t * 240);
32
+ return "hsl(".concat(hue, ", 80%, 50%)");
33
+ }
34
+
35
+ // ── PathFlowManager ─────────────────────────────────────────────────────────
36
+
37
+ var PathFlowManager = /*#__PURE__*/function (_BaseDisposable) {
38
+ /**
39
+ * @param {Object} sceneViewer - The central sceneViewer hub
40
+ */
41
+ function PathFlowManager(sceneViewer) {
42
+ var _this;
43
+ _rollupPluginBabelHelpers.classCallCheck(this, PathFlowManager);
44
+ _this = _rollupPluginBabelHelpers.callSuper(this, PathFlowManager);
45
+ _this.sceneViewer = sceneViewer;
46
+
47
+ /**
48
+ * Runtime-only attribute overrides.
49
+ * Map<pathId, Record<attributeKey, value>>
50
+ * Cleared when the session ends or resetDerived() is called.
51
+ * @type {Map<string, Record<string, any>>}
52
+ */
53
+ _this._derivedStore = new Map();
54
+ return _this;
55
+ }
56
+
57
+ // ── Public API — attribute write ──────────────────────────────────────────
58
+
59
+ /**
60
+ * Set a declared (persistent) flow attribute on a path.
61
+ * The value is stored in PathData and will be serialised with the scene.
62
+ * Triggers a visual update.
63
+ *
64
+ * @param {string} pathId - e.g. "PUMP-1-CONN-1-->CHILLER-1-CONN-2"
65
+ * @param {string} key - One of FLOW_ATTRIBUTE_KEYS
66
+ * @param {any} value
67
+ */
68
+ _rollupPluginBabelHelpers.inherits(PathFlowManager, _BaseDisposable);
69
+ return _rollupPluginBabelHelpers.createClass(PathFlowManager, [{
70
+ key: "setDeclared",
71
+ value: function setDeclared(pathId, key, value) {
72
+ var pd = this._getPathData(pathId);
73
+ if (!pd) {
74
+ console.warn("PathFlowManager.setDeclared: no PathData found for \"".concat(pathId, "\""));
75
+ return;
76
+ }
77
+ pd.setFlowAttribute(key, value);
78
+ this.applyVisualizationForPath(pathId);
79
+ }
80
+
81
+ /**
82
+ * Set a derived (runtime) flow attribute on a path.
83
+ * Overrides the declared value during this session but is not persisted.
84
+ * Triggers a visual update.
85
+ *
86
+ * @param {string} pathId
87
+ * @param {string} key
88
+ * @param {any} value
89
+ */
90
+ }, {
91
+ key: "setDerived",
92
+ value: function setDerived(pathId, key, value) {
93
+ if (!this._derivedStore.has(pathId)) {
94
+ this._derivedStore.set(pathId, {});
95
+ }
96
+ this._derivedStore.get(pathId)[key] = value;
97
+ this.applyVisualizationForPath(pathId);
98
+ }
99
+
100
+ /**
101
+ * Clear derived overrides for one path or all paths, then re-apply
102
+ * visualizations so that declared values take effect again.
103
+ *
104
+ * @param {string} [pathId] - Omit to reset all paths.
105
+ */
106
+ }, {
107
+ key: "resetDerived",
108
+ value: function resetDerived(pathId) {
109
+ var _this2 = this;
110
+ if (pathId !== undefined) {
111
+ this._derivedStore.delete(pathId);
112
+ this.applyVisualizationForPath(pathId);
113
+ } else {
114
+ var affected = _rollupPluginBabelHelpers.toConsumableArray(this._derivedStore.keys());
115
+ this._derivedStore.clear();
116
+ affected.forEach(function (id) {
117
+ return _this2.applyVisualizationForPath(id);
118
+ });
119
+ }
120
+ }
121
+
122
+ // ── Public API — attribute read ───────────────────────────────────────────
123
+
124
+ /**
125
+ * Resolve the effective value of a single attribute for a path.
126
+ * Resolution order: derived > declared > null.
127
+ *
128
+ * @param {string} pathId
129
+ * @param {string} key
130
+ * @returns {any|null}
131
+ */
132
+ }, {
133
+ key: "resolve",
134
+ value: function resolve(pathId, key) {
135
+ var derived = this._derivedStore.get(pathId);
136
+ if (derived && Object.prototype.hasOwnProperty.call(derived, key)) {
137
+ return derived[key];
138
+ }
139
+ var pd = this._getPathData(pathId);
140
+ if (pd) {
141
+ return pd.getFlowAttribute(key);
142
+ }
143
+ return null;
144
+ }
145
+
146
+ /**
147
+ * Resolve all four flow attributes for a path as a plain object.
148
+ * Each key is either the effective value or null if unset.
149
+ *
150
+ * @param {string} pathId
151
+ * @returns {{ flowDirection: any, flowSpeed: any, flowTemperature: any, flowMaterial: any }}
152
+ */
153
+ }, {
154
+ key: "resolveAll",
155
+ value: function resolveAll(pathId) {
156
+ var _this3 = this;
157
+ return Object.fromEntries(pathfindingData.FLOW_ATTRIBUTE_KEYS.map(function (key) {
158
+ return [key, _this3.resolve(pathId, key)];
159
+ }));
160
+ }
161
+
162
+ // ── Visualization ─────────────────────────────────────────────────────────
163
+
164
+ /**
165
+ * Compute and apply the visual colour for a single path based on its resolved
166
+ * flow attributes. Currently maps flowTemperature to a blue→red colour ramp.
167
+ * No-ops gracefully if the path has no renderable attributes or no pipe
168
+ * material exists yet.
169
+ *
170
+ * @param {string} pathId
171
+ */
172
+ }, {
173
+ key: "applyVisualizationForPath",
174
+ value: function applyVisualizationForPath(pathId) {
175
+ var temp = this.resolve(pathId, 'flowTemperature');
176
+ if (temp === null || temp === undefined) {
177
+ return; // No temperature declared — leave default pipe color
178
+ }
179
+ var color = temperatureToColor(temp);
180
+ var renderingManager = this._getRenderingManager();
181
+ if (!renderingManager) return;
182
+
183
+ // pathId = "from-->to"; extract the two halves
184
+ var sepIdx = pathId.indexOf('-->');
185
+ if (sepIdx === -1) {
186
+ console.warn("PathFlowManager: malformed pathId \"".concat(pathId, "\""));
187
+ return;
188
+ }
189
+ var from = pathId.slice(0, sepIdx);
190
+ var to = pathId.slice(sepIdx + 3);
191
+ renderingManager.updatePathColor(from, to, color);
192
+ console.log("\uD83C\uDF21\uFE0F PathFlowManager: \"".concat(pathId, "\" \u2192 flowTemperature ").concat(temp, " \u2192 ").concat(color));
193
+ }
194
+
195
+ /**
196
+ * Apply visualizations for every known path (union of pathDataStore and derived store).
197
+ * Call this after scene load or after bulk attribute changes.
198
+ */
199
+ }, {
200
+ key: "applyAllVisualizations",
201
+ value: function applyAllVisualizations() {
202
+ var _this4 = this;
203
+ var pathIds = new Set();
204
+ var pfMgr = this._getPathfindingManager();
205
+ if (pfMgr !== null && pfMgr !== void 0 && pfMgr.pathDataStore) {
206
+ pfMgr.pathDataStore.forEach(function (_, id) {
207
+ return pathIds.add(id);
208
+ });
209
+ }
210
+ this._derivedStore.forEach(function (_, id) {
211
+ return pathIds.add(id);
212
+ });
213
+ pathIds.forEach(function (id) {
214
+ return _this4.applyVisualizationForPath(id);
215
+ });
216
+ console.log("\uD83C\uDF0A PathFlowManager.applyAllVisualizations: processed ".concat(pathIds.size, " path(s)"));
217
+ }
218
+
219
+ // ── Lifecycle ─────────────────────────────────────────────────────────────
220
+ }, {
221
+ key: "dispose",
222
+ value: function dispose() {
223
+ this._derivedStore.clear();
224
+ this.sceneViewer = null;
225
+ _rollupPluginBabelHelpers.superPropGet(PathFlowManager, "dispose", this, 3)([]);
226
+ }
227
+
228
+ // ── Private helpers ───────────────────────────────────────────────────────
229
+
230
+ /**
231
+ * @returns {import('../../core/pathfindingData.js').PathData|null}
232
+ * @private
233
+ */
234
+ }, {
235
+ key: "_getPathData",
236
+ value: function _getPathData(pathId) {
237
+ var _this$_getPathfinding, _this$_getPathfinding2;
238
+ return (_this$_getPathfinding = (_this$_getPathfinding2 = this._getPathfindingManager()) === null || _this$_getPathfinding2 === void 0 || (_this$_getPathfinding2 = _this$_getPathfinding2.pathDataStore) === null || _this$_getPathfinding2 === void 0 ? void 0 : _this$_getPathfinding2.get(pathId)) !== null && _this$_getPathfinding !== void 0 ? _this$_getPathfinding : null;
239
+ }
240
+
241
+ /**
242
+ * @returns {import('../pathfinding/pathfindingManager.js').PathfindingManager|null}
243
+ * @private
244
+ */
245
+ }, {
246
+ key: "_getPathfindingManager",
247
+ value: function _getPathfindingManager() {
248
+ var _this$sceneViewer$man, _this$sceneViewer;
249
+ return (_this$sceneViewer$man = (_this$sceneViewer = this.sceneViewer) === null || _this$sceneViewer === void 0 || (_this$sceneViewer = _this$sceneViewer.managers) === null || _this$sceneViewer === void 0 ? void 0 : _this$sceneViewer.pathfindingManager) !== null && _this$sceneViewer$man !== void 0 ? _this$sceneViewer$man : null;
250
+ }
251
+
252
+ /**
253
+ * @returns {import('../pathfinding/PathRenderingManager.js').PathRenderingManager|null}
254
+ * @private
255
+ */
256
+ }, {
257
+ key: "_getRenderingManager",
258
+ value: function _getRenderingManager() {
259
+ var _this$_getPathfinding3, _this$_getPathfinding4;
260
+ return (_this$_getPathfinding3 = (_this$_getPathfinding4 = this._getPathfindingManager()) === null || _this$_getPathfinding4 === void 0 ? void 0 : _this$_getPathfinding4.renderingManager) !== null && _this$_getPathfinding3 !== void 0 ? _this$_getPathfinding3 : null;
261
+ }
262
+ }]);
263
+ }(baseDisposable.BaseDisposable);
264
+
265
+ exports.PathFlowManager = PathFlowManager;
@@ -42,16 +42,58 @@ var PathRenderingManager = /*#__PURE__*/function (_BaseDisposable) {
42
42
  emissive: 0
43
43
  });
44
44
  _this.registerDisposable(_this._gatewayGeometry, _this._gatewayMaterial);
45
+
46
+ /**
47
+ * Map of pathId -> THREE.Material for per-path color control.
48
+ * pathId format: "${from}-->${to}"
49
+ * All segments within a path share the same material instance.
50
+ * @type {Map<string, THREE.Material>}
51
+ */
52
+ _this._pathMaterials = new Map();
45
53
  return _this;
46
54
  }
47
55
 
48
56
  /**
49
- * Get path colors for visual distinction
50
- * @param {number} index - Path index
51
- * @returns {string} Hex color string
57
+ * Dispose all tracked per-path materials and clear the map.
58
+ * Called at the start of createPipePaths to clean up stale materials.
59
+ * @private
52
60
  */
53
61
  _rollupPluginBabelHelpers.inherits(PathRenderingManager, _BaseDisposable);
54
62
  return _rollupPluginBabelHelpers.createClass(PathRenderingManager, [{
63
+ key: "_clearPathMaterials",
64
+ value: function _clearPathMaterials() {
65
+ this._pathMaterials.forEach(function (mat) {
66
+ return mat.dispose();
67
+ });
68
+ this._pathMaterials.clear();
69
+ }
70
+
71
+ /**
72
+ * Update the color of all pipe segments belonging to a specific path.
73
+ * Operates on the shared per-path material — no scene traversal needed.
74
+ *
75
+ * @param {string} from - Source connector ID
76
+ * @param {string} to - Target connector ID
77
+ * @param {string|number} color - Any value accepted by THREE.Color.set()
78
+ */
79
+ }, {
80
+ key: "updatePathColor",
81
+ value: function updatePathColor(from, to, color) {
82
+ var pathId = "".concat(from, "-->").concat(to);
83
+ var mat = this._pathMaterials.get(pathId);
84
+ if (mat) {
85
+ mat.color.set(color);
86
+ } else {
87
+ console.warn("\u26A0\uFE0F PathRenderingManager.updatePathColor: no material found for path \"".concat(pathId, "\""));
88
+ }
89
+ }
90
+
91
+ /**
92
+ * Get path colors for visual distinction
93
+ * @param {number} index - Path index
94
+ * @returns {string} Hex color string
95
+ */
96
+ }, {
55
97
  key: "getPathColor",
56
98
  value: function getPathColor(index) {
57
99
  var colors = [
@@ -206,7 +248,11 @@ var PathRenderingManager = /*#__PURE__*/function (_BaseDisposable) {
206
248
  var globalSegmentIndex = maxExistingIndex + 1;
207
249
  console.log("\uD83D\uDD22 Starting segment index at ".concat(globalSegmentIndex, " (max existing: ").concat(maxExistingIndex, ")"));
208
250
  var pipeRadius = 0.1;
209
- var pipeMaterial = this.createPipeMaterial(crosscubeTextureSet);
251
+ // Base material created once; per-path materials are cloned from it below.
252
+ var baseMaterial = this.createPipeMaterial(crosscubeTextureSet);
253
+
254
+ // Dispose previous path materials (they were attached to now-removed segments)
255
+ this._clearPathMaterials();
210
256
  paths.forEach(function (pathData, index) {
211
257
  if (pathData.path && pathData.path.length >= 2) {
212
258
  // Convert path points to Vector3 objects for consistent handling
@@ -223,6 +269,12 @@ var PathRenderingManager = /*#__PURE__*/function (_BaseDisposable) {
223
269
  }
224
270
  });
225
271
 
272
+ // Create a per-path material clone so each path can have its color updated independently.
273
+ var pathId = "".concat(pathData.from, "-->").concat(pathData.to);
274
+ var perPathMaterial = baseMaterial.clone();
275
+ _this3._pathMaterials.set(pathId, perPathMaterial);
276
+ console.log("\uD83C\uDFA8 Created per-path material for \"".concat(pathId, "\""));
277
+
226
278
  // Check if endpoints are component connectors (from pathfinder result)
227
279
  var fromIsComponentConnector = pathData.fromObjectType === 'component-connector';
228
280
  var toIsComponentConnector = pathData.toObjectType === 'component-connector';
@@ -247,13 +299,13 @@ var PathRenderingManager = /*#__PURE__*/function (_BaseDisposable) {
247
299
  var cylinderGeometry = new THREE__namespace.CylinderGeometry(pipeRadius, pipeRadius, length, 16, 1, false);
248
300
 
249
301
  // Determine material (debug red if rectified and in dev mode)
250
- var materialToUse = pipeMaterial;
302
+ var materialToUse = perPathMaterial;
251
303
 
252
304
  // Check for dev mode (strict localhost only)
253
305
  var isDev = typeof window !== 'undefined' && (window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1');
254
306
  if (isDev && pathData.rectifiedSegments && pathData.rectifiedSegments.includes(j)) {
255
- // Create red debug material by cloning the pipe material to match the look
256
- materialToUse = pipeMaterial.clone();
307
+ // Create red debug material by cloning the per-path material to match the look
308
+ materialToUse = perPathMaterial.clone();
257
309
  materialToUse.color.setHex(0xff0000);
258
310
  console.log("\uD83C\uDFA8 Coloring rectified segment ".concat(j, " red"));
259
311
  }
@@ -315,7 +367,7 @@ var PathRenderingManager = /*#__PURE__*/function (_BaseDisposable) {
315
367
  sceneViewer.scene.add(cylinder);
316
368
 
317
369
  // Add smooth elbow joints only at actual direction changes (not at every point)
318
- _this3.createAndAddElbowIfNeeded(pathPoints, j, pipeRadius, pipeMaterial, pathData, index, cylinder // Pass the segment so elbow can be added as a child
370
+ _this3.createAndAddElbowIfNeeded(pathPoints, j, pipeRadius, perPathMaterial, pathData, index, cylinder // Pass the segment so elbow can be added as a child
319
371
  );
320
372
  }
321
373
  }
@@ -420,6 +472,9 @@ var PathRenderingManager = /*#__PURE__*/function (_BaseDisposable) {
420
472
  value: function dispose() {
421
473
  console.log('🗑️ Disposing PathRenderingManager...');
422
474
 
475
+ // Dispose per-path materials
476
+ this._clearPathMaterials();
477
+
423
478
  // Call parent dispose to clean up registered resources (shared gateway geometry/material)
424
479
  _rollupPluginBabelHelpers.superPropGet(PathRenderingManager, "dispose", this, 3)([]);
425
480