@2112-lab/central-plant 0.1.71 → 0.1.72
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 +1332 -168
- package/dist/cjs/src/core/centralPlant.js +206 -154
- package/dist/cjs/src/index.js +5 -0
- package/dist/cjs/src/managers/CacheManager.js +1083 -0
- package/dist/cjs/src/managers/scene/modelManager.js +48 -12
- package/dist/cjs/src/managers/scene/sceneOperationsManager.js +2 -2
- package/dist/esm/src/core/centralPlant.js +206 -154
- package/dist/esm/src/index.js +1 -0
- package/dist/esm/src/managers/CacheManager.js +1075 -0
- package/dist/esm/src/managers/scene/modelManager.js +48 -12
- package/dist/esm/src/managers/scene/sceneOperationsManager.js +2 -2
- package/package.json +1 -1
|
@@ -382,7 +382,7 @@ var ModelManager = /*#__PURE__*/function () {
|
|
|
382
382
|
key: "preloadMissingModels",
|
|
383
383
|
value: (function () {
|
|
384
384
|
var _preloadMissingModels = _rollupPluginBabelHelpers.asyncToGenerator(/*#__PURE__*/_rollupPluginBabelHelpers.regenerator().m(function _callee4(data, componentDictionary) {
|
|
385
|
-
var _data$scene, _data$scene2, requiredModels, preloaderStatus, cachedModels, missingModels, _iterator, _step, modelKey, _t5, _t6;
|
|
385
|
+
var _data$scene, _data$scene2, requiredModels, preloaderStatus, cachedModels, missingModels, basePath, modelUrls, _iterator, _step, modelKey, _t5, _t6;
|
|
386
386
|
return _rollupPluginBabelHelpers.regenerator().w(function (_context4) {
|
|
387
387
|
while (1) switch (_context4.n) {
|
|
388
388
|
case 0:
|
|
@@ -399,25 +399,58 @@ var ModelManager = /*#__PURE__*/function () {
|
|
|
399
399
|
return _context4.a(2);
|
|
400
400
|
case 1:
|
|
401
401
|
requiredModels = new Set();
|
|
402
|
+
console.log("\uD83D\uDD0D Checking ".concat(data.scene.children.length, " scene objects for required models..."));
|
|
402
403
|
data.scene.children.forEach(function (child) {
|
|
403
|
-
var _child$userData
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
404
|
+
var _child$userData;
|
|
405
|
+
var libraryId = (_child$userData = child.userData) === null || _child$userData === void 0 ? void 0 : _child$userData.libraryId;
|
|
406
|
+
if (libraryId) {
|
|
407
|
+
if (componentDictionary[libraryId]) {
|
|
408
|
+
var modelKey = componentDictionary[libraryId].modelKey;
|
|
409
|
+
if (modelKey) {
|
|
410
|
+
requiredModels.add(modelKey);
|
|
411
|
+
// console.log(` Found required model for ${libraryId}: ${modelKey}`)
|
|
412
|
+
} else {
|
|
413
|
+
console.warn(" Item ".concat(libraryId, " has no modelKey in dictionary"));
|
|
414
|
+
}
|
|
415
|
+
} else {
|
|
416
|
+
console.warn(" Item ".concat(libraryId, " found in scene but missing from dictionary"));
|
|
409
417
|
}
|
|
410
418
|
}
|
|
411
419
|
});
|
|
412
|
-
console.log('🔍 Required models for this scene:', Array.from(requiredModels));
|
|
420
|
+
console.log('🔍 Required models for this scene (Set):', Array.from(requiredModels));
|
|
413
421
|
_context4.n = 2;
|
|
414
422
|
return this.verifyModelPreloaderCache();
|
|
415
423
|
case 2:
|
|
416
424
|
preloaderStatus = _context4.v;
|
|
417
425
|
cachedModels = preloaderStatus.cachedModels;
|
|
426
|
+
console.log('ModelPreloader cached models:', cachedModels);
|
|
427
|
+
|
|
428
|
+
// Calculate missing models for IN-MEMORY preloading
|
|
418
429
|
missingModels = Array.from(requiredModels).filter(function (model) {
|
|
419
430
|
return !cachedModels.includes(model);
|
|
420
431
|
});
|
|
432
|
+
console.log('Missing models (calculated):', missingModels);
|
|
433
|
+
|
|
434
|
+
// OPTIONAL: Prime persistent browser cache (Cache Storage) using injected primer
|
|
435
|
+
// We prime ALL required models to ensure they are in the persistent cache, even if already in memory
|
|
436
|
+
if (requiredModels.size > 0 && this.sceneViewer && this.sceneViewer.centralPlant) {
|
|
437
|
+
// Construct URLs based on preloader's base path
|
|
438
|
+
basePath = modelPreloader["default"].modelsBasePath || '/library/models/';
|
|
439
|
+
modelUrls = Array.from(requiredModels).map(function (key) {
|
|
440
|
+
return "".concat(basePath).concat(key);
|
|
441
|
+
});
|
|
442
|
+
console.log("\uD83D\uDCBE Priming persistent cache for ".concat(modelUrls.length, " assets..."));
|
|
443
|
+
this.sceneViewer.centralPlant.primeCache(modelUrls).then(function (result) {
|
|
444
|
+
if (result && !result.skipped) {
|
|
445
|
+
console.log("\u2705 Persistent cache primed: ".concat(result.success, " success, ").concat(result.failed, " failed"));
|
|
446
|
+
if (result.failed > 0) {
|
|
447
|
+
console.warn('Cache priming failures:', result.errors);
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
}).catch(function (err) {
|
|
451
|
+
return console.warn('Persistent cache priming failed:', err);
|
|
452
|
+
});
|
|
453
|
+
}
|
|
421
454
|
if (!(missingModels.length > 0)) {
|
|
422
455
|
_context4.n = 12;
|
|
423
456
|
break;
|
|
@@ -425,7 +458,7 @@ var ModelManager = /*#__PURE__*/function () {
|
|
|
425
458
|
console.warn('⚠️ Some required models are not cached:', missingModels);
|
|
426
459
|
console.log('🔄 Attempting to preload missing models...');
|
|
427
460
|
|
|
428
|
-
// Preload missing models
|
|
461
|
+
// Preload missing models (Main in-memory preloader)
|
|
429
462
|
_iterator = _rollupPluginBabelHelpers.createForOfIteratorHelper(missingModels);
|
|
430
463
|
_context4.p = 3;
|
|
431
464
|
_iterator.s();
|
|
@@ -560,19 +593,22 @@ var ModelManager = /*#__PURE__*/function () {
|
|
|
560
593
|
key: "loadComponentDictionary",
|
|
561
594
|
value: (function () {
|
|
562
595
|
var _loadComponentDictionary = _rollupPluginBabelHelpers.asyncToGenerator(/*#__PURE__*/_rollupPluginBabelHelpers.regenerator().m(function _callee6() {
|
|
563
|
-
var response, _t7;
|
|
596
|
+
var response, dict, _t7;
|
|
564
597
|
return _rollupPluginBabelHelpers.regenerator().w(function (_context6) {
|
|
565
598
|
while (1) switch (_context6.n) {
|
|
566
599
|
case 0:
|
|
567
600
|
_context6.p = 0;
|
|
601
|
+
console.log('🔄 ModelManager loading component dictionary...');
|
|
568
602
|
_context6.n = 1;
|
|
569
|
-
return fetch('
|
|
603
|
+
return fetch('/library/component-dictionary.json');
|
|
570
604
|
case 1:
|
|
571
605
|
response = _context6.v;
|
|
572
606
|
_context6.n = 2;
|
|
573
607
|
return response.json();
|
|
574
608
|
case 2:
|
|
575
|
-
|
|
609
|
+
dict = _context6.v;
|
|
610
|
+
console.log('✅ ModelManager loaded dictionary:', Object.keys(dict).length, 'entries');
|
|
611
|
+
return _context6.a(2, dict);
|
|
576
612
|
case 3:
|
|
577
613
|
_context6.p = 3;
|
|
578
614
|
_t7 = _context6.v;
|
|
@@ -1146,9 +1146,9 @@ var SceneOperationsManager = /*#__PURE__*/function () {
|
|
|
1146
1146
|
// Store current scene data even for default scene
|
|
1147
1147
|
component.currentSceneData = data;
|
|
1148
1148
|
|
|
1149
|
-
// Use the consolidated scene loading function
|
|
1149
|
+
// Use the consolidated scene loading function (treat as imported to ensure consistent behavior)
|
|
1150
1150
|
_context8.n = 4;
|
|
1151
|
-
return this.
|
|
1151
|
+
return this.loadSceneFromData(data);
|
|
1152
1152
|
case 4:
|
|
1153
1153
|
_context8.n = 6;
|
|
1154
1154
|
break;
|