@2112-lab/central-plant 0.1.1 → 0.1.3

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.
Files changed (55) hide show
  1. package/dist/bundle/index.js +1 -15140
  2. package/dist/cjs/_virtual/_rollupPluginBabelHelpers.js +1 -353
  3. package/dist/cjs/node_modules/@2112-lab/pathfinder/dist/index.esm.js +1 -0
  4. package/dist/cjs/node_modules/three/examples/jsm/controls/OrbitControls.js +1 -1292
  5. package/dist/cjs/node_modules/three/examples/jsm/controls/TransformControls.js +1 -1543
  6. package/dist/cjs/node_modules/three/examples/jsm/loaders/GLTFLoader.js +1 -4374
  7. package/dist/cjs/node_modules/three/examples/jsm/loaders/RGBELoader.js +1 -465
  8. package/dist/cjs/node_modules/three/examples/jsm/utils/BufferGeometryUtils.js +1 -117
  9. package/dist/cjs/src/animationManager.js +1 -121
  10. package/dist/cjs/src/componentManager.js +1 -151
  11. package/dist/cjs/src/debugLogger.js +1 -176
  12. package/dist/cjs/src/disposalManager.js +1 -185
  13. package/dist/cjs/src/environmentManager.js +1 -1308
  14. package/dist/cjs/src/hotReloadManager.js +1 -252
  15. package/dist/cjs/src/index.js +1 -128
  16. package/dist/cjs/src/keyboardControlsManager.js +1 -206
  17. package/dist/cjs/src/nameUtils.js +1 -106
  18. package/dist/cjs/src/pathfindingManager.js +1 -321
  19. package/dist/cjs/src/performanceMonitor.js +1 -718
  20. package/dist/cjs/src/sceneExportManager.js +1 -292
  21. package/dist/cjs/src/sceneInitializationManager.js +1 -540
  22. package/dist/cjs/src/textureConfig.js +1 -624
  23. package/dist/cjs/src/transformControlsManager.js +1 -851
  24. package/dist/esm/_virtual/_rollupPluginBabelHelpers.js +1 -328
  25. package/dist/esm/node_modules/@2112-lab/pathfinder/dist/index.esm.js +1 -0
  26. package/dist/esm/node_modules/three/examples/jsm/controls/OrbitControls.js +1 -1287
  27. package/dist/esm/node_modules/three/examples/jsm/controls/TransformControls.js +1 -1537
  28. package/dist/esm/node_modules/three/examples/jsm/loaders/GLTFLoader.js +1 -4370
  29. package/dist/esm/node_modules/three/examples/jsm/loaders/RGBELoader.js +1 -461
  30. package/dist/esm/node_modules/three/examples/jsm/utils/BufferGeometryUtils.js +1 -113
  31. package/dist/esm/src/animationManager.js +1 -112
  32. package/dist/esm/src/componentManager.js +1 -123
  33. package/dist/esm/src/debugLogger.js +1 -167
  34. package/dist/esm/src/disposalManager.js +1 -155
  35. package/dist/esm/src/environmentManager.js +1 -1282
  36. package/dist/esm/src/hotReloadManager.js +1 -244
  37. package/dist/esm/src/index.js +1 -118
  38. package/dist/esm/src/keyboardControlsManager.js +1 -196
  39. package/dist/esm/src/nameUtils.js +1 -99
  40. package/dist/esm/src/pathfindingManager.js +1 -295
  41. package/dist/esm/src/performanceMonitor.js +1 -712
  42. package/dist/esm/src/sceneExportManager.js +1 -286
  43. package/dist/esm/src/sceneInitializationManager.js +1 -513
  44. package/dist/esm/src/textureConfig.js +1 -595
  45. package/dist/esm/src/transformControlsManager.js +1 -827
  46. package/dist/index.d.ts +0 -4
  47. package/package.json +1 -1
  48. package/dist/cjs/src/ConnectionManager.js +0 -114
  49. package/dist/cjs/src/Pathfinder.js +0 -88
  50. package/dist/cjs/src/modelPreloader.js +0 -488
  51. package/dist/cjs/src/sceneOperationsManager.js +0 -596
  52. package/dist/esm/src/ConnectionManager.js +0 -110
  53. package/dist/esm/src/Pathfinder.js +0 -84
  54. package/dist/esm/src/modelPreloader.js +0 -464
  55. package/dist/esm/src/sceneOperationsManager.js +0 -572
@@ -1,596 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var _rollupPluginBabelHelpers = require('../_virtual/_rollupPluginBabelHelpers.js');
6
- var nameUtils = require('./nameUtils.js');
7
-
8
- function _interopNamespace(e) {
9
- if (e && e.__esModule) return e;
10
- var n = Object.create(null);
11
- if (e) {
12
- Object.keys(e).forEach(function (k) {
13
- if (k !== 'default') {
14
- var d = Object.getOwnPropertyDescriptor(e, k);
15
- Object.defineProperty(n, k, d.get ? d : {
16
- enumerable: true,
17
- get: function () { return e[k]; }
18
- });
19
- }
20
- });
21
- }
22
- n["default"] = e;
23
- return Object.freeze(n);
24
- }
25
-
26
- /**
27
- * SceneOperationsManager
28
- * Handles scene loading, clearing, and object management operations
29
- */
30
-
31
- var THREE;
32
-
33
- /**
34
- * Dynamically import ThreeJS when in browser environment
35
- */
36
- function importDependencies() {
37
- return _importDependencies.apply(this, arguments);
38
- }
39
- function _importDependencies() {
40
- _importDependencies = _rollupPluginBabelHelpers.asyncToGenerator(/*#__PURE__*/_rollupPluginBabelHelpers.regenerator().m(function _callee() {
41
- var _t;
42
- return _rollupPluginBabelHelpers.regenerator().w(function (_context) {
43
- while (1) switch (_context.n) {
44
- case 0:
45
- if (!(typeof window !== 'undefined')) {
46
- _context.n = 4;
47
- break;
48
- }
49
- _context.p = 1;
50
- _context.n = 2;
51
- return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('three')); });
52
- case 2:
53
- THREE = _context.v;
54
- _context.n = 4;
55
- break;
56
- case 3:
57
- _context.p = 3;
58
- _t = _context.v;
59
- console.error('Failed to load Three.js:', _t);
60
- throw new Error('SceneOperationsManager: Required dependencies could not be loaded');
61
- case 4:
62
- return _context.a(2);
63
- }
64
- }, _callee, null, [[1, 3]]);
65
- }));
66
- return _importDependencies.apply(this, arguments);
67
- }
68
-
69
- /**
70
- * Class for managing scene operations like loading, clearing, and object management
71
- */
72
- var SceneOperationsManager = /*#__PURE__*/function () {
73
- /**
74
- * Create a SceneOperationsManager
75
- * @param {Object} component - The component with scene, camera, renderer, etc.
76
- */
77
- function SceneOperationsManager(component) {
78
- _rollupPluginBabelHelpers.classCallCheck(this, SceneOperationsManager);
79
- this.component = component;
80
-
81
- // Initialize if in browser environment
82
- if (typeof window !== 'undefined') {
83
- importDependencies();
84
- }
85
- }
86
-
87
- /**
88
- * Clear scene objects while preserving base environment
89
- */
90
- return _rollupPluginBabelHelpers.createClass(SceneOperationsManager, [{
91
- key: "clearSceneObjects",
92
- value: function clearSceneObjects() {
93
- var component = this.component;
94
- console.log('🧹 Starting scene clear operation...');
95
-
96
- // First, deselect any currently selected object
97
- this.deselectObject();
98
-
99
- // Store reference to transform controls to ensure it's not removed
100
- var transformControlsRef = null;
101
- if (component.transformManager && component.transformManager.transformControls) {
102
- // Explicitly disable transform controls before clearing
103
- console.log('🔧 Disabling transform controls before scene clear');
104
- component.transformManager.setEnabled(false);
105
- component.transformManager.transformControls.visible = false;
106
- transformControlsRef = component.transformManager.transformControls;
107
- console.log('🔧 Stored reference to existing transform controls');
108
- }
109
- var objectsToRemove = [];
110
- var transformControlsFound = 0;
111
- var totalChildren = 0;
112
- component.scene.traverse(function (child) {
113
- var _child$userData, _child$userData2, _child$userData3, _child$userData4, _child$geometry;
114
- totalChildren++;
115
-
116
- // Check for transform controls using multiple detection methods
117
- var isTransformControl = child === transformControlsRef || ((_child$userData = child.userData) === null || _child$userData === void 0 ? void 0 : _child$userData.isTransformControls) || child.isTransformControls || child.type && child.type.includes('TransformControls');
118
- if (isTransformControl) {
119
- transformControlsFound++;
120
- console.log('🔧 Found transform controls, preserving:', child.uuid);
121
- }
122
-
123
- // Remove imported scene objects but preserve base ground, walls, lights, and transform controls
124
- if (child !== component.scene && !((_child$userData2 = child.userData) !== null && _child$userData2 !== void 0 && _child$userData2.isBrickWall) && !((_child$userData3 = child.userData) !== null && _child$userData3 !== void 0 && _child$userData3.isBaseGround) && !((_child$userData4 = child.userData) !== null && _child$userData4 !== void 0 && _child$userData4.isBaseGrid) && !isTransformControl && !child.isLight && ((_child$geometry = child.geometry) === null || _child$geometry === void 0 ? void 0 : _child$geometry.type) !== 'PlaneGeometry') {
125
- objectsToRemove.push(child);
126
- }
127
- });
128
- console.log("\uD83D\uDCCA Scene analysis: ".concat(totalChildren, " total children, ").concat(transformControlsFound, " transform controls found, ").concat(objectsToRemove.length, " objects to remove"));
129
- objectsToRemove.forEach(function (obj) {
130
- component.scene.remove(obj);
131
-
132
- // Dispose of geometry and materials to prevent memory leaks
133
- if (obj.geometry) obj.geometry.dispose();
134
- if (obj.material) {
135
- if (Array.isArray(obj.material)) {
136
- obj.material.forEach(function (mat) {
137
- return mat.dispose();
138
- });
139
- } else {
140
- obj.material.dispose();
141
- }
142
- }
143
- });
144
-
145
- // Clear any references to removed objects
146
- component.selectedObjectForTransform = null;
147
- if (component.transformHistory) {
148
- component.transformHistory = [];
149
- }
150
-
151
- // Make sure transform controls exist after clearing
152
- if (!component.transformManager || !component.transformManager.transformControls) {
153
- console.log('🔧 Transform controls missing after scene clear, reinitializing...');
154
- if (typeof component.initTransformControls === 'function') {
155
- component.initTransformControls();
156
- }
157
- }
158
-
159
- // Ensure transform controls are still properly attached after scene operations
160
- this.ensureTransformControlsAttached(false);
161
- console.log('✅ Scene clear operation completed');
162
- }
163
-
164
- /**
165
- * Ensure transform controls remain properly attached after scene operations
166
- * @param {boolean} attachToSelected - Whether to attach to selected object
167
- */
168
- }, {
169
- key: "ensureTransformControlsAttached",
170
- value: function ensureTransformControlsAttached() {
171
- var attachToSelected = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
172
- var component = this.component;
173
- if (component.transformManager) {
174
- // Re-enable transform controls after scene operations
175
- component.transformManager.setEnabled(true);
176
-
177
- // Reattach to selected object if one exists and flag is true
178
- if (attachToSelected && component.selectedObjectForTransform) {
179
- component.transformManager.selectObject(component.selectedObjectForTransform);
180
- }
181
- }
182
- }
183
-
184
- /**
185
- * Deselect any selected object
186
- */
187
- }, {
188
- key: "deselectObject",
189
- value: function deselectObject() {
190
- var component = this.component;
191
- if (component.transformManager && component.selectedObjectForTransform) {
192
- component.transformManager.deselectObject();
193
- component.selectedObjectForTransform = null;
194
- }
195
- }
196
-
197
- /**
198
- * Load scene data from JSON
199
- * @param {Object|string} sceneData - Scene data object or JSON string
200
- */
201
- }, {
202
- key: "loadSceneData",
203
- value: function loadSceneData(sceneData) {
204
- var component = this.component;
205
- console.log('📥 Starting scene load operation...');
206
-
207
- // Parse JSON if string provided
208
- var parsedData = sceneData;
209
- if (typeof sceneData === 'string') {
210
- try {
211
- parsedData = JSON.parse(sceneData);
212
- } catch (e) {
213
- console.error('❌ Failed to parse scene data:', e);
214
- return false;
215
- }
216
- }
217
-
218
- // Validate scene data format
219
- if (!parsedData || !parsedData.scene || !parsedData.scene.object) {
220
- console.error('❌ Invalid scene data format');
221
- return false;
222
- }
223
-
224
- // Store reference to scene data
225
- component.currentSceneData = parsedData;
226
-
227
- // Clear existing scene objects
228
- this.clearSceneObjects();
229
-
230
- // Load scene objects
231
- this._loadSceneObjects(parsedData.scene.object);
232
-
233
- // Load connections if applicable
234
- if (parsedData.connections && Array.isArray(parsedData.connections)) {
235
- this._loadConnections(parsedData.connections);
236
- }
237
- console.log('✅ Scene load completed');
238
- return true;
239
- }
240
-
241
- /**
242
- * Load scene objects from parsed scene data
243
- * @param {Object} sceneObject - The root scene object from parsed data
244
- * @private
245
- */
246
- }, {
247
- key: "_loadSceneObjects",
248
- value: function _loadSceneObjects(sceneObject) {
249
- var _this = this;
250
- var component = this.component;
251
-
252
- // Recursively process all object children
253
- if (sceneObject.children && Array.isArray(sceneObject.children)) {
254
- sceneObject.children.forEach(function (childData) {
255
- var childObject = _this._createObjectFromData(childData);
256
- if (childObject) {
257
- component.scene.add(childObject);
258
- }
259
- });
260
- }
261
- }
262
-
263
- /**
264
- * Create a Three.js object from object data
265
- * @param {Object} objectData - The object data from parsed scene
266
- * @returns {THREE.Object3D} The created object or null if invalid
267
- * @private
268
- */
269
- }, {
270
- key: "_createObjectFromData",
271
- value: function _createObjectFromData(objectData) {
272
- var _this2 = this;
273
- // Ensure THREE is loaded
274
- if (!THREE) {
275
- console.warn('⚠️ THREE.js not loaded, cannot create objects');
276
- return null;
277
- }
278
-
279
- // Create base object
280
- var object = new THREE.Object3D();
281
-
282
- // Set UUID (use hardcoded UUID if possible)
283
- if (objectData.uuid) {
284
- object.uuid = objectData.uuid;
285
- }
286
-
287
- // Set name
288
- object.name = objectData.name || 'Unnamed';
289
-
290
- // Set position
291
- if (objectData.position) {
292
- object.position.set(objectData.position.x || 0, objectData.position.y || 0, objectData.position.z || 0);
293
- }
294
-
295
- // Set rotation (convert from degrees to radians)
296
- if (objectData.rotation) {
297
- object.rotation.set((objectData.rotation.x || 0) * (Math.PI / 180), (objectData.rotation.y || 0) * (Math.PI / 180), (objectData.rotation.z || 0) * (Math.PI / 180));
298
- }
299
-
300
- // Set scale
301
- if (objectData.scale) {
302
- object.scale.set(objectData.scale.x || 1, objectData.scale.y || 1, objectData.scale.z || 1);
303
- }
304
-
305
- // Set userData
306
- if (objectData.userData) {
307
- object.userData = _rollupPluginBabelHelpers.objectSpread2({}, objectData.userData);
308
- }
309
-
310
- // Special handling for different object types
311
- this._setupObjectByType(object, objectData);
312
-
313
- // Process children recursively
314
- if (objectData.children && Array.isArray(objectData.children)) {
315
- objectData.children.forEach(function (childData) {
316
- var childObject = _this2._createObjectFromData(childData);
317
- if (childObject) {
318
- object.add(childObject);
319
- }
320
- });
321
- }
322
- return object;
323
- }
324
-
325
- /**
326
- * Set up object properties based on type
327
- * @param {THREE.Object3D} object - The object to set up
328
- * @param {Object} objectData - The object data
329
- * @private
330
- */
331
- }, {
332
- key: "_setupObjectByType",
333
- value: function _setupObjectByType(object, objectData) {
334
- var _objectData$userData, _objectData$userData2;
335
- // Handle library component objects
336
- if ((_objectData$userData = objectData.userData) !== null && _objectData$userData !== void 0 && _objectData$userData.componentType && (_objectData$userData2 = objectData.userData) !== null && _objectData$userData2 !== void 0 && _objectData$userData2.libraryId) {
337
- // If model preloader is available, attempt to load model
338
- if (this.component.modelPreloader) {
339
- this.component.modelPreloader.loadComponentById(objectData.userData.libraryId, function (model) {
340
- if (model) {
341
- // Copy model but preserve our object's transform and userData
342
- var position = object.position.clone();
343
- var rotation = object.rotation.clone();
344
- var scale = object.scale.clone();
345
- var userData = _rollupPluginBabelHelpers.objectSpread2({}, object.userData);
346
-
347
- // Copy model properties to our object
348
- object.copy(model);
349
-
350
- // Restore transform and userData
351
- object.position.copy(position);
352
- object.rotation.copy(rotation);
353
- object.scale.copy(scale);
354
- object.userData = userData;
355
- console.log("\u2705 Loaded model for ".concat(objectData.name, " (").concat(objectData.userData.libraryId, ")"));
356
- }
357
- });
358
- }
359
- }
360
-
361
- // Handle primitive geometry
362
- if (objectData.geometry) {
363
- var geometry;
364
-
365
- // Create appropriate geometry based on type hint
366
- if (objectData.geometry === 'CONNECTOR-GEO') {
367
- geometry = new THREE.SphereGeometry(0.5, 16, 16);
368
- } else if (objectData.geometry === 'GATEWAY-GEO') {
369
- geometry = new THREE.CylinderGeometry(0.5, 0.5, 1, 16);
370
- } else {
371
- // Default to box geometry for other types
372
- geometry = new THREE.BoxGeometry(1, 1, 1);
373
- }
374
-
375
- // Create mesh with geometry and basic material
376
- var material = new THREE.MeshStandardMaterial({
377
- color: 0x999999,
378
- transparent: true,
379
- opacity: 0.7
380
- });
381
- var mesh = new THREE.Mesh(geometry, material);
382
-
383
- // Copy transform from parent
384
- mesh.position.copy(object.position);
385
- mesh.rotation.copy(object.rotation);
386
- mesh.scale.copy(object.scale);
387
-
388
- // Reset parent transform since the mesh now has it
389
- object.position.set(0, 0, 0);
390
- object.rotation.set(0, 0, 0);
391
- object.scale.set(1, 1, 1);
392
-
393
- // Add mesh as child of parent
394
- object.add(mesh);
395
- }
396
- }
397
-
398
- /**
399
- * Load connections from scene data
400
- * @param {Array} connections - Array of connection objects
401
- * @private
402
- */
403
- }, {
404
- key: "_loadConnections",
405
- value: function _loadConnections(connections) {
406
- var component = this.component;
407
- if (!component.pathfindingManager) {
408
- console.warn('⚠️ Cannot load connections: pathfindingManager not available');
409
- return;
410
- }
411
-
412
- // Clear existing connections
413
- if (component.pathfindingManager.clearAllPaths) {
414
- component.pathfindingManager.clearAllPaths();
415
- }
416
-
417
- // Process each connection
418
- connections.forEach(function (connection) {
419
- if (!connection.source || !connection.target) {
420
- return;
421
- }
422
-
423
- // Find source and target objects
424
- var sourceObj = nameUtils.findObjectByHardcodedUuid(component.scene, connection.source);
425
- var targetObj = nameUtils.findObjectByHardcodedUuid(component.scene, connection.target);
426
- if (sourceObj && targetObj) {
427
- // Create connection if objects found
428
- component.pathfindingManager.createConnection(sourceObj, targetObj, connection.type || 'default');
429
- } else {
430
- console.warn("\u26A0\uFE0F Could not create connection: objects not found (".concat(connection.source, " -> ").concat(connection.target, ")"));
431
- }
432
- });
433
- }
434
-
435
- /**
436
- * Ensure scene elements are visible
437
- * Makes sure all scene elements are properly visible and within camera view
438
- */
439
- }, {
440
- key: "ensureSceneElementsVisible",
441
- value: function ensureSceneElementsVisible() {
442
- var component = this.component;
443
- if (!component.scene || !component.camera) {
444
- console.warn('⚠️ Cannot ensure scene elements visibility: scene or camera missing');
445
- return false;
446
- }
447
-
448
- // Reset camera position if it's too close to origin
449
- if (component.camera.position.length() < 5) {
450
- component.camera.position.set(10, 10, 10);
451
- component.camera.lookAt(0, 0, 0);
452
- if (component.controls) {
453
- component.controls.target.set(0, 0, 0);
454
- component.controls.update();
455
- }
456
- }
457
-
458
- // Check if scene has any visible objects
459
- var hasVisibleObjects = false;
460
- component.scene.traverse(function (child) {
461
- if (child.visible && child !== component.scene && !child.isLight) {
462
- hasVisibleObjects = true;
463
- }
464
- });
465
- if (!hasVisibleObjects) {
466
- console.warn('⚠️ Scene has no visible objects');
467
- }
468
- return hasVisibleObjects;
469
- }
470
-
471
- /**
472
- * Find object in scene by name
473
- * @param {string} name - The name to search for
474
- * @returns {THREE.Object3D|null} The found object or null
475
- */
476
- }, {
477
- key: "findObjectByName",
478
- value: function findObjectByName(name) {
479
- if (!name || !this.component.scene) {
480
- return null;
481
- }
482
- var foundObject = null;
483
- this.component.scene.traverse(function (child) {
484
- if (child.name === name) {
485
- foundObject = child;
486
- }
487
- });
488
- return foundObject;
489
- }
490
-
491
- /**
492
- * Find object in scene by UUID
493
- * @param {string} uuid - The UUID to search for
494
- * @returns {THREE.Object3D|null} The found object or null
495
- */
496
- }, {
497
- key: "findObjectByUuid",
498
- value: function findObjectByUuid(uuid) {
499
- if (!uuid || !this.component.scene) {
500
- return null;
501
- }
502
- var foundObject = null;
503
- this.component.scene.traverse(function (child) {
504
- if (child.uuid === uuid) {
505
- foundObject = child;
506
- }
507
- });
508
- return foundObject;
509
- }
510
-
511
- /**
512
- * Remove an object from the scene
513
- * @param {THREE.Object3D} object - The object to remove
514
- */
515
- }, {
516
- key: "removeObject",
517
- value: function removeObject(object) {
518
- if (!object || !this.component.scene) {
519
- return false;
520
- }
521
-
522
- // Deselect if this is the selected object
523
- if (this.component.selectedObjectForTransform === object) {
524
- this.deselectObject();
525
- }
526
-
527
- // Remove from scene
528
- this.component.scene.remove(object);
529
-
530
- // Dispose resources
531
- if (object.geometry) object.geometry.dispose();
532
- if (object.material) {
533
- if (Array.isArray(object.material)) {
534
- object.material.forEach(function (mat) {
535
- return mat.dispose();
536
- });
537
- } else {
538
- object.material.dispose();
539
- }
540
- }
541
- return true;
542
- }
543
-
544
- /**
545
- * Duplicate an object in the scene
546
- * @param {THREE.Object3D} sourceObject - The object to duplicate
547
- * @param {Object} [options] - Options for duplication
548
- * @param {THREE.Vector3} [options.positionOffset] - Position offset for the duplicate
549
- * @returns {THREE.Object3D|null} The duplicated object or null if failed
550
- */
551
- }, {
552
- key: "duplicateObject",
553
- value: function duplicateObject(sourceObject) {
554
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
555
- if (!sourceObject || !this.component.scene) {
556
- return null;
557
- }
558
-
559
- // Create clone of source object
560
- var clonedObject = sourceObject.clone();
561
-
562
- // Generate new UUID to ensure uniqueness
563
- clonedObject.uuid = THREE.MathUtils.generateUUID();
564
-
565
- // Update name to indicate it's a copy
566
- if (!clonedObject.name.includes('_copy')) {
567
- clonedObject.name = "".concat(clonedObject.name, "_copy");
568
- }
569
-
570
- // Apply position offset if specified
571
- if (options.positionOffset) {
572
- clonedObject.position.add(options.positionOffset);
573
- } else {
574
- // Default offset if none provided
575
- clonedObject.position.x += 2;
576
- }
577
-
578
- // Add to scene
579
- this.component.scene.add(clonedObject);
580
- return clonedObject;
581
- }
582
- }]);
583
- }();
584
-
585
- /**
586
- * Factory function to get SceneOperationsManager instance
587
- * @param {CentralPlantComponent} component - The component instance
588
- * @returns {SceneOperationsManager} SceneOperationsManager instance
589
- */
590
- function getSceneOperationsManager(component) {
591
- return new SceneOperationsManager(component);
592
- }
593
-
594
- exports.SceneOperationsManager = SceneOperationsManager;
595
- exports["default"] = SceneOperationsManager;
596
- exports.getSceneOperationsManager = getSceneOperationsManager;
@@ -1,110 +0,0 @@
1
- import { createClass as _createClass, typeof as _typeof, createForOfIteratorHelper as _createForOfIteratorHelper, slicedToArray as _slicedToArray, classCallCheck as _classCallCheck } from '../_virtual/_rollupPluginBabelHelpers.js';
2
-
3
- /**
4
- * ConnectionManager class
5
- * Handles object connections in the pathfinding system with improved safety for missing data
6
- */
7
- var ConnectionManager = /*#__PURE__*/function () {
8
- function ConnectionManager(sceneManager) {
9
- _classCallCheck(this, ConnectionManager);
10
- this.sceneManager = sceneManager;
11
- }
12
-
13
- /**
14
- * Safely cluster connections by shared objects
15
- * @param {Array<Object>} connections - Array of connections between objects (or null/undefined)
16
- * @returns {Array<Object>} Array of clusters
17
- */
18
- return _createClass(ConnectionManager, [{
19
- key: "clusterConnections",
20
- value: function clusterConnections(connections) {
21
- // Safety check for undefined or non-array connections
22
- if (!connections || !Array.isArray(connections)) {
23
- console.warn('ConnectionManager: No valid connections provided');
24
- return [];
25
- }
26
- var clusters = new Map(); // Map of object UUID to its cluster
27
- var clusterMap = new Map(); // Map of cluster ID to set of object UUIDs
28
- var nextClusterId = 0;
29
-
30
- // Process each connection
31
- connections.forEach(function (conn) {
32
- // Safety check for invalid connection format
33
- if (!conn || _typeof(conn) !== 'object' || !conn.from || !conn.to) {
34
- console.warn('ConnectionManager: Invalid connection format', conn);
35
- return;
36
- }
37
- var from = conn.from,
38
- to = conn.to;
39
-
40
- // If neither object is in a cluster, create new cluster
41
- if (!clusters.has(from) && !clusters.has(to)) {
42
- var clusterId = nextClusterId++;
43
- clusters.set(from, clusterId);
44
- clusters.set(to, clusterId);
45
- clusterMap.set(clusterId, new Set([from, to]));
46
- }
47
- // If only 'from' is in a cluster, add 'to' to that cluster
48
- else if (clusters.has(from) && !clusters.has(to)) {
49
- var _clusterId = clusters.get(from);
50
- clusters.set(to, _clusterId);
51
- clusterMap.get(_clusterId).add(to);
52
- }
53
- // If only 'to' is in a cluster, add 'from' to that cluster
54
- else if (!clusters.has(from) && clusters.has(to)) {
55
- var _clusterId2 = clusters.get(to);
56
- clusters.set(from, _clusterId2);
57
- clusterMap.get(_clusterId2).add(from);
58
- }
59
- // If both are in different clusters, merge the clusters
60
- else if (clusters.has(from) && clusters.has(to) && clusters.get(from) !== clusters.get(to)) {
61
- var fromCluster = clusters.get(from);
62
- var toCluster = clusters.get(to);
63
- var fromObjects = clusterMap.get(fromCluster);
64
- var toObjects = clusterMap.get(toCluster);
65
-
66
- // Merge all objects from 'to' cluster into 'from' cluster
67
- var _iterator = _createForOfIteratorHelper(toObjects),
68
- _step;
69
- try {
70
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
71
- var obj = _step.value;
72
- clusters.set(obj, fromCluster);
73
- fromObjects.add(obj);
74
- }
75
-
76
- // Delete the now-empty 'to' cluster
77
- } catch (err) {
78
- _iterator.e(err);
79
- } finally {
80
- _iterator.f();
81
- }
82
- clusterMap.delete(toCluster);
83
- }
84
- });
85
-
86
- // Convert clusters to array format
87
- var result = [];
88
- var _iterator2 = _createForOfIteratorHelper(clusterMap.entries()),
89
- _step2;
90
- try {
91
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
92
- var _step2$value = _slicedToArray(_step2.value, 2),
93
- clusterId = _step2$value[0],
94
- objectSet = _step2$value[1];
95
- result.push({
96
- id: clusterId,
97
- objects: Array.from(objectSet)
98
- });
99
- }
100
- } catch (err) {
101
- _iterator2.e(err);
102
- } finally {
103
- _iterator2.f();
104
- }
105
- return result;
106
- }
107
- }]);
108
- }();
109
-
110
- export { ConnectionManager as default };