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