@2112-lab/central-plant 0.1.0 → 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 +7782 -6543
- 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/animationManager.js +15 -15
- package/dist/cjs/src/componentManager.js +8 -8
- package/dist/cjs/src/disposalManager.js +12 -12
- package/dist/cjs/src/environmentManager.js +392 -99
- package/dist/cjs/src/hotReloadManager.js +26 -26
- package/dist/cjs/src/index.js +19 -66
- package/dist/cjs/src/keyboardControlsManager.js +23 -23
- package/dist/cjs/src/nameUtils.js +21 -21
- package/dist/cjs/src/pathfindingManager.js +311 -129
- package/dist/cjs/src/performanceMonitor.js +52 -52
- package/dist/cjs/src/sceneExportManager.js +23 -23
- package/dist/cjs/src/sceneInitializationManager.js +18 -18
- package/dist/cjs/src/textureConfig.js +469 -40
- package/dist/cjs/src/transformControlsManager.js +79 -79
- 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/animationManager.js +15 -15
- package/dist/esm/src/componentManager.js +8 -8
- package/dist/esm/src/disposalManager.js +12 -12
- package/dist/esm/src/environmentManager.js +393 -100
- package/dist/esm/src/hotReloadManager.js +26 -26
- package/dist/esm/src/index.js +19 -66
- package/dist/esm/src/keyboardControlsManager.js +23 -23
- package/dist/esm/src/nameUtils.js +21 -21
- package/dist/esm/src/pathfindingManager.js +313 -129
- package/dist/esm/src/performanceMonitor.js +52 -52
- package/dist/esm/src/sceneExportManager.js +23 -23
- package/dist/esm/src/sceneInitializationManager.js +18 -18
- package/dist/esm/src/textureConfig.js +469 -42
- package/dist/esm/src/transformControlsManager.js +79 -79
- package/dist/index.d.ts +255 -259
- package/package.json +52 -53
- package/dist/cjs/src/ConnectionManager.js +0 -114
- package/dist/cjs/src/Pathfinder.js +0 -88
- package/dist/cjs/src/modelPreloader.js +0 -360
- package/dist/cjs/src/sceneOperationsManager.js +0 -560
- package/dist/esm/src/ConnectionManager.js +0 -110
- package/dist/esm/src/Pathfinder.js +0 -84
- package/dist/esm/src/modelPreloader.js +0 -337
- package/dist/esm/src/sceneOperationsManager.js +0 -536
|
@@ -1,21 +1,20 @@
|
|
|
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
|
-
/**
|
|
18
|
-
* Get pathfinder version information
|
|
16
|
+
/**
|
|
17
|
+
* Get pathfinder version information
|
|
19
18
|
*/
|
|
20
19
|
return _createClass(PathfindingManager, [{
|
|
21
20
|
key: "getPathfinderVersionInfo",
|
|
@@ -46,8 +45,8 @@ var PathfindingManager = /*#__PURE__*/function () {
|
|
|
46
45
|
}
|
|
47
46
|
return getPathfinderVersionInfo;
|
|
48
47
|
}()
|
|
49
|
-
/**
|
|
50
|
-
* Log pathfinder version information
|
|
48
|
+
/**
|
|
49
|
+
* Log pathfinder version information
|
|
51
50
|
*/
|
|
52
51
|
)
|
|
53
52
|
}, {
|
|
@@ -90,8 +89,8 @@ var PathfindingManager = /*#__PURE__*/function () {
|
|
|
90
89
|
}
|
|
91
90
|
return logPathfinderVersion;
|
|
92
91
|
}()
|
|
93
|
-
/**
|
|
94
|
-
* Get path colors for visual distinction
|
|
92
|
+
/**
|
|
93
|
+
* Get path colors for visual distinction
|
|
95
94
|
*/
|
|
96
95
|
)
|
|
97
96
|
}, {
|
|
@@ -101,8 +100,8 @@ var PathfindingManager = /*#__PURE__*/function () {
|
|
|
101
100
|
return colors[index % colors.length];
|
|
102
101
|
}
|
|
103
102
|
|
|
104
|
-
/**
|
|
105
|
-
* Initialize pathfinder and create paths
|
|
103
|
+
/**
|
|
104
|
+
* Initialize pathfinder and create paths
|
|
106
105
|
*/
|
|
107
106
|
}, {
|
|
108
107
|
key: "initializePathfinder",
|
|
@@ -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
|
}));
|
|
@@ -156,140 +141,339 @@ var PathfindingManager = /*#__PURE__*/function () {
|
|
|
156
141
|
}
|
|
157
142
|
return initializePathfinder;
|
|
158
143
|
}()
|
|
159
|
-
/**
|
|
160
|
-
|
|
144
|
+
/**
|
|
145
|
+
/**
|
|
146
|
+
* Remove all existing paths from the scene
|
|
161
147
|
*/
|
|
162
148
|
)
|
|
163
149
|
}, {
|
|
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
|
-
/**
|
|
202
|
-
* Material factory function to reduce duplication
|
|
179
|
+
/**
|
|
180
|
+
* Material factory function to reduce duplication
|
|
203
181
|
*/
|
|
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
|
-
/**
|
|
218
|
-
* Helper function to create pipe paths
|
|
225
|
+
/**
|
|
226
|
+
* Helper function to create pipe paths
|
|
219
227
|
*/
|
|
220
228
|
}, {
|
|
221
229
|
key: "createPipePaths",
|
|
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
|
+
}
|
|
240
277
|
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
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
|
+
}
|
|
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 };
|