@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,337 @@
|
|
|
1
|
+
import { createClass as _createClass, classCallCheck as _classCallCheck, asyncToGenerator as _asyncToGenerator, regenerator as _regenerator, regeneratorValues as _regeneratorValues, createForOfIteratorHelper as _createForOfIteratorHelper } from '../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
|
+
import 'three';
|
|
3
|
+
|
|
4
|
+
var ModelPreloader = /*#__PURE__*/function () {
|
|
5
|
+
function ModelPreloader() {
|
|
6
|
+
_classCallCheck(this, ModelPreloader);
|
|
7
|
+
this.modelCache = new Map(); // Cache for loaded GLB models
|
|
8
|
+
this.loadingPromises = new Map(); // Track ongoing loads to prevent duplicates
|
|
9
|
+
this.isPreloading = false;
|
|
10
|
+
this.preloadingPromise = null;
|
|
11
|
+
this.componentDictionary = null;
|
|
12
|
+
|
|
13
|
+
// Load GLTFLoader dynamically if available
|
|
14
|
+
this.gltfLoader = null;
|
|
15
|
+
this.initLoader();
|
|
16
|
+
}
|
|
17
|
+
return _createClass(ModelPreloader, [{
|
|
18
|
+
key: "initLoader",
|
|
19
|
+
value: function () {
|
|
20
|
+
var _initLoader = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
|
|
21
|
+
var GLTFLoaderModule, _t;
|
|
22
|
+
return _regenerator().w(function (_context) {
|
|
23
|
+
while (1) switch (_context.n) {
|
|
24
|
+
case 0:
|
|
25
|
+
_context.p = 0;
|
|
26
|
+
if (!(typeof window !== 'undefined')) {
|
|
27
|
+
_context.n = 3;
|
|
28
|
+
break;
|
|
29
|
+
}
|
|
30
|
+
_context.n = 1;
|
|
31
|
+
return import('three');
|
|
32
|
+
case 1:
|
|
33
|
+
_context.v;
|
|
34
|
+
_context.n = 2;
|
|
35
|
+
return import('../node_modules/three/examples/jsm/loaders/GLTFLoader.js');
|
|
36
|
+
case 2:
|
|
37
|
+
GLTFLoaderModule = _context.v;
|
|
38
|
+
this.gltfLoader = new GLTFLoaderModule.GLTFLoader();
|
|
39
|
+
case 3:
|
|
40
|
+
_context.n = 5;
|
|
41
|
+
break;
|
|
42
|
+
case 4:
|
|
43
|
+
_context.p = 4;
|
|
44
|
+
_t = _context.v;
|
|
45
|
+
console.warn('Failed to initialize GLTFLoader:', _t);
|
|
46
|
+
case 5:
|
|
47
|
+
return _context.a(2);
|
|
48
|
+
}
|
|
49
|
+
}, _callee, this, [[0, 4]]);
|
|
50
|
+
}));
|
|
51
|
+
function initLoader() {
|
|
52
|
+
return _initLoader.apply(this, arguments);
|
|
53
|
+
}
|
|
54
|
+
return initLoader;
|
|
55
|
+
}()
|
|
56
|
+
/**
|
|
57
|
+
* Preload all models from the component dictionary
|
|
58
|
+
* @param {Object} componentDictionary - The component dictionary object
|
|
59
|
+
* @returns {Promise} Promise that resolves when all models are loaded
|
|
60
|
+
*/
|
|
61
|
+
}, {
|
|
62
|
+
key: "preloadAllModels",
|
|
63
|
+
value: (function () {
|
|
64
|
+
var _preloadAllModels = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(componentDictionary) {
|
|
65
|
+
var _this = this;
|
|
66
|
+
return _regenerator().w(function (_context4) {
|
|
67
|
+
while (1) switch (_context4.n) {
|
|
68
|
+
case 0:
|
|
69
|
+
if (!this.isPreloading) {
|
|
70
|
+
_context4.n = 1;
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
console.log('⏳ Preloading already in progress, returning existing promise');
|
|
74
|
+
return _context4.a(2, this.preloadingPromise);
|
|
75
|
+
case 1:
|
|
76
|
+
if (componentDictionary) {
|
|
77
|
+
_context4.n = 2;
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
80
|
+
throw new Error('Component dictionary is required to preload models');
|
|
81
|
+
case 2:
|
|
82
|
+
this.isPreloading = true;
|
|
83
|
+
this.componentDictionary = componentDictionary;
|
|
84
|
+
|
|
85
|
+
// Create a promise to track overall preloading
|
|
86
|
+
this.preloadingPromise = new Promise(/*#__PURE__*/function () {
|
|
87
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(resolve) {
|
|
88
|
+
var results, modelKeysSet, loadPromises, _iterator, _step, _loop, _t2, _t3;
|
|
89
|
+
return _regenerator().w(function (_context3) {
|
|
90
|
+
while (1) switch (_context3.n) {
|
|
91
|
+
case 0:
|
|
92
|
+
_context3.p = 0;
|
|
93
|
+
console.log("\uD83D\uDE80 Starting preload of models from dictionary with ".concat(Object.keys(componentDictionary).length, " components"));
|
|
94
|
+
results = {
|
|
95
|
+
total: 0,
|
|
96
|
+
success: 0,
|
|
97
|
+
failed: 0,
|
|
98
|
+
skipped: 0,
|
|
99
|
+
modelKeys: []
|
|
100
|
+
}; // Extract all unique model keys from the dictionary
|
|
101
|
+
modelKeysSet = new Set();
|
|
102
|
+
Object.values(componentDictionary).forEach(function (component) {
|
|
103
|
+
if (component.modelKey) {
|
|
104
|
+
modelKeysSet.add(component.modelKey);
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
results.total = modelKeysSet.size;
|
|
108
|
+
results.modelKeys = Array.from(modelKeysSet);
|
|
109
|
+
|
|
110
|
+
// Load basic models first
|
|
111
|
+
console.log("\uD83D\uDCE6 Found ".concat(results.total, " unique model keys to preload"));
|
|
112
|
+
|
|
113
|
+
// Return early if no models to load
|
|
114
|
+
if (!(results.total === 0)) {
|
|
115
|
+
_context3.n = 1;
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
118
|
+
_this.isPreloading = false;
|
|
119
|
+
resolve(results);
|
|
120
|
+
return _context3.a(2);
|
|
121
|
+
case 1:
|
|
122
|
+
// Process each model key
|
|
123
|
+
loadPromises = [];
|
|
124
|
+
_iterator = _createForOfIteratorHelper(results.modelKeys);
|
|
125
|
+
_context3.p = 2;
|
|
126
|
+
_loop = /*#__PURE__*/_regenerator().m(function _loop() {
|
|
127
|
+
var modelKey, modelUrl;
|
|
128
|
+
return _regenerator().w(function (_context2) {
|
|
129
|
+
while (1) switch (_context2.n) {
|
|
130
|
+
case 0:
|
|
131
|
+
modelKey = _step.value;
|
|
132
|
+
modelUrl = _this.getModelUrlFromKey(modelKey);
|
|
133
|
+
if (modelUrl) {
|
|
134
|
+
loadPromises.push(_this.preloadModel(modelKey, modelUrl).then(function () {
|
|
135
|
+
results.success++;
|
|
136
|
+
}).catch(function (error) {
|
|
137
|
+
console.error("\u274C Failed to preload model ".concat(modelKey, ":"), error);
|
|
138
|
+
results.failed++;
|
|
139
|
+
}));
|
|
140
|
+
} else {
|
|
141
|
+
console.warn("\u26A0\uFE0F No URL found for model key: ".concat(modelKey));
|
|
142
|
+
results.skipped++;
|
|
143
|
+
}
|
|
144
|
+
case 1:
|
|
145
|
+
return _context2.a(2);
|
|
146
|
+
}
|
|
147
|
+
}, _loop);
|
|
148
|
+
});
|
|
149
|
+
_iterator.s();
|
|
150
|
+
case 3:
|
|
151
|
+
if ((_step = _iterator.n()).done) {
|
|
152
|
+
_context3.n = 5;
|
|
153
|
+
break;
|
|
154
|
+
}
|
|
155
|
+
return _context3.d(_regeneratorValues(_loop()), 4);
|
|
156
|
+
case 4:
|
|
157
|
+
_context3.n = 3;
|
|
158
|
+
break;
|
|
159
|
+
case 5:
|
|
160
|
+
_context3.n = 7;
|
|
161
|
+
break;
|
|
162
|
+
case 6:
|
|
163
|
+
_context3.p = 6;
|
|
164
|
+
_t2 = _context3.v;
|
|
165
|
+
_iterator.e(_t2);
|
|
166
|
+
case 7:
|
|
167
|
+
_context3.p = 7;
|
|
168
|
+
_iterator.f();
|
|
169
|
+
return _context3.f(7);
|
|
170
|
+
case 8:
|
|
171
|
+
_context3.n = 9;
|
|
172
|
+
return Promise.allSettled(loadPromises);
|
|
173
|
+
case 9:
|
|
174
|
+
console.log('✅ Model preloading completed with results:', results);
|
|
175
|
+
_this.isPreloading = false;
|
|
176
|
+
resolve(results);
|
|
177
|
+
_context3.n = 11;
|
|
178
|
+
break;
|
|
179
|
+
case 10:
|
|
180
|
+
_context3.p = 10;
|
|
181
|
+
_t3 = _context3.v;
|
|
182
|
+
console.error('❌ Error during model preloading:', _t3);
|
|
183
|
+
_this.isPreloading = false;
|
|
184
|
+
resolve({
|
|
185
|
+
total: 0,
|
|
186
|
+
success: 0,
|
|
187
|
+
failed: 1,
|
|
188
|
+
skipped: 0,
|
|
189
|
+
error: _t3.message
|
|
190
|
+
});
|
|
191
|
+
case 11:
|
|
192
|
+
return _context3.a(2);
|
|
193
|
+
}
|
|
194
|
+
}, _callee2, null, [[2, 6, 7, 8], [0, 10]]);
|
|
195
|
+
}));
|
|
196
|
+
return function (_x2) {
|
|
197
|
+
return _ref.apply(this, arguments);
|
|
198
|
+
};
|
|
199
|
+
}());
|
|
200
|
+
return _context4.a(2, this.preloadingPromise);
|
|
201
|
+
}
|
|
202
|
+
}, _callee3, this);
|
|
203
|
+
}));
|
|
204
|
+
function preloadAllModels(_x) {
|
|
205
|
+
return _preloadAllModels.apply(this, arguments);
|
|
206
|
+
}
|
|
207
|
+
return preloadAllModels;
|
|
208
|
+
}()
|
|
209
|
+
/**
|
|
210
|
+
* Convert a model key to a URL
|
|
211
|
+
* @param {string} modelKey - The model key from the dictionary
|
|
212
|
+
* @returns {string} The URL for the model
|
|
213
|
+
*/
|
|
214
|
+
)
|
|
215
|
+
}, {
|
|
216
|
+
key: "getModelUrlFromKey",
|
|
217
|
+
value: function getModelUrlFromKey(modelKey) {
|
|
218
|
+
// The modelKey already includes the .glb extension from the component dictionary
|
|
219
|
+
return modelKey;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Preload a specific model
|
|
224
|
+
* @param {string} modelKey - The model key
|
|
225
|
+
* @param {string} modelUrl - The URL to the model
|
|
226
|
+
* @returns {Promise} Promise that resolves with the loaded model
|
|
227
|
+
*/
|
|
228
|
+
}, {
|
|
229
|
+
key: "preloadModel",
|
|
230
|
+
value: (function () {
|
|
231
|
+
var _preloadModel = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(modelKey, modelUrl) {
|
|
232
|
+
var _this2 = this;
|
|
233
|
+
var loadPromise;
|
|
234
|
+
return _regenerator().w(function (_context5) {
|
|
235
|
+
while (1) switch (_context5.n) {
|
|
236
|
+
case 0:
|
|
237
|
+
if (this.gltfLoader) {
|
|
238
|
+
_context5.n = 2;
|
|
239
|
+
break;
|
|
240
|
+
}
|
|
241
|
+
_context5.n = 1;
|
|
242
|
+
return this.initLoader();
|
|
243
|
+
case 1:
|
|
244
|
+
if (this.gltfLoader) {
|
|
245
|
+
_context5.n = 2;
|
|
246
|
+
break;
|
|
247
|
+
}
|
|
248
|
+
throw new Error('GLTFLoader is not available');
|
|
249
|
+
case 2:
|
|
250
|
+
if (!this.modelCache.has(modelKey)) {
|
|
251
|
+
_context5.n = 3;
|
|
252
|
+
break;
|
|
253
|
+
}
|
|
254
|
+
return _context5.a(2, this.modelCache.get(modelKey));
|
|
255
|
+
case 3:
|
|
256
|
+
if (!this.loadingPromises.has(modelKey)) {
|
|
257
|
+
_context5.n = 4;
|
|
258
|
+
break;
|
|
259
|
+
}
|
|
260
|
+
return _context5.a(2, this.loadingPromises.get(modelKey));
|
|
261
|
+
case 4:
|
|
262
|
+
// Start loading the model
|
|
263
|
+
loadPromise = new Promise(function (resolve, reject) {
|
|
264
|
+
_this2.gltfLoader.load(modelUrl, function (gltf) {
|
|
265
|
+
console.log("\u2705 Successfully loaded model: ".concat(modelKey, " from ").concat(modelUrl));
|
|
266
|
+
_this2.modelCache.set(modelKey, gltf);
|
|
267
|
+
_this2.loadingPromises.delete(modelKey);
|
|
268
|
+
resolve(gltf);
|
|
269
|
+
}, function (progress) {
|
|
270
|
+
// Optional progress callback
|
|
271
|
+
if (progress.lengthComputable) {
|
|
272
|
+
progress.loaded / progress.total * 100;
|
|
273
|
+
// console.log(`📥 Loading ${modelKey}: ${percentComplete.toFixed(1)}%`);
|
|
274
|
+
}
|
|
275
|
+
}, function (error) {
|
|
276
|
+
console.error("\u274C Failed to load model ".concat(modelKey, " from ").concat(modelUrl, ":"), error);
|
|
277
|
+
|
|
278
|
+
// Add more detailed error information
|
|
279
|
+
if (error.message && error.message.includes('404')) {
|
|
280
|
+
console.error(" File not found. Check if the model exists at: ".concat(modelUrl));
|
|
281
|
+
} else if (error.message && error.message.includes('JSON')) {
|
|
282
|
+
console.error(" Invalid GLB file format. The file may be corrupted or is not a valid GLB/GLTF file.");
|
|
283
|
+
}
|
|
284
|
+
_this2.loadingPromises.delete(modelKey);
|
|
285
|
+
reject(error);
|
|
286
|
+
});
|
|
287
|
+
}); // Store the loading promise
|
|
288
|
+
this.loadingPromises.set(modelKey, loadPromise);
|
|
289
|
+
return _context5.a(2, loadPromise);
|
|
290
|
+
}
|
|
291
|
+
}, _callee4, this);
|
|
292
|
+
}));
|
|
293
|
+
function preloadModel(_x3, _x4) {
|
|
294
|
+
return _preloadModel.apply(this, arguments);
|
|
295
|
+
}
|
|
296
|
+
return preloadModel;
|
|
297
|
+
}()
|
|
298
|
+
/**
|
|
299
|
+
* Get a model from the cache
|
|
300
|
+
* @param {string} modelKey - The model key
|
|
301
|
+
* @returns {Object|null} The loaded model or null if not found
|
|
302
|
+
*/
|
|
303
|
+
)
|
|
304
|
+
}, {
|
|
305
|
+
key: "getModel",
|
|
306
|
+
value: function getModel(modelKey) {
|
|
307
|
+
return this.modelCache.get(modelKey) || null;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* Clear the model cache
|
|
312
|
+
*/
|
|
313
|
+
}, {
|
|
314
|
+
key: "clearCache",
|
|
315
|
+
value: function clearCache() {
|
|
316
|
+
this.modelCache.clear();
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* Get statistics about the model cache
|
|
321
|
+
* @returns {Object} Cache statistics
|
|
322
|
+
*/
|
|
323
|
+
}, {
|
|
324
|
+
key: "getCacheStats",
|
|
325
|
+
value: function getCacheStats() {
|
|
326
|
+
return {
|
|
327
|
+
cacheSize: this.modelCache.size,
|
|
328
|
+
cachedModels: Array.from(this.modelCache.keys()),
|
|
329
|
+
loading: Array.from(this.loadingPromises.keys()),
|
|
330
|
+
isPreloading: this.isPreloading
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
}]);
|
|
334
|
+
}(); // Create singleton instance
|
|
335
|
+
var modelPreloader = new ModelPreloader();
|
|
336
|
+
|
|
337
|
+
export { ModelPreloader, modelPreloader as default };
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Name Utilities
|
|
3
|
+
* Common helper functions for name and UUID generation
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Generate UUID from name using consistent transformation rules
|
|
8
|
+
* @param {string} name - The name to convert to UUID
|
|
9
|
+
* @returns {string} The generated UUID
|
|
10
|
+
*/
|
|
11
|
+
function generateUuidFromName(name) {
|
|
12
|
+
if (!name) return null;
|
|
13
|
+
|
|
14
|
+
// Convert name to uppercase and replace spaces with hyphens
|
|
15
|
+
var uuid = name.toUpperCase().replace(/\s+COMPONENT$/i, '') // Remove "Component" suffix
|
|
16
|
+
.replace(/\s+/g, '-') // Replace spaces with hyphens
|
|
17
|
+
.replace(/[^A-Z0-9\-]/g, ''); // Remove special characters except hyphens
|
|
18
|
+
|
|
19
|
+
// Clean up any duplicate "COMPONENT" text that might have been left behind
|
|
20
|
+
uuid = uuid.replace(/-COMPONENT$/, '');
|
|
21
|
+
return uuid;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Check if two names would generate the same UUID
|
|
26
|
+
* @param {string} name1 - First name
|
|
27
|
+
* @param {string} name2 - Second name
|
|
28
|
+
* @returns {boolean} Whether the names generate the same UUID
|
|
29
|
+
*/
|
|
30
|
+
function namesGenerateSameUuid(name1, name2) {
|
|
31
|
+
var uuid1 = generateUuidFromName(name1);
|
|
32
|
+
var uuid2 = generateUuidFromName(name2);
|
|
33
|
+
return uuid1 && uuid2 && uuid1 === uuid2;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Find an object in a Three.js scene by hardcoded UUID with fallback strategies
|
|
38
|
+
* @param {THREE.Scene} scene - The Three.js scene to search
|
|
39
|
+
* @param {string} targetUuid - The UUID to search for
|
|
40
|
+
* @returns {THREE.Object3D|null} The found object or null
|
|
41
|
+
*/
|
|
42
|
+
function findObjectByHardcodedUuid(scene, targetUuid) {
|
|
43
|
+
if (!scene || !targetUuid) return null;
|
|
44
|
+
var foundObject = null;
|
|
45
|
+
scene.traverse(function (child) {
|
|
46
|
+
var _child$userData;
|
|
47
|
+
if (foundObject) return; // Stop if already found
|
|
48
|
+
|
|
49
|
+
// Strategy 1: Direct UUID match (HIGHEST PRIORITY)
|
|
50
|
+
if (child.uuid === targetUuid) {
|
|
51
|
+
foundObject = child;
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Strategy 2: Original hardcoded UUID match
|
|
56
|
+
if (((_child$userData = child.userData) === null || _child$userData === void 0 ? void 0 : _child$userData.originalUuid) === targetUuid) {
|
|
57
|
+
foundObject = child;
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Strategy 3: Name-based UUID match (FALLBACK)
|
|
62
|
+
if (child.name) {
|
|
63
|
+
var generatedUuid = generateUuidFromName(child.name);
|
|
64
|
+
if (generatedUuid === targetUuid) {
|
|
65
|
+
foundObject = child;
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
return foundObject;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Get the hardcoded UUID for an object, prioritizing original over current
|
|
75
|
+
* @param {THREE.Object3D} object - The Three.js object
|
|
76
|
+
* @returns {string|null} The hardcoded UUID or null
|
|
77
|
+
*/
|
|
78
|
+
function getHardcodedUuid(object) {
|
|
79
|
+
var _object$userData;
|
|
80
|
+
if (!object) return null;
|
|
81
|
+
|
|
82
|
+
// Priority 1: Original hardcoded UUID stored in userData
|
|
83
|
+
if ((_object$userData = object.userData) !== null && _object$userData !== void 0 && _object$userData.originalUuid) {
|
|
84
|
+
return object.userData.originalUuid;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Priority 2: Current UUID (if it looks like a hardcoded one)
|
|
88
|
+
if (object.uuid && !object.uuid.includes('-') && object.uuid.length > 10) {
|
|
89
|
+
return object.uuid;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// Priority 3: Generate from name if available
|
|
93
|
+
if (object.name) {
|
|
94
|
+
return generateUuidFromName(object.name);
|
|
95
|
+
}
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export { findObjectByHardcodedUuid, generateUuidFromName, getHardcodedUuid, namesGenerateSameUuid };
|