@2112-lab/central-plant 0.3.56 → 0.3.57
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 +58 -33
- package/dist/cjs/src/core/centralPlant.js +32 -20
- package/dist/cjs/src/managers/cache/CacheManager.js +18 -7
- package/dist/cjs/src/managers/environment/environmentManager.js +8 -6
- package/dist/esm/src/core/centralPlant.js +32 -20
- package/dist/esm/src/managers/cache/CacheManager.js +18 -7
- package/dist/esm/src/managers/environment/environmentManager.js +8 -6
- package/package.json +1 -1
package/dist/bundle/index.js
CHANGED
|
@@ -27361,13 +27361,15 @@ var EnvironmentManager = /*#__PURE__*/function () {
|
|
|
27361
27361
|
return this.createSkybox();
|
|
27362
27362
|
case 1:
|
|
27363
27363
|
this.setupLighting();
|
|
27364
|
-
_context4.n = 2;
|
|
27365
|
-
return this.addTexturedGround();
|
|
27366
|
-
case 2:
|
|
27367
|
-
// await this.addBrickWalls()
|
|
27368
27364
|
this.addHorizonFog();
|
|
27369
|
-
|
|
27370
|
-
|
|
27365
|
+
|
|
27366
|
+
// 2. Add ground (synchronously adds basic mesh)
|
|
27367
|
+
// We do NOT await the texture loading here to speed up scene "Ready" state
|
|
27368
|
+
this.addTexturedGround().catch(function (err) {
|
|
27369
|
+
return console.warn('⚠️ Ground texture load failed:', err);
|
|
27370
|
+
});
|
|
27371
|
+
console.log('Environment initialization completed (textures loading in background)');
|
|
27372
|
+
case 2:
|
|
27371
27373
|
return _context4.a(2);
|
|
27372
27374
|
}
|
|
27373
27375
|
}, _callee4, this);
|
|
@@ -41823,7 +41825,7 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
41823
41825
|
* Initialize the CentralPlant manager
|
|
41824
41826
|
*
|
|
41825
41827
|
* @constructor
|
|
41826
|
-
* @version 0.3.
|
|
41828
|
+
* @version 0.3.57
|
|
41827
41829
|
* @updated 2025-10-22
|
|
41828
41830
|
*
|
|
41829
41831
|
* @description Creates a new CentralPlant instance and initializes internal managers and utilities.
|
|
@@ -44441,23 +44443,18 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
44441
44443
|
/**
|
|
44442
44444
|
* Initialize model preloading from component dictionary
|
|
44443
44445
|
* @param {string} [basePath='/library/'] - Base path for both dictionary and models (can be local path or S3 URL)
|
|
44444
|
-
* @
|
|
44445
|
-
* @
|
|
44446
|
-
* @
|
|
44447
|
-
* // Local files (default)
|
|
44448
|
-
* await centralPlant.initializeModelPreloading()
|
|
44449
|
-
*
|
|
44450
|
-
* // S3 bucket
|
|
44451
|
-
* await centralPlant.initializeModelPreloading('https://my-bucket.s3.amazonaws.com/library/')
|
|
44452
|
-
*
|
|
44453
|
-
* // Custom local path
|
|
44454
|
-
* await centralPlant.initializeModelPreloading('/custom/assets/')
|
|
44446
|
+
* @param {Object} [options={}] - Optimization options
|
|
44447
|
+
* @param {boolean} [options.autoPreloadModels=true] - If false, only loads the dictionary and skips preloading GLBs (improves initial load)
|
|
44448
|
+
* @returns {Promise<Object>} Preloading progress results or dictionary summary
|
|
44455
44449
|
*/
|
|
44456
44450
|
}, {
|
|
44457
44451
|
key: "initializeModelPreloading",
|
|
44458
44452
|
value: (function () {
|
|
44459
44453
|
var _initializeModelPreloading = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10() {
|
|
44460
44454
|
var basePath,
|
|
44455
|
+
options,
|
|
44456
|
+
_options$autoPreloadM,
|
|
44457
|
+
autoPreloadModels,
|
|
44461
44458
|
normalizedBasePath,
|
|
44462
44459
|
dictionaryPath,
|
|
44463
44460
|
modelsBasePath,
|
|
@@ -44471,6 +44468,8 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
44471
44468
|
while (1) switch (_context10.n) {
|
|
44472
44469
|
case 0:
|
|
44473
44470
|
basePath = _args10.length > 0 && _args10[0] !== undefined ? _args10[0] : '/library/';
|
|
44471
|
+
options = _args10.length > 1 && _args10[1] !== undefined ? _args10[1] : {};
|
|
44472
|
+
_options$autoPreloadM = options.autoPreloadModels, autoPreloadModels = _options$autoPreloadM === void 0 ? true : _options$autoPreloadM;
|
|
44474
44473
|
_context10.p = 1;
|
|
44475
44474
|
// Ensure basePath ends with a slash
|
|
44476
44475
|
normalizedBasePath = basePath.endsWith('/') ? basePath : "".concat(basePath, "/");
|
|
@@ -44480,6 +44479,7 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
44480
44479
|
console.log("\uD83D\uDCC2 Base path: ".concat(normalizedBasePath));
|
|
44481
44480
|
console.log("\uD83D\uDCDA Dictionary path: ".concat(dictionaryPath));
|
|
44482
44481
|
console.log("\uFFFD Models path: ".concat(modelsBasePath));
|
|
44482
|
+
console.log("\u26A1 Auto-preload models: ".concat(autoPreloadModels));
|
|
44483
44483
|
|
|
44484
44484
|
// Load the component dictionary
|
|
44485
44485
|
_context10.n = 2;
|
|
@@ -44496,25 +44496,39 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
44496
44496
|
return response.json();
|
|
44497
44497
|
case 4:
|
|
44498
44498
|
componentDictionary = _context10.v;
|
|
44499
|
-
console.log('📚 Component dictionary loaded:', Object.keys(componentDictionary));
|
|
44499
|
+
console.log('📚 Component dictionary loaded:', Object.keys(componentDictionary).length);
|
|
44500
44500
|
|
|
44501
|
-
//
|
|
44501
|
+
// Get the model preloader utility
|
|
44502
44502
|
_modelPreloader2 = this.getUtility('modelPreloader');
|
|
44503
|
-
|
|
44504
|
-
|
|
44503
|
+
if (autoPreloadModels) {
|
|
44504
|
+
_context10.n = 5;
|
|
44505
|
+
break;
|
|
44506
|
+
}
|
|
44507
|
+
console.log('⚡ Lazy loading enabled: skipping automatic GLB preloading');
|
|
44508
|
+
// We still need to give the preloader the dictionary and base path for later use
|
|
44509
|
+
_modelPreloader2.componentDictionary = componentDictionary;
|
|
44510
|
+
_modelPreloader2.setModelsBasePath(modelsBasePath);
|
|
44511
|
+
return _context10.a(2, {
|
|
44512
|
+
successCount: 0,
|
|
44513
|
+
failureCount: 0,
|
|
44514
|
+
dictionaryCount: Object.keys(componentDictionary).length
|
|
44515
|
+
});
|
|
44505
44516
|
case 5:
|
|
44517
|
+
_context10.n = 6;
|
|
44518
|
+
return _modelPreloader2.preloadAllModels(componentDictionary, modelsBasePath);
|
|
44519
|
+
case 6:
|
|
44506
44520
|
progress = _context10.v;
|
|
44507
44521
|
console.log('🎉 Model preloading completed:', progress);
|
|
44508
44522
|
return _context10.a(2, progress);
|
|
44509
|
-
case
|
|
44510
|
-
_context10.p =
|
|
44523
|
+
case 7:
|
|
44524
|
+
_context10.p = 7;
|
|
44511
44525
|
_t3 = _context10.v;
|
|
44512
44526
|
console.error('❌ Failed to initialize model preloading:', _t3);
|
|
44513
44527
|
throw _t3;
|
|
44514
|
-
case
|
|
44528
|
+
case 8:
|
|
44515
44529
|
return _context10.a(2);
|
|
44516
44530
|
}
|
|
44517
|
-
}, _callee10, this, [[1,
|
|
44531
|
+
}, _callee10, this, [[1, 7]]);
|
|
44518
44532
|
}));
|
|
44519
44533
|
function initializeModelPreloading() {
|
|
44520
44534
|
return _initializeModelPreloading.apply(this, arguments);
|
|
@@ -46484,7 +46498,7 @@ var CacheManager = /*#__PURE__*/function () {
|
|
|
46484
46498
|
key: "execute",
|
|
46485
46499
|
value: (function () {
|
|
46486
46500
|
var _execute = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(_ref) {
|
|
46487
|
-
var cacheKey, sourceKey, expiryMs, fetcher, processor, _ref$metadata, metadata, cacheName, cache, cachedResponse, cachedTime, age, result, fetchResult, blobOrJson, contentType, contentSize, responseBody, headers, cacheResponse, fallbackResult, _t2;
|
|
46501
|
+
var cacheKey, sourceKey, expiryMs, fetcher, processor, _ref$metadata, metadata, cacheName, cache, cachedResponse, cachedTime, age, result, fetchResult, blobOrJson, error, contentType, contentSize, responseBody, headers, cacheResponse, fallbackResult, _t2;
|
|
46488
46502
|
return _regenerator().w(function (_context4) {
|
|
46489
46503
|
while (1) switch (_context4.n) {
|
|
46490
46504
|
case 0:
|
|
@@ -46537,7 +46551,9 @@ var CacheManager = /*#__PURE__*/function () {
|
|
|
46537
46551
|
_context4.n = 9;
|
|
46538
46552
|
break;
|
|
46539
46553
|
}
|
|
46540
|
-
|
|
46554
|
+
error = new Error("Fetch failed: ".concat(fetchResult.status)); // Do not retry 404s - the file is genuinely missing
|
|
46555
|
+
if (fetchResult.status === 404) error.noRetry = true;
|
|
46556
|
+
throw error;
|
|
46541
46557
|
case 9:
|
|
46542
46558
|
_context4.n = 10;
|
|
46543
46559
|
return processor(fetchResult.clone());
|
|
@@ -46588,20 +46604,29 @@ var CacheManager = /*#__PURE__*/function () {
|
|
|
46588
46604
|
case 15:
|
|
46589
46605
|
fallbackResult = _context4.v;
|
|
46590
46606
|
if (!(fallbackResult instanceof Response)) {
|
|
46607
|
+
_context4.n = 18;
|
|
46608
|
+
break;
|
|
46609
|
+
}
|
|
46610
|
+
if (fallbackResult.ok) {
|
|
46591
46611
|
_context4.n = 16;
|
|
46592
46612
|
break;
|
|
46593
46613
|
}
|
|
46594
|
-
|
|
46614
|
+
throw new Error("Fallback fetch failed: ".concat(fallbackResult.status));
|
|
46595
46615
|
case 16:
|
|
46596
|
-
|
|
46616
|
+
_context4.n = 17;
|
|
46617
|
+
return processor(fallbackResult);
|
|
46597
46618
|
case 17:
|
|
46598
|
-
_context4.
|
|
46619
|
+
return _context4.a(2, _context4.v);
|
|
46620
|
+
case 18:
|
|
46621
|
+
return _context4.a(2, fallbackResult);
|
|
46622
|
+
case 19:
|
|
46623
|
+
_context4.p = 19;
|
|
46599
46624
|
_context4.v;
|
|
46600
46625
|
throw _t2;
|
|
46601
|
-
case
|
|
46626
|
+
case 20:
|
|
46602
46627
|
return _context4.a(2);
|
|
46603
46628
|
}
|
|
46604
|
-
}, _callee4, this, [[14,
|
|
46629
|
+
}, _callee4, this, [[14, 19], [1, 13]]);
|
|
46605
46630
|
}));
|
|
46606
46631
|
function execute(_x2) {
|
|
46607
46632
|
return _execute.apply(this, arguments);
|
|
@@ -58,7 +58,7 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
58
58
|
* Initialize the CentralPlant manager
|
|
59
59
|
*
|
|
60
60
|
* @constructor
|
|
61
|
-
* @version 0.3.
|
|
61
|
+
* @version 0.3.57
|
|
62
62
|
* @updated 2025-10-22
|
|
63
63
|
*
|
|
64
64
|
* @description Creates a new CentralPlant instance and initializes internal managers and utilities.
|
|
@@ -2676,23 +2676,18 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
2676
2676
|
/**
|
|
2677
2677
|
* Initialize model preloading from component dictionary
|
|
2678
2678
|
* @param {string} [basePath='/library/'] - Base path for both dictionary and models (can be local path or S3 URL)
|
|
2679
|
-
* @
|
|
2680
|
-
* @
|
|
2681
|
-
* @
|
|
2682
|
-
* // Local files (default)
|
|
2683
|
-
* await centralPlant.initializeModelPreloading()
|
|
2684
|
-
*
|
|
2685
|
-
* // S3 bucket
|
|
2686
|
-
* await centralPlant.initializeModelPreloading('https://my-bucket.s3.amazonaws.com/library/')
|
|
2687
|
-
*
|
|
2688
|
-
* // Custom local path
|
|
2689
|
-
* await centralPlant.initializeModelPreloading('/custom/assets/')
|
|
2679
|
+
* @param {Object} [options={}] - Optimization options
|
|
2680
|
+
* @param {boolean} [options.autoPreloadModels=true] - If false, only loads the dictionary and skips preloading GLBs (improves initial load)
|
|
2681
|
+
* @returns {Promise<Object>} Preloading progress results or dictionary summary
|
|
2690
2682
|
*/
|
|
2691
2683
|
}, {
|
|
2692
2684
|
key: "initializeModelPreloading",
|
|
2693
2685
|
value: (function () {
|
|
2694
2686
|
var _initializeModelPreloading = _rollupPluginBabelHelpers.asyncToGenerator(/*#__PURE__*/_rollupPluginBabelHelpers.regenerator().m(function _callee10() {
|
|
2695
2687
|
var basePath,
|
|
2688
|
+
options,
|
|
2689
|
+
_options$autoPreloadM,
|
|
2690
|
+
autoPreloadModels,
|
|
2696
2691
|
normalizedBasePath,
|
|
2697
2692
|
dictionaryPath,
|
|
2698
2693
|
modelsBasePath,
|
|
@@ -2706,6 +2701,8 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
2706
2701
|
while (1) switch (_context10.n) {
|
|
2707
2702
|
case 0:
|
|
2708
2703
|
basePath = _args10.length > 0 && _args10[0] !== undefined ? _args10[0] : '/library/';
|
|
2704
|
+
options = _args10.length > 1 && _args10[1] !== undefined ? _args10[1] : {};
|
|
2705
|
+
_options$autoPreloadM = options.autoPreloadModels, autoPreloadModels = _options$autoPreloadM === void 0 ? true : _options$autoPreloadM;
|
|
2709
2706
|
_context10.p = 1;
|
|
2710
2707
|
// Ensure basePath ends with a slash
|
|
2711
2708
|
normalizedBasePath = basePath.endsWith('/') ? basePath : "".concat(basePath, "/");
|
|
@@ -2715,6 +2712,7 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
2715
2712
|
console.log("\uD83D\uDCC2 Base path: ".concat(normalizedBasePath));
|
|
2716
2713
|
console.log("\uD83D\uDCDA Dictionary path: ".concat(dictionaryPath));
|
|
2717
2714
|
console.log("\uFFFD Models path: ".concat(modelsBasePath));
|
|
2715
|
+
console.log("\u26A1 Auto-preload models: ".concat(autoPreloadModels));
|
|
2718
2716
|
|
|
2719
2717
|
// Load the component dictionary
|
|
2720
2718
|
_context10.n = 2;
|
|
@@ -2731,25 +2729,39 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
2731
2729
|
return response.json();
|
|
2732
2730
|
case 4:
|
|
2733
2731
|
componentDictionary = _context10.v;
|
|
2734
|
-
console.log('📚 Component dictionary loaded:', Object.keys(componentDictionary));
|
|
2732
|
+
console.log('📚 Component dictionary loaded:', Object.keys(componentDictionary).length);
|
|
2735
2733
|
|
|
2736
|
-
//
|
|
2734
|
+
// Get the model preloader utility
|
|
2737
2735
|
_modelPreloader2 = this.getUtility('modelPreloader');
|
|
2738
|
-
|
|
2739
|
-
|
|
2736
|
+
if (autoPreloadModels) {
|
|
2737
|
+
_context10.n = 5;
|
|
2738
|
+
break;
|
|
2739
|
+
}
|
|
2740
|
+
console.log('⚡ Lazy loading enabled: skipping automatic GLB preloading');
|
|
2741
|
+
// We still need to give the preloader the dictionary and base path for later use
|
|
2742
|
+
_modelPreloader2.componentDictionary = componentDictionary;
|
|
2743
|
+
_modelPreloader2.setModelsBasePath(modelsBasePath);
|
|
2744
|
+
return _context10.a(2, {
|
|
2745
|
+
successCount: 0,
|
|
2746
|
+
failureCount: 0,
|
|
2747
|
+
dictionaryCount: Object.keys(componentDictionary).length
|
|
2748
|
+
});
|
|
2740
2749
|
case 5:
|
|
2750
|
+
_context10.n = 6;
|
|
2751
|
+
return _modelPreloader2.preloadAllModels(componentDictionary, modelsBasePath);
|
|
2752
|
+
case 6:
|
|
2741
2753
|
progress = _context10.v;
|
|
2742
2754
|
console.log('🎉 Model preloading completed:', progress);
|
|
2743
2755
|
return _context10.a(2, progress);
|
|
2744
|
-
case
|
|
2745
|
-
_context10.p =
|
|
2756
|
+
case 7:
|
|
2757
|
+
_context10.p = 7;
|
|
2746
2758
|
_t3 = _context10.v;
|
|
2747
2759
|
console.error('❌ Failed to initialize model preloading:', _t3);
|
|
2748
2760
|
throw _t3;
|
|
2749
|
-
case
|
|
2761
|
+
case 8:
|
|
2750
2762
|
return _context10.a(2);
|
|
2751
2763
|
}
|
|
2752
|
-
}, _callee10, this, [[1,
|
|
2764
|
+
}, _callee10, this, [[1, 7]]);
|
|
2753
2765
|
}));
|
|
2754
2766
|
function initializeModelPreloading() {
|
|
2755
2767
|
return _initializeModelPreloading.apply(this, arguments);
|
|
@@ -202,7 +202,7 @@ var CacheManager = /*#__PURE__*/function () {
|
|
|
202
202
|
key: "execute",
|
|
203
203
|
value: (function () {
|
|
204
204
|
var _execute = _rollupPluginBabelHelpers.asyncToGenerator(/*#__PURE__*/_rollupPluginBabelHelpers.regenerator().m(function _callee4(_ref) {
|
|
205
|
-
var cacheKey, sourceKey, expiryMs, fetcher, processor, _ref$metadata, metadata, cacheName, cache, cachedResponse, cachedTime, age, result, fetchResult, blobOrJson, contentType, contentSize, responseBody, headers, cacheResponse, fallbackResult, _t2;
|
|
205
|
+
var cacheKey, sourceKey, expiryMs, fetcher, processor, _ref$metadata, metadata, cacheName, cache, cachedResponse, cachedTime, age, result, fetchResult, blobOrJson, error, contentType, contentSize, responseBody, headers, cacheResponse, fallbackResult, _t2;
|
|
206
206
|
return _rollupPluginBabelHelpers.regenerator().w(function (_context4) {
|
|
207
207
|
while (1) switch (_context4.n) {
|
|
208
208
|
case 0:
|
|
@@ -255,7 +255,9 @@ var CacheManager = /*#__PURE__*/function () {
|
|
|
255
255
|
_context4.n = 9;
|
|
256
256
|
break;
|
|
257
257
|
}
|
|
258
|
-
|
|
258
|
+
error = new Error("Fetch failed: ".concat(fetchResult.status)); // Do not retry 404s - the file is genuinely missing
|
|
259
|
+
if (fetchResult.status === 404) error.noRetry = true;
|
|
260
|
+
throw error;
|
|
259
261
|
case 9:
|
|
260
262
|
_context4.n = 10;
|
|
261
263
|
return processor(fetchResult.clone());
|
|
@@ -306,20 +308,29 @@ var CacheManager = /*#__PURE__*/function () {
|
|
|
306
308
|
case 15:
|
|
307
309
|
fallbackResult = _context4.v;
|
|
308
310
|
if (!(fallbackResult instanceof Response)) {
|
|
311
|
+
_context4.n = 18;
|
|
312
|
+
break;
|
|
313
|
+
}
|
|
314
|
+
if (fallbackResult.ok) {
|
|
309
315
|
_context4.n = 16;
|
|
310
316
|
break;
|
|
311
317
|
}
|
|
312
|
-
|
|
318
|
+
throw new Error("Fallback fetch failed: ".concat(fallbackResult.status));
|
|
313
319
|
case 16:
|
|
314
|
-
|
|
320
|
+
_context4.n = 17;
|
|
321
|
+
return processor(fallbackResult);
|
|
315
322
|
case 17:
|
|
316
|
-
_context4.
|
|
323
|
+
return _context4.a(2, _context4.v);
|
|
324
|
+
case 18:
|
|
325
|
+
return _context4.a(2, fallbackResult);
|
|
326
|
+
case 19:
|
|
327
|
+
_context4.p = 19;
|
|
317
328
|
_context4.v;
|
|
318
329
|
throw _t2;
|
|
319
|
-
case
|
|
330
|
+
case 20:
|
|
320
331
|
return _context4.a(2);
|
|
321
332
|
}
|
|
322
|
-
}, _callee4, this, [[14,
|
|
333
|
+
}, _callee4, this, [[14, 19], [1, 13]]);
|
|
323
334
|
}));
|
|
324
335
|
function execute(_x2) {
|
|
325
336
|
return _execute.apply(this, arguments);
|
|
@@ -423,13 +423,15 @@ var EnvironmentManager = /*#__PURE__*/function () {
|
|
|
423
423
|
return this.createSkybox();
|
|
424
424
|
case 1:
|
|
425
425
|
this.setupLighting();
|
|
426
|
-
_context4.n = 2;
|
|
427
|
-
return this.addTexturedGround();
|
|
428
|
-
case 2:
|
|
429
|
-
// await this.addBrickWalls()
|
|
430
426
|
this.addHorizonFog();
|
|
431
|
-
|
|
432
|
-
|
|
427
|
+
|
|
428
|
+
// 2. Add ground (synchronously adds basic mesh)
|
|
429
|
+
// We do NOT await the texture loading here to speed up scene "Ready" state
|
|
430
|
+
this.addTexturedGround().catch(function (err) {
|
|
431
|
+
return console.warn('⚠️ Ground texture load failed:', err);
|
|
432
|
+
});
|
|
433
|
+
console.log('Environment initialization completed (textures loading in background)');
|
|
434
|
+
case 2:
|
|
433
435
|
return _context4.a(2);
|
|
434
436
|
}
|
|
435
437
|
}, _callee4, this);
|
|
@@ -34,7 +34,7 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
34
34
|
* Initialize the CentralPlant manager
|
|
35
35
|
*
|
|
36
36
|
* @constructor
|
|
37
|
-
* @version 0.3.
|
|
37
|
+
* @version 0.3.57
|
|
38
38
|
* @updated 2025-10-22
|
|
39
39
|
*
|
|
40
40
|
* @description Creates a new CentralPlant instance and initializes internal managers and utilities.
|
|
@@ -2652,23 +2652,18 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
2652
2652
|
/**
|
|
2653
2653
|
* Initialize model preloading from component dictionary
|
|
2654
2654
|
* @param {string} [basePath='/library/'] - Base path for both dictionary and models (can be local path or S3 URL)
|
|
2655
|
-
* @
|
|
2656
|
-
* @
|
|
2657
|
-
* @
|
|
2658
|
-
* // Local files (default)
|
|
2659
|
-
* await centralPlant.initializeModelPreloading()
|
|
2660
|
-
*
|
|
2661
|
-
* // S3 bucket
|
|
2662
|
-
* await centralPlant.initializeModelPreloading('https://my-bucket.s3.amazonaws.com/library/')
|
|
2663
|
-
*
|
|
2664
|
-
* // Custom local path
|
|
2665
|
-
* await centralPlant.initializeModelPreloading('/custom/assets/')
|
|
2655
|
+
* @param {Object} [options={}] - Optimization options
|
|
2656
|
+
* @param {boolean} [options.autoPreloadModels=true] - If false, only loads the dictionary and skips preloading GLBs (improves initial load)
|
|
2657
|
+
* @returns {Promise<Object>} Preloading progress results or dictionary summary
|
|
2666
2658
|
*/
|
|
2667
2659
|
}, {
|
|
2668
2660
|
key: "initializeModelPreloading",
|
|
2669
2661
|
value: (function () {
|
|
2670
2662
|
var _initializeModelPreloading = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10() {
|
|
2671
2663
|
var basePath,
|
|
2664
|
+
options,
|
|
2665
|
+
_options$autoPreloadM,
|
|
2666
|
+
autoPreloadModels,
|
|
2672
2667
|
normalizedBasePath,
|
|
2673
2668
|
dictionaryPath,
|
|
2674
2669
|
modelsBasePath,
|
|
@@ -2682,6 +2677,8 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
2682
2677
|
while (1) switch (_context10.n) {
|
|
2683
2678
|
case 0:
|
|
2684
2679
|
basePath = _args10.length > 0 && _args10[0] !== undefined ? _args10[0] : '/library/';
|
|
2680
|
+
options = _args10.length > 1 && _args10[1] !== undefined ? _args10[1] : {};
|
|
2681
|
+
_options$autoPreloadM = options.autoPreloadModels, autoPreloadModels = _options$autoPreloadM === void 0 ? true : _options$autoPreloadM;
|
|
2685
2682
|
_context10.p = 1;
|
|
2686
2683
|
// Ensure basePath ends with a slash
|
|
2687
2684
|
normalizedBasePath = basePath.endsWith('/') ? basePath : "".concat(basePath, "/");
|
|
@@ -2691,6 +2688,7 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
2691
2688
|
console.log("\uD83D\uDCC2 Base path: ".concat(normalizedBasePath));
|
|
2692
2689
|
console.log("\uD83D\uDCDA Dictionary path: ".concat(dictionaryPath));
|
|
2693
2690
|
console.log("\uFFFD Models path: ".concat(modelsBasePath));
|
|
2691
|
+
console.log("\u26A1 Auto-preload models: ".concat(autoPreloadModels));
|
|
2694
2692
|
|
|
2695
2693
|
// Load the component dictionary
|
|
2696
2694
|
_context10.n = 2;
|
|
@@ -2707,25 +2705,39 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
2707
2705
|
return response.json();
|
|
2708
2706
|
case 4:
|
|
2709
2707
|
componentDictionary = _context10.v;
|
|
2710
|
-
console.log('📚 Component dictionary loaded:', Object.keys(componentDictionary));
|
|
2708
|
+
console.log('📚 Component dictionary loaded:', Object.keys(componentDictionary).length);
|
|
2711
2709
|
|
|
2712
|
-
//
|
|
2710
|
+
// Get the model preloader utility
|
|
2713
2711
|
_modelPreloader2 = this.getUtility('modelPreloader');
|
|
2714
|
-
|
|
2715
|
-
|
|
2712
|
+
if (autoPreloadModels) {
|
|
2713
|
+
_context10.n = 5;
|
|
2714
|
+
break;
|
|
2715
|
+
}
|
|
2716
|
+
console.log('⚡ Lazy loading enabled: skipping automatic GLB preloading');
|
|
2717
|
+
// We still need to give the preloader the dictionary and base path for later use
|
|
2718
|
+
_modelPreloader2.componentDictionary = componentDictionary;
|
|
2719
|
+
_modelPreloader2.setModelsBasePath(modelsBasePath);
|
|
2720
|
+
return _context10.a(2, {
|
|
2721
|
+
successCount: 0,
|
|
2722
|
+
failureCount: 0,
|
|
2723
|
+
dictionaryCount: Object.keys(componentDictionary).length
|
|
2724
|
+
});
|
|
2716
2725
|
case 5:
|
|
2726
|
+
_context10.n = 6;
|
|
2727
|
+
return _modelPreloader2.preloadAllModels(componentDictionary, modelsBasePath);
|
|
2728
|
+
case 6:
|
|
2717
2729
|
progress = _context10.v;
|
|
2718
2730
|
console.log('🎉 Model preloading completed:', progress);
|
|
2719
2731
|
return _context10.a(2, progress);
|
|
2720
|
-
case
|
|
2721
|
-
_context10.p =
|
|
2732
|
+
case 7:
|
|
2733
|
+
_context10.p = 7;
|
|
2722
2734
|
_t3 = _context10.v;
|
|
2723
2735
|
console.error('❌ Failed to initialize model preloading:', _t3);
|
|
2724
2736
|
throw _t3;
|
|
2725
|
-
case
|
|
2737
|
+
case 8:
|
|
2726
2738
|
return _context10.a(2);
|
|
2727
2739
|
}
|
|
2728
|
-
}, _callee10, this, [[1,
|
|
2740
|
+
}, _callee10, this, [[1, 7]]);
|
|
2729
2741
|
}));
|
|
2730
2742
|
function initializeModelPreloading() {
|
|
2731
2743
|
return _initializeModelPreloading.apply(this, arguments);
|
|
@@ -198,7 +198,7 @@ var CacheManager = /*#__PURE__*/function () {
|
|
|
198
198
|
key: "execute",
|
|
199
199
|
value: (function () {
|
|
200
200
|
var _execute = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(_ref) {
|
|
201
|
-
var cacheKey, sourceKey, expiryMs, fetcher, processor, _ref$metadata, metadata, cacheName, cache, cachedResponse, cachedTime, age, result, fetchResult, blobOrJson, contentType, contentSize, responseBody, headers, cacheResponse, fallbackResult, _t2;
|
|
201
|
+
var cacheKey, sourceKey, expiryMs, fetcher, processor, _ref$metadata, metadata, cacheName, cache, cachedResponse, cachedTime, age, result, fetchResult, blobOrJson, error, contentType, contentSize, responseBody, headers, cacheResponse, fallbackResult, _t2;
|
|
202
202
|
return _regenerator().w(function (_context4) {
|
|
203
203
|
while (1) switch (_context4.n) {
|
|
204
204
|
case 0:
|
|
@@ -251,7 +251,9 @@ var CacheManager = /*#__PURE__*/function () {
|
|
|
251
251
|
_context4.n = 9;
|
|
252
252
|
break;
|
|
253
253
|
}
|
|
254
|
-
|
|
254
|
+
error = new Error("Fetch failed: ".concat(fetchResult.status)); // Do not retry 404s - the file is genuinely missing
|
|
255
|
+
if (fetchResult.status === 404) error.noRetry = true;
|
|
256
|
+
throw error;
|
|
255
257
|
case 9:
|
|
256
258
|
_context4.n = 10;
|
|
257
259
|
return processor(fetchResult.clone());
|
|
@@ -302,20 +304,29 @@ var CacheManager = /*#__PURE__*/function () {
|
|
|
302
304
|
case 15:
|
|
303
305
|
fallbackResult = _context4.v;
|
|
304
306
|
if (!(fallbackResult instanceof Response)) {
|
|
307
|
+
_context4.n = 18;
|
|
308
|
+
break;
|
|
309
|
+
}
|
|
310
|
+
if (fallbackResult.ok) {
|
|
305
311
|
_context4.n = 16;
|
|
306
312
|
break;
|
|
307
313
|
}
|
|
308
|
-
|
|
314
|
+
throw new Error("Fallback fetch failed: ".concat(fallbackResult.status));
|
|
309
315
|
case 16:
|
|
310
|
-
|
|
316
|
+
_context4.n = 17;
|
|
317
|
+
return processor(fallbackResult);
|
|
311
318
|
case 17:
|
|
312
|
-
_context4.
|
|
319
|
+
return _context4.a(2, _context4.v);
|
|
320
|
+
case 18:
|
|
321
|
+
return _context4.a(2, fallbackResult);
|
|
322
|
+
case 19:
|
|
323
|
+
_context4.p = 19;
|
|
313
324
|
_context4.v;
|
|
314
325
|
throw _t2;
|
|
315
|
-
case
|
|
326
|
+
case 20:
|
|
316
327
|
return _context4.a(2);
|
|
317
328
|
}
|
|
318
|
-
}, _callee4, this, [[14,
|
|
329
|
+
}, _callee4, this, [[14, 19], [1, 13]]);
|
|
319
330
|
}));
|
|
320
331
|
function execute(_x2) {
|
|
321
332
|
return _execute.apply(this, arguments);
|
|
@@ -399,13 +399,15 @@ var EnvironmentManager = /*#__PURE__*/function () {
|
|
|
399
399
|
return this.createSkybox();
|
|
400
400
|
case 1:
|
|
401
401
|
this.setupLighting();
|
|
402
|
-
_context4.n = 2;
|
|
403
|
-
return this.addTexturedGround();
|
|
404
|
-
case 2:
|
|
405
|
-
// await this.addBrickWalls()
|
|
406
402
|
this.addHorizonFog();
|
|
407
|
-
|
|
408
|
-
|
|
403
|
+
|
|
404
|
+
// 2. Add ground (synchronously adds basic mesh)
|
|
405
|
+
// We do NOT await the texture loading here to speed up scene "Ready" state
|
|
406
|
+
this.addTexturedGround().catch(function (err) {
|
|
407
|
+
return console.warn('⚠️ Ground texture load failed:', err);
|
|
408
|
+
});
|
|
409
|
+
console.log('Environment initialization completed (textures loading in background)');
|
|
410
|
+
case 2:
|
|
409
411
|
return _context4.a(2);
|
|
410
412
|
}
|
|
411
413
|
}, _callee4, this);
|