@2112-lab/central-plant 0.3.16 → 0.3.17

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.
@@ -186,6 +186,7 @@ var ModelManager = /*#__PURE__*/function () {
186
186
  _context2.n = 1;
187
187
  break;
188
188
  }
189
+ console.log("\uD83C\uDFAF GLB cache HIT: ".concat(modelKey));
189
190
  return _context2.a(2, gltfScene);
190
191
  case 1:
191
192
  // Check if preloading is in progress
@@ -194,6 +195,7 @@ var ModelManager = /*#__PURE__*/function () {
194
195
  _context2.n = 6;
195
196
  break;
196
197
  }
198
+ console.log("\u23F3 Waiting for preloader: ".concat(modelKey));
197
199
  _context2.p = 2;
198
200
  _context2.n = 3;
199
201
  return modelPreloader.preloadingPromise;
@@ -203,6 +205,7 @@ var ModelManager = /*#__PURE__*/function () {
203
205
  _context2.n = 4;
204
206
  break;
205
207
  }
208
+ console.log("\uD83C\uDFAF GLB cache HIT (after preload): ".concat(modelKey));
206
209
  return _context2.a(2, gltfScene);
207
210
  case 4:
208
211
  _context2.n = 6;
@@ -530,7 +533,7 @@ var ModelManager = /*#__PURE__*/function () {
530
533
  value: (function () {
531
534
  var _replaceWithGLBModels = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(libraryObjectsToReplace) {
532
535
  var _this3 = this;
533
- var glbLoadingPromises;
536
+ var startTime, glbLoadingPromises;
534
537
  return _regenerator().w(function (_context5) {
535
538
  while (1) switch (_context5.n) {
536
539
  case 0:
@@ -540,23 +543,29 @@ var ModelManager = /*#__PURE__*/function () {
540
543
  }
541
544
  return _context5.a(2);
542
545
  case 1:
546
+ startTime = performance.now();
543
547
  console.log("\uD83D\uDD04 Replacing ".concat(libraryObjectsToReplace.length, " objects with GLB models..."));
544
548
  glbLoadingPromises = libraryObjectsToReplace.map(function (_ref, index) {
545
549
  var basicObject = _ref.basicObject,
546
550
  jsonData = _ref.jsonData,
547
551
  componentData = _ref.componentData;
552
+ var modelStart = performance.now();
548
553
  return _this3.loadLibraryModel(basicObject, jsonData, componentData).then(function (libraryModel) {
554
+ var _jsonData$userData;
555
+ console.log("\u23F1\uFE0F GLB loaded: ".concat(((_jsonData$userData = jsonData.userData) === null || _jsonData$userData === void 0 ? void 0 : _jsonData$userData.libraryId) || jsonData.uuid, " in ").concat((performance.now() - modelStart).toFixed(0), "ms"));
549
556
  libraryObjectsToReplace[index].glbModel = libraryModel;
550
557
  return libraryModel;
551
558
  }).catch(function (error) {
552
- var _jsonData$userData;
553
- console.error("Failed to load ".concat((_jsonData$userData = jsonData.userData) === null || _jsonData$userData === void 0 ? void 0 : _jsonData$userData.libraryId, " GLB model:"), error);
559
+ var _jsonData$userData2;
560
+ console.error("Failed to load ".concat((_jsonData$userData2 = jsonData.userData) === null || _jsonData$userData2 === void 0 ? void 0 : _jsonData$userData2.libraryId, " GLB model:"), error);
554
561
  return basicObject;
555
562
  });
556
563
  });
557
564
  _context5.n = 2;
558
565
  return Promise.all(glbLoadingPromises);
559
566
  case 2:
567
+ console.log("\u23F1\uFE0F All GLB models loaded in ".concat((performance.now() - startTime).toFixed(0), "ms"));
568
+
560
569
  // Update world bounding boxes for loaded models and propagate to the live Three.js objects
561
570
  libraryObjectsToReplace.forEach(function (_ref2) {
562
571
  var jsonData = _ref2.jsonData,
@@ -680,9 +680,13 @@ var SceneOperationsManager = /*#__PURE__*/function () {
680
680
  value: (function () {
681
681
  var _loadSceneData = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(data) {
682
682
  var isImported,
683
+ timers,
684
+ totalStart,
685
+ phaseStart,
683
686
  _yield$this$_createBa,
684
687
  crosscubeTextureSet,
685
688
  libraryObjectsToReplace,
689
+ totalTime,
686
690
  _args4 = arguments,
687
691
  _t3;
688
692
  return _regenerator().w(function (_context4) {
@@ -690,13 +694,20 @@ var SceneOperationsManager = /*#__PURE__*/function () {
690
694
  case 0:
691
695
  isImported = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : true;
692
696
  this.sceneViewer;
697
+ timers = {};
698
+ totalStart = performance.now();
693
699
  _context4.p = 1;
694
700
  console.log("Loading scene data (".concat(isImported ? 'imported' : 'default', ")..."));
695
701
 
696
702
  // Phase 1: Prepare scene
703
+ phaseStart = performance.now();
697
704
  _context4.n = 2;
698
705
  return this._prepareSceneForLoading(data, isImported);
699
706
  case 2:
707
+ timers.phase1_prepare = performance.now() - phaseStart;
708
+
709
+ // Phase 2: Load dependencies and create basic objects
710
+ phaseStart = performance.now();
700
711
  _context4.n = 3;
701
712
  return this._createBasicSceneObjects(data);
702
713
  case 3:
@@ -706,17 +717,33 @@ var SceneOperationsManager = /*#__PURE__*/function () {
706
717
  _yield$this$_createBa.materials;
707
718
  crosscubeTextureSet = _yield$this$_createBa.crosscubeTextureSet;
708
719
  libraryObjectsToReplace = _yield$this$_createBa.libraryObjectsToReplace;
720
+ timers.phase2_createObjects = performance.now() - phaseStart;
721
+
722
+ // Phase 3: Replace basic objects with GLB models (moved before pathfinding)
723
+ phaseStart = performance.now();
709
724
  _context4.n = 4;
710
725
  return this.modelManager.replaceWithGLBModels(libraryObjectsToReplace);
711
726
  case 4:
727
+ timers.phase3_glbModels = performance.now() - phaseStart;
728
+
729
+ // Phase 4: Setup pathfinding (moved after GLB loading for consistent bounding boxes)
730
+ phaseStart = performance.now();
712
731
  _context4.n = 5;
713
732
  return this._setupPathfinding(data, crosscubeTextureSet);
714
733
  case 5:
734
+ timers.phase4_pathfinding = performance.now() - phaseStart;
735
+
715
736
  // Phase 5: Finalize scene
737
+ phaseStart = performance.now();
716
738
  this._finalizeScene(data, crosscubeTextureSet, isImported);
739
+ timers.phase5_finalize = performance.now() - phaseStart;
717
740
 
718
741
  // Phase 6: Load behaviors (after GLB models are present so output objects can be resolved)
742
+ phaseStart = performance.now();
719
743
  this._processBehaviors(data);
744
+ timers.phase6_behaviors = performance.now() - phaseStart;
745
+ totalTime = performance.now() - totalStart;
746
+ console.log("\u23F1\uFE0F Scene Loading Performance:\n Phase 1 (Prepare) : ".concat(timers.phase1_prepare.toFixed(0), "ms\n Phase 2 (Create Objects): ").concat(timers.phase2_createObjects.toFixed(0), "ms\n Phase 3 (GLB Models) : ").concat(timers.phase3_glbModels.toFixed(0), "ms\n Phase 4 (Pathfinding) : ").concat(timers.phase4_pathfinding.toFixed(0), "ms\n Phase 5 (Finalize) : ").concat(timers.phase5_finalize.toFixed(0), "ms\n Phase 6 (Behaviors) : ").concat(timers.phase6_behaviors.toFixed(0), "ms\n \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n Total : ").concat(totalTime.toFixed(0), "ms"));
720
747
  console.log('✅ Scene loaded successfully');
721
748
 
722
749
  // Notify UI components (e.g. SceneHierarchy) that the scene is fully loaded
@@ -1,6 +1,7 @@
1
1
  import { createClass as _createClass, typeof as _typeof, classCallCheck as _classCallCheck, asyncToGenerator as _asyncToGenerator, regenerator as _regenerator } from '../../_virtual/_rollupPluginBabelHelpers.js';
2
2
  import * as THREE from 'three';
3
3
  import { GLTFLoader } from '../../node_modules/three/examples/jsm/loaders/GLTFLoader.js';
4
+ import { DRACOLoader } from '../../node_modules/three/examples/jsm/loaders/DRACOLoader.js';
4
5
 
5
6
  var ModelPreloader = /*#__PURE__*/function () {
6
7
  function ModelPreloader() {
@@ -8,13 +9,18 @@ var ModelPreloader = /*#__PURE__*/function () {
8
9
  this.modelCache = new Map(); // Cache for loaded models
9
10
  this.loadingPromises = new Map(); // Track ongoing loads to prevent duplicates
10
11
  this.gltfLoader = new GLTFLoader();
12
+
13
+ // Setup DRACO decoder for compressed GLB files
14
+ this.dracoLoader = new DRACOLoader();
15
+ this.dracoLoader.setDecoderPath('/draco/');
16
+ this.gltfLoader.setDRACOLoader(this.dracoLoader);
11
17
  this.isPreloading = false;
12
18
  this.preloadingPromise = null;
13
19
  this.componentDictionary = null;
14
20
  this.modelsBasePath = '/library/models/'; // Default local path
15
21
  this.urlResolver = null; // Optional function to resolve model URLs (for S3 authentication)
16
22
 
17
- console.log('🚀 ModelPreloader initialized with GLB support');
23
+ console.log('🚀 ModelPreloader initialized with GLB + DRACO support');
18
24
  }
19
25
 
20
26
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@2112-lab/central-plant",
3
- "version": "0.3.16",
3
+ "version": "0.3.17",
4
4
  "description": "Utility modules for the Central Plant Application",
5
5
  "main": "dist/bundle/index.js",
6
6
  "module": "dist/esm/src/index.js",