@2112-lab/central-plant 0.1.0
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/README.md +0 -0
- package/dist/bundle/index.js +14259 -0
- package/dist/cjs/_virtual/_rollupPluginBabelHelpers.js +353 -0
- package/dist/cjs/node_modules/three/examples/jsm/controls/OrbitControls.js +1292 -0
- package/dist/cjs/node_modules/three/examples/jsm/controls/TransformControls.js +1543 -0
- package/dist/cjs/node_modules/three/examples/jsm/loaders/GLTFLoader.js +4374 -0
- package/dist/cjs/node_modules/three/examples/jsm/loaders/RGBELoader.js +465 -0
- package/dist/cjs/node_modules/three/examples/jsm/utils/BufferGeometryUtils.js +117 -0
- package/dist/cjs/src/ConnectionManager.js +114 -0
- package/dist/cjs/src/Pathfinder.js +88 -0
- package/dist/cjs/src/animationManager.js +121 -0
- package/dist/cjs/src/componentManager.js +151 -0
- package/dist/cjs/src/debugLogger.js +176 -0
- package/dist/cjs/src/disposalManager.js +185 -0
- package/dist/cjs/src/environmentManager.js +1015 -0
- package/dist/cjs/src/hotReloadManager.js +252 -0
- package/dist/cjs/src/index.js +126 -0
- package/dist/cjs/src/keyboardControlsManager.js +206 -0
- package/dist/cjs/src/modelPreloader.js +360 -0
- package/dist/cjs/src/nameUtils.js +106 -0
- package/dist/cjs/src/pathfindingManager.js +321 -0
- package/dist/cjs/src/performanceMonitor.js +718 -0
- package/dist/cjs/src/sceneExportManager.js +292 -0
- package/dist/cjs/src/sceneInitializationManager.js +540 -0
- package/dist/cjs/src/sceneOperationsManager.js +560 -0
- package/dist/cjs/src/textureConfig.js +195 -0
- package/dist/cjs/src/transformControlsManager.js +851 -0
- package/dist/esm/_virtual/_rollupPluginBabelHelpers.js +328 -0
- package/dist/esm/node_modules/three/examples/jsm/controls/OrbitControls.js +1287 -0
- package/dist/esm/node_modules/three/examples/jsm/controls/TransformControls.js +1537 -0
- package/dist/esm/node_modules/three/examples/jsm/loaders/GLTFLoader.js +4370 -0
- package/dist/esm/node_modules/three/examples/jsm/loaders/RGBELoader.js +461 -0
- package/dist/esm/node_modules/three/examples/jsm/utils/BufferGeometryUtils.js +113 -0
- package/dist/esm/src/ConnectionManager.js +110 -0
- package/dist/esm/src/Pathfinder.js +84 -0
- package/dist/esm/src/animationManager.js +112 -0
- package/dist/esm/src/componentManager.js +123 -0
- package/dist/esm/src/debugLogger.js +167 -0
- package/dist/esm/src/disposalManager.js +155 -0
- package/dist/esm/src/environmentManager.js +989 -0
- package/dist/esm/src/hotReloadManager.js +244 -0
- package/dist/esm/src/index.js +117 -0
- package/dist/esm/src/keyboardControlsManager.js +196 -0
- package/dist/esm/src/modelPreloader.js +337 -0
- package/dist/esm/src/nameUtils.js +99 -0
- package/dist/esm/src/pathfindingManager.js +295 -0
- package/dist/esm/src/performanceMonitor.js +712 -0
- package/dist/esm/src/sceneExportManager.js +286 -0
- package/dist/esm/src/sceneInitializationManager.js +513 -0
- package/dist/esm/src/sceneOperationsManager.js +536 -0
- package/dist/esm/src/textureConfig.js +168 -0
- package/dist/esm/src/transformControlsManager.js +827 -0
- package/dist/index.d.ts +259 -0
- package/package.json +53 -0
|
@@ -0,0 +1,560 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var _rollupPluginBabelHelpers = require('../_virtual/_rollupPluginBabelHelpers.js');
|
|
6
|
+
var nameUtils = require('./nameUtils.js');
|
|
7
|
+
|
|
8
|
+
function _interopNamespace(e) {
|
|
9
|
+
if (e && e.__esModule) return e;
|
|
10
|
+
var n = Object.create(null);
|
|
11
|
+
if (e) {
|
|
12
|
+
Object.keys(e).forEach(function (k) {
|
|
13
|
+
if (k !== 'default') {
|
|
14
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
15
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: function () { return e[k]; }
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
n["default"] = e;
|
|
23
|
+
return Object.freeze(n);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* SceneOperationsManager
|
|
28
|
+
* Handles scene loading, clearing, and object management operations
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
var THREE;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Dynamically import ThreeJS when in browser environment
|
|
35
|
+
*/
|
|
36
|
+
function importDependencies() {
|
|
37
|
+
return _importDependencies.apply(this, arguments);
|
|
38
|
+
}
|
|
39
|
+
function _importDependencies() {
|
|
40
|
+
_importDependencies = _rollupPluginBabelHelpers.asyncToGenerator(/*#__PURE__*/_rollupPluginBabelHelpers.regenerator().m(function _callee() {
|
|
41
|
+
var _t;
|
|
42
|
+
return _rollupPluginBabelHelpers.regenerator().w(function (_context) {
|
|
43
|
+
while (1) switch (_context.n) {
|
|
44
|
+
case 0:
|
|
45
|
+
if (!(typeof window !== 'undefined')) {
|
|
46
|
+
_context.n = 4;
|
|
47
|
+
break;
|
|
48
|
+
}
|
|
49
|
+
_context.p = 1;
|
|
50
|
+
_context.n = 2;
|
|
51
|
+
return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('three')); });
|
|
52
|
+
case 2:
|
|
53
|
+
THREE = _context.v;
|
|
54
|
+
_context.n = 4;
|
|
55
|
+
break;
|
|
56
|
+
case 3:
|
|
57
|
+
_context.p = 3;
|
|
58
|
+
_t = _context.v;
|
|
59
|
+
console.error('Failed to load Three.js:', _t);
|
|
60
|
+
throw new Error('SceneOperationsManager: Required dependencies could not be loaded');
|
|
61
|
+
case 4:
|
|
62
|
+
return _context.a(2);
|
|
63
|
+
}
|
|
64
|
+
}, _callee, null, [[1, 3]]);
|
|
65
|
+
}));
|
|
66
|
+
return _importDependencies.apply(this, arguments);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Class for managing scene operations like loading, clearing, and object management
|
|
71
|
+
*/
|
|
72
|
+
var SceneOperationsManager = /*#__PURE__*/function () {
|
|
73
|
+
/**
|
|
74
|
+
* Create a SceneOperationsManager
|
|
75
|
+
* @param {Object} component - The component with scene, camera, renderer, etc.
|
|
76
|
+
*/
|
|
77
|
+
function SceneOperationsManager(component) {
|
|
78
|
+
_rollupPluginBabelHelpers.classCallCheck(this, SceneOperationsManager);
|
|
79
|
+
this.component = component;
|
|
80
|
+
|
|
81
|
+
// Initialize if in browser environment
|
|
82
|
+
if (typeof window !== 'undefined') {
|
|
83
|
+
importDependencies();
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Clear scene objects while preserving base environment
|
|
89
|
+
*/
|
|
90
|
+
return _rollupPluginBabelHelpers.createClass(SceneOperationsManager, [{
|
|
91
|
+
key: "clearSceneObjects",
|
|
92
|
+
value: function clearSceneObjects() {
|
|
93
|
+
var component = this.component;
|
|
94
|
+
console.log('🧹 Starting scene clear operation...');
|
|
95
|
+
|
|
96
|
+
// First, deselect any currently selected object
|
|
97
|
+
this.deselectObject();
|
|
98
|
+
|
|
99
|
+
// Store reference to transform controls to ensure it's not removed
|
|
100
|
+
var transformControlsRef = null;
|
|
101
|
+
if (component.transformManager && component.transformManager.transformControls) {
|
|
102
|
+
// Explicitly disable transform controls before clearing
|
|
103
|
+
console.log('🔧 Disabling transform controls before scene clear');
|
|
104
|
+
component.transformManager.setEnabled(false);
|
|
105
|
+
component.transformManager.transformControls.visible = false;
|
|
106
|
+
transformControlsRef = component.transformManager.transformControls;
|
|
107
|
+
console.log('🔧 Stored reference to existing transform controls');
|
|
108
|
+
}
|
|
109
|
+
var objectsToRemove = [];
|
|
110
|
+
var transformControlsFound = 0;
|
|
111
|
+
var totalChildren = 0;
|
|
112
|
+
component.scene.traverse(function (child) {
|
|
113
|
+
var _child$userData, _child$userData2, _child$userData3, _child$userData4, _child$geometry;
|
|
114
|
+
totalChildren++;
|
|
115
|
+
|
|
116
|
+
// Check for transform controls using multiple detection methods
|
|
117
|
+
var isTransformControl = child === transformControlsRef || ((_child$userData = child.userData) === null || _child$userData === void 0 ? void 0 : _child$userData.isTransformControls) || child.isTransformControls || child.type && child.type.includes('TransformControls');
|
|
118
|
+
if (isTransformControl) {
|
|
119
|
+
transformControlsFound++;
|
|
120
|
+
console.log('🔧 Found transform controls, preserving:', child.uuid);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// Remove imported scene objects but preserve base ground, walls, lights, and transform controls
|
|
124
|
+
if (child !== component.scene && !((_child$userData2 = child.userData) !== null && _child$userData2 !== void 0 && _child$userData2.isBrickWall) && !((_child$userData3 = child.userData) !== null && _child$userData3 !== void 0 && _child$userData3.isBaseGround) && !((_child$userData4 = child.userData) !== null && _child$userData4 !== void 0 && _child$userData4.isBaseGrid) && !isTransformControl && !child.isLight && ((_child$geometry = child.geometry) === null || _child$geometry === void 0 ? void 0 : _child$geometry.type) !== 'PlaneGeometry') {
|
|
125
|
+
objectsToRemove.push(child);
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
console.log("\uD83D\uDCCA Scene analysis: ".concat(totalChildren, " total children, ").concat(transformControlsFound, " transform controls found, ").concat(objectsToRemove.length, " objects to remove"));
|
|
129
|
+
objectsToRemove.forEach(function (obj) {
|
|
130
|
+
component.scene.remove(obj);
|
|
131
|
+
|
|
132
|
+
// Dispose of geometry and materials to prevent memory leaks
|
|
133
|
+
if (obj.geometry) obj.geometry.dispose();
|
|
134
|
+
if (obj.material) {
|
|
135
|
+
if (Array.isArray(obj.material)) {
|
|
136
|
+
obj.material.forEach(function (mat) {
|
|
137
|
+
return mat.dispose();
|
|
138
|
+
});
|
|
139
|
+
} else {
|
|
140
|
+
obj.material.dispose();
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
// Clear any references to removed objects
|
|
146
|
+
component.selectedObjectForTransform = null;
|
|
147
|
+
if (component.transformHistory) {
|
|
148
|
+
component.transformHistory = [];
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// Make sure transform controls exist after clearing
|
|
152
|
+
if (!component.transformManager || !component.transformManager.transformControls) {
|
|
153
|
+
console.log('🔧 Transform controls missing after scene clear, reinitializing...');
|
|
154
|
+
if (typeof component.initTransformControls === 'function') {
|
|
155
|
+
component.initTransformControls();
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// Ensure transform controls are still properly attached after scene operations
|
|
160
|
+
this.ensureTransformControlsAttached(false);
|
|
161
|
+
console.log('✅ Scene clear operation completed');
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Ensure transform controls remain properly attached after scene operations
|
|
166
|
+
* @param {boolean} attachToSelected - Whether to attach to selected object
|
|
167
|
+
*/
|
|
168
|
+
}, {
|
|
169
|
+
key: "ensureTransformControlsAttached",
|
|
170
|
+
value: function ensureTransformControlsAttached() {
|
|
171
|
+
var attachToSelected = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
172
|
+
var component = this.component;
|
|
173
|
+
if (component.transformManager) {
|
|
174
|
+
// Re-enable transform controls after scene operations
|
|
175
|
+
component.transformManager.setEnabled(true);
|
|
176
|
+
|
|
177
|
+
// Reattach to selected object if one exists and flag is true
|
|
178
|
+
if (attachToSelected && component.selectedObjectForTransform) {
|
|
179
|
+
component.transformManager.selectObject(component.selectedObjectForTransform);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Deselect any selected object
|
|
186
|
+
*/
|
|
187
|
+
}, {
|
|
188
|
+
key: "deselectObject",
|
|
189
|
+
value: function deselectObject() {
|
|
190
|
+
var component = this.component;
|
|
191
|
+
if (component.transformManager && component.selectedObjectForTransform) {
|
|
192
|
+
component.transformManager.deselectObject();
|
|
193
|
+
component.selectedObjectForTransform = null;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Load scene data from JSON
|
|
199
|
+
* @param {Object|string} sceneData - Scene data object or JSON string
|
|
200
|
+
*/
|
|
201
|
+
}, {
|
|
202
|
+
key: "loadSceneData",
|
|
203
|
+
value: function loadSceneData(sceneData) {
|
|
204
|
+
var component = this.component;
|
|
205
|
+
console.log('📥 Starting scene load operation...');
|
|
206
|
+
|
|
207
|
+
// Parse JSON if string provided
|
|
208
|
+
var parsedData = sceneData;
|
|
209
|
+
if (typeof sceneData === 'string') {
|
|
210
|
+
try {
|
|
211
|
+
parsedData = JSON.parse(sceneData);
|
|
212
|
+
} catch (e) {
|
|
213
|
+
console.error('❌ Failed to parse scene data:', e);
|
|
214
|
+
return false;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
// Validate scene data format
|
|
219
|
+
if (!parsedData || !parsedData.scene || !parsedData.scene.object) {
|
|
220
|
+
console.error('❌ Invalid scene data format');
|
|
221
|
+
return false;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// Store reference to scene data
|
|
225
|
+
component.currentSceneData = parsedData;
|
|
226
|
+
|
|
227
|
+
// Clear existing scene objects
|
|
228
|
+
this.clearSceneObjects();
|
|
229
|
+
|
|
230
|
+
// Load scene objects
|
|
231
|
+
this._loadSceneObjects(parsedData.scene.object);
|
|
232
|
+
|
|
233
|
+
// Load connections if applicable
|
|
234
|
+
if (parsedData.connections && Array.isArray(parsedData.connections)) {
|
|
235
|
+
this._loadConnections(parsedData.connections);
|
|
236
|
+
}
|
|
237
|
+
console.log('✅ Scene load completed');
|
|
238
|
+
return true;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Load scene objects from parsed scene data
|
|
243
|
+
* @param {Object} sceneObject - The root scene object from parsed data
|
|
244
|
+
* @private
|
|
245
|
+
*/
|
|
246
|
+
}, {
|
|
247
|
+
key: "_loadSceneObjects",
|
|
248
|
+
value: function _loadSceneObjects(sceneObject) {
|
|
249
|
+
var _this = this;
|
|
250
|
+
var component = this.component;
|
|
251
|
+
|
|
252
|
+
// Recursively process all object children
|
|
253
|
+
if (sceneObject.children && Array.isArray(sceneObject.children)) {
|
|
254
|
+
sceneObject.children.forEach(function (childData) {
|
|
255
|
+
var childObject = _this._createObjectFromData(childData);
|
|
256
|
+
if (childObject) {
|
|
257
|
+
component.scene.add(childObject);
|
|
258
|
+
}
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* Create a Three.js object from object data
|
|
265
|
+
* @param {Object} objectData - The object data from parsed scene
|
|
266
|
+
* @returns {THREE.Object3D} The created object or null if invalid
|
|
267
|
+
* @private
|
|
268
|
+
*/
|
|
269
|
+
}, {
|
|
270
|
+
key: "_createObjectFromData",
|
|
271
|
+
value: function _createObjectFromData(objectData) {
|
|
272
|
+
var _this2 = this;
|
|
273
|
+
// Ensure THREE is loaded
|
|
274
|
+
if (!THREE) {
|
|
275
|
+
console.warn('⚠️ THREE.js not loaded, cannot create objects');
|
|
276
|
+
return null;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
// Create base object
|
|
280
|
+
var object = new THREE.Object3D();
|
|
281
|
+
|
|
282
|
+
// Set UUID (use hardcoded UUID if possible)
|
|
283
|
+
if (objectData.uuid) {
|
|
284
|
+
object.uuid = objectData.uuid;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
// Set name
|
|
288
|
+
object.name = objectData.name || 'Unnamed';
|
|
289
|
+
|
|
290
|
+
// Set position
|
|
291
|
+
if (objectData.position) {
|
|
292
|
+
object.position.set(objectData.position.x || 0, objectData.position.y || 0, objectData.position.z || 0);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
// Set rotation (convert from degrees to radians)
|
|
296
|
+
if (objectData.rotation) {
|
|
297
|
+
object.rotation.set((objectData.rotation.x || 0) * (Math.PI / 180), (objectData.rotation.y || 0) * (Math.PI / 180), (objectData.rotation.z || 0) * (Math.PI / 180));
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
// Set scale
|
|
301
|
+
if (objectData.scale) {
|
|
302
|
+
object.scale.set(objectData.scale.x || 1, objectData.scale.y || 1, objectData.scale.z || 1);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
// Set userData
|
|
306
|
+
if (objectData.userData) {
|
|
307
|
+
object.userData = _rollupPluginBabelHelpers.objectSpread2({}, objectData.userData);
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
// Special handling for different object types
|
|
311
|
+
this._setupObjectByType(object, objectData);
|
|
312
|
+
|
|
313
|
+
// Process children recursively
|
|
314
|
+
if (objectData.children && Array.isArray(objectData.children)) {
|
|
315
|
+
objectData.children.forEach(function (childData) {
|
|
316
|
+
var childObject = _this2._createObjectFromData(childData);
|
|
317
|
+
if (childObject) {
|
|
318
|
+
object.add(childObject);
|
|
319
|
+
}
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
return object;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* Set up object properties based on type
|
|
327
|
+
* @param {THREE.Object3D} object - The object to set up
|
|
328
|
+
* @param {Object} objectData - The object data
|
|
329
|
+
* @private
|
|
330
|
+
*/
|
|
331
|
+
}, {
|
|
332
|
+
key: "_setupObjectByType",
|
|
333
|
+
value: function _setupObjectByType(object, objectData) {
|
|
334
|
+
var _objectData$userData, _objectData$userData2;
|
|
335
|
+
// Handle library component objects
|
|
336
|
+
if ((_objectData$userData = objectData.userData) !== null && _objectData$userData !== void 0 && _objectData$userData.componentType && (_objectData$userData2 = objectData.userData) !== null && _objectData$userData2 !== void 0 && _objectData$userData2.libraryId) {
|
|
337
|
+
// If model preloader is available, attempt to load model
|
|
338
|
+
if (this.component.modelPreloader) {
|
|
339
|
+
this.component.modelPreloader.loadComponentById(objectData.userData.libraryId, function (model) {
|
|
340
|
+
if (model) {
|
|
341
|
+
// Copy model but preserve our object's transform and userData
|
|
342
|
+
var position = object.position.clone();
|
|
343
|
+
var rotation = object.rotation.clone();
|
|
344
|
+
var scale = object.scale.clone();
|
|
345
|
+
var userData = _rollupPluginBabelHelpers.objectSpread2({}, object.userData);
|
|
346
|
+
|
|
347
|
+
// Copy model properties to our object
|
|
348
|
+
object.copy(model);
|
|
349
|
+
|
|
350
|
+
// Restore transform and userData
|
|
351
|
+
object.position.copy(position);
|
|
352
|
+
object.rotation.copy(rotation);
|
|
353
|
+
object.scale.copy(scale);
|
|
354
|
+
object.userData = userData;
|
|
355
|
+
console.log("\u2705 Loaded model for ".concat(objectData.name, " (").concat(objectData.userData.libraryId, ")"));
|
|
356
|
+
}
|
|
357
|
+
});
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
// Handle primitive geometry
|
|
362
|
+
if (objectData.geometry) {
|
|
363
|
+
var geometry;
|
|
364
|
+
|
|
365
|
+
// Create appropriate geometry based on type hint
|
|
366
|
+
if (objectData.geometry === 'CONNECTOR-GEO') {
|
|
367
|
+
geometry = new THREE.SphereGeometry(0.5, 16, 16);
|
|
368
|
+
} else if (objectData.geometry === 'GATEWAY-GEO') {
|
|
369
|
+
geometry = new THREE.CylinderGeometry(0.5, 0.5, 1, 16);
|
|
370
|
+
} else {
|
|
371
|
+
// Default to box geometry for other types
|
|
372
|
+
geometry = new THREE.BoxGeometry(1, 1, 1);
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
// Create mesh with geometry and basic material
|
|
376
|
+
var material = new THREE.MeshStandardMaterial({
|
|
377
|
+
color: 0x999999,
|
|
378
|
+
transparent: true,
|
|
379
|
+
opacity: 0.7
|
|
380
|
+
});
|
|
381
|
+
var mesh = new THREE.Mesh(geometry, material);
|
|
382
|
+
|
|
383
|
+
// Copy transform from parent
|
|
384
|
+
mesh.position.copy(object.position);
|
|
385
|
+
mesh.rotation.copy(object.rotation);
|
|
386
|
+
mesh.scale.copy(object.scale);
|
|
387
|
+
|
|
388
|
+
// Reset parent transform since the mesh now has it
|
|
389
|
+
object.position.set(0, 0, 0);
|
|
390
|
+
object.rotation.set(0, 0, 0);
|
|
391
|
+
object.scale.set(1, 1, 1);
|
|
392
|
+
|
|
393
|
+
// Add mesh as child of parent
|
|
394
|
+
object.add(mesh);
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
/**
|
|
399
|
+
* Load connections from scene data
|
|
400
|
+
* @param {Array} connections - Array of connection objects
|
|
401
|
+
* @private
|
|
402
|
+
*/
|
|
403
|
+
}, {
|
|
404
|
+
key: "_loadConnections",
|
|
405
|
+
value: function _loadConnections(connections) {
|
|
406
|
+
var component = this.component;
|
|
407
|
+
if (!component.pathfindingManager) {
|
|
408
|
+
console.warn('⚠️ Cannot load connections: pathfindingManager not available');
|
|
409
|
+
return;
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
// Clear existing connections
|
|
413
|
+
if (component.pathfindingManager.clearAllPaths) {
|
|
414
|
+
component.pathfindingManager.clearAllPaths();
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
// Process each connection
|
|
418
|
+
connections.forEach(function (connection) {
|
|
419
|
+
if (!connection.source || !connection.target) {
|
|
420
|
+
return;
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
// Find source and target objects
|
|
424
|
+
var sourceObj = nameUtils.findObjectByHardcodedUuid(component.scene, connection.source);
|
|
425
|
+
var targetObj = nameUtils.findObjectByHardcodedUuid(component.scene, connection.target);
|
|
426
|
+
if (sourceObj && targetObj) {
|
|
427
|
+
// Create connection if objects found
|
|
428
|
+
component.pathfindingManager.createConnection(sourceObj, targetObj, connection.type || 'default');
|
|
429
|
+
} else {
|
|
430
|
+
console.warn("\u26A0\uFE0F Could not create connection: objects not found (".concat(connection.source, " -> ").concat(connection.target, ")"));
|
|
431
|
+
}
|
|
432
|
+
});
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
/**
|
|
436
|
+
* Find object in scene by name
|
|
437
|
+
* @param {string} name - The name to search for
|
|
438
|
+
* @returns {THREE.Object3D|null} The found object or null
|
|
439
|
+
*/
|
|
440
|
+
}, {
|
|
441
|
+
key: "findObjectByName",
|
|
442
|
+
value: function findObjectByName(name) {
|
|
443
|
+
if (!name || !this.component.scene) {
|
|
444
|
+
return null;
|
|
445
|
+
}
|
|
446
|
+
var foundObject = null;
|
|
447
|
+
this.component.scene.traverse(function (child) {
|
|
448
|
+
if (child.name === name) {
|
|
449
|
+
foundObject = child;
|
|
450
|
+
}
|
|
451
|
+
});
|
|
452
|
+
return foundObject;
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
/**
|
|
456
|
+
* Find object in scene by UUID
|
|
457
|
+
* @param {string} uuid - The UUID to search for
|
|
458
|
+
* @returns {THREE.Object3D|null} The found object or null
|
|
459
|
+
*/
|
|
460
|
+
}, {
|
|
461
|
+
key: "findObjectByUuid",
|
|
462
|
+
value: function findObjectByUuid(uuid) {
|
|
463
|
+
if (!uuid || !this.component.scene) {
|
|
464
|
+
return null;
|
|
465
|
+
}
|
|
466
|
+
var foundObject = null;
|
|
467
|
+
this.component.scene.traverse(function (child) {
|
|
468
|
+
if (child.uuid === uuid) {
|
|
469
|
+
foundObject = child;
|
|
470
|
+
}
|
|
471
|
+
});
|
|
472
|
+
return foundObject;
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
/**
|
|
476
|
+
* Remove an object from the scene
|
|
477
|
+
* @param {THREE.Object3D} object - The object to remove
|
|
478
|
+
*/
|
|
479
|
+
}, {
|
|
480
|
+
key: "removeObject",
|
|
481
|
+
value: function removeObject(object) {
|
|
482
|
+
if (!object || !this.component.scene) {
|
|
483
|
+
return false;
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
// Deselect if this is the selected object
|
|
487
|
+
if (this.component.selectedObjectForTransform === object) {
|
|
488
|
+
this.deselectObject();
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
// Remove from scene
|
|
492
|
+
this.component.scene.remove(object);
|
|
493
|
+
|
|
494
|
+
// Dispose resources
|
|
495
|
+
if (object.geometry) object.geometry.dispose();
|
|
496
|
+
if (object.material) {
|
|
497
|
+
if (Array.isArray(object.material)) {
|
|
498
|
+
object.material.forEach(function (mat) {
|
|
499
|
+
return mat.dispose();
|
|
500
|
+
});
|
|
501
|
+
} else {
|
|
502
|
+
object.material.dispose();
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
return true;
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
/**
|
|
509
|
+
* Duplicate an object in the scene
|
|
510
|
+
* @param {THREE.Object3D} sourceObject - The object to duplicate
|
|
511
|
+
* @param {Object} [options] - Options for duplication
|
|
512
|
+
* @param {THREE.Vector3} [options.positionOffset] - Position offset for the duplicate
|
|
513
|
+
* @returns {THREE.Object3D|null} The duplicated object or null if failed
|
|
514
|
+
*/
|
|
515
|
+
}, {
|
|
516
|
+
key: "duplicateObject",
|
|
517
|
+
value: function duplicateObject(sourceObject) {
|
|
518
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
519
|
+
if (!sourceObject || !this.component.scene) {
|
|
520
|
+
return null;
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
// Create clone of source object
|
|
524
|
+
var clonedObject = sourceObject.clone();
|
|
525
|
+
|
|
526
|
+
// Generate new UUID to ensure uniqueness
|
|
527
|
+
clonedObject.uuid = THREE.MathUtils.generateUUID();
|
|
528
|
+
|
|
529
|
+
// Update name to indicate it's a copy
|
|
530
|
+
if (!clonedObject.name.includes('_copy')) {
|
|
531
|
+
clonedObject.name = "".concat(clonedObject.name, "_copy");
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
// Apply position offset if specified
|
|
535
|
+
if (options.positionOffset) {
|
|
536
|
+
clonedObject.position.add(options.positionOffset);
|
|
537
|
+
} else {
|
|
538
|
+
// Default offset if none provided
|
|
539
|
+
clonedObject.position.x += 2;
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
// Add to scene
|
|
543
|
+
this.component.scene.add(clonedObject);
|
|
544
|
+
return clonedObject;
|
|
545
|
+
}
|
|
546
|
+
}]);
|
|
547
|
+
}();
|
|
548
|
+
|
|
549
|
+
/**
|
|
550
|
+
* Factory function to get SceneOperationsManager instance
|
|
551
|
+
* @param {CentralPlantComponent} component - The component instance
|
|
552
|
+
* @returns {SceneOperationsManager} SceneOperationsManager instance
|
|
553
|
+
*/
|
|
554
|
+
function getSceneOperationsManager(component) {
|
|
555
|
+
return new SceneOperationsManager(component);
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
exports.SceneOperationsManager = SceneOperationsManager;
|
|
559
|
+
exports["default"] = SceneOperationsManager;
|
|
560
|
+
exports.getSceneOperationsManager = getSceneOperationsManager;
|