@2112-lab/central-plant 0.1.1 → 0.1.3

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.
Files changed (55) hide show
  1. package/dist/bundle/index.js +1 -15140
  2. package/dist/cjs/_virtual/_rollupPluginBabelHelpers.js +1 -353
  3. package/dist/cjs/node_modules/@2112-lab/pathfinder/dist/index.esm.js +1 -0
  4. package/dist/cjs/node_modules/three/examples/jsm/controls/OrbitControls.js +1 -1292
  5. package/dist/cjs/node_modules/three/examples/jsm/controls/TransformControls.js +1 -1543
  6. package/dist/cjs/node_modules/three/examples/jsm/loaders/GLTFLoader.js +1 -4374
  7. package/dist/cjs/node_modules/three/examples/jsm/loaders/RGBELoader.js +1 -465
  8. package/dist/cjs/node_modules/three/examples/jsm/utils/BufferGeometryUtils.js +1 -117
  9. package/dist/cjs/src/animationManager.js +1 -121
  10. package/dist/cjs/src/componentManager.js +1 -151
  11. package/dist/cjs/src/debugLogger.js +1 -176
  12. package/dist/cjs/src/disposalManager.js +1 -185
  13. package/dist/cjs/src/environmentManager.js +1 -1308
  14. package/dist/cjs/src/hotReloadManager.js +1 -252
  15. package/dist/cjs/src/index.js +1 -128
  16. package/dist/cjs/src/keyboardControlsManager.js +1 -206
  17. package/dist/cjs/src/nameUtils.js +1 -106
  18. package/dist/cjs/src/pathfindingManager.js +1 -321
  19. package/dist/cjs/src/performanceMonitor.js +1 -718
  20. package/dist/cjs/src/sceneExportManager.js +1 -292
  21. package/dist/cjs/src/sceneInitializationManager.js +1 -540
  22. package/dist/cjs/src/textureConfig.js +1 -624
  23. package/dist/cjs/src/transformControlsManager.js +1 -851
  24. package/dist/esm/_virtual/_rollupPluginBabelHelpers.js +1 -328
  25. package/dist/esm/node_modules/@2112-lab/pathfinder/dist/index.esm.js +1 -0
  26. package/dist/esm/node_modules/three/examples/jsm/controls/OrbitControls.js +1 -1287
  27. package/dist/esm/node_modules/three/examples/jsm/controls/TransformControls.js +1 -1537
  28. package/dist/esm/node_modules/three/examples/jsm/loaders/GLTFLoader.js +1 -4370
  29. package/dist/esm/node_modules/three/examples/jsm/loaders/RGBELoader.js +1 -461
  30. package/dist/esm/node_modules/three/examples/jsm/utils/BufferGeometryUtils.js +1 -113
  31. package/dist/esm/src/animationManager.js +1 -112
  32. package/dist/esm/src/componentManager.js +1 -123
  33. package/dist/esm/src/debugLogger.js +1 -167
  34. package/dist/esm/src/disposalManager.js +1 -155
  35. package/dist/esm/src/environmentManager.js +1 -1282
  36. package/dist/esm/src/hotReloadManager.js +1 -244
  37. package/dist/esm/src/index.js +1 -118
  38. package/dist/esm/src/keyboardControlsManager.js +1 -196
  39. package/dist/esm/src/nameUtils.js +1 -99
  40. package/dist/esm/src/pathfindingManager.js +1 -295
  41. package/dist/esm/src/performanceMonitor.js +1 -712
  42. package/dist/esm/src/sceneExportManager.js +1 -286
  43. package/dist/esm/src/sceneInitializationManager.js +1 -513
  44. package/dist/esm/src/textureConfig.js +1 -595
  45. package/dist/esm/src/transformControlsManager.js +1 -827
  46. package/dist/index.d.ts +0 -4
  47. package/package.json +1 -1
  48. package/dist/cjs/src/ConnectionManager.js +0 -114
  49. package/dist/cjs/src/Pathfinder.js +0 -88
  50. package/dist/cjs/src/modelPreloader.js +0 -488
  51. package/dist/cjs/src/sceneOperationsManager.js +0 -596
  52. package/dist/esm/src/ConnectionManager.js +0 -110
  53. package/dist/esm/src/Pathfinder.js +0 -84
  54. package/dist/esm/src/modelPreloader.js +0 -464
  55. package/dist/esm/src/sceneOperationsManager.js +0 -572
@@ -1,84 +0,0 @@
1
- import { createClass as _createClass, toConsumableArray as _toConsumableArray, classCallCheck as _classCallCheck } from '../_virtual/_rollupPluginBabelHelpers.js';
2
- import ConnectionManager from './ConnectionManager.js';
3
-
4
- /**
5
- * Pathfinder class
6
- * Enhanced version with better error handling for missing data
7
- */
8
- var Pathfinder = /*#__PURE__*/function () {
9
- function Pathfinder(sceneData) {
10
- _classCallCheck(this, Pathfinder);
11
- this.sceneData = sceneData || {};
12
- this.connectionManager = new ConnectionManager();
13
- }
14
-
15
- /**
16
- * Find paths in the scene
17
- * @returns {Array} Array of paths
18
- */
19
- return _createClass(Pathfinder, [{
20
- key: "findPaths",
21
- value: function findPaths() {
22
- var _this = this;
23
- console.log('[DEBUG] Starting findPaths()');
24
- try {
25
- var connections = this.sceneData.connections;
26
-
27
- // Safety check for connections
28
- if (!connections || !Array.isArray(connections)) {
29
- console.warn('Pathfinder: No valid connections provided in scene data');
30
- return [];
31
- }
32
-
33
- // Create clusters from connections
34
- var clusters = this.connectionManager.clusterConnections(connections);
35
-
36
- // Return empty array if there are no valid clusters
37
- if (!clusters || !clusters.length) {
38
- console.log('Pathfinder: No valid connection clusters generated');
39
- return [];
40
- }
41
-
42
- // Process the clusters and generate paths
43
- // (Simplified implementation, the actual process would be more complex)
44
- var paths = [];
45
- clusters.forEach(function (cluster) {
46
- if (cluster && cluster.objects && Array.isArray(cluster.objects)) {
47
- // Generate path for this cluster
48
- var clusterPaths = _this._generatePathsForCluster(cluster);
49
- paths.push.apply(paths, _toConsumableArray(clusterPaths));
50
- }
51
- });
52
- return paths;
53
- } catch (error) {
54
- console.error('Pathfinder: Error finding paths:', error);
55
- return [];
56
- }
57
- }
58
-
59
- /**
60
- * Generate paths for a single cluster
61
- * @param {Object} cluster - The cluster to generate paths for
62
- * @returns {Array} Array of paths for this cluster
63
- * @private
64
- */
65
- }, {
66
- key: "_generatePathsForCluster",
67
- value: function _generatePathsForCluster(cluster) {
68
- // This is a placeholder implementation
69
- // In your actual system, this would use your existing pathfinding logic
70
- return cluster.objects.map(function (obj, index, arr) {
71
- if (index < arr.length - 1) {
72
- return {
73
- from: obj,
74
- to: arr[index + 1],
75
- path: [] // This would normally contain 3D points for the path
76
- };
77
- }
78
- return null;
79
- }).filter(Boolean);
80
- }
81
- }]);
82
- }();
83
-
84
- export { Pathfinder as default };
@@ -1,464 +0,0 @@
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
- console.log('preloadAllModels called with:', componentDictionary ? "Dictionary of ".concat(Object.keys(componentDictionary).length, " components") : 'No dictionary provided');
70
- if (!this.isPreloading) {
71
- _context4.n = 1;
72
- break;
73
- }
74
- console.log('⏳ Preloading already in progress, returning existing promise');
75
- return _context4.a(2, this.preloadingPromise);
76
- case 1:
77
- if (componentDictionary) {
78
- _context4.n = 2;
79
- break;
80
- }
81
- console.error('❌ Component dictionary is required to preload models');
82
- return _context4.a(2, {
83
- total: 0,
84
- success: 0,
85
- failed: 1,
86
- skipped: 0,
87
- error: 'Component dictionary is required'
88
- });
89
- case 2:
90
- this.isPreloading = true;
91
- this.componentDictionary = componentDictionary;
92
-
93
- // Create a promise to track overall preloading
94
- this.preloadingPromise = new Promise(/*#__PURE__*/function () {
95
- var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(resolve) {
96
- var results, modelKeysSet, loadPromises, _iterator, _step, _loop, _t2, _t3;
97
- return _regenerator().w(function (_context3) {
98
- while (1) switch (_context3.n) {
99
- case 0:
100
- _context3.p = 0;
101
- console.log("\uD83D\uDE80 Starting preload of models from dictionary with ".concat(Object.keys(componentDictionary).length, " components"));
102
- results = {
103
- total: 0,
104
- success: 0,
105
- failed: 0,
106
- skipped: 0,
107
- modelKeys: []
108
- }; // Extract all unique model keys from the dictionary
109
- modelKeysSet = new Set();
110
- Object.values(componentDictionary).forEach(function (component) {
111
- if (component.modelKey) {
112
- modelKeysSet.add(component.modelKey);
113
- }
114
- });
115
- results.total = modelKeysSet.size;
116
- results.modelKeys = Array.from(modelKeysSet);
117
-
118
- // Load basic models first
119
- console.log("\uD83D\uDCE6 Found ".concat(results.total, " unique model keys to preload"));
120
-
121
- // Return early if no models to load
122
- if (!(results.total === 0)) {
123
- _context3.n = 1;
124
- break;
125
- }
126
- _this.isPreloading = false;
127
- resolve(results);
128
- return _context3.a(2);
129
- case 1:
130
- // Process each model key
131
- loadPromises = [];
132
- _iterator = _createForOfIteratorHelper(results.modelKeys);
133
- _context3.p = 2;
134
- _loop = /*#__PURE__*/_regenerator().m(function _loop() {
135
- var modelKey, modelUrl;
136
- return _regenerator().w(function (_context2) {
137
- while (1) switch (_context2.n) {
138
- case 0:
139
- modelKey = _step.value;
140
- modelUrl = _this.getModelUrlFromKey(modelKey);
141
- if (modelUrl) {
142
- loadPromises.push(_this.preloadModel(modelKey, modelUrl).then(function () {
143
- results.success++;
144
- }).catch(function (error) {
145
- console.error("\u274C Failed to preload model ".concat(modelKey, ":"), error);
146
- results.failed++;
147
- }));
148
- } else {
149
- console.warn("\u26A0\uFE0F No URL found for model key: ".concat(modelKey));
150
- results.skipped++;
151
- }
152
- case 1:
153
- return _context2.a(2);
154
- }
155
- }, _loop);
156
- });
157
- _iterator.s();
158
- case 3:
159
- if ((_step = _iterator.n()).done) {
160
- _context3.n = 5;
161
- break;
162
- }
163
- return _context3.d(_regeneratorValues(_loop()), 4);
164
- case 4:
165
- _context3.n = 3;
166
- break;
167
- case 5:
168
- _context3.n = 7;
169
- break;
170
- case 6:
171
- _context3.p = 6;
172
- _t2 = _context3.v;
173
- _iterator.e(_t2);
174
- case 7:
175
- _context3.p = 7;
176
- _iterator.f();
177
- return _context3.f(7);
178
- case 8:
179
- _context3.n = 9;
180
- return Promise.allSettled(loadPromises);
181
- case 9:
182
- console.log('✅ Model preloading completed with results:', results);
183
- _this.isPreloading = false;
184
- resolve(results);
185
- _context3.n = 11;
186
- break;
187
- case 10:
188
- _context3.p = 10;
189
- _t3 = _context3.v;
190
- console.error('❌ Error during model preloading:', _t3);
191
- _this.isPreloading = false;
192
- resolve({
193
- total: 0,
194
- success: 0,
195
- failed: 1,
196
- skipped: 0,
197
- error: _t3.message
198
- });
199
- case 11:
200
- return _context3.a(2);
201
- }
202
- }, _callee2, null, [[2, 6, 7, 8], [0, 10]]);
203
- }));
204
- return function (_x2) {
205
- return _ref.apply(this, arguments);
206
- };
207
- }());
208
- return _context4.a(2, this.preloadingPromise);
209
- }
210
- }, _callee3, this);
211
- }));
212
- function preloadAllModels(_x) {
213
- return _preloadAllModels.apply(this, arguments);
214
- }
215
- return preloadAllModels;
216
- }()
217
- /**
218
- * Load a component model by its ID
219
- * @param {string} componentId - The component ID from the dictionary
220
- * @param {Function} callback - Optional callback function to call when loading completes
221
- * @returns {Promise} Promise that resolves with the loaded model
222
- */
223
- )
224
- }, {
225
- key: "loadComponentById",
226
- value: (function () {
227
- var _loadComponentById = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(componentId, callback) {
228
- var component, modelUrl, model, _t4;
229
- return _regenerator().w(function (_context5) {
230
- while (1) switch (_context5.n) {
231
- case 0:
232
- if (this.componentDictionary) {
233
- _context5.n = 1;
234
- break;
235
- }
236
- console.warn('⚠️ No component dictionary available for loadComponentById');
237
- if (callback) callback(null);
238
- return _context5.a(2, null);
239
- case 1:
240
- component = this.componentDictionary[componentId];
241
- if (!(!component || !component.modelKey)) {
242
- _context5.n = 2;
243
- break;
244
- }
245
- console.warn("\u26A0\uFE0F No component or model key found for ID: ".concat(componentId));
246
- if (callback) callback(null);
247
- return _context5.a(2, null);
248
- case 2:
249
- _context5.p = 2;
250
- modelUrl = this.getModelUrlFromKey(component.modelKey);
251
- _context5.n = 3;
252
- return this.preloadModel(component.modelKey, modelUrl);
253
- case 3:
254
- model = _context5.v;
255
- if (callback) callback(model);
256
- return _context5.a(2, model);
257
- case 4:
258
- _context5.p = 4;
259
- _t4 = _context5.v;
260
- console.error("\u274C Failed to load component model for ID: ".concat(componentId), _t4);
261
- if (callback) callback(null);
262
- return _context5.a(2, null);
263
- }
264
- }, _callee4, this, [[2, 4]]);
265
- }));
266
- function loadComponentById(_x3, _x4) {
267
- return _loadComponentById.apply(this, arguments);
268
- }
269
- return loadComponentById;
270
- }()
271
- /**
272
- * Get a cached model by its key
273
- * @param {string} modelKey - The model key
274
- * @returns {Object|null} The loaded model or null if not found
275
- */
276
- )
277
- }, {
278
- key: "getCachedModel",
279
- value: function getCachedModel(modelKey) {
280
- return this.modelCache.get(modelKey) || null;
281
- }
282
-
283
- /**
284
- * Get all cache keys
285
- * @returns {Array} Array of model keys in the cache
286
- */
287
- }, {
288
- key: "getCacheKeys",
289
- value: function getCacheKeys() {
290
- return Array.from(this.modelCache.keys());
291
- }
292
-
293
- /**
294
- * Convert a model key to a URL
295
- * @param {string} modelKey - The model key from the dictionary
296
- * @returns {string} The URL for the model
297
- */
298
- }, {
299
- key: "getModelUrlFromKey",
300
- value: function getModelUrlFromKey(modelKey) {
301
- // The modelKey already includes the .glb extension from the component dictionary
302
- return modelKey;
303
- }
304
-
305
- /**
306
- * Preload a specific model
307
- * @param {string} modelKey - The model key
308
- * @param {string} modelUrl - The URL to the model
309
- * @returns {Promise} Promise that resolves with the loaded model
310
- */
311
- }, {
312
- key: "preloadModel",
313
- value: (function () {
314
- var _preloadModel = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(modelKey, modelUrl) {
315
- var _this2 = this;
316
- var loadPromise;
317
- return _regenerator().w(function (_context6) {
318
- while (1) switch (_context6.n) {
319
- case 0:
320
- if (this.gltfLoader) {
321
- _context6.n = 2;
322
- break;
323
- }
324
- _context6.n = 1;
325
- return this.initLoader();
326
- case 1:
327
- if (this.gltfLoader) {
328
- _context6.n = 2;
329
- break;
330
- }
331
- throw new Error('GLTFLoader is not available');
332
- case 2:
333
- if (!this.modelCache.has(modelKey)) {
334
- _context6.n = 3;
335
- break;
336
- }
337
- return _context6.a(2, this.modelCache.get(modelKey));
338
- case 3:
339
- if (!this.loadingPromises.has(modelKey)) {
340
- _context6.n = 4;
341
- break;
342
- }
343
- return _context6.a(2, this.loadingPromises.get(modelKey));
344
- case 4:
345
- // Start loading the model
346
- loadPromise = new Promise(function (resolve, reject) {
347
- _this2.gltfLoader.load(modelUrl, function (gltf) {
348
- console.log("\u2705 Successfully loaded model: ".concat(modelKey, " from ").concat(modelUrl));
349
- _this2.modelCache.set(modelKey, gltf);
350
- _this2.loadingPromises.delete(modelKey);
351
- resolve(gltf);
352
- }, function (progress) {
353
- // Optional progress callback
354
- if (progress.lengthComputable) {
355
- progress.loaded / progress.total * 100;
356
- // console.log(`📥 Loading ${modelKey}: ${percentComplete.toFixed(1)}%`);
357
- }
358
- }, function (error) {
359
- console.error("\u274C Failed to load model ".concat(modelKey, " from ").concat(modelUrl, ":"), error);
360
-
361
- // Add more detailed error information
362
- if (error.message && error.message.includes('404')) {
363
- console.error(" File not found. Check if the model exists at: ".concat(modelUrl));
364
- } else if (error.message && error.message.includes('JSON')) {
365
- console.error(" Invalid GLB file format. The file may be corrupted or is not a valid GLB/GLTF file.");
366
- }
367
- _this2.loadingPromises.delete(modelKey);
368
- reject(error);
369
- });
370
- }); // Store the loading promise
371
- this.loadingPromises.set(modelKey, loadPromise);
372
- return _context6.a(2, loadPromise);
373
- }
374
- }, _callee5, this);
375
- }));
376
- function preloadModel(_x5, _x6) {
377
- return _preloadModel.apply(this, arguments);
378
- }
379
- return preloadModel;
380
- }()
381
- /**
382
- * Get a model from the cache
383
- * @param {string} modelKey - The model key
384
- * @returns {Object|null} The loaded model or null if not found
385
- */
386
- )
387
- }, {
388
- key: "getModel",
389
- value: function getModel(modelKey) {
390
- return this.modelCache.get(modelKey) || null;
391
- }
392
-
393
- /**
394
- * Clear the model cache
395
- */
396
- }, {
397
- key: "clearCache",
398
- value: function clearCache() {
399
- this.modelCache.clear();
400
- }
401
-
402
- /**
403
- * Get statistics about the model cache
404
- * @returns {Object} Cache statistics
405
- */
406
- }, {
407
- key: "getCacheStats",
408
- value: function getCacheStats() {
409
- return {
410
- cacheSize: this.modelCache.size,
411
- cachedModels: Array.from(this.modelCache.keys()),
412
- loading: Array.from(this.loadingPromises.keys()),
413
- isPreloading: this.isPreloading
414
- };
415
- }
416
- }]);
417
- }(); // Create singleton instance with explicit methods
418
- var modelPreloader = new ModelPreloader();
419
-
420
- // Ensure the model preloader is fully initialized
421
- if (typeof window !== 'undefined') {
422
- // Only run in browser environment
423
- modelPreloader.initLoader().catch(function (err) {
424
- console.warn('Error initializing model preloader:', err);
425
- });
426
- }
427
-
428
- // Create a simple proxy object with all methods explicitly defined
429
- // This helps ensure webpack correctly recognizes all methods
430
- var explicitModelPreloader = {
431
- // Core methods from original implementation
432
- preloadAllModels: function preloadAllModels(componentDictionary) {
433
- return modelPreloader.preloadAllModels(componentDictionary);
434
- },
435
- preloadModel: function preloadModel(modelKey, modelUrl) {
436
- return modelPreloader.preloadModel(modelKey, modelUrl);
437
- },
438
- getModel: function getModel(modelKey) {
439
- return modelPreloader.getModel(modelKey);
440
- },
441
- clearCache: function clearCache() {
442
- return modelPreloader.clearCache();
443
- },
444
- getCacheStats: function getCacheStats() {
445
- return modelPreloader.getCacheStats();
446
- },
447
- getModelUrlFromKey: function getModelUrlFromKey(modelKey) {
448
- return modelPreloader.getModelUrlFromKey(modelKey);
449
- },
450
- // Added methods
451
- loadComponentById: function loadComponentById(componentId, callback) {
452
- return modelPreloader.loadComponentById(componentId, callback);
453
- },
454
- getCachedModel: function getCachedModel(modelKey) {
455
- return modelPreloader.getCachedModel(modelKey);
456
- },
457
- getCacheKeys: function getCacheKeys() {
458
- return modelPreloader.getCacheKeys();
459
- },
460
- // Original model cache access
461
- modelCache: modelPreloader.modelCache
462
- };
463
-
464
- export { ModelPreloader, explicitModelPreloader as default, explicitModelPreloader as modelPreloader };