@2112-lab/central-plant 0.1.39 → 0.1.41
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/dist/bundle/index.js +7991 -7054
- package/dist/cjs/src/core/centralPlant.js +48 -3
- package/dist/cjs/src/core/centralPlantInternals.js +75 -566
- package/dist/cjs/src/core/sceneViewer.js +38 -13
- package/dist/cjs/src/index.js +6 -4
- package/dist/cjs/src/managers/components/pathfindingManager.js +75 -60
- package/dist/cjs/src/managers/components/transformOperationsManager.js +929 -0
- package/dist/cjs/src/managers/controls/keyboardControlsManager.js +57 -1
- package/dist/cjs/src/managers/controls/transformControls.js +11 -3
- package/dist/cjs/src/managers/controls/transformControlsManager.js +563 -263
- package/dist/cjs/src/managers/pathfinding/ConnectorManager.js +385 -0
- package/dist/cjs/src/managers/pathfinding/PathIntersectionDetector.js +387 -0
- package/dist/cjs/src/managers/pathfinding/PathRenderingManager.js +401 -0
- package/dist/cjs/src/managers/pathfinding/pathfindingManager.js +378 -0
- package/dist/cjs/src/managers/pathfinding/sceneDataManager.js +256 -0
- package/dist/cjs/src/managers/scene/animationManager.js +145 -0
- package/dist/cjs/src/managers/scene/sceneExportManager.js +14 -13
- package/dist/cjs/src/managers/scene/sceneOperationsManager.js +516 -21
- package/dist/cjs/src/managers/scene/sceneTooltipsManager.js +1 -8
- package/dist/cjs/src/managers/system/operationHistoryManager.js +414 -0
- package/dist/cjs/src/managers/system/settingsManager.js +2 -1
- package/dist/cjs/src/utils/objectTypes.js +5 -7
- package/dist/esm/src/core/centralPlant.js +48 -3
- package/dist/esm/src/core/centralPlantInternals.js +76 -567
- package/dist/esm/src/core/sceneViewer.js +38 -13
- package/dist/esm/src/index.js +4 -3
- package/dist/esm/src/managers/components/pathfindingManager.js +75 -60
- package/dist/esm/src/managers/components/transformOperationsManager.js +904 -0
- package/dist/esm/src/managers/controls/keyboardControlsManager.js +57 -1
- package/dist/esm/src/managers/controls/transformControls.js +11 -3
- package/dist/esm/src/managers/controls/transformControlsManager.js +564 -264
- package/dist/esm/src/managers/pathfinding/ConnectorManager.js +361 -0
- package/dist/esm/src/managers/pathfinding/PathIntersectionDetector.js +363 -0
- package/dist/esm/src/managers/pathfinding/PathRenderingManager.js +377 -0
- package/dist/esm/src/managers/pathfinding/pathfindingManager.js +374 -0
- package/dist/esm/src/managers/pathfinding/sceneDataManager.js +232 -0
- package/dist/esm/src/managers/scene/animationManager.js +141 -0
- package/dist/esm/src/managers/scene/sceneExportManager.js +14 -13
- package/dist/esm/src/managers/scene/sceneOperationsManager.js +516 -21
- package/dist/esm/src/managers/scene/sceneTooltipsManager.js +1 -8
- package/dist/esm/src/managers/system/operationHistoryManager.js +409 -0
- package/dist/esm/src/managers/system/settingsManager.js +2 -1
- package/dist/esm/src/utils/objectTypes.js +5 -7
- package/dist/index.d.ts +2 -2
- package/package.json +1 -1
|
@@ -245,8 +245,19 @@ var sceneViewer = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
245
245
|
var _this3 = this;
|
|
246
246
|
// Prevent duplicate handlers
|
|
247
247
|
if (this._resizeHandlerSetup) return;
|
|
248
|
+
|
|
249
|
+
// Debounce timer for resize events
|
|
250
|
+
var resizeTimeout = null;
|
|
248
251
|
var resizeHandler = function resizeHandler() {
|
|
249
|
-
|
|
252
|
+
// Clear any pending resize
|
|
253
|
+
if (resizeTimeout) {
|
|
254
|
+
clearTimeout(resizeTimeout);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
// Debounce resize to prevent excessive calls
|
|
258
|
+
resizeTimeout = setTimeout(function () {
|
|
259
|
+
_this3.handleResize();
|
|
260
|
+
}, 100); // 100ms debounce delay
|
|
250
261
|
};
|
|
251
262
|
window.addEventListener('resize', resizeHandler);
|
|
252
263
|
this._resizeHandlerSetup = true;
|
|
@@ -265,17 +276,33 @@ var sceneViewer = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
265
276
|
var width = this.container.clientWidth;
|
|
266
277
|
var height = this.container.clientHeight;
|
|
267
278
|
|
|
279
|
+
// Validate dimensions to prevent invalid resize
|
|
280
|
+
if (width <= 0 || height <= 0) {
|
|
281
|
+
console.warn('⚠️ Invalid resize dimensions:', {
|
|
282
|
+
width: width,
|
|
283
|
+
height: height
|
|
284
|
+
});
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
|
|
268
288
|
// Update camera aspect ratio
|
|
269
289
|
this.camera.aspect = width / height;
|
|
270
290
|
this.camera.updateProjectionMatrix();
|
|
271
291
|
|
|
272
|
-
// Update renderer size
|
|
273
|
-
this.renderer.setSize(width, height);
|
|
292
|
+
// Update renderer size (updateStyle=true to sync canvas CSS)
|
|
293
|
+
this.renderer.setSize(width, height, true);
|
|
294
|
+
|
|
295
|
+
// Force renderer to clear and re-render to prevent blank screen
|
|
296
|
+
this.renderer.clear();
|
|
274
297
|
|
|
275
298
|
// Update tooltips manager if available
|
|
276
299
|
if (this.tooltipsManager) {
|
|
277
300
|
this.tooltipsManager.resize();
|
|
278
301
|
}
|
|
302
|
+
console.log('🔄 Window resized:', {
|
|
303
|
+
width: width,
|
|
304
|
+
height: height
|
|
305
|
+
});
|
|
279
306
|
}
|
|
280
307
|
|
|
281
308
|
/**
|
|
@@ -566,20 +593,18 @@ var sceneViewer = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
566
593
|
}, {
|
|
567
594
|
key: "isSelectableObject",
|
|
568
595
|
value: function isSelectableObject(object) {
|
|
569
|
-
var _object$userData
|
|
596
|
+
var _object$userData;
|
|
570
597
|
if (object.type == "TransformControlsPlane") {
|
|
571
598
|
object = object.object;
|
|
572
599
|
}
|
|
573
600
|
|
|
574
|
-
// Allow pipe segments
|
|
575
|
-
|
|
576
|
-
var isPipeJunction = ((_object$userData2 = object.userData) === null || _object$userData2 === void 0 ? void 0 : _object$userData2.isPipeJunction) === true;
|
|
577
|
-
if (isPipeSegment) {
|
|
601
|
+
// Allow pipe segments to be selected
|
|
602
|
+
if (((_object$userData = object.userData) === null || _object$userData === void 0 ? void 0 : _object$userData.objectType) === "segment") {
|
|
578
603
|
return true;
|
|
579
604
|
}
|
|
580
605
|
|
|
581
606
|
// Exclude regular polyline parent objects (pipe paths) from selection
|
|
582
|
-
if (object.name && object.name.toLowerCase().includes("polyline")
|
|
607
|
+
if (object.name && object.name.toLowerCase().includes("polyline")) {
|
|
583
608
|
return false;
|
|
584
609
|
}
|
|
585
610
|
|
|
@@ -631,7 +656,7 @@ var sceneViewer = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
631
656
|
}, {
|
|
632
657
|
key: "selectObject",
|
|
633
658
|
value: function selectObject(object) {
|
|
634
|
-
var _object$
|
|
659
|
+
var _object$userData2;
|
|
635
660
|
if (!object || !object.uuid) {
|
|
636
661
|
console.warn('⚠️ Cannot select invalid object');
|
|
637
662
|
return false;
|
|
@@ -642,7 +667,7 @@ var sceneViewer = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
642
667
|
|
|
643
668
|
// Emit selection event with component details
|
|
644
669
|
var componentId = object.name || object.uuid;
|
|
645
|
-
var objectType = ((_object$
|
|
670
|
+
var objectType = ((_object$userData2 = object.userData) === null || _object$userData2 === void 0 ? void 0 : _object$userData2.objectType) || 'component';
|
|
646
671
|
this.emit('component-selected', {
|
|
647
672
|
id: componentId,
|
|
648
673
|
uuid: object.uuid,
|
|
@@ -663,8 +688,8 @@ var sceneViewer = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
663
688
|
var fullCleanup = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
664
689
|
if (this.transformManager) {
|
|
665
690
|
if (fullCleanup) {
|
|
666
|
-
// First deselect any
|
|
667
|
-
if (this.transformManager.
|
|
691
|
+
// First deselect any objects
|
|
692
|
+
if (this.transformManager.selectedObjects && this.transformManager.selectedObjects.length > 0) {
|
|
668
693
|
this.transformManager.deselectObject();
|
|
669
694
|
}
|
|
670
695
|
|
package/dist/esm/src/index.js
CHANGED
|
@@ -9,8 +9,9 @@ export { SceneExportManager } from './managers/scene/sceneExportManager.js';
|
|
|
9
9
|
export { SceneTooltipsManager } from './managers/scene/sceneTooltipsManager.js';
|
|
10
10
|
export { SceneHierarchyManager } from './managers/scene/sceneHierarchyManager.js';
|
|
11
11
|
export { ComponentManager } from './managers/components/componentManager.js';
|
|
12
|
-
export { AnimationManager } from './managers/
|
|
13
|
-
export { PathfindingManager } from './managers/
|
|
12
|
+
export { AnimationManager } from './managers/scene/animationManager.js';
|
|
13
|
+
export { PathfindingManager } from './managers/pathfinding/pathfindingManager.js';
|
|
14
|
+
export { PathIntersectionDetector } from './managers/pathfinding/PathIntersectionDetector.js';
|
|
14
15
|
export { ComponentDataManager } from './managers/components/componentDataManager.js';
|
|
15
16
|
export { createTransformControls } from './managers/controls/transformControlsManager.js';
|
|
16
17
|
export { KeyboardControlsManager } from './managers/controls/keyboardControlsManager.js';
|
|
@@ -20,7 +21,7 @@ export { EnvironmentManager } from './managers/environment/environmentManager.js
|
|
|
20
21
|
export { loadTextureSetAndCreateMaterial } from './managers/environment/textureConfig.js';
|
|
21
22
|
export { ThreeJSResourceManager } from './managers/system/threeJSResourceManager.js';
|
|
22
23
|
export { PerformanceMonitorManager } from './managers/system/performanceMonitorManager.js';
|
|
23
|
-
export {
|
|
24
|
+
export { OperationHistoryManager } from './managers/system/operationHistoryManager.js';
|
|
24
25
|
export { ModelManager } from './managers/scene/modelManager.js';
|
|
25
26
|
export { default as modelPreloader } from './rendering/modelPreloader.js';
|
|
26
27
|
import * as rendering2D from './rendering/rendering2D.js';
|
|
@@ -124,18 +124,10 @@ var PathfindingManager = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
124
124
|
return;
|
|
125
125
|
}
|
|
126
126
|
children.forEach(function (child) {
|
|
127
|
-
var _child$userData, _child$userData2, _child$userData3, _child$userData5, _child$userData6, _child$userData7;
|
|
127
|
+
var _child$userData, _child$userData2, _child$userData3, _child$userData5, _child$userData6, _child$userData7, _child$userData8;
|
|
128
128
|
// Skip manual segments - they are visual only and not obstacles for pathfinding
|
|
129
|
+
// BUT: Keep them in the scene data structure for parent-child relationships
|
|
129
130
|
var isManualSegment = ((_child$userData = child.userData) === null || _child$userData === void 0 ? void 0 : _child$userData.objectType) === 'segment';
|
|
130
|
-
if (isManualSegment) {
|
|
131
|
-
console.log("\u23ED\uFE0F Skipping manual segment in pathfinder: ".concat(child.uuid));
|
|
132
|
-
|
|
133
|
-
// Still process the segment's connector children if they exist
|
|
134
|
-
if (child.children && Array.isArray(child.children) && child.children.length > 0) {
|
|
135
|
-
_collectAllObjects(child.children);
|
|
136
|
-
}
|
|
137
|
-
return; // Skip adding the segment itself
|
|
138
|
-
}
|
|
139
131
|
|
|
140
132
|
// Convert connectors to position-based format (Phase 2 Refactoring)
|
|
141
133
|
// BUT: Skip manual (declared) connectors and gateways - their positions are already set
|
|
@@ -169,6 +161,13 @@ var PathfindingManager = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
169
161
|
delete child.rotation;
|
|
170
162
|
}
|
|
171
163
|
|
|
164
|
+
// IMPORTANT: Remove bounding boxes from manual segments so they're not treated as obstacles
|
|
165
|
+
// Manual segments are visual-only representations of paths that have already been manually positioned
|
|
166
|
+
if (isManualSegment && (_child$userData8 = child.userData) !== null && _child$userData8 !== void 0 && _child$userData8.worldBoundingBox) {
|
|
167
|
+
console.log("\uD83D\uDD27 Removing bounding box from manual segment: ".concat(child.uuid));
|
|
168
|
+
delete child.userData.worldBoundingBox;
|
|
169
|
+
}
|
|
170
|
+
|
|
172
171
|
// If this object has children, recursively collect them before clearing
|
|
173
172
|
if (child.children && Array.isArray(child.children) && child.children.length > 0) {
|
|
174
173
|
_collectAllObjects(child.children);
|
|
@@ -198,11 +197,13 @@ var PathfindingManager = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
198
197
|
key: "_executePathfinding",
|
|
199
198
|
value: (function () {
|
|
200
199
|
var _executePathfinding2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(sceneData, connections) {
|
|
200
|
+
var _simplifiedSceneData$;
|
|
201
201
|
var options,
|
|
202
202
|
_options$context,
|
|
203
203
|
context,
|
|
204
204
|
sceneDataCopy,
|
|
205
205
|
connectionsCopy,
|
|
206
|
+
simplifiedSceneData,
|
|
206
207
|
pathfindingResult,
|
|
207
208
|
_args = arguments;
|
|
208
209
|
return _regenerator().w(function (_context) {
|
|
@@ -219,8 +220,10 @@ var PathfindingManager = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
219
220
|
|
|
220
221
|
// Create a deep copy of scene data to avoid mutation of the original
|
|
221
222
|
sceneDataCopy = JSON.parse(JSON.stringify(sceneData)); // Deep copy connections to prevent pathfinder from mutating the original
|
|
222
|
-
connectionsCopy = JSON.parse(JSON.stringify(connections));
|
|
223
|
-
|
|
223
|
+
connectionsCopy = JSON.parse(JSON.stringify(connections));
|
|
224
|
+
simplifiedSceneData = JSON.parse(JSON.stringify(this.getSimplifiedSceneData()));
|
|
225
|
+
console.log('[Pathfinder] simplifiedSceneData length at creation:', (_simplifiedSceneData$ = simplifiedSceneData.children) === null || _simplifiedSceneData$ === void 0 ? void 0 : _simplifiedSceneData$.length);
|
|
226
|
+
console.log('[Pathfinder] simplifiedSceneData (deep clone for inspection):', JSON.parse(JSON.stringify(simplifiedSceneData)));
|
|
224
227
|
console.log('🏗️ [Pathfinder] sceneData structure before:', JSON.parse(JSON.stringify(sceneDataCopy)));
|
|
225
228
|
|
|
226
229
|
// Flatten the sceneData structure - move all connector children to root level
|
|
@@ -233,7 +236,7 @@ var PathfindingManager = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
233
236
|
|
|
234
237
|
// Find paths using v1.0.17 API (sceneData and connections separately)
|
|
235
238
|
// Pass deep copy to ensure pathfinder cannot mutate original connections
|
|
236
|
-
pathfindingResult = this.pathfinder.findPaths(
|
|
239
|
+
pathfindingResult = this.pathfinder.findPaths(simplifiedSceneData, connectionsCopy);
|
|
237
240
|
console.log('[Pathfinder] Found paths:', JSON.parse(JSON.stringify(pathfindingResult.paths)));
|
|
238
241
|
console.log('Generated gateways:', JSON.parse(JSON.stringify(pathfindingResult.gateways)));
|
|
239
242
|
console.log('Rewired connections:', JSON.parse(JSON.stringify(pathfindingResult.rewiredConnections)));
|
|
@@ -292,8 +295,6 @@ var PathfindingManager = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
292
295
|
isDeclared: false,
|
|
293
296
|
gatewayId: gateway.id,
|
|
294
297
|
originalUuid: gateway.id,
|
|
295
|
-
origin: 'computed',
|
|
296
|
-
// Keep for backward compatibility
|
|
297
298
|
// Deep copy connections to prevent mutations affecting pathfinder's internal state
|
|
298
299
|
connections: gateway.connections ? {
|
|
299
300
|
removed: gateway.connections.removed ? _toConsumableArray(gateway.connections.removed) : [],
|
|
@@ -313,14 +314,18 @@ var PathfindingManager = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
313
314
|
key: "getSimplifiedSceneData",
|
|
314
315
|
value: function getSimplifiedSceneData() {
|
|
315
316
|
// Collect all objects with objectType (flattened list from scene traversal)
|
|
317
|
+
// Filter out ALL computed objects - only include declared/source objects
|
|
316
318
|
var sceneDataNew = [];
|
|
317
319
|
this.sceneViewer.scene.traverse(function (obj) {
|
|
318
|
-
if (obj.userData && obj.userData.objectType
|
|
320
|
+
if (obj.userData && obj.userData.objectType) {
|
|
321
|
+
// Skip computed gateways (only include declared/manual gateways)
|
|
322
|
+
if (obj.userData.objectType === 'gateway' && !obj.userData.isDeclared) {
|
|
323
|
+
return;
|
|
324
|
+
}
|
|
319
325
|
sceneDataNew.push(obj);
|
|
320
326
|
}
|
|
321
327
|
});
|
|
322
328
|
console.log('🔗 [Pathfinder] sceneDataNew (flattened):', sceneDataNew);
|
|
323
|
-
console.log('🔗 [Pathfinder] this.sceneViewer.scene:', this.sceneViewer.scene);
|
|
324
329
|
|
|
325
330
|
// Calculate world bounding boxes for each object individually (after flattening)
|
|
326
331
|
// This way we don't need to worry about children - each object is standalone
|
|
@@ -344,12 +349,16 @@ var PathfindingManager = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
344
349
|
bbox.applyMatrix4(obj.matrixWorld);
|
|
345
350
|
|
|
346
351
|
// Only include valid bounding boxes
|
|
347
|
-
if
|
|
352
|
+
// Check if all components of min and max are finite numbers
|
|
353
|
+
var isValidBBox = !bbox.isEmpty() && isFinite(bbox.min.x) && isFinite(bbox.min.y) && isFinite(bbox.min.z) && isFinite(bbox.max.x) && isFinite(bbox.max.y) && isFinite(bbox.max.z);
|
|
354
|
+
if (isValidBBox) {
|
|
348
355
|
worldBoundingBox = {
|
|
349
356
|
min: bbox.min.toArray(),
|
|
350
357
|
max: bbox.max.toArray()
|
|
351
358
|
};
|
|
352
359
|
console.log("\uD83D\uDCE6 Calculated worldBoundingBox for ".concat(uuid, ":"), worldBoundingBox);
|
|
360
|
+
} else {
|
|
361
|
+
console.log('🔗 [Pathfinder] sceneDataNew worldBoundingBox not calculated');
|
|
353
362
|
}
|
|
354
363
|
}
|
|
355
364
|
} catch (error) {
|
|
@@ -360,7 +369,10 @@ var PathfindingManager = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
360
369
|
else if (obj.isGroup || ((_obj$children = obj.children) === null || _obj$children === void 0 ? void 0 : _obj$children.length) > 0) {
|
|
361
370
|
try {
|
|
362
371
|
var _bbox = new THREE.Box3().setFromObject(obj);
|
|
363
|
-
|
|
372
|
+
|
|
373
|
+
// Check if all components of min and max are finite numbers
|
|
374
|
+
var _isValidBBox = !_bbox.isEmpty() && isFinite(_bbox.min.x) && isFinite(_bbox.min.y) && isFinite(_bbox.min.z) && isFinite(_bbox.max.x) && isFinite(_bbox.max.y) && isFinite(_bbox.max.z);
|
|
375
|
+
if (_isValidBBox) {
|
|
364
376
|
worldBoundingBox = {
|
|
365
377
|
min: _bbox.min.toArray(),
|
|
366
378
|
max: _bbox.max.toArray()
|
|
@@ -371,12 +383,18 @@ var PathfindingManager = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
371
383
|
console.warn("\u26A0\uFE0F Failed to calculate bounding box for ".concat(uuid, ":"), error);
|
|
372
384
|
}
|
|
373
385
|
}
|
|
374
|
-
|
|
386
|
+
var results = {
|
|
375
387
|
uuid: uuid,
|
|
376
388
|
userData: _objectSpread2(_objectSpread2({}, obj.userData), worldBoundingBox && {
|
|
377
389
|
worldBoundingBox: worldBoundingBox
|
|
378
390
|
})
|
|
379
391
|
};
|
|
392
|
+
if (obj.userData.objectType.includes('connector') || obj.userData.objectType === 'gateway') {
|
|
393
|
+
var worldPosition = new THREE.Vector3();
|
|
394
|
+
obj.getWorldPosition(worldPosition);
|
|
395
|
+
results.userData.position = [worldPosition.x, worldPosition.y, worldPosition.z];
|
|
396
|
+
}
|
|
397
|
+
return results;
|
|
380
398
|
});
|
|
381
399
|
return simplifiedSceneData;
|
|
382
400
|
}
|
|
@@ -470,10 +488,10 @@ var PathfindingManager = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
470
488
|
*/
|
|
471
489
|
}, {
|
|
472
490
|
key: "createPipeMaterial",
|
|
473
|
-
value: function createPipeMaterial(crosscubeTextureSet
|
|
491
|
+
value: function createPipeMaterial(crosscubeTextureSet) {
|
|
474
492
|
if (crosscubeTextureSet) {
|
|
475
493
|
var materialProps = _objectSpread2(_objectSpread2({}, crosscubeTextureSet.config.materialProps), {}, {
|
|
476
|
-
color: this.getPathColor(
|
|
494
|
+
color: this.getPathColor(0),
|
|
477
495
|
map: crosscubeTextureSet.textures.diffuse,
|
|
478
496
|
normalMap: crosscubeTextureSet.textures.normal,
|
|
479
497
|
roughnessMap: crosscubeTextureSet.textures.roughness,
|
|
@@ -482,7 +500,9 @@ var PathfindingManager = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
482
500
|
clearcoat: 0.2,
|
|
483
501
|
clearcoatRoughness: 0.2,
|
|
484
502
|
envMapIntensity: 0.6,
|
|
485
|
-
reflectivity: 0.4
|
|
503
|
+
reflectivity: 0.4,
|
|
504
|
+
transparent: true,
|
|
505
|
+
opacity: 0.75
|
|
486
506
|
});
|
|
487
507
|
|
|
488
508
|
// Handle normalScale conversion to Vector2
|
|
@@ -500,7 +520,7 @@ var PathfindingManager = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
500
520
|
return material;
|
|
501
521
|
} else {
|
|
502
522
|
return new THREE.MeshPhysicalMaterial({
|
|
503
|
-
color: this.getPathColor(
|
|
523
|
+
color: this.getPathColor(0),
|
|
504
524
|
metalness: 0.9,
|
|
505
525
|
roughness: 0.7,
|
|
506
526
|
clearcoat: 0.1,
|
|
@@ -523,7 +543,7 @@ var PathfindingManager = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
523
543
|
paths.forEach(function (pathData, index) {
|
|
524
544
|
if (pathData.path && pathData.path.length >= 2) {
|
|
525
545
|
var pipeRadius = 0.1;
|
|
526
|
-
var pipeMaterial = _this4.createPipeMaterial(crosscubeTextureSet
|
|
546
|
+
var pipeMaterial = _this4.createPipeMaterial(crosscubeTextureSet);
|
|
527
547
|
|
|
528
548
|
// Convert path points to Vector3 objects for consistent handling
|
|
529
549
|
var pathPoints = pathData.path.map(function (point) {
|
|
@@ -569,12 +589,11 @@ var PathfindingManager = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
569
589
|
|
|
570
590
|
// Add userData to make pipe segments selectable and for tooltip display
|
|
571
591
|
cylinder.userData = {
|
|
572
|
-
|
|
592
|
+
objectType: 'segment',
|
|
573
593
|
segmentId: segmentId,
|
|
574
594
|
segmentIndex: globalSegmentIndex,
|
|
575
595
|
pathFrom: pathData.from,
|
|
576
|
-
pathTo: pathData.to
|
|
577
|
-
pathIndex: index
|
|
596
|
+
pathTo: pathData.to
|
|
578
597
|
};
|
|
579
598
|
|
|
580
599
|
// Increment global segment counter
|
|
@@ -600,11 +619,11 @@ var PathfindingManager = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
600
619
|
}, {
|
|
601
620
|
key: "manualizeSegment",
|
|
602
621
|
value: function manualizeSegment(segment, currentSceneData) {
|
|
603
|
-
|
|
622
|
+
var _segment$userData;
|
|
623
|
+
if (!segment || !((_segment$userData = segment.userData) !== null && _segment$userData !== void 0 && _segment$userData.objectType) === 'segment') {
|
|
604
624
|
console.log('❌ Object is not a pipe segment:', {
|
|
605
625
|
isObject: !!segment,
|
|
606
|
-
hasUserData: !!(segment && segment.userData)
|
|
607
|
-
isPipeSegment: !!(segment && segment.userData && segment.userData.isPipeSegment)
|
|
626
|
+
hasUserData: !!(segment && segment.userData)
|
|
608
627
|
});
|
|
609
628
|
return;
|
|
610
629
|
}
|
|
@@ -692,18 +711,16 @@ var PathfindingManager = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
692
711
|
var additionalSceneDataProps = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
693
712
|
// Mark in the scene object
|
|
694
713
|
object.userData.isDeclared = true;
|
|
695
|
-
object.userData.origin = 'declared'; // Backward compatibility
|
|
696
714
|
|
|
697
715
|
// Find and update in scene data
|
|
698
716
|
var foundInSceneData = false;
|
|
699
717
|
for (var i = 0; i < currentSceneData.scene.children.length; i++) {
|
|
700
|
-
var _object$userData, _child$
|
|
718
|
+
var _object$userData, _child$userData9;
|
|
701
719
|
var child = currentSceneData.scene.children[i];
|
|
702
|
-
if (child.uuid === object.uuid || child.uuid === ((_object$userData = object.userData) === null || _object$userData === void 0 ? void 0 : _object$userData.originalUuid) || object.uuid === ((_child$
|
|
720
|
+
if (child.uuid === object.uuid || child.uuid === ((_object$userData = object.userData) === null || _object$userData === void 0 ? void 0 : _object$userData.originalUuid) || object.uuid === ((_child$userData9 = child.userData) === null || _child$userData9 === void 0 ? void 0 : _child$userData9.originalUuid)) {
|
|
703
721
|
var _object$userData2, _object$userData3;
|
|
704
722
|
if (!child.userData) child.userData = {};
|
|
705
723
|
child.userData.isDeclared = true;
|
|
706
|
-
child.userData.origin = 'declared';
|
|
707
724
|
|
|
708
725
|
// Update position in scene data
|
|
709
726
|
if (!child.position) {
|
|
@@ -725,14 +742,13 @@ var PathfindingManager = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
725
742
|
|
|
726
743
|
// If not found in scene data, add it
|
|
727
744
|
if (!foundInSceneData) {
|
|
728
|
-
var _object$userData4, _object$userData5, _object$userData6
|
|
745
|
+
var _object$userData4, _object$userData5, _object$userData6;
|
|
729
746
|
console.log("\u26A0\uFE0F Object ".concat(object.uuid, " not found in scene data, adding it now"));
|
|
730
747
|
var sceneDataObject = _objectSpread2({
|
|
731
748
|
uuid: object.uuid,
|
|
732
749
|
userData: _objectSpread2({
|
|
733
750
|
objectType: object.userData.objectType,
|
|
734
|
-
isDeclared: true
|
|
735
|
-
origin: 'declared'
|
|
751
|
+
isDeclared: true
|
|
736
752
|
}, object.userData),
|
|
737
753
|
position: {
|
|
738
754
|
x: object.position.x,
|
|
@@ -747,20 +763,20 @@ var PathfindingManager = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
747
763
|
}
|
|
748
764
|
|
|
749
765
|
// For segments, initialize children array to hold connectors
|
|
750
|
-
if ((_object$userData6 = object.userData)
|
|
766
|
+
if (((_object$userData6 = object.userData) === null || _object$userData6 === void 0 ? void 0 : _object$userData6.objectType) === 'segment') {
|
|
751
767
|
sceneDataObject.children = [];
|
|
752
768
|
console.log("\uD83D\uDCE6 Initialized children array for segment: ".concat(object.uuid));
|
|
753
769
|
}
|
|
754
770
|
currentSceneData.scene.children.push(sceneDataObject);
|
|
755
771
|
console.log("\u2705 Added object to scene data as declared: ".concat(object.uuid));
|
|
756
772
|
} else {
|
|
757
|
-
var _object$
|
|
773
|
+
var _object$userData8;
|
|
758
774
|
// If segment was found in scene data, ensure it has a children array
|
|
759
775
|
var _child = currentSceneData.scene.children.find(function (c) {
|
|
760
|
-
var _object$
|
|
761
|
-
return c.uuid === object.uuid || c.uuid === ((_object$
|
|
776
|
+
var _object$userData7, _c$userData;
|
|
777
|
+
return c.uuid === object.uuid || c.uuid === ((_object$userData7 = object.userData) === null || _object$userData7 === void 0 ? void 0 : _object$userData7.originalUuid) || object.uuid === ((_c$userData = c.userData) === null || _c$userData === void 0 ? void 0 : _c$userData.originalUuid);
|
|
762
778
|
});
|
|
763
|
-
if (_child && ((_object$
|
|
779
|
+
if (_child && ((_object$userData8 = object.userData) === null || _object$userData8 === void 0 ? void 0 : _object$userData8.objectType) === 'segment') {
|
|
764
780
|
if (!_child.children) {
|
|
765
781
|
_child.children = [];
|
|
766
782
|
console.log("\uD83D\uDCE6 Initialized children array for existing segment: ".concat(_child.uuid));
|
|
@@ -771,7 +787,7 @@ var PathfindingManager = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
771
787
|
|
|
772
788
|
/**
|
|
773
789
|
* Check and convert gateways at the original path endpoints to manual (declared)
|
|
774
|
-
* This method now delegates to
|
|
790
|
+
* This method now delegates to manualizeGateway to ensure consistent gateway handling
|
|
775
791
|
* @param {Array} connectors - Array of connector objects (used to get segment reference)
|
|
776
792
|
* @param {Object} currentSceneData - Current scene data
|
|
777
793
|
* @returns {Array<string>} Array of converted gateway UUIDs
|
|
@@ -780,7 +796,7 @@ var PathfindingManager = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
780
796
|
key: "convertConnectedGatewaysToManual",
|
|
781
797
|
value: function convertConnectedGatewaysToManual(connectors, currentSceneData) {
|
|
782
798
|
var _connectors$,
|
|
783
|
-
_segment$
|
|
799
|
+
_segment$userData2,
|
|
784
800
|
_this5 = this;
|
|
785
801
|
console.log('🔍 Checking for connected gateways to convert to manual...');
|
|
786
802
|
var sceneViewer = this.sceneViewer;
|
|
@@ -788,7 +804,7 @@ var PathfindingManager = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
788
804
|
|
|
789
805
|
// Get the segment from the first connector's userData
|
|
790
806
|
var segment = (_connectors$ = connectors[0]) !== null && _connectors$ !== void 0 && (_connectors$ = _connectors$.userData) !== null && _connectors$ !== void 0 && _connectors$.manualSegmentUuid ? sceneViewer.scene.getObjectByProperty('uuid', connectors[0].userData.manualSegmentUuid) : null;
|
|
791
|
-
if (!segment || !((_segment$
|
|
807
|
+
if (!segment || !((_segment$userData2 = segment.userData) !== null && _segment$userData2 !== void 0 && _segment$userData2.objectType) === 'segment') {
|
|
792
808
|
console.log('❌ Could not find segment for gateway conversion');
|
|
793
809
|
return [];
|
|
794
810
|
}
|
|
@@ -809,18 +825,18 @@ var PathfindingManager = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
809
825
|
}
|
|
810
826
|
});
|
|
811
827
|
if (endpointObject) {
|
|
812
|
-
var _endpointObject$userD, _endpointObject$userD2, _endpointObject$userD3, _endpointObject$userD4, _endpointObject$userD5, _endpointObject$userD6
|
|
813
|
-
console.log("\uD83D\uDD0D Found endpoint object: ".concat(endpointObject.uuid, " - objectType: ").concat((_endpointObject$userD = endpointObject.userData) === null || _endpointObject$userD === void 0 ? void 0 : _endpointObject$userD.objectType, ", isDeclared: ").concat((_endpointObject$userD2 = endpointObject.userData) === null || _endpointObject$userD2 === void 0 ? void 0 : _endpointObject$userD2.isDeclared
|
|
828
|
+
var _endpointObject$userD, _endpointObject$userD2, _endpointObject$userD3, _endpointObject$userD4, _endpointObject$userD5, _endpointObject$userD6;
|
|
829
|
+
console.log("\uD83D\uDD0D Found endpoint object: ".concat(endpointObject.uuid, " - objectType: ").concat((_endpointObject$userD = endpointObject.userData) === null || _endpointObject$userD === void 0 ? void 0 : _endpointObject$userD.objectType, ", isDeclared: ").concat((_endpointObject$userD2 = endpointObject.userData) === null || _endpointObject$userD2 === void 0 ? void 0 : _endpointObject$userD2.isDeclared));
|
|
814
830
|
|
|
815
831
|
// Check if this endpoint is a gateway that needs to be converted to manual
|
|
816
832
|
// IMPORTANT: Only convert if it's NOT already declared to prevent double-processing
|
|
817
|
-
if (((_endpointObject$
|
|
833
|
+
if (((_endpointObject$userD3 = endpointObject.userData) === null || _endpointObject$userD3 === void 0 ? void 0 : _endpointObject$userD3.objectType) === 'gateway' && ((_endpointObject$userD4 = endpointObject.userData) === null || _endpointObject$userD4 === void 0 ? void 0 : _endpointObject$userD4.isDeclared) !== true) {
|
|
818
834
|
console.log("\uD83D\uDD27 Found computed gateway at endpoint: ".concat(endpointObject.uuid, " - converting to manual"));
|
|
819
835
|
|
|
820
836
|
// Convert gateway to manual (declared) using manualizeGateway for consistency
|
|
821
837
|
_this5.manualizeGateway(endpointObject, currentSceneData);
|
|
822
838
|
convertedGateways.push(endpointObject);
|
|
823
|
-
} else if (((_endpointObject$
|
|
839
|
+
} else if (((_endpointObject$userD5 = endpointObject.userData) === null || _endpointObject$userD5 === void 0 ? void 0 : _endpointObject$userD5.objectType) === 'gateway' && ((_endpointObject$userD6 = endpointObject.userData) === null || _endpointObject$userD6 === void 0 ? void 0 : _endpointObject$userD6.isDeclared) === true) {
|
|
824
840
|
console.log("\u2139\uFE0F Gateway ".concat(endpointObject.uuid, " is already declared (manual), skipping conversion"));
|
|
825
841
|
}
|
|
826
842
|
} else {
|
|
@@ -909,8 +925,7 @@ var PathfindingManager = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
909
925
|
if (!gateway || !gateway.userData || gateway.userData.objectType !== 'gateway') {
|
|
910
926
|
console.log('❌ Object is not a gateway:', {
|
|
911
927
|
isObject: !!gateway,
|
|
912
|
-
hasUserData: !!(gateway && gateway.userData)
|
|
913
|
-
isGateway: !!(gateway && gateway.userData && gateway.userData.objectType === 'gateway')
|
|
928
|
+
hasUserData: !!(gateway && gateway.userData)
|
|
914
929
|
});
|
|
915
930
|
return;
|
|
916
931
|
}
|
|
@@ -974,7 +989,6 @@ var PathfindingManager = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
974
989
|
gatewayId: gateway.userData.gatewayId || gateway.uuid,
|
|
975
990
|
originalUuid: gateway.userData.originalUuid || gateway.uuid,
|
|
976
991
|
isDeclared: true,
|
|
977
|
-
origin: 'declared',
|
|
978
992
|
connections: gateway.userData.connections,
|
|
979
993
|
position: [gateway.position.x, gateway.position.y, gateway.position.z]
|
|
980
994
|
},
|
|
@@ -1142,11 +1156,12 @@ var PathfindingManager = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
1142
1156
|
startConnector.position.copy(localStartPosition);
|
|
1143
1157
|
startConnector.uuid = "SEGMENT-".concat(segmentIndex, "-CONNECTOR-1");
|
|
1144
1158
|
startConnector.userData = {
|
|
1145
|
-
objectType: 'connector',
|
|
1159
|
+
objectType: 'segment-connector',
|
|
1146
1160
|
isManualSegmentConnector: true,
|
|
1147
1161
|
segmentId: segmentId,
|
|
1148
1162
|
connectorType: 'start',
|
|
1149
|
-
manualSegmentUuid: segment.uuid
|
|
1163
|
+
manualSegmentUuid: segment.uuid,
|
|
1164
|
+
isDeclared: true
|
|
1150
1165
|
};
|
|
1151
1166
|
|
|
1152
1167
|
// Add start connector as child of segment
|
|
@@ -1161,11 +1176,12 @@ var PathfindingManager = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
1161
1176
|
endConnector.position.copy(localEndPosition);
|
|
1162
1177
|
endConnector.uuid = "SEGMENT-".concat(segmentIndex, "-CONNECTOR-2");
|
|
1163
1178
|
endConnector.userData = {
|
|
1164
|
-
objectType: 'connector',
|
|
1179
|
+
objectType: 'segment-connector',
|
|
1165
1180
|
isManualSegmentConnector: true,
|
|
1166
1181
|
segmentId: segmentId,
|
|
1167
1182
|
connectorType: 'end',
|
|
1168
|
-
manualSegmentUuid: segment.uuid
|
|
1183
|
+
manualSegmentUuid: segment.uuid,
|
|
1184
|
+
isDeclared: true
|
|
1169
1185
|
};
|
|
1170
1186
|
|
|
1171
1187
|
// Add end connector as child of segment
|
|
@@ -1363,7 +1379,6 @@ var PathfindingManager = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
1363
1379
|
elbowIndex: j,
|
|
1364
1380
|
pathFrom: pathData.from,
|
|
1365
1381
|
pathTo: pathData.to,
|
|
1366
|
-
pathIndex: index,
|
|
1367
1382
|
angle: (angle * 180 / Math.PI).toFixed(1),
|
|
1368
1383
|
// Add component data for tooltips
|
|
1369
1384
|
component: {
|
|
@@ -1461,11 +1476,11 @@ var PathfindingManager = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
1461
1476
|
_step2;
|
|
1462
1477
|
try {
|
|
1463
1478
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
1464
|
-
var _object$
|
|
1479
|
+
var _object$userData9, _child$userData0;
|
|
1465
1480
|
var child = _step2.value;
|
|
1466
1481
|
// Use the centralized findObjectByHardcodedUuid logic (but for JSON objects)
|
|
1467
1482
|
// Strategy 1: Direct hardcoded UUID match (HIGHEST PRIORITY)
|
|
1468
|
-
if (child.uuid === object.uuid || child.uuid === ((_object$
|
|
1483
|
+
if (child.uuid === object.uuid || child.uuid === ((_object$userData9 = object.userData) === null || _object$userData9 === void 0 ? void 0 : _object$userData9.originalUuid) || object.uuid === ((_child$userData0 = child.userData) === null || _child$userData0 === void 0 ? void 0 : _child$userData0.originalUuid)) {
|
|
1469
1484
|
return child;
|
|
1470
1485
|
}
|
|
1471
1486
|
|