@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/cjs/src/index.js
CHANGED
|
@@ -9,50 +9,15 @@ var disposalManager = require('./disposalManager.js');
|
|
|
9
9
|
var environmentManager = require('./environmentManager.js');
|
|
10
10
|
var hotReloadManager = require('./hotReloadManager.js');
|
|
11
11
|
var keyboardControlsManager = require('./keyboardControlsManager.js');
|
|
12
|
-
var modelPreloader$1 = require('./modelPreloader.js');
|
|
13
12
|
var nameUtils = require('./nameUtils.js');
|
|
14
13
|
var pathfindingManager = require('./pathfindingManager.js');
|
|
15
14
|
var performanceMonitor = require('./performanceMonitor.js');
|
|
16
15
|
var sceneExportManager = require('./sceneExportManager.js');
|
|
17
16
|
var sceneInitializationManager = require('./sceneInitializationManager.js');
|
|
18
|
-
var sceneOperationsManager = require('./sceneOperationsManager.js');
|
|
19
17
|
var textureConfig = require('./textureConfig.js');
|
|
20
18
|
var transformControlsManager = require('./transformControlsManager.js');
|
|
21
|
-
var Pathfinder = require('./Pathfinder.js');
|
|
22
|
-
var ConnectionManager = require('./ConnectionManager.js');
|
|
23
19
|
|
|
24
|
-
|
|
25
|
-
* @module CentralPlant/Utils
|
|
26
|
-
* @description Central Plant Utilities Module
|
|
27
|
-
*
|
|
28
|
-
* This is the main entry point for all utility functions and classes
|
|
29
|
-
* used in the Central Plant application. Import this module to access
|
|
30
|
-
* all utility functions through a single interface.
|
|
31
|
-
*
|
|
32
|
-
* @example
|
|
33
|
-
* // Import the entire utilities module
|
|
34
|
-
* import CentralPlant from 'central-plant';
|
|
35
|
-
*
|
|
36
|
-
* // Use a specific utility
|
|
37
|
-
* CentralPlant.modelPreloader.preloadAllModels(...);
|
|
38
|
-
*
|
|
39
|
-
* @example
|
|
40
|
-
* // Import specific modules
|
|
41
|
-
* import { modelPreloader, nameUtils } from 'CentralPlant';
|
|
42
|
-
*
|
|
43
|
-
* // Use them directly
|
|
44
|
-
* modelPreloader.preloadAllModels(...);
|
|
45
|
-
*
|
|
46
|
-
* @example
|
|
47
|
-
* // Import common functions directly
|
|
48
|
-
* import { getHardcodedUuid, logger } from 'CentralPlant';
|
|
49
|
-
*
|
|
50
|
-
* // Use functions directly
|
|
51
|
-
* const uuid = getHardcodedUuid(object);
|
|
52
|
-
* logger.info('Operation completed');
|
|
53
|
-
*/
|
|
54
|
-
// Use the explicit modelPreloader object as the named export
|
|
55
|
-
var modelPreloader = modelPreloader$1.modelPreloader;
|
|
20
|
+
// Import all utility modules
|
|
56
21
|
|
|
57
22
|
/**
|
|
58
23
|
* Central API object that provides access to all utility modules
|
|
@@ -64,17 +29,13 @@ var modelPreloader = modelPreloader$1.modelPreloader;
|
|
|
64
29
|
* @property {Object} environment - 3D environment management utilities
|
|
65
30
|
* @property {Object} hotReload - Hot reload handling utilities
|
|
66
31
|
* @property {Object} keyboardControls - Keyboard controls management
|
|
67
|
-
* @property {Object} modelPreloader - Model preloading utilities
|
|
68
32
|
* @property {Object} name - Name and UUID management utilities
|
|
69
33
|
* @property {Object} pathfinding - Pathfinding utilities
|
|
70
34
|
* @property {Object} performance - Performance monitoring utilities
|
|
71
35
|
* @property {Object} sceneExport - Scene export utilities
|
|
72
36
|
* @property {Object} sceneInitialization - Scene initialization utilities
|
|
73
|
-
* @property {Object} sceneOperations - Scene operations utilities
|
|
74
37
|
* @property {Object} texture - Texture management utilities
|
|
75
38
|
* @property {Object} transformControls - Transform controls utilities
|
|
76
|
-
* @property {Object} pathfinder - Pathfinder utilities
|
|
77
|
-
* @property {Object} connectionManager - Connection management utilities
|
|
78
39
|
*/
|
|
79
40
|
var CentralPlantUtils = {
|
|
80
41
|
animation: animationManager,
|
|
@@ -84,17 +45,13 @@ var CentralPlantUtils = {
|
|
|
84
45
|
environment: environmentManager,
|
|
85
46
|
hotReload: hotReloadManager,
|
|
86
47
|
keyboardControls: keyboardControlsManager,
|
|
87
|
-
modelPreloader: modelPreloader,
|
|
88
48
|
name: nameUtils,
|
|
89
49
|
pathfinding: pathfindingManager,
|
|
90
50
|
performance: performanceMonitor,
|
|
91
51
|
sceneExport: sceneExportManager,
|
|
92
52
|
sceneInitialization: sceneInitializationManager,
|
|
93
|
-
sceneOperations: sceneOperationsManager,
|
|
94
53
|
texture: textureConfig,
|
|
95
|
-
transformControls: transformControlsManager
|
|
96
|
-
pathfinder: Pathfinder,
|
|
97
|
-
connectionManager: ConnectionManager
|
|
54
|
+
transformControls: transformControlsManager
|
|
98
55
|
};
|
|
99
56
|
|
|
100
57
|
exports.animationManager = animationManager;
|
|
@@ -113,16 +70,10 @@ exports.generateUuidFromName = nameUtils.generateUuidFromName;
|
|
|
113
70
|
exports.getHardcodedUuid = nameUtils.getHardcodedUuid;
|
|
114
71
|
exports.nameUtils = nameUtils;
|
|
115
72
|
exports.pathfindingManager = pathfindingManager;
|
|
116
|
-
exports.performanceMonitor = performanceMonitor;
|
|
117
73
|
exports.getSceneExportManager = sceneExportManager.getSceneExportManager;
|
|
118
74
|
exports.sceneExportManager = sceneExportManager;
|
|
119
75
|
exports.sceneInitializationManager = sceneInitializationManager;
|
|
120
|
-
exports.getSceneOperationsManager = sceneOperationsManager.getSceneOperationsManager;
|
|
121
|
-
exports.sceneOperationsManager = sceneOperationsManager;
|
|
122
76
|
exports.textureConfig = textureConfig;
|
|
123
77
|
exports.getTransformControlsManager = transformControlsManager.getTransformControlsManager;
|
|
124
78
|
exports.transformControlsManager = transformControlsManager;
|
|
125
|
-
exports.Pathfinder = Pathfinder;
|
|
126
|
-
exports.ConnectionManager = ConnectionManager;
|
|
127
79
|
exports["default"] = CentralPlantUtils;
|
|
128
|
-
exports.modelPreloader = modelPreloader;
|
|
@@ -4,8 +4,9 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var _rollupPluginBabelHelpers = require('../_virtual/_rollupPluginBabelHelpers.js');
|
|
6
6
|
var THREE = require('three');
|
|
7
|
-
var
|
|
7
|
+
var index_esm = require('../node_modules/@2112-lab/pathfinder/dist/index.esm.js');
|
|
8
8
|
var debugLogger = require('./debugLogger.js');
|
|
9
|
+
var nameUtils = require('./nameUtils.js');
|
|
9
10
|
|
|
10
11
|
function _interopNamespace(e) {
|
|
11
12
|
if (e && e.__esModule) return e;
|
|
@@ -31,11 +32,9 @@ var PathfindingManager = /*#__PURE__*/function () {
|
|
|
31
32
|
function PathfindingManager(component) {
|
|
32
33
|
_rollupPluginBabelHelpers.classCallCheck(this, PathfindingManager);
|
|
33
34
|
this.component = component;
|
|
35
|
+
this.pathfinder = null;
|
|
34
36
|
this.crosscubeTextureSet = null;
|
|
35
37
|
this.pathfinderVersionInfo = null;
|
|
36
|
-
|
|
37
|
-
// Initialize pathfinder
|
|
38
|
-
this.pathfinder = new Pathfinder["default"](component === null || component === void 0 ? void 0 : component.sceneData);
|
|
39
38
|
}
|
|
40
39
|
|
|
41
40
|
/**
|
|
@@ -137,41 +136,27 @@ var PathfindingManager = /*#__PURE__*/function () {
|
|
|
137
136
|
return _rollupPluginBabelHelpers.regenerator().w(function (_context3) {
|
|
138
137
|
while (1) switch (_context3.n) {
|
|
139
138
|
case 0:
|
|
140
|
-
if (Pathfinder["default"]) {
|
|
141
|
-
_context3.n = 1;
|
|
142
|
-
break;
|
|
143
|
-
}
|
|
144
|
-
_context3.n = 1;
|
|
145
|
-
return importPathfinder();
|
|
146
|
-
case 1:
|
|
147
139
|
component = this.component;
|
|
148
140
|
this.crosscubeTextureSet = crosscubeTextureSet;
|
|
149
141
|
|
|
150
142
|
// Log pathfinder version information
|
|
151
|
-
_context3.n =
|
|
143
|
+
_context3.n = 1;
|
|
152
144
|
return this.logPathfinderVersion('Scene Loading');
|
|
153
|
-
case
|
|
154
|
-
this.pathfinder = new Pathfinder
|
|
155
|
-
|
|
145
|
+
case 1:
|
|
146
|
+
this.pathfinder = new index_esm.Pathfinder(data);
|
|
147
|
+
component.pathfinder = this.pathfinder;
|
|
156
148
|
|
|
157
149
|
// Add debugging for pathfinder input
|
|
158
150
|
console.log('🔍 PATHFINDER DEBUGGING:');
|
|
159
151
|
console.log('🔗 Connections:', data.connections);
|
|
160
152
|
console.log('🏗️ Scene structure:', JSON.parse(JSON.stringify((_data$scene = data.scene) === null || _data$scene === void 0 ? void 0 : _data$scene.object)));
|
|
161
|
-
|
|
162
|
-
// Ensure connections exist before finding paths
|
|
163
|
-
if (!(!data.connections || !Array.isArray(data.connections))) {
|
|
164
|
-
_context3.n = 3;
|
|
165
|
-
break;
|
|
166
|
-
}
|
|
167
|
-
console.warn('⚠️ No connections found in scene data, skipping path finding');
|
|
168
|
-
return _context3.a(2, []);
|
|
169
|
-
case 3:
|
|
170
153
|
paths = this.pathfinder.findPaths();
|
|
171
154
|
console.log('Found paths:', paths);
|
|
172
155
|
|
|
173
156
|
// Create pipe paths with materials
|
|
174
|
-
|
|
157
|
+
this.createPipePaths(paths, crosscubeTextureSet);
|
|
158
|
+
case 2:
|
|
159
|
+
return _context3.a(2);
|
|
175
160
|
}
|
|
176
161
|
}, _callee3, this);
|
|
177
162
|
}));
|
|
@@ -181,6 +166,7 @@ var PathfindingManager = /*#__PURE__*/function () {
|
|
|
181
166
|
return initializePathfinder;
|
|
182
167
|
}()
|
|
183
168
|
/**
|
|
169
|
+
/**
|
|
184
170
|
* Remove all existing paths from the scene
|
|
185
171
|
*/
|
|
186
172
|
)
|
|
@@ -188,38 +174,30 @@ var PathfindingManager = /*#__PURE__*/function () {
|
|
|
188
174
|
key: "removeAllPaths",
|
|
189
175
|
value: function removeAllPaths() {
|
|
190
176
|
var component = this.component;
|
|
191
|
-
if (!component || !component.scene) {
|
|
192
|
-
return;
|
|
193
|
-
}
|
|
194
177
|
console.log("removeAllPaths started");
|
|
195
178
|
var objectsToRemove = [];
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
objectsToRemove.push(
|
|
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);
|
|
201
184
|
}
|
|
202
185
|
});
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
}
|
|
212
|
-
if (object.material) {
|
|
213
|
-
if (Array.isArray(object.material)) {
|
|
214
|
-
object.material.forEach(function (material) {
|
|
215
|
-
return material.dispose();
|
|
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();
|
|
216
194
|
});
|
|
217
195
|
} else {
|
|
218
|
-
|
|
196
|
+
obj.material.dispose();
|
|
219
197
|
}
|
|
220
198
|
}
|
|
221
|
-
}
|
|
222
|
-
console.log("Removed ".concat(objectsToRemove.length, "
|
|
199
|
+
}
|
|
200
|
+
console.log("\u2705 Removed ".concat(objectsToRemove.length, " polyline objects from scene"));
|
|
223
201
|
}
|
|
224
202
|
|
|
225
203
|
/**
|
|
@@ -228,14 +206,44 @@ var PathfindingManager = /*#__PURE__*/function () {
|
|
|
228
206
|
}, {
|
|
229
207
|
key: "createPipeMaterial",
|
|
230
208
|
value: function createPipeMaterial(crosscubeTextureSet, pathIndex) {
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
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
|
+
}
|
|
239
247
|
}
|
|
240
248
|
|
|
241
249
|
/**
|
|
@@ -246,76 +254,250 @@ var PathfindingManager = /*#__PURE__*/function () {
|
|
|
246
254
|
value: function createPipePaths(paths, crosscubeTextureSet) {
|
|
247
255
|
var _this = this;
|
|
248
256
|
var component = this.component;
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
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);
|
|
253
278
|
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
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);
|
|
261
298
|
}
|
|
262
|
-
|
|
263
|
-
|
|
299
|
+
});
|
|
300
|
+
}
|
|
264
301
|
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
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
|
|
270
321
|
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
var geometry = new THREE__namespace.TubeGeometry(curve, tubularSegments, pipeRadius, radialSegments, false);
|
|
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
|
+
}
|
|
276
326
|
|
|
277
|
-
|
|
278
|
-
|
|
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
|
+
}
|
|
279
335
|
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
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;
|
|
287
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);
|
|
288
359
|
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
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
|
+
}
|
|
294
368
|
}
|
|
295
369
|
});
|
|
296
|
-
return pipeObjects;
|
|
297
370
|
}
|
|
298
|
-
|
|
299
|
-
|
|
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
|
+
});
|
|
300
401
|
|
|
301
|
-
// Create a
|
|
302
|
-
|
|
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
|
+
});
|
|
303
411
|
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
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
|
+
}();
|
|
318
502
|
|
|
319
503
|
exports.PathfindingManager = PathfindingManager;
|
|
320
|
-
exports["default"] = pathfindingManager$1;
|
|
321
|
-
exports.getPathfindingManager = getPathfindingManager;
|
|
@@ -37,6 +37,13 @@ function _asyncToGenerator(n) {
|
|
|
37
37
|
function _classCallCheck(a, n) {
|
|
38
38
|
if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
|
|
39
39
|
}
|
|
40
|
+
function _construct(t, e, r) {
|
|
41
|
+
if (_isNativeReflectConstruct()) return Reflect.construct.apply(null, arguments);
|
|
42
|
+
var o = [null];
|
|
43
|
+
o.push.apply(o, e);
|
|
44
|
+
var p = new (t.bind.apply(t, o))();
|
|
45
|
+
return r && _setPrototypeOf(p, r.prototype), p;
|
|
46
|
+
}
|
|
40
47
|
function _defineProperties(e, r) {
|
|
41
48
|
for (var t = 0; t < r.length; t++) {
|
|
42
49
|
var o = r[t];
|
|
@@ -104,6 +111,14 @@ function _defineProperty(e, r, t) {
|
|
|
104
111
|
writable: !0
|
|
105
112
|
}) : e[r] = t, e;
|
|
106
113
|
}
|
|
114
|
+
function _isNativeReflectConstruct() {
|
|
115
|
+
try {
|
|
116
|
+
var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
117
|
+
} catch (t) {}
|
|
118
|
+
return (_isNativeReflectConstruct = function () {
|
|
119
|
+
return !!t;
|
|
120
|
+
})();
|
|
121
|
+
}
|
|
107
122
|
function _iterableToArray(r) {
|
|
108
123
|
if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
|
|
109
124
|
}
|
|
@@ -288,6 +303,11 @@ function _regeneratorValues(e) {
|
|
|
288
303
|
}
|
|
289
304
|
throw new TypeError(typeof e + " is not iterable");
|
|
290
305
|
}
|
|
306
|
+
function _setPrototypeOf(t, e) {
|
|
307
|
+
return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
|
|
308
|
+
return t.__proto__ = e, t;
|
|
309
|
+
}, _setPrototypeOf(t, e);
|
|
310
|
+
}
|
|
291
311
|
function _slicedToArray(r, e) {
|
|
292
312
|
return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
|
|
293
313
|
}
|
|
@@ -308,15 +328,6 @@ function _toPropertyKey(t) {
|
|
|
308
328
|
var i = _toPrimitive(t, "string");
|
|
309
329
|
return "symbol" == typeof i ? i : i + "";
|
|
310
330
|
}
|
|
311
|
-
function _typeof(o) {
|
|
312
|
-
"@babel/helpers - typeof";
|
|
313
|
-
|
|
314
|
-
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
|
|
315
|
-
return typeof o;
|
|
316
|
-
} : function (o) {
|
|
317
|
-
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
318
|
-
}, _typeof(o);
|
|
319
|
-
}
|
|
320
331
|
function _unsupportedIterableToArray(r, a) {
|
|
321
332
|
if (r) {
|
|
322
333
|
if ("string" == typeof r) return _arrayLikeToArray(r, a);
|
|
@@ -325,4 +336,4 @@ function _unsupportedIterableToArray(r, a) {
|
|
|
325
336
|
}
|
|
326
337
|
}
|
|
327
338
|
|
|
328
|
-
export { _arrayLikeToArray as arrayLikeToArray, _arrayWithHoles as arrayWithHoles, _arrayWithoutHoles as arrayWithoutHoles, _asyncToGenerator as asyncToGenerator, _classCallCheck as classCallCheck, _createClass as createClass, _createForOfIteratorHelper as createForOfIteratorHelper, _defineProperty as defineProperty, _iterableToArray as iterableToArray, _iterableToArrayLimit as iterableToArrayLimit, _nonIterableRest as nonIterableRest, _nonIterableSpread as nonIterableSpread, _objectSpread2 as objectSpread2, _regenerator as regenerator, _regeneratorDefine as regeneratorDefine, _regeneratorValues as regeneratorValues, _slicedToArray as slicedToArray, _toConsumableArray as toConsumableArray, _toPrimitive as toPrimitive, _toPropertyKey as toPropertyKey,
|
|
339
|
+
export { _arrayLikeToArray as arrayLikeToArray, _arrayWithHoles as arrayWithHoles, _arrayWithoutHoles as arrayWithoutHoles, _asyncToGenerator as asyncToGenerator, _classCallCheck as classCallCheck, _construct as construct, _createClass as createClass, _createForOfIteratorHelper as createForOfIteratorHelper, _defineProperty as defineProperty, _isNativeReflectConstruct as isNativeReflectConstruct, _iterableToArray as iterableToArray, _iterableToArrayLimit as iterableToArrayLimit, _nonIterableRest as nonIterableRest, _nonIterableSpread as nonIterableSpread, _objectSpread2 as objectSpread2, _regenerator as regenerator, _regeneratorDefine as regeneratorDefine, _regeneratorValues as regeneratorValues, _setPrototypeOf as setPrototypeOf, _slicedToArray as slicedToArray, _toConsumableArray as toConsumableArray, _toPrimitive as toPrimitive, _toPropertyKey as toPropertyKey, _unsupportedIterableToArray as unsupportedIterableToArray };
|