@2112-lab/central-plant 0.1.1 → 0.1.2
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 +6234 -5876
- package/dist/cjs/_virtual/_rollupPluginBabelHelpers.js +23 -10
- package/dist/cjs/node_modules/@2112-lab/pathfinder/dist/index.esm.js +1448 -0
- package/dist/cjs/src/index.js +2 -51
- package/dist/cjs/src/pathfindingManager.js +297 -115
- package/dist/esm/_virtual/_rollupPluginBabelHelpers.js +21 -10
- package/dist/esm/node_modules/@2112-lab/pathfinder/dist/index.esm.js +1444 -0
- package/dist/esm/src/index.js +3 -51
- package/dist/esm/src/pathfindingManager.js +299 -115
- package/dist/index.d.ts +0 -4
- package/package.json +1 -1
- package/dist/cjs/src/ConnectionManager.js +0 -114
- package/dist/cjs/src/Pathfinder.js +0 -88
- package/dist/cjs/src/modelPreloader.js +0 -488
- package/dist/cjs/src/sceneOperationsManager.js +0 -596
- package/dist/esm/src/ConnectionManager.js +0 -110
- package/dist/esm/src/Pathfinder.js +0 -84
- package/dist/esm/src/modelPreloader.js +0 -464
- package/dist/esm/src/sceneOperationsManager.js +0 -572
package/dist/esm/src/index.js
CHANGED
|
@@ -13,64 +13,24 @@ import * as hotReloadManager from './hotReloadManager.js';
|
|
|
13
13
|
export { hotReloadManager };
|
|
14
14
|
import * as keyboardControlsManager from './keyboardControlsManager.js';
|
|
15
15
|
export { keyboardControlsManager };
|
|
16
|
-
import { modelPreloader as explicitModelPreloader } from './modelPreloader.js';
|
|
17
16
|
import * as nameUtils from './nameUtils.js';
|
|
18
17
|
export { nameUtils };
|
|
19
18
|
export { findObjectByHardcodedUuid, generateUuidFromName, getHardcodedUuid } from './nameUtils.js';
|
|
20
19
|
import * as pathfindingManager from './pathfindingManager.js';
|
|
21
20
|
export { pathfindingManager };
|
|
22
21
|
import * as performanceMonitor from './performanceMonitor.js';
|
|
23
|
-
export { performanceMonitor };
|
|
24
22
|
import * as sceneExportManager from './sceneExportManager.js';
|
|
25
23
|
export { sceneExportManager };
|
|
26
24
|
export { getSceneExportManager } from './sceneExportManager.js';
|
|
27
25
|
import * as sceneInitializationManager from './sceneInitializationManager.js';
|
|
28
26
|
export { sceneInitializationManager };
|
|
29
|
-
import * as sceneOperationsManager from './sceneOperationsManager.js';
|
|
30
|
-
export { sceneOperationsManager };
|
|
31
|
-
export { getSceneOperationsManager } from './sceneOperationsManager.js';
|
|
32
27
|
import * as textureConfig from './textureConfig.js';
|
|
33
28
|
export { textureConfig };
|
|
34
29
|
import * as transformControlsManager from './transformControlsManager.js';
|
|
35
30
|
export { transformControlsManager };
|
|
36
31
|
export { getTransformControlsManager } from './transformControlsManager.js';
|
|
37
|
-
import * as Pathfinder from './Pathfinder.js';
|
|
38
|
-
export { Pathfinder };
|
|
39
|
-
import * as ConnectionManager from './ConnectionManager.js';
|
|
40
|
-
export { ConnectionManager };
|
|
41
32
|
|
|
42
|
-
|
|
43
|
-
* @module CentralPlant/Utils
|
|
44
|
-
* @description Central Plant Utilities Module
|
|
45
|
-
*
|
|
46
|
-
* This is the main entry point for all utility functions and classes
|
|
47
|
-
* used in the Central Plant application. Import this module to access
|
|
48
|
-
* all utility functions through a single interface.
|
|
49
|
-
*
|
|
50
|
-
* @example
|
|
51
|
-
* // Import the entire utilities module
|
|
52
|
-
* import CentralPlant from 'central-plant';
|
|
53
|
-
*
|
|
54
|
-
* // Use a specific utility
|
|
55
|
-
* CentralPlant.modelPreloader.preloadAllModels(...);
|
|
56
|
-
*
|
|
57
|
-
* @example
|
|
58
|
-
* // Import specific modules
|
|
59
|
-
* import { modelPreloader, nameUtils } from 'CentralPlant';
|
|
60
|
-
*
|
|
61
|
-
* // Use them directly
|
|
62
|
-
* modelPreloader.preloadAllModels(...);
|
|
63
|
-
*
|
|
64
|
-
* @example
|
|
65
|
-
* // Import common functions directly
|
|
66
|
-
* import { getHardcodedUuid, logger } from 'CentralPlant';
|
|
67
|
-
*
|
|
68
|
-
* // Use functions directly
|
|
69
|
-
* const uuid = getHardcodedUuid(object);
|
|
70
|
-
* logger.info('Operation completed');
|
|
71
|
-
*/
|
|
72
|
-
// Use the explicit modelPreloader object as the named export
|
|
73
|
-
var modelPreloader = explicitModelPreloader;
|
|
33
|
+
// Import all utility modules
|
|
74
34
|
|
|
75
35
|
/**
|
|
76
36
|
* Central API object that provides access to all utility modules
|
|
@@ -82,17 +42,13 @@ var modelPreloader = explicitModelPreloader;
|
|
|
82
42
|
* @property {Object} environment - 3D environment management utilities
|
|
83
43
|
* @property {Object} hotReload - Hot reload handling utilities
|
|
84
44
|
* @property {Object} keyboardControls - Keyboard controls management
|
|
85
|
-
* @property {Object} modelPreloader - Model preloading utilities
|
|
86
45
|
* @property {Object} name - Name and UUID management utilities
|
|
87
46
|
* @property {Object} pathfinding - Pathfinding utilities
|
|
88
47
|
* @property {Object} performance - Performance monitoring utilities
|
|
89
48
|
* @property {Object} sceneExport - Scene export utilities
|
|
90
49
|
* @property {Object} sceneInitialization - Scene initialization utilities
|
|
91
|
-
* @property {Object} sceneOperations - Scene operations utilities
|
|
92
50
|
* @property {Object} texture - Texture management utilities
|
|
93
51
|
* @property {Object} transformControls - Transform controls utilities
|
|
94
|
-
* @property {Object} pathfinder - Pathfinder utilities
|
|
95
|
-
* @property {Object} connectionManager - Connection management utilities
|
|
96
52
|
*/
|
|
97
53
|
var CentralPlantUtils = {
|
|
98
54
|
animation: animationManager,
|
|
@@ -102,17 +58,13 @@ var CentralPlantUtils = {
|
|
|
102
58
|
environment: environmentManager,
|
|
103
59
|
hotReload: hotReloadManager,
|
|
104
60
|
keyboardControls: keyboardControlsManager,
|
|
105
|
-
modelPreloader: modelPreloader,
|
|
106
61
|
name: nameUtils,
|
|
107
62
|
pathfinding: pathfindingManager,
|
|
108
63
|
performance: performanceMonitor,
|
|
109
64
|
sceneExport: sceneExportManager,
|
|
110
65
|
sceneInitialization: sceneInitializationManager,
|
|
111
|
-
sceneOperations: sceneOperationsManager,
|
|
112
66
|
texture: textureConfig,
|
|
113
|
-
transformControls: transformControlsManager
|
|
114
|
-
pathfinder: Pathfinder,
|
|
115
|
-
connectionManager: ConnectionManager
|
|
67
|
+
transformControls: transformControlsManager
|
|
116
68
|
};
|
|
117
69
|
|
|
118
|
-
export { CentralPlantUtils as default
|
|
70
|
+
export { CentralPlantUtils as default };
|
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
import { createClass as _createClass, classCallCheck as _classCallCheck, asyncToGenerator as _asyncToGenerator, regenerator as _regenerator } from '../_virtual/_rollupPluginBabelHelpers.js';
|
|
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
2
|
import * as THREE from 'three';
|
|
3
|
-
import Pathfinder from '
|
|
4
|
-
import { pathfinderLogger } from './debugLogger.js';
|
|
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';
|
|
5
6
|
|
|
6
7
|
var PathfindingManager = /*#__PURE__*/function () {
|
|
7
8
|
function PathfindingManager(component) {
|
|
8
9
|
_classCallCheck(this, PathfindingManager);
|
|
9
10
|
this.component = component;
|
|
11
|
+
this.pathfinder = null;
|
|
10
12
|
this.crosscubeTextureSet = null;
|
|
11
13
|
this.pathfinderVersionInfo = null;
|
|
12
|
-
|
|
13
|
-
// Initialize pathfinder
|
|
14
|
-
this.pathfinder = new Pathfinder(component === null || component === void 0 ? void 0 : component.sceneData);
|
|
15
14
|
}
|
|
16
15
|
|
|
17
16
|
/**
|
|
@@ -113,41 +112,27 @@ var PathfindingManager = /*#__PURE__*/function () {
|
|
|
113
112
|
return _regenerator().w(function (_context3) {
|
|
114
113
|
while (1) switch (_context3.n) {
|
|
115
114
|
case 0:
|
|
116
|
-
if (Pathfinder) {
|
|
117
|
-
_context3.n = 1;
|
|
118
|
-
break;
|
|
119
|
-
}
|
|
120
|
-
_context3.n = 1;
|
|
121
|
-
return importPathfinder();
|
|
122
|
-
case 1:
|
|
123
115
|
component = this.component;
|
|
124
116
|
this.crosscubeTextureSet = crosscubeTextureSet;
|
|
125
117
|
|
|
126
118
|
// Log pathfinder version information
|
|
127
|
-
_context3.n =
|
|
119
|
+
_context3.n = 1;
|
|
128
120
|
return this.logPathfinderVersion('Scene Loading');
|
|
129
|
-
case
|
|
121
|
+
case 1:
|
|
130
122
|
this.pathfinder = new Pathfinder(data);
|
|
131
|
-
|
|
123
|
+
component.pathfinder = this.pathfinder;
|
|
132
124
|
|
|
133
125
|
// Add debugging for pathfinder input
|
|
134
126
|
console.log('🔍 PATHFINDER DEBUGGING:');
|
|
135
127
|
console.log('🔗 Connections:', data.connections);
|
|
136
128
|
console.log('🏗️ Scene structure:', JSON.parse(JSON.stringify((_data$scene = data.scene) === null || _data$scene === void 0 ? void 0 : _data$scene.object)));
|
|
137
|
-
|
|
138
|
-
// Ensure connections exist before finding paths
|
|
139
|
-
if (!(!data.connections || !Array.isArray(data.connections))) {
|
|
140
|
-
_context3.n = 3;
|
|
141
|
-
break;
|
|
142
|
-
}
|
|
143
|
-
console.warn('⚠️ No connections found in scene data, skipping path finding');
|
|
144
|
-
return _context3.a(2, []);
|
|
145
|
-
case 3:
|
|
146
129
|
paths = this.pathfinder.findPaths();
|
|
147
130
|
console.log('Found paths:', paths);
|
|
148
131
|
|
|
149
132
|
// Create pipe paths with materials
|
|
150
|
-
|
|
133
|
+
this.createPipePaths(paths, crosscubeTextureSet);
|
|
134
|
+
case 2:
|
|
135
|
+
return _context3.a(2);
|
|
151
136
|
}
|
|
152
137
|
}, _callee3, this);
|
|
153
138
|
}));
|
|
@@ -157,6 +142,7 @@ var PathfindingManager = /*#__PURE__*/function () {
|
|
|
157
142
|
return initializePathfinder;
|
|
158
143
|
}()
|
|
159
144
|
/**
|
|
145
|
+
/**
|
|
160
146
|
* Remove all existing paths from the scene
|
|
161
147
|
*/
|
|
162
148
|
)
|
|
@@ -164,38 +150,30 @@ var PathfindingManager = /*#__PURE__*/function () {
|
|
|
164
150
|
key: "removeAllPaths",
|
|
165
151
|
value: function removeAllPaths() {
|
|
166
152
|
var component = this.component;
|
|
167
|
-
if (!component || !component.scene) {
|
|
168
|
-
return;
|
|
169
|
-
}
|
|
170
153
|
console.log("removeAllPaths started");
|
|
171
154
|
var objectsToRemove = [];
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
objectsToRemove.push(
|
|
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);
|
|
177
160
|
}
|
|
178
161
|
});
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
}
|
|
188
|
-
if (object.material) {
|
|
189
|
-
if (Array.isArray(object.material)) {
|
|
190
|
-
object.material.forEach(function (material) {
|
|
191
|
-
return material.dispose();
|
|
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();
|
|
192
170
|
});
|
|
193
171
|
} else {
|
|
194
|
-
|
|
172
|
+
obj.material.dispose();
|
|
195
173
|
}
|
|
196
174
|
}
|
|
197
|
-
}
|
|
198
|
-
console.log("Removed ".concat(objectsToRemove.length, "
|
|
175
|
+
}
|
|
176
|
+
console.log("\u2705 Removed ".concat(objectsToRemove.length, " polyline objects from scene"));
|
|
199
177
|
}
|
|
200
178
|
|
|
201
179
|
/**
|
|
@@ -204,14 +182,44 @@ var PathfindingManager = /*#__PURE__*/function () {
|
|
|
204
182
|
}, {
|
|
205
183
|
key: "createPipeMaterial",
|
|
206
184
|
value: function createPipeMaterial(crosscubeTextureSet, pathIndex) {
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
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
|
+
}
|
|
215
223
|
}
|
|
216
224
|
|
|
217
225
|
/**
|
|
@@ -222,74 +230,250 @@ var PathfindingManager = /*#__PURE__*/function () {
|
|
|
222
230
|
value: function createPipePaths(paths, crosscubeTextureSet) {
|
|
223
231
|
var _this = this;
|
|
224
232
|
var component = this.component;
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
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);
|
|
229
254
|
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
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);
|
|
237
274
|
}
|
|
238
|
-
|
|
239
|
-
|
|
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
|
|
240
297
|
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
var curve = new THREE.CatmullRomCurve3(points);
|
|
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
|
+
}
|
|
246
302
|
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
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
|
+
}
|
|
252
311
|
|
|
253
|
-
|
|
254
|
-
|
|
312
|
+
// Strategy 3: Name match
|
|
313
|
+
if (object.name && child.name && object.name === child.name) {
|
|
314
|
+
return child;
|
|
315
|
+
}
|
|
255
316
|
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
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;
|
|
263
330
|
};
|
|
331
|
+
jsonObject = _findJsonObject(currentSceneData.scene.object.children);
|
|
332
|
+
if (jsonObject) {
|
|
333
|
+
// Compute world bounding box
|
|
334
|
+
var boundingBox = new THREE.Box3().setFromObject(object);
|
|
264
335
|
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
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
|
+
}
|
|
270
344
|
}
|
|
271
345
|
});
|
|
272
|
-
return pipeObjects;
|
|
273
346
|
}
|
|
274
|
-
|
|
275
|
-
|
|
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
|
+
});
|
|
276
377
|
|
|
277
|
-
// Create a
|
|
278
|
-
|
|
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
|
+
});
|
|
279
387
|
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
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
|
+
}();
|
|
294
478
|
|
|
295
|
-
export { PathfindingManager
|
|
479
|
+
export { PathfindingManager };
|
package/dist/index.d.ts
CHANGED