@2112-lab/central-plant 0.3.15 → 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.
@@ -444,6 +444,22 @@ var PathfindingManager = /*#__PURE__*/function (_BaseDisposable) {
444
444
  this.pathfinder = new pathfinder.Pathfinder(this.pathfinderConfig);
445
445
  this.sceneViewer.pathfinder = this.pathfinder;
446
446
 
447
+ // ── Early exit if no connections ───────────────────────────────────
448
+ // Skip expensive bounding box computation when there's nothing to connect
449
+ if (!(!connections || connections.length === 0)) {
450
+ _context.n = 1;
451
+ break;
452
+ }
453
+ console.log("\u23ED\uFE0F Skipping pathfinding - no connections [".concat(context, "]"));
454
+ return _context.a(2, {
455
+ paths: [],
456
+ gateways: [],
457
+ rewiredConnections: [],
458
+ metrics: {
459
+ total: 0
460
+ }
461
+ });
462
+ case 1:
447
463
  // ── Stage 1: Input Generation ──────────────────────────────────────
448
464
  inputGenStart = performance.now(); // Ensure all matrices are up to date before bounding box calculations (for all pathfinding executions)
449
465
  this.sceneViewer.scene.updateMatrixWorld(true);
@@ -210,6 +210,7 @@ var ModelManager = /*#__PURE__*/function () {
210
210
  _context2.n = 1;
211
211
  break;
212
212
  }
213
+ console.log("\uD83C\uDFAF GLB cache HIT: ".concat(modelKey));
213
214
  return _context2.a(2, gltfScene);
214
215
  case 1:
215
216
  // Check if preloading is in progress
@@ -218,6 +219,7 @@ var ModelManager = /*#__PURE__*/function () {
218
219
  _context2.n = 6;
219
220
  break;
220
221
  }
222
+ console.log("\u23F3 Waiting for preloader: ".concat(modelKey));
221
223
  _context2.p = 2;
222
224
  _context2.n = 3;
223
225
  return modelPreloader["default"].preloadingPromise;
@@ -227,6 +229,7 @@ var ModelManager = /*#__PURE__*/function () {
227
229
  _context2.n = 4;
228
230
  break;
229
231
  }
232
+ console.log("\uD83C\uDFAF GLB cache HIT (after preload): ".concat(modelKey));
230
233
  return _context2.a(2, gltfScene);
231
234
  case 4:
232
235
  _context2.n = 6;
@@ -554,7 +557,7 @@ var ModelManager = /*#__PURE__*/function () {
554
557
  value: (function () {
555
558
  var _replaceWithGLBModels = _rollupPluginBabelHelpers.asyncToGenerator(/*#__PURE__*/_rollupPluginBabelHelpers.regenerator().m(function _callee5(libraryObjectsToReplace) {
556
559
  var _this3 = this;
557
- var glbLoadingPromises;
560
+ var startTime, glbLoadingPromises;
558
561
  return _rollupPluginBabelHelpers.regenerator().w(function (_context5) {
559
562
  while (1) switch (_context5.n) {
560
563
  case 0:
@@ -564,23 +567,29 @@ var ModelManager = /*#__PURE__*/function () {
564
567
  }
565
568
  return _context5.a(2);
566
569
  case 1:
570
+ startTime = performance.now();
567
571
  console.log("\uD83D\uDD04 Replacing ".concat(libraryObjectsToReplace.length, " objects with GLB models..."));
568
572
  glbLoadingPromises = libraryObjectsToReplace.map(function (_ref, index) {
569
573
  var basicObject = _ref.basicObject,
570
574
  jsonData = _ref.jsonData,
571
575
  componentData = _ref.componentData;
576
+ var modelStart = performance.now();
572
577
  return _this3.loadLibraryModel(basicObject, jsonData, componentData).then(function (libraryModel) {
578
+ var _jsonData$userData;
579
+ 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"));
573
580
  libraryObjectsToReplace[index].glbModel = libraryModel;
574
581
  return libraryModel;
575
582
  }).catch(function (error) {
576
- var _jsonData$userData;
577
- console.error("Failed to load ".concat((_jsonData$userData = jsonData.userData) === null || _jsonData$userData === void 0 ? void 0 : _jsonData$userData.libraryId, " GLB model:"), error);
583
+ var _jsonData$userData2;
584
+ console.error("Failed to load ".concat((_jsonData$userData2 = jsonData.userData) === null || _jsonData$userData2 === void 0 ? void 0 : _jsonData$userData2.libraryId, " GLB model:"), error);
578
585
  return basicObject;
579
586
  });
580
587
  });
581
588
  _context5.n = 2;
582
589
  return Promise.all(glbLoadingPromises);
583
590
  case 2:
591
+ console.log("\u23F1\uFE0F All GLB models loaded in ".concat((performance.now() - startTime).toFixed(0), "ms"));
592
+
584
593
  // Update world bounding boxes for loaded models and propagate to the live Three.js objects
585
594
  libraryObjectsToReplace.forEach(function (_ref2) {
586
595
  var jsonData = _ref2.jsonData,
@@ -704,9 +704,13 @@ var SceneOperationsManager = /*#__PURE__*/function () {
704
704
  value: (function () {
705
705
  var _loadSceneData = _rollupPluginBabelHelpers.asyncToGenerator(/*#__PURE__*/_rollupPluginBabelHelpers.regenerator().m(function _callee4(data) {
706
706
  var isImported,
707
+ timers,
708
+ totalStart,
709
+ phaseStart,
707
710
  _yield$this$_createBa,
708
711
  crosscubeTextureSet,
709
712
  libraryObjectsToReplace,
713
+ totalTime,
710
714
  _args4 = arguments,
711
715
  _t3;
712
716
  return _rollupPluginBabelHelpers.regenerator().w(function (_context4) {
@@ -714,13 +718,20 @@ var SceneOperationsManager = /*#__PURE__*/function () {
714
718
  case 0:
715
719
  isImported = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : true;
716
720
  this.sceneViewer;
721
+ timers = {};
722
+ totalStart = performance.now();
717
723
  _context4.p = 1;
718
724
  console.log("Loading scene data (".concat(isImported ? 'imported' : 'default', ")..."));
719
725
 
720
726
  // Phase 1: Prepare scene
727
+ phaseStart = performance.now();
721
728
  _context4.n = 2;
722
729
  return this._prepareSceneForLoading(data, isImported);
723
730
  case 2:
731
+ timers.phase1_prepare = performance.now() - phaseStart;
732
+
733
+ // Phase 2: Load dependencies and create basic objects
734
+ phaseStart = performance.now();
724
735
  _context4.n = 3;
725
736
  return this._createBasicSceneObjects(data);
726
737
  case 3:
@@ -730,17 +741,33 @@ var SceneOperationsManager = /*#__PURE__*/function () {
730
741
  _yield$this$_createBa.materials;
731
742
  crosscubeTextureSet = _yield$this$_createBa.crosscubeTextureSet;
732
743
  libraryObjectsToReplace = _yield$this$_createBa.libraryObjectsToReplace;
744
+ timers.phase2_createObjects = performance.now() - phaseStart;
745
+
746
+ // Phase 3: Replace basic objects with GLB models (moved before pathfinding)
747
+ phaseStart = performance.now();
733
748
  _context4.n = 4;
734
749
  return this.modelManager.replaceWithGLBModels(libraryObjectsToReplace);
735
750
  case 4:
751
+ timers.phase3_glbModels = performance.now() - phaseStart;
752
+
753
+ // Phase 4: Setup pathfinding (moved after GLB loading for consistent bounding boxes)
754
+ phaseStart = performance.now();
736
755
  _context4.n = 5;
737
756
  return this._setupPathfinding(data, crosscubeTextureSet);
738
757
  case 5:
758
+ timers.phase4_pathfinding = performance.now() - phaseStart;
759
+
739
760
  // Phase 5: Finalize scene
761
+ phaseStart = performance.now();
740
762
  this._finalizeScene(data, crosscubeTextureSet, isImported);
763
+ timers.phase5_finalize = performance.now() - phaseStart;
741
764
 
742
765
  // Phase 6: Load behaviors (after GLB models are present so output objects can be resolved)
766
+ phaseStart = performance.now();
743
767
  this._processBehaviors(data);
768
+ timers.phase6_behaviors = performance.now() - phaseStart;
769
+ totalTime = performance.now() - totalStart;
770
+ 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"));
744
771
  console.log('✅ Scene loaded successfully');
745
772
 
746
773
  // Notify UI components (e.g. SceneHierarchy) that the scene is fully loaded
@@ -5,6 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
6
6
  var THREE = require('three');
7
7
  var GLTFLoader = require('../../node_modules/three/examples/jsm/loaders/GLTFLoader.js');
8
+ var DRACOLoader = require('../../node_modules/three/examples/jsm/loaders/DRACOLoader.js');
8
9
 
9
10
  function _interopNamespace(e) {
10
11
  if (e && e.__esModule) return e;
@@ -32,13 +33,18 @@ var ModelPreloader = /*#__PURE__*/function () {
32
33
  this.modelCache = new Map(); // Cache for loaded models
33
34
  this.loadingPromises = new Map(); // Track ongoing loads to prevent duplicates
34
35
  this.gltfLoader = new GLTFLoader.GLTFLoader();
36
+
37
+ // Setup DRACO decoder for compressed GLB files
38
+ this.dracoLoader = new DRACOLoader.DRACOLoader();
39
+ this.dracoLoader.setDecoderPath('/draco/');
40
+ this.gltfLoader.setDRACOLoader(this.dracoLoader);
35
41
  this.isPreloading = false;
36
42
  this.preloadingPromise = null;
37
43
  this.componentDictionary = null;
38
44
  this.modelsBasePath = '/library/models/'; // Default local path
39
45
  this.urlResolver = null; // Optional function to resolve model URLs (for S3 authentication)
40
46
 
41
- console.log('🚀 ModelPreloader initialized with GLB support');
47
+ console.log('🚀 ModelPreloader initialized with GLB + DRACO support');
42
48
  }
43
49
 
44
50
  /**