@2112-lab/central-plant 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/dist/bundle/index.js +7782 -6543
  2. package/dist/cjs/_virtual/_rollupPluginBabelHelpers.js +23 -10
  3. package/dist/cjs/node_modules/@2112-lab/pathfinder/dist/index.esm.js +1448 -0
  4. package/dist/cjs/src/animationManager.js +15 -15
  5. package/dist/cjs/src/componentManager.js +8 -8
  6. package/dist/cjs/src/disposalManager.js +12 -12
  7. package/dist/cjs/src/environmentManager.js +392 -99
  8. package/dist/cjs/src/hotReloadManager.js +26 -26
  9. package/dist/cjs/src/index.js +19 -66
  10. package/dist/cjs/src/keyboardControlsManager.js +23 -23
  11. package/dist/cjs/src/nameUtils.js +21 -21
  12. package/dist/cjs/src/pathfindingManager.js +311 -129
  13. package/dist/cjs/src/performanceMonitor.js +52 -52
  14. package/dist/cjs/src/sceneExportManager.js +23 -23
  15. package/dist/cjs/src/sceneInitializationManager.js +18 -18
  16. package/dist/cjs/src/textureConfig.js +469 -40
  17. package/dist/cjs/src/transformControlsManager.js +79 -79
  18. package/dist/esm/_virtual/_rollupPluginBabelHelpers.js +21 -10
  19. package/dist/esm/node_modules/@2112-lab/pathfinder/dist/index.esm.js +1444 -0
  20. package/dist/esm/src/animationManager.js +15 -15
  21. package/dist/esm/src/componentManager.js +8 -8
  22. package/dist/esm/src/disposalManager.js +12 -12
  23. package/dist/esm/src/environmentManager.js +393 -100
  24. package/dist/esm/src/hotReloadManager.js +26 -26
  25. package/dist/esm/src/index.js +19 -66
  26. package/dist/esm/src/keyboardControlsManager.js +23 -23
  27. package/dist/esm/src/nameUtils.js +21 -21
  28. package/dist/esm/src/pathfindingManager.js +313 -129
  29. package/dist/esm/src/performanceMonitor.js +52 -52
  30. package/dist/esm/src/sceneExportManager.js +23 -23
  31. package/dist/esm/src/sceneInitializationManager.js +18 -18
  32. package/dist/esm/src/textureConfig.js +469 -42
  33. package/dist/esm/src/transformControlsManager.js +79 -79
  34. package/dist/index.d.ts +255 -259
  35. package/package.json +52 -53
  36. package/dist/cjs/src/ConnectionManager.js +0 -114
  37. package/dist/cjs/src/Pathfinder.js +0 -88
  38. package/dist/cjs/src/modelPreloader.js +0 -360
  39. package/dist/cjs/src/sceneOperationsManager.js +0 -560
  40. package/dist/esm/src/ConnectionManager.js +0 -110
  41. package/dist/esm/src/Pathfinder.js +0 -84
  42. package/dist/esm/src/modelPreloader.js +0 -337
  43. package/dist/esm/src/sceneOperationsManager.js +0 -536
@@ -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,337 +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
- 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 };