@2112-lab/central-plant 0.1.2 → 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 (46) hide show
  1. package/dist/bundle/index.js +1 -15498
  2. package/dist/cjs/_virtual/_rollupPluginBabelHelpers.js +1 -366
  3. package/dist/cjs/node_modules/@2112-lab/pathfinder/dist/index.esm.js +1 -1448
  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 -79
  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 -503
  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 -339
  25. package/dist/esm/node_modules/@2112-lab/pathfinder/dist/index.esm.js +1 -1444
  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 -70
  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 -479
  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/package.json +1 -1
@@ -1,479 +1 @@
1
- import { createClass as _createClass, objectSpread2 as _objectSpread2, construct as _construct, toConsumableArray as _toConsumableArray, classCallCheck as _classCallCheck, createForOfIteratorHelper as _createForOfIteratorHelper, asyncToGenerator as _asyncToGenerator, regenerator as _regenerator } from '../_virtual/_rollupPluginBabelHelpers.js';
2
- import * as THREE from 'three';
3
- import { Pathfinder } from '../node_modules/@2112-lab/pathfinder/dist/index.esm.js';
4
- import { logger, pathfinderLogger } from './debugLogger.js';
5
- import { generateUuidFromName } from './nameUtils.js';
6
-
7
- var PathfindingManager = /*#__PURE__*/function () {
8
- function PathfindingManager(component) {
9
- _classCallCheck(this, PathfindingManager);
10
- this.component = component;
11
- this.pathfinder = null;
12
- this.crosscubeTextureSet = null;
13
- this.pathfinderVersionInfo = null;
14
- }
15
-
16
- /**
17
- * Get pathfinder version information
18
- */
19
- return _createClass(PathfindingManager, [{
20
- key: "getPathfinderVersionInfo",
21
- value: (function () {
22
- var _getPathfinderVersionInfo = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
23
- var versionInfo;
24
- return _regenerator().w(function (_context) {
25
- while (1) switch (_context.n) {
26
- case 0:
27
- if (!this.pathfinderVersionInfo) {
28
- _context.n = 1;
29
- break;
30
- }
31
- return _context.a(2, this.pathfinderVersionInfo);
32
- case 1:
33
- versionInfo = {
34
- version: '1.0.15',
35
- detectionMethod: 'hardcoded-fallback',
36
- timestamp: new Date().toISOString()
37
- };
38
- this.pathfinderVersionInfo = versionInfo;
39
- return _context.a(2, versionInfo);
40
- }
41
- }, _callee, this);
42
- }));
43
- function getPathfinderVersionInfo() {
44
- return _getPathfinderVersionInfo.apply(this, arguments);
45
- }
46
- return getPathfinderVersionInfo;
47
- }()
48
- /**
49
- * Log pathfinder version information
50
- */
51
- )
52
- }, {
53
- key: "logPathfinderVersion",
54
- value: (function () {
55
- var _logPathfinderVersion = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
56
- var context,
57
- versionInfo,
58
- _args2 = arguments,
59
- _t;
60
- return _regenerator().w(function (_context2) {
61
- while (1) switch (_context2.n) {
62
- case 0:
63
- context = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : 'Unknown Context';
64
- _context2.p = 1;
65
- _context2.n = 2;
66
- return this.getPathfinderVersionInfo();
67
- case 2:
68
- versionInfo = _context2.v;
69
- pathfinderLogger.info("[".concat(context, "] Pathfinder Module Information:"), {
70
- version: versionInfo.version,
71
- detectionMethod: versionInfo.detectionMethod,
72
- context: context,
73
- timestamp: versionInfo.timestamp,
74
- pathfinderInstance: !!this.pathfinder
75
- });
76
- _context2.n = 4;
77
- break;
78
- case 3:
79
- _context2.p = 3;
80
- _t = _context2.v;
81
- pathfinderLogger.error("[".concat(context, "] Failed to get pathfinder version:"), _t);
82
- case 4:
83
- return _context2.a(2);
84
- }
85
- }, _callee2, this, [[1, 3]]);
86
- }));
87
- function logPathfinderVersion() {
88
- return _logPathfinderVersion.apply(this, arguments);
89
- }
90
- return logPathfinderVersion;
91
- }()
92
- /**
93
- * Get path colors for visual distinction
94
- */
95
- )
96
- }, {
97
- key: "getPathColor",
98
- value: function getPathColor(index) {
99
- var colors = ['#468e49', '#245e29', '#2e80d2', '#1d51a1'];
100
- return colors[index % colors.length];
101
- }
102
-
103
- /**
104
- * Initialize pathfinder and create paths
105
- */
106
- }, {
107
- key: "initializePathfinder",
108
- value: (function () {
109
- var _initializePathfinder = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(data, crosscubeTextureSet) {
110
- var _data$scene;
111
- var component, paths;
112
- return _regenerator().w(function (_context3) {
113
- while (1) switch (_context3.n) {
114
- case 0:
115
- component = this.component;
116
- this.crosscubeTextureSet = crosscubeTextureSet;
117
-
118
- // Log pathfinder version information
119
- _context3.n = 1;
120
- return this.logPathfinderVersion('Scene Loading');
121
- case 1:
122
- this.pathfinder = new Pathfinder(data);
123
- component.pathfinder = this.pathfinder;
124
-
125
- // Add debugging for pathfinder input
126
- console.log('🔍 PATHFINDER DEBUGGING:');
127
- console.log('🔗 Connections:', data.connections);
128
- console.log('🏗️ Scene structure:', JSON.parse(JSON.stringify((_data$scene = data.scene) === null || _data$scene === void 0 ? void 0 : _data$scene.object)));
129
- paths = this.pathfinder.findPaths();
130
- console.log('Found paths:', paths);
131
-
132
- // Create pipe paths with materials
133
- this.createPipePaths(paths, crosscubeTextureSet);
134
- case 2:
135
- return _context3.a(2);
136
- }
137
- }, _callee3, this);
138
- }));
139
- function initializePathfinder(_x, _x2) {
140
- return _initializePathfinder.apply(this, arguments);
141
- }
142
- return initializePathfinder;
143
- }()
144
- /**
145
- /**
146
- * Remove all existing paths from the scene
147
- */
148
- )
149
- }, {
150
- key: "removeAllPaths",
151
- value: function removeAllPaths() {
152
- var component = this.component;
153
- console.log("removeAllPaths started");
154
- var objectsToRemove = [];
155
- component.scene.traverse(function (obj) {
156
- // Check the name property instead of uuid, as UUIDs are auto-generated
157
- if (obj.name && obj.name.includes("Polyline")) {
158
- console.log("removeAllPaths ".concat(obj.name, " (uuid: ").concat(obj.uuid, ") found"));
159
- objectsToRemove.push(obj);
160
- }
161
- });
162
- for (var _i = 0, _objectsToRemove = objectsToRemove; _i < _objectsToRemove.length; _i++) {
163
- var obj = _objectsToRemove[_i];
164
- component.scene.remove(obj);
165
- if (obj.geometry) obj.geometry.dispose();
166
- if (obj.material) {
167
- if (Array.isArray(obj.material)) {
168
- obj.material.forEach(function (mat) {
169
- return mat.dispose();
170
- });
171
- } else {
172
- obj.material.dispose();
173
- }
174
- }
175
- }
176
- console.log("\u2705 Removed ".concat(objectsToRemove.length, " polyline objects from scene"));
177
- }
178
-
179
- /**
180
- * Material factory function to reduce duplication
181
- */
182
- }, {
183
- key: "createPipeMaterial",
184
- value: function createPipeMaterial(crosscubeTextureSet, pathIndex) {
185
- if (crosscubeTextureSet) {
186
- var materialProps = _objectSpread2(_objectSpread2({}, crosscubeTextureSet.config.materialProps), {}, {
187
- color: this.getPathColor(pathIndex),
188
- map: crosscubeTextureSet.textures.diffuse,
189
- normalMap: crosscubeTextureSet.textures.normal,
190
- roughnessMap: crosscubeTextureSet.textures.roughness,
191
- metalness: 0.2,
192
- roughness: 0.9,
193
- clearcoat: 0.2,
194
- clearcoatRoughness: 0.2,
195
- envMapIntensity: 0.6,
196
- reflectivity: 0.4
197
- });
198
-
199
- // Handle normalScale conversion to Vector2
200
- if (materialProps.normalScale && Array.isArray(materialProps.normalScale)) {
201
- materialProps.normalScale = _construct(THREE.Vector2, _toConsumableArray(materialProps.normalScale));
202
- }
203
- var material = new THREE.MeshPhysicalMaterial(materialProps);
204
-
205
- // Configure texture wrapping and repeat
206
- var pipeTextures = [material.map, material.normalMap, material.roughnessMap].filter(Boolean);
207
- pipeTextures.forEach(function (texture) {
208
- texture.wrapS = texture.wrapT = THREE.RepeatWrapping;
209
- texture.repeat.set(crosscubeTextureSet.config.repeat.x * 2, crosscubeTextureSet.config.repeat.y * 2);
210
- });
211
- return material;
212
- } else {
213
- return new THREE.MeshPhysicalMaterial({
214
- color: this.getPathColor(pathIndex),
215
- metalness: 0.9,
216
- roughness: 0.7,
217
- clearcoat: 0.1,
218
- clearcoatRoughness: 0.3,
219
- envMapIntensity: 1.5,
220
- reflectivity: 0.3
221
- });
222
- }
223
- }
224
-
225
- /**
226
- * Helper function to create pipe paths
227
- */
228
- }, {
229
- key: "createPipePaths",
230
- value: function createPipePaths(paths, crosscubeTextureSet) {
231
- var _this = this;
232
- var component = this.component;
233
- paths.forEach(function (pathData, index) {
234
- if (pathData.path) {
235
- var polyline = new THREE.Object3D();
236
- polyline.name = "Polyline ".concat(pathData.from, "-").concat(pathData.to);
237
- var pipeRadius = 0.1;
238
- var pipeMaterial = _this.createPipeMaterial(crosscubeTextureSet, index);
239
- for (var j = 0; j < pathData.path.length - 1; j++) {
240
- var start = pathData.path[j];
241
- var end = pathData.path[j + 1];
242
- var direction = new THREE.Vector3().subVectors(end, start);
243
- var length = direction.length();
244
- var cylinderGeometry = new THREE.CylinderGeometry(pipeRadius, pipeRadius, length, 8, 1, false);
245
- var cylinder = new THREE.Mesh(cylinderGeometry, pipeMaterial);
246
- cylinder.position.copy(start).add(end).multiplyScalar(0.5);
247
- var quaternion = new THREE.Quaternion();
248
- var up = new THREE.Vector3(0, 1, 0);
249
- quaternion.setFromUnitVectors(up, direction.normalize());
250
- cylinder.quaternion.copy(quaternion);
251
- cylinder.castShadow = true;
252
- cylinder.receiveShadow = true;
253
- polyline.add(cylinder);
254
-
255
- // Add junction spheres at 90-degree turns
256
- if (j < pathData.path.length - 2) {
257
- var nextStart = pathData.path[j + 1];
258
- var nextEnd = pathData.path[j + 2];
259
- var currentDir = direction.normalize();
260
- var nextDir = new THREE.Vector3().subVectors(nextEnd, nextStart).normalize();
261
- var angle = Math.acos(currentDir.dot(nextDir));
262
- if (Math.abs(angle - Math.PI / 2) < 0.1) {
263
- var sphereGeometry = new THREE.SphereGeometry(pipeRadius, 16, 16);
264
- var sphere = new THREE.Mesh(sphereGeometry, pipeMaterial);
265
- sphere.position.copy(end);
266
- sphere.castShadow = true;
267
- sphere.receiveShadow = true;
268
- polyline.add(sphere);
269
- }
270
- }
271
- }
272
- polyline.name = "Polyline";
273
- component.scene.add(polyline);
274
- }
275
- });
276
- }
277
-
278
- /**
279
- * Recompute world bounding boxes after transforms
280
- */
281
- }, {
282
- key: "recomputeWorldBoundingBoxes",
283
- value: function recomputeWorldBoundingBoxes(currentSceneData) {
284
- var component = this.component;
285
- component.scene.traverse(function (object) {
286
- if (object.isMesh) {
287
- // Find the corresponding JSON object
288
- var jsonObject = null;
289
- var _findJsonObject = function findJsonObject(children) {
290
- var _iterator = _createForOfIteratorHelper(children),
291
- _step;
292
- try {
293
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
294
- var _object$userData, _child$userData;
295
- var child = _step.value;
296
- // Enhanced matching logic with hardcoded UUID priority
297
-
298
- // Strategy 1: Direct hardcoded UUID match (HIGHEST PRIORITY)
299
- if (child.uuid === object.uuid || child.uuid === ((_object$userData = object.userData) === null || _object$userData === void 0 ? void 0 : _object$userData.originalUuid) || object.uuid === ((_child$userData = child.userData) === null || _child$userData === void 0 ? void 0 : _child$userData.originalUuid)) {
300
- return child;
301
- }
302
-
303
- // Strategy 2: Name-based UUID match (FALLBACK)
304
- if (object.name && child.name) {
305
- var objectGeneratedUuid = generateUuidFromName(object.name);
306
- var childGeneratedUuid = generateUuidFromName(child.name);
307
- if (objectGeneratedUuid === childGeneratedUuid || objectGeneratedUuid === child.uuid || childGeneratedUuid === object.uuid) {
308
- return child;
309
- }
310
- }
311
-
312
- // Strategy 3: Name match
313
- if (object.name && child.name && object.name === child.name) {
314
- return child;
315
- }
316
-
317
- // Recursively search children
318
- if (child.children) {
319
- console.log("child children found in:", child);
320
- var found = _findJsonObject(child.children);
321
- if (found) return found;
322
- }
323
- }
324
- } catch (err) {
325
- _iterator.e(err);
326
- } finally {
327
- _iterator.f();
328
- }
329
- return null;
330
- };
331
- jsonObject = _findJsonObject(currentSceneData.scene.object.children);
332
- if (jsonObject) {
333
- // Compute world bounding box
334
- var boundingBox = new THREE.Box3().setFromObject(object);
335
-
336
- // Store in JSON userData for pathfinder
337
- if (!jsonObject.userData) jsonObject.userData = {};
338
- jsonObject.userData.worldBoundingBox = {
339
- min: boundingBox.min.toArray(),
340
- max: boundingBox.max.toArray()
341
- };
342
- console.log("Added world bounding box for ".concat(jsonObject.name, ":"), jsonObject.userData.worldBoundingBox);
343
- }
344
- }
345
- });
346
- }
347
- /**
348
- * Update pathfinding with new connections data
349
- */
350
- }, {
351
- key: "updatePathfindingWithConnections",
352
- value: (function () {
353
- var _updatePathfindingWithConnections = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(newConnections) {
354
- var _component$currentSce, _component$currentSce2, _component$currentSce3, _updatedSceneData$sce;
355
- var component, updatedSceneData, paths;
356
- return _regenerator().w(function (_context4) {
357
- while (1) switch (_context4.n) {
358
- case 0:
359
- component = this.component; // Check if we have current scene data to work with
360
- if (component.currentSceneData) {
361
- _context4.n = 1;
362
- break;
363
- }
364
- console.warn('⚠️ No current scene data available for pathfinder update');
365
- return _context4.a(2, false);
366
- case 1:
367
- // Remove all existing paths from the scene
368
- this.removeAllPaths();
369
- console.log('🔄 Updating pathfinder with new connections:', newConnections);
370
- console.log('🔍 Current scene data structure:', {
371
- hasConnections: !!component.currentSceneData.connections,
372
- connectionsCount: ((_component$currentSce = component.currentSceneData.connections) === null || _component$currentSce === void 0 ? void 0 : _component$currentSce.length) || 0,
373
- hasScene: !!component.currentSceneData.scene,
374
- hasSceneObject: !!((_component$currentSce2 = component.currentSceneData.scene) !== null && _component$currentSce2 !== void 0 && _component$currentSce2.object),
375
- childrenCount: ((_component$currentSce3 = component.currentSceneData.scene) === null || _component$currentSce3 === void 0 || (_component$currentSce3 = _component$currentSce3.object) === null || _component$currentSce3 === void 0 || (_component$currentSce3 = _component$currentSce3.children) === null || _component$currentSce3 === void 0 ? void 0 : _component$currentSce3.length) || 0
376
- });
377
-
378
- // Create a deep copy of the current scene data to avoid mutations
379
- updatedSceneData = JSON.parse(JSON.stringify(component.currentSceneData)); // Update the connections in the copied scene data
380
- updatedSceneData.connections = _toConsumableArray(newConnections);
381
- console.log('🔍 Updated scene data for pathfinder:', {
382
- connectionsCount: updatedSceneData.connections.length,
383
- connections: updatedSceneData.connections,
384
- hasScene: !!updatedSceneData.scene,
385
- childrenCount: ((_updatedSceneData$sce = updatedSceneData.scene) === null || _updatedSceneData$sce === void 0 || (_updatedSceneData$sce = _updatedSceneData$sce.object) === null || _updatedSceneData$sce === void 0 || (_updatedSceneData$sce = _updatedSceneData$sce.children) === null || _updatedSceneData$sce === void 0 ? void 0 : _updatedSceneData$sce.length) || 0
386
- });
387
-
388
- // Log pathfinder version for connection updates
389
- _context4.n = 2;
390
- return this.logPathfinderVersion('Connections Update');
391
- case 2:
392
- // Create new pathfinder instance with updated data
393
- this.pathfinder = new Pathfinder(updatedSceneData);
394
- component.pathfinder = this.pathfinder;
395
-
396
- // Find new paths with updated connections
397
- paths = this.pathfinder.findPaths();
398
- console.log('🔍 Found paths with updated connections:', {
399
- pathCount: paths.length,
400
- paths: paths.map(function (p) {
401
- var _p$path;
402
- return {
403
- from: p.from,
404
- to: p.to,
405
- hasPath: !!p.path,
406
- pathLength: ((_p$path = p.path) === null || _p$path === void 0 ? void 0 : _p$path.length) || 0
407
- };
408
- })
409
- });
410
-
411
- // Create pipe paths with materials
412
- this.createPipePaths(paths, this.crosscubeTextureSet);
413
-
414
- // Update the component's current scene data to reflect the changes
415
- component.currentSceneData = updatedSceneData;
416
- console.log('✅ Pathfinding updated successfully with new connections');
417
- return _context4.a(2, true);
418
- }
419
- }, _callee4, this);
420
- }));
421
- function updatePathfindingWithConnections(_x3) {
422
- return _updatePathfindingWithConnections.apply(this, arguments);
423
- }
424
- return updatePathfindingWithConnections;
425
- }()
426
- /**
427
- * Update pathfinding after object transforms
428
- */
429
- )
430
- }, {
431
- key: "updatePathfindingAfterTransform",
432
- value: (function () {
433
- var _updatePathfindingAfterTransform = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(currentSceneData) {
434
- var paths;
435
- return _regenerator().w(function (_context5) {
436
- while (1) switch (_context5.n) {
437
- case 0:
438
- // Remove all existing paths from the scene
439
- this.removeAllPaths();
440
- console.log('🔄 Starting pathfinding with updated scene data...');
441
-
442
- // Log pathfinder version for transform updates
443
- _context5.n = 1;
444
- return this.logPathfinderVersion('Transform Update');
445
- case 1:
446
- this.pathfinder = new Pathfinder(currentSceneData);
447
- this.component.pathfinder = this.pathfinder;
448
- paths = this.pathfinder.findPaths();
449
- console.log('Found paths:', paths);
450
-
451
- // Create pipe paths with materials
452
- this.createPipePaths(paths, this.crosscubeTextureSet);
453
- case 2:
454
- return _context5.a(2);
455
- }
456
- }, _callee5, this);
457
- }));
458
- function updatePathfindingAfterTransform(_x4) {
459
- return _updatePathfindingAfterTransform.apply(this, arguments);
460
- }
461
- return updatePathfindingAfterTransform;
462
- }()
463
- /**
464
- * Dispose of pathfinding resources
465
- */
466
- )
467
- }, {
468
- key: "dispose",
469
- value: function dispose() {
470
- this.removeAllPaths();
471
- this.pathfinder = null;
472
- this.crosscubeTextureSet = null;
473
- this.pathfinderVersionInfo = null;
474
- logger.info('PathfindingManager disposed');
475
- }
476
- }]);
477
- }();
478
-
479
- export { PathfindingManager };
1
+ import{createClass as t,objectSpread2 as e,construct as n,toConsumableArray as r,classCallCheck as i,createForOfIteratorHelper as a,asyncToGenerator as s,regenerator as o}from"../_virtual/_rollupPluginBabelHelpers.js";import*as u from"three";import{Pathfinder as h}from"../node_modules/@2112-lab/pathfinder/dist/index.esm.js";import{logger as c,pathfinderLogger as l}from"./debugLogger.js";import{generateUuidFromName as f}from"./nameUtils.js";var v=function(){return t(function t(e){i(this,t),this.component=e,this.pathfinder=null,this.crosscubeTextureSet=null,this.pathfinderVersionInfo=null},[{key:"getPathfinderVersionInfo",value:(y=s(o().m(function t(){var e;return o().w(function(t){for(;;)switch(t.n){case 0:if(!this.pathfinderVersionInfo){t.n=1;break}return t.a(2,this.pathfinderVersionInfo);case 1:return e={version:"1.0.15",detectionMethod:"hardcoded-fallback",timestamp:(new Date).toISOString()},this.pathfinderVersionInfo=e,t.a(2,e)}},t,this)})),function(){return y.apply(this,arguments)})},{key:"logPathfinderVersion",value:(p=s(o().m(function t(){var e,n,r,i=arguments;return o().w(function(t){for(;;)switch(t.n){case 0:return e=i.length>0&&void 0!==i[0]?i[0]:"Unknown Context",t.p=1,t.n=2,this.getPathfinderVersionInfo();case 2:n=t.v,l.info("[".concat(e,"] Pathfinder Module Information:"),{version:n.version,detectionMethod:n.detectionMethod,context:e,timestamp:n.timestamp,pathfinderInstance:!!this.pathfinder}),t.n=4;break;case 3:t.p=3,r=t.v,l.error("[".concat(e,"] Failed to get pathfinder version:"),r);case 4:return t.a(2)}},t,this,[[1,3]])})),function(){return p.apply(this,arguments)})},{key:"getPathColor",value:function(t){var e=["#468e49","#245e29","#2e80d2","#1d51a1"];return e[t%e.length]}},{key:"initializePathfinder",value:(m=s(o().m(function t(e,n){var r,i;return o().w(function(t){for(;;)switch(t.n){case 0:return r=this.component,this.crosscubeTextureSet=n,t.n=1,this.logPathfinderVersion("Scene Loading");case 1:this.pathfinder=new h(e),r.pathfinder=this.pathfinder,i=this.pathfinder.findPaths(),this.createPipePaths(i,n);case 2:return t.a(2)}},t,this)})),function(t,e){return m.apply(this,arguments)})},{key:"removeAllPaths",value:function(){var t=this.component,e=[];t.scene.traverse(function(t){t.name&&t.name.includes("Polyline")&&e.push(t)});for(var n=0,r=e;n<r.length;n++){var i=r[n];t.scene.remove(i),i.geometry&&i.geometry.dispose(),i.material&&(Array.isArray(i.material)?i.material.forEach(function(t){return t.dispose()}):i.material.dispose())}}},{key:"createPipeMaterial",value:function(t,i){if(t){var a=e(e({},t.config.materialProps),{},{color:this.getPathColor(i),map:t.textures.diffuse,normalMap:t.textures.normal,roughnessMap:t.textures.roughness,metalness:.2,roughness:.9,clearcoat:.2,clearcoatRoughness:.2,envMapIntensity:.6,reflectivity:.4});a.normalScale&&Array.isArray(a.normalScale)&&(a.normalScale=n(u.Vector2,r(a.normalScale)));var s=new u.MeshPhysicalMaterial(a);return[s.map,s.normalMap,s.roughnessMap].filter(Boolean).forEach(function(e){e.wrapS=e.wrapT=u.RepeatWrapping,e.repeat.set(2*t.config.repeat.x,2*t.config.repeat.y)}),s}return new u.MeshPhysicalMaterial({color:this.getPathColor(i),metalness:.9,roughness:.7,clearcoat:.1,clearcoatRoughness:.3,envMapIntensity:1.5,reflectivity:.3})}},{key:"createPipePaths",value:function(t,e){var n=this,r=this.component;t.forEach(function(t,i){if(t.path){var a=new u.Object3D;a.name="Polyline ".concat(t.from,"-").concat(t.to);for(var s=n.createPipeMaterial(e,i),o=0;o<t.path.length-1;o++){var h=t.path[o],c=t.path[o+1],l=(new u.Vector3).subVectors(c,h),f=l.length(),v=new u.CylinderGeometry(.1,.1,f,8,1,!1),d=new u.Mesh(v,s);d.position.copy(h).add(c).multiplyScalar(.5);var m=new u.Quaternion,p=new u.Vector3(0,1,0);if(m.setFromUnitVectors(p,l.normalize()),d.quaternion.copy(m),d.castShadow=!0,d.receiveShadow=!0,a.add(d),o<t.path.length-2){var y=t.path[o+1],w=t.path[o+2],g=l.normalize(),k=(new u.Vector3).subVectors(w,y).normalize(),P=Math.acos(g.dot(k));if(Math.abs(P-Math.PI/2)<.1){var M=new u.SphereGeometry(.1,16,16),b=new u.Mesh(M,s);b.position.copy(c),b.castShadow=!0,b.receiveShadow=!0,a.add(b)}}}a.name="Polyline",r.scene.add(a)}})}},{key:"recomputeWorldBoundingBoxes",value:function(t){this.component.scene.traverse(function(e){if(e.isMesh){var n=null,r=function(t){var n,i=a(t);try{for(i.s();!(n=i.n()).done;){var s,o,u=n.value;if(u.uuid===e.uuid||u.uuid===(null===(s=e.userData)||void 0===s?void 0:s.originalUuid)||e.uuid===(null===(o=u.userData)||void 0===o?void 0:o.originalUuid))return u;if(e.name&&u.name){var h=f(e.name),c=f(u.name);if(h===c||h===u.uuid||c===e.uuid)return u}if(e.name&&u.name&&e.name===u.name)return u;if(u.children){var l=r(u.children);if(l)return l}}}catch(t){i.e(t)}finally{i.f()}return null};if(n=r(t.scene.object.children)){var i=(new u.Box3).setFromObject(e);n.userData||(n.userData={}),n.userData.worldBoundingBox={min:i.min.toArray(),max:i.max.toArray()}}}})}},{key:"updatePathfindingWithConnections",value:(d=s(o().m(function t(e){var n,i,a;return o().w(function(t){for(;;)switch(t.n){case 0:if((n=this.component).currentSceneData){t.n=1;break}return t.a(2,!1);case 1:return this.removeAllPaths(),(i=JSON.parse(JSON.stringify(n.currentSceneData))).connections=r(e),t.n=2,this.logPathfinderVersion("Connections Update");case 2:return this.pathfinder=new h(i),n.pathfinder=this.pathfinder,a=this.pathfinder.findPaths(),this.createPipePaths(a,this.crosscubeTextureSet),n.currentSceneData=i,t.a(2,!0)}},t,this)})),function(t){return d.apply(this,arguments)})},{key:"updatePathfindingAfterTransform",value:(v=s(o().m(function t(e){var n;return o().w(function(t){for(;;)switch(t.n){case 0:return this.removeAllPaths(),t.n=1,this.logPathfinderVersion("Transform Update");case 1:this.pathfinder=new h(e),this.component.pathfinder=this.pathfinder,n=this.pathfinder.findPaths(),this.createPipePaths(n,this.crosscubeTextureSet);case 2:return t.a(2)}},t,this)})),function(t){return v.apply(this,arguments)})},{key:"dispose",value:function(){this.removeAllPaths(),this.pathfinder=null,this.crosscubeTextureSet=null,this.pathfinderVersionInfo=null,c.info("PathfindingManager disposed")}}]);var v,d,m,p,y}();export{v as PathfindingManager};