@2112-lab/central-plant 0.3.34 → 0.3.36

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 (28) hide show
  1. package/dist/bundle/index.js +632 -170
  2. package/dist/cjs/src/core/centralPlant.js +41 -17
  3. package/dist/cjs/src/core/centralPlantInternals.js +6 -2
  4. package/dist/cjs/src/core/sceneViewer.js +6 -24
  5. package/dist/cjs/src/managers/behaviors/IoBehaviorManager.js +510 -44
  6. package/dist/cjs/src/managers/cache/S3CacheService.js +2 -33
  7. package/dist/cjs/src/managers/cache/S3MetadataCacheService.js +0 -1
  8. package/dist/cjs/src/managers/components/componentDataManager.js +2 -6
  9. package/dist/cjs/src/managers/controls/transformControlsManager.js +32 -10
  10. package/dist/cjs/src/managers/scene/modelManager.js +11 -5
  11. package/dist/cjs/src/managers/scene/sceneExportManager.js +10 -3
  12. package/dist/cjs/src/managers/scene/sceneOperationsManager.js +11 -3
  13. package/dist/cjs/src/rendering/modelPreloader.js +1 -17
  14. package/dist/cjs/src/utils/ioDeviceUtils.js +0 -5
  15. package/dist/esm/src/core/centralPlant.js +41 -17
  16. package/dist/esm/src/core/centralPlantInternals.js +6 -2
  17. package/dist/esm/src/core/sceneViewer.js +6 -24
  18. package/dist/esm/src/managers/behaviors/IoBehaviorManager.js +511 -45
  19. package/dist/esm/src/managers/cache/S3CacheService.js +2 -33
  20. package/dist/esm/src/managers/cache/S3MetadataCacheService.js +0 -1
  21. package/dist/esm/src/managers/components/componentDataManager.js +2 -6
  22. package/dist/esm/src/managers/controls/transformControlsManager.js +32 -10
  23. package/dist/esm/src/managers/scene/modelManager.js +11 -5
  24. package/dist/esm/src/managers/scene/sceneExportManager.js +10 -3
  25. package/dist/esm/src/managers/scene/sceneOperationsManager.js +11 -3
  26. package/dist/esm/src/rendering/modelPreloader.js +1 -17
  27. package/dist/esm/src/utils/ioDeviceUtils.js +0 -5
  28. package/package.json +1 -1
@@ -770,7 +770,6 @@ function _findInAllCachePartitions() {
770
770
  _context16.n = 7;
771
771
  break;
772
772
  }
773
- console.log("\u2705 [findInAllCachePartitions] Found in ".concat(cacheName, " (exact match): ").concat(cacheKey.substring(0, 80), "..."));
774
773
  return _context16.a(2, response);
775
774
  case 7:
776
775
  if (!(encodedCacheKey !== cacheKey)) {
@@ -785,7 +784,6 @@ function _findInAllCachePartitions() {
785
784
  _context16.n = 9;
786
785
  break;
787
786
  }
788
- console.log("\u2705 [findInAllCachePartitions] Found in ".concat(cacheName, " (encoded match): ").concat(encodedCacheKey.substring(0, 80), "..."));
789
787
  return _context16.a(2, response);
790
788
  case 9:
791
789
  _context16.n = 4;
@@ -820,8 +818,6 @@ function _getCachedS3Object() {
820
818
  cachedResponse,
821
819
  cachedTime,
822
820
  age,
823
- _allKeys,
824
- matchingKeys,
825
821
  _args19 = arguments;
826
822
  return _rollupPluginBabelHelpers.regenerator().w(function (_context19) {
827
823
  while (1) switch (_context19.n) {
@@ -829,50 +825,26 @@ function _getCachedS3Object() {
829
825
  storageOptions = _args19.length > 1 && _args19[1] !== undefined ? _args19[1] : {};
830
826
  expiryMs = _args19.length > 2 && _args19[2] !== undefined ? _args19[2] : null;
831
827
  cacheKey = "https://s3.cache/".concat(s3Key);
832
- expiry = expiryMs || CacheManager.cacheManager.getExpiryForPath(s3Key);
833
- console.log("\uD83D\uDD0D [S3Cache] Checking for cached S3 object:", {
834
- s3Key: s3Key,
835
- cacheKey: cacheKey
836
- });
837
-
838
- // First, check ALL app cache partitions for a hit (handles auth race condition)
828
+ expiry = expiryMs || CacheManager.cacheManager.getExpiryForPath(s3Key); // First, check ALL app cache partitions for a hit (handles auth race condition)
839
829
  _context19.n = 1;
840
830
  return findInAllCachePartitions(cacheKey);
841
831
  case 1:
842
832
  cachedResponse = _context19.v;
843
833
  if (!cachedResponse) {
844
- _context19.n = 4;
834
+ _context19.n = 3;
845
835
  break;
846
836
  }
847
837
  cachedTime = cachedResponse.headers.get('x-cached-time');
848
838
  age = Date.now() - parseInt(cachedTime || '0');
849
- console.log("\u2705 [S3Cache] Found in cache partition, age: ".concat(Math.round(age / 1000), "s, expiry: ").concat(Math.round(expiry / 1000), "s"));
850
839
  if (!(age < expiry)) {
851
840
  _context19.n = 3;
852
841
  break;
853
842
  }
854
- console.log("\u2705 [S3Cache] Returning cached blob for: ".concat(s3Key));
855
843
  _context19.n = 2;
856
844
  return cachedResponse.blob();
857
845
  case 2:
858
846
  return _context19.a(2, _context19.v);
859
847
  case 3:
860
- console.log("\u23F0 [S3Cache] Cache entry expired, will re-fetch");
861
- _context19.n = 6;
862
- break;
863
- case 4:
864
- console.log("\u274C [S3Cache] Not found in any cache partition");
865
- _context19.n = 5;
866
- return getAllCacheKeys();
867
- case 5:
868
- _allKeys = _context19.v;
869
- matchingKeys = _rollupPluginBabelHelpers.toConsumableArray(_allKeys).filter(function (k) {
870
- return k.includes('24dd6a7a') || k.includes('.glb');
871
- });
872
- if (matchingKeys.length > 0) {
873
- console.log("\uD83D\uDD0D [S3Cache] Available GLB cache keys:", matchingKeys.slice(0, 5));
874
- }
875
- case 6:
876
848
  return _context19.a(2, CacheManager.cacheManager.execute({
877
849
  cacheKey: cacheKey,
878
850
  sourceKey: s3Key,
@@ -1031,7 +1003,6 @@ function _preloadS3Objects() {
1031
1003
  };
1032
1004
  }()));
1033
1005
  case 1:
1034
- console.log("\u2705 Preload complete: ".concat(results.success, " success, ").concat(results.failed, " failed"));
1035
1006
  return _context22.a(2, results);
1036
1007
  }
1037
1008
  }, _callee22);
@@ -1209,7 +1180,6 @@ function _preloadLocalFiles() {
1209
1180
  return _rollupPluginBabelHelpers.regenerator().w(function (_context29) {
1210
1181
  while (1) switch (_context29.n) {
1211
1182
  case 0:
1212
- console.log("preloadLocalFiles started");
1213
1183
  results = {
1214
1184
  success: 0,
1215
1185
  failed: 0,
@@ -1248,7 +1218,6 @@ function _preloadLocalFiles() {
1248
1218
  };
1249
1219
  }()));
1250
1220
  case 1:
1251
- console.log("preloadLocalFiles finished");
1252
1221
  if (results.failed > 0) {
1253
1222
  console.warn("\u26A0\uFE0F preloadLocalFiles Cache priming finished with errors: ".concat(results.failed, " failed"), results.errors);
1254
1223
  }
@@ -473,7 +473,6 @@ var S3MetadataCacheService = /*#__PURE__*/function () {
473
473
  // Update memory cache
474
474
  this._memoryCache = metadata;
475
475
  this._memoryCacheTime = Date.now();
476
- console.log("\uD83D\uDCBE S3MetadataCacheService: Set ".concat(components.length, " components"));
477
476
  return _context9.a(2, true);
478
477
  case 4:
479
478
  _context9.p = 4;
@@ -344,7 +344,7 @@ var ComponentDataManager = /*#__PURE__*/function (_BaseDisposable) {
344
344
  value: (function () {
345
345
  var _extendComponentDictionary = _rollupPluginBabelHelpers.asyncToGenerator(/*#__PURE__*/_rollupPluginBabelHelpers.regenerator().m(function _callee3(additionalComponents) {
346
346
  var _this3 = this;
347
- var _this$sceneViewer, newComponents, skippedCount, addedCount, modelPreloader, _t;
347
+ var _this$sceneViewer, newComponents, modelPreloader, _t;
348
348
  return _rollupPluginBabelHelpers.regenerator().w(function (_context3) {
349
349
  while (1) switch (_context3.n) {
350
350
  case 0:
@@ -368,7 +368,6 @@ var ComponentDataManager = /*#__PURE__*/function (_BaseDisposable) {
368
368
  _context3.p = 3;
369
369
  // Filter out components that already exist in the dictionary (deduplication)
370
370
  newComponents = {};
371
- skippedCount = 0;
372
371
  Object.entries(additionalComponents).forEach(function (_ref3) {
373
372
  var _ref4 = _rollupPluginBabelHelpers.slicedToArray(_ref3, 2),
374
373
  key = _ref4[0],
@@ -376,13 +375,12 @@ var ComponentDataManager = /*#__PURE__*/function (_BaseDisposable) {
376
375
  if (!_this3.componentDictionary[key]) {
377
376
  newComponents[key] = component;
378
377
  } else {
379
- skippedCount++;
380
378
  console.log("\u26A0\uFE0F Skipping duplicate component: ".concat(key, " (").concat(component.name || 'unnamed', ")"));
381
379
  }
382
380
  });
383
381
 
384
382
  // Merge only new components into dictionary
385
- addedCount = Object.keys(newComponents).length;
383
+ Object.keys(newComponents).length;
386
384
  Object.assign(this.componentDictionary, newComponents);
387
385
 
388
386
  // Update ModelPreloader's dictionary reference
@@ -390,12 +388,10 @@ var ComponentDataManager = /*#__PURE__*/function (_BaseDisposable) {
390
388
  modelPreloader = (_this$sceneViewer = this.sceneViewer) === null || _this$sceneViewer === void 0 || (_this$sceneViewer = _this$sceneViewer.centralPlant) === null || _this$sceneViewer === void 0 || (_this$sceneViewer = _this$sceneViewer.utilities) === null || _this$sceneViewer === void 0 ? void 0 : _this$sceneViewer.modelPreloader;
391
389
  if (modelPreloader) {
392
390
  modelPreloader.componentDictionary = this.componentDictionary;
393
- console.log("\uD83D\uDD04 Updated ModelPreloader's dictionary reference (".concat(Object.keys(this.componentDictionary).length, " total components)"));
394
391
  }
395
392
 
396
393
  // Clear cache to force refresh
397
394
  this.clearCache();
398
- console.log("\u2705 extendComponentDictionary(): Added ".concat(addedCount, " new components (").concat(skippedCount, " duplicates skipped)"));
399
395
  return _context3.a(2, true);
400
396
  case 4:
401
397
  _context3.p = 4;
@@ -463,6 +463,7 @@ var TransformControlsManager = /*#__PURE__*/function () {
463
463
  // Detect pointerdown on an IO device mesh and convert a drag gesture into
464
464
  // state changes. Up/right = positive direction, down/left = negative.
465
465
  this.eventHandlers.pointerdown = function (event) {
466
+ var _ioDeviceObject$userD, _this4$sceneViewer;
466
467
  if (_this4.transformState.isTransforming) return;
467
468
  if (!_this4.callbacks.onIODeviceDrag) return;
468
469
  _this4._calculateMousePosition(event, mouse);
@@ -475,14 +476,14 @@ var TransformControlsManager = /*#__PURE__*/function () {
475
476
  try {
476
477
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
477
478
  var hit = _step.value;
478
- var obj = hit.object;
479
- while (obj) {
480
- var _obj$userData;
481
- if (((_obj$userData = obj.userData) === null || _obj$userData === void 0 ? void 0 : _obj$userData.objectType) === 'io-device') {
482
- ioDeviceObject = obj;
479
+ var _obj = hit.object;
480
+ while (_obj) {
481
+ var _obj$userData2;
482
+ if (((_obj$userData2 = _obj.userData) === null || _obj$userData2 === void 0 ? void 0 : _obj$userData2.objectType) === 'io-device') {
483
+ ioDeviceObject = _obj;
483
484
  break;
484
485
  }
485
- obj = obj.parent;
486
+ _obj = _obj.parent;
486
487
  }
487
488
  if (ioDeviceObject) {
488
489
  hitMesh = hit.object;
@@ -496,6 +497,27 @@ var TransformControlsManager = /*#__PURE__*/function () {
496
497
  }
497
498
  if (!ioDeviceObject) return;
498
499
 
500
+ // Only allow drag if the clicked mesh is animated (not the parent io-device group)
501
+ // Resolve parentUuid and attachmentId
502
+ var parentUuid = null;
503
+ var obj = ioDeviceObject.parent;
504
+ while (obj) {
505
+ var _obj$userData;
506
+ if (((_obj$userData = obj.userData) === null || _obj$userData === void 0 ? void 0 : _obj$userData.objectType) === 'component') {
507
+ parentUuid = obj.userData.originalUuid || obj.uuid;
508
+ break;
509
+ }
510
+ obj = obj.parent;
511
+ }
512
+ var attachmentId = (_ioDeviceObject$userD = ioDeviceObject.userData) === null || _ioDeviceObject$userD === void 0 ? void 0 : _ioDeviceObject$userD.attachmentId;
513
+ if (parentUuid && attachmentId && (_this4$sceneViewer = _this4.sceneViewer) !== null && _this4$sceneViewer !== void 0 && (_this4$sceneViewer = _this4$sceneViewer.managers) !== null && _this4$sceneViewer !== void 0 && _this4$sceneViewer.ioBehaviorManager) {
514
+ var animatedMeshes = _this4.sceneViewer.managers.ioBehaviorManager.getAnimatedMeshes(parentUuid, attachmentId);
515
+ // If there are animated meshes registered, only allow drag if hitMesh is one of them
516
+ if (animatedMeshes.length > 0 && !animatedMeshes.includes(hitMesh)) {
517
+ return; // Clicked on non-draggable part of the io-device
518
+ }
519
+ }
520
+
499
521
  // Begin session
500
522
  _this4._ioDragMesh = ioDeviceObject;
501
523
  _this4._ioDragStartX = event.clientX;
@@ -558,8 +580,8 @@ var TransformControlsManager = /*#__PURE__*/function () {
558
580
  var hit = _step2.value;
559
581
  var obj = hit.object;
560
582
  while (obj) {
561
- var _obj$userData2;
562
- if (((_obj$userData2 = obj.userData) === null || _obj$userData2 === void 0 ? void 0 : _obj$userData2.objectType) === 'io-device') {
583
+ var _obj$userData3;
584
+ if (((_obj$userData3 = obj.userData) === null || _obj$userData3 === void 0 ? void 0 : _obj$userData3.objectType) === 'io-device') {
563
585
  _this4.callbacks.onIODeviceClick(obj);
564
586
  return;
565
587
  }
@@ -2219,8 +2241,8 @@ var TransformControlsManager = /*#__PURE__*/function () {
2219
2241
  key: "_updateSegmentReference",
2220
2242
  value: function _updateSegmentReference(oldSegment, newSegment, index) {
2221
2243
  var selectedIndex = this.selectedObjects.findIndex(function (obj) {
2222
- var _obj$userData3;
2223
- return obj.uuid === oldSegment.uuid || ((_obj$userData3 = obj.userData) === null || _obj$userData3 === void 0 ? void 0 : _obj$userData3.originalUuid) === oldSegment.uuid;
2244
+ var _obj$userData4;
2245
+ return obj.uuid === oldSegment.uuid || ((_obj$userData4 = obj.userData) === null || _obj$userData4 === void 0 ? void 0 : _obj$userData4.originalUuid) === oldSegment.uuid;
2224
2246
  });
2225
2247
  if (selectedIndex !== -1 && newSegment) {
2226
2248
  // Clear bounding box cache
@@ -114,7 +114,7 @@ var ModelManager = /*#__PURE__*/function () {
114
114
 
115
115
  // Attach IO devices for smart components (import flow)
116
116
  if (!(componentData.isSmart && componentData.attachedDevices)) {
117
- _context2.n = 8;
117
+ _context2.n = 9;
118
118
  break;
119
119
  }
120
120
  _context2.n = 4;
@@ -123,7 +123,7 @@ var ModelManager = /*#__PURE__*/function () {
123
123
  // Register behavior configs for each attached device
124
124
  ioBehavMgr = (_this$sceneViewer = this.sceneViewer) === null || _this$sceneViewer === void 0 || (_this$sceneViewer = _this$sceneViewer.managers) === null || _this$sceneViewer === void 0 ? void 0 : _this$sceneViewer.ioBehaviorManager;
125
125
  if (!ioBehavMgr) {
126
- _context2.n = 8;
126
+ _context2.n = 9;
127
127
  break;
128
128
  }
129
129
  _loop = /*#__PURE__*/_rollupPluginBabelHelpers.regenerator().m(function _loop() {
@@ -172,6 +172,12 @@ var ModelManager = /*#__PURE__*/function () {
172
172
  _context2.n = 5;
173
173
  break;
174
174
  case 8:
175
+ // Register component-level behaviors (intra-component io-device linking)
176
+ if (componentData.behaviors && componentData.behaviors.length > 0) {
177
+ console.log("[ModelManager] Registering ".concat(componentData.behaviors.length, " component-level behavior(s) for ").concat(originalProps.uuid));
178
+ ioBehavMgr.registerComponentBehaviors(originalProps.uuid, componentData.behaviors);
179
+ }
180
+ case 9:
175
181
  // Replace mesh in scene
176
182
  this._replaceMeshInScene(targetMesh, libraryModel, originalProps.parent, component);
177
183
 
@@ -190,13 +196,13 @@ var ModelManager = /*#__PURE__*/function () {
190
196
  }
191
197
  console.log("\uD83C\uDF89 ".concat((_jsonEntry$userData3 = jsonEntry.userData) === null || _jsonEntry$userData3 === void 0 ? void 0 : _jsonEntry$userData3.libraryId, " GLB model successfully rendered in scene"));
192
198
  return _context2.a(2, libraryModel);
193
- case 9:
194
- _context2.p = 9;
199
+ case 10:
200
+ _context2.p = 10;
195
201
  _t = _context2.v;
196
202
  console.error("\u274C Error loading ".concat((_jsonEntry$userData4 = jsonEntry.userData) === null || _jsonEntry$userData4 === void 0 ? void 0 : _jsonEntry$userData4.libraryId, " GLB model:"), _t);
197
203
  return _context2.a(2, targetMesh);
198
204
  }
199
- }, _callee, this, [[1, 9]]);
205
+ }, _callee, this, [[1, 10]]);
200
206
  }));
201
207
  function loadLibraryModel(_x, _x2, _x3) {
202
208
  return _loadLibraryModel.apply(this, arguments);
@@ -77,7 +77,8 @@ var SceneExportManager = /*#__PURE__*/function () {
77
77
  }, {
78
78
  key: "exportSceneData",
79
79
  value: function exportSceneData() {
80
- var _this = this;
80
+ var _this = this,
81
+ _this$sceneViewer$cur2;
81
82
  console.log('📤 Starting scene export...');
82
83
  if (!this.sceneViewer.scene) {
83
84
  console.warn('⚠️ No scene available for export');
@@ -289,6 +290,12 @@ var SceneExportManager = /*#__PURE__*/function () {
289
290
  children: sceneChildren
290
291
  }
291
292
  };
293
+
294
+ // Preserve cross-component behaviors authored in the Behavior window
295
+ var sceneBehaviors = (_this$sceneViewer$cur2 = this.sceneViewer.currentSceneData) === null || _this$sceneViewer$cur2 === void 0 ? void 0 : _this$sceneViewer$cur2.behaviors;
296
+ if (sceneBehaviors && sceneBehaviors.length > 0) {
297
+ exportData.behaviors = sceneBehaviors;
298
+ }
292
299
  console.log('✅ Scene export completed:', exportData);
293
300
  console.log("\uD83D\uDCCA Exported ".concat(sceneChildren.length, " components and ").concat(exportData.connections.length, " connections"));
294
301
  return exportData;
@@ -354,7 +361,7 @@ var SceneExportManager = /*#__PURE__*/function () {
354
361
  }, {
355
362
  key: "getExportMetadata",
356
363
  value: function getExportMetadata() {
357
- var _this$sceneViewer$cur2;
364
+ var _this$sceneViewer$cur3;
358
365
  if (!this.sceneViewer.scene) {
359
366
  return null;
360
367
  }
@@ -365,7 +372,7 @@ var SceneExportManager = /*#__PURE__*/function () {
365
372
  return {
366
373
  totalObjects: objectCount,
367
374
  hasCurrentSceneData: !!this.sceneViewer.currentSceneData,
368
- connectionsCount: ((_this$sceneViewer$cur2 = this.sceneViewer.currentSceneData) === null || _this$sceneViewer$cur2 === void 0 || (_this$sceneViewer$cur2 = _this$sceneViewer$cur2.connections) === null || _this$sceneViewer$cur2 === void 0 ? void 0 : _this$sceneViewer$cur2.length) || 0,
375
+ connectionsCount: ((_this$sceneViewer$cur3 = this.sceneViewer.currentSceneData) === null || _this$sceneViewer$cur3 === void 0 || (_this$sceneViewer$cur3 = _this$sceneViewer$cur3.connections) === null || _this$sceneViewer$cur3 === void 0 ? void 0 : _this$sceneViewer$cur3.length) || 0,
369
376
  exportTimestamp: new Date().toISOString()
370
377
  };
371
378
  }
@@ -792,7 +792,7 @@ var SceneOperationsManager = /*#__PURE__*/function () {
792
792
  key: "_prepareSceneForLoading",
793
793
  value: (function () {
794
794
  var _prepareSceneForLoading2 = _rollupPluginBabelHelpers.asyncToGenerator(/*#__PURE__*/_rollupPluginBabelHelpers.regenerator().m(function _callee5(data, isImported) {
795
- var component, _component$managers;
795
+ var component, _component$managers, _component$managers2, ioBehavMgr;
796
796
  return _rollupPluginBabelHelpers.regenerator().w(function (_context5) {
797
797
  while (1) switch (_context5.n) {
798
798
  case 0:
@@ -809,6 +809,16 @@ var SceneOperationsManager = /*#__PURE__*/function () {
809
809
  if ((_component$managers = component.managers) !== null && _component$managers !== void 0 && (_component$managers = _component$managers.pathfinding) !== null && _component$managers !== void 0 && _component$managers.snapshotManager) {
810
810
  component.managers.pathfinding.snapshotManager.reset();
811
811
  }
812
+
813
+ // Register behaviors with IoBehaviorManager
814
+ ioBehavMgr = (_component$managers2 = component.managers) === null || _component$managers2 === void 0 ? void 0 : _component$managers2.ioBehaviorManager;
815
+ if (ioBehavMgr && data.behaviors) {
816
+ console.log("[Behavior] Registering ".concat(data.behaviors.length, " behavior(s) from scene data"));
817
+ ioBehavMgr.setCrossComponentBehaviors(data.behaviors);
818
+ } else if (ioBehavMgr) {
819
+ console.log('[Behavior] No behaviors in scene data, clearing cross-component behaviors');
820
+ ioBehavMgr.setCrossComponentBehaviors([]);
821
+ }
812
822
  case 2:
813
823
  // Mark all imported objects as declared in the scene data
814
824
  // This ensures manual segment connectors and other objects are recognized as declared
@@ -887,7 +897,6 @@ var SceneOperationsManager = /*#__PURE__*/function () {
887
897
 
888
898
  // Check if dictionary has connector children and component doesn't already have them
889
899
  if (dictEntry !== null && dictEntry !== void 0 && dictEntry.children && Array.isArray(dictEntry.children) && dictEntry.children.length > 0) {
890
- // Only inject if the component doesn't already have children
891
900
  if (!child.children || child.children.length === 0) {
892
901
  // Get component rotation (in degrees from JSON)
893
902
  var rotation = child.rotation || {
@@ -917,7 +926,6 @@ var SceneOperationsManager = /*#__PURE__*/function () {
917
926
  connectorsInjected++;
918
927
  return clonedConnector;
919
928
  });
920
- console.log("\uD83D\uDD0C Injected ".concat(child.children.length, " connectors for ").concat(child.uuid, " (").concat(libraryId, ") with rotation [").concat(rotation.x, "\xB0, ").concat(rotation.y, "\xB0, ").concat(rotation.z, "\xB0]"));
921
929
  componentsProcessed++;
922
930
  }
923
931
  }
@@ -204,17 +204,14 @@ var ModelPreloader = /*#__PURE__*/function () {
204
204
  _context3.n = 1;
205
205
  break;
206
206
  }
207
- console.log("\uD83C\uDFAF Model ".concat(modelKey, " already cached, skipping"));
208
207
  return _context3.a(2, this.modelCache.get(modelKey));
209
208
  case 1:
210
209
  if (!this.loadingPromises.has(modelKey)) {
211
210
  _context3.n = 2;
212
211
  break;
213
212
  }
214
- console.log("\u23F3 Model ".concat(modelKey, " already loading, waiting for completion"));
215
213
  return _context3.a(2, this.loadingPromises.get(modelKey));
216
214
  case 2:
217
- console.log("\uD83D\uDD04 Starting preload of GLB model: ".concat(modelKey));
218
215
  loadPromise = new Promise(/*#__PURE__*/function () {
219
216
  var _ref = _rollupPluginBabelHelpers.asyncToGenerator(/*#__PURE__*/_rollupPluginBabelHelpers.regenerator().m(function _callee2(resolve, reject) {
220
217
  var modelPath, _t;
@@ -230,7 +227,6 @@ var ModelPreloader = /*#__PURE__*/function () {
230
227
  return _this2.urlResolver(modelKey);
231
228
  case 2:
232
229
  modelPath = _context2.v;
233
- console.log("\uD83D\uDD17 Resolved URL for ".concat(modelKey, ":"), modelPath.substring(0, 100) + '...');
234
230
  _context2.n = 4;
235
231
  break;
236
232
  case 3:
@@ -244,11 +240,9 @@ var ModelPreloader = /*#__PURE__*/function () {
244
240
  break;
245
241
  case 5:
246
242
  modelPath = "".concat(_this2.modelsBasePath).concat(modelKey);
247
- console.log("\uD83D\uDCC2 Loading from: ".concat(modelPath));
248
243
  case 6:
249
244
  // Load GLB model
250
245
  _this2.gltfLoader.load(modelPath, function (gltf) {
251
- console.log("\u2705 Successfully preloaded GLB model: ".concat(modelKey));
252
246
  // Cache the scene for future use
253
247
  _this2.modelCache.set(modelKey, gltf.scene);
254
248
 
@@ -267,13 +261,6 @@ var ModelPreloader = /*#__PURE__*/function () {
267
261
  resolve(gltf.scene);
268
262
  }, function (progress) {
269
263
  // Optional: track loading progress
270
- if (progress.lengthComputable) {
271
- var percentage = progress.loaded / progress.total * 100;
272
- if (percentage % 25 === 0) {
273
- // Log every 25%
274
- console.log("\uD83D\uDCCA Loading GLB ".concat(modelKey, ": ").concat(percentage.toFixed(0), "%"));
275
- }
276
- }
277
264
  }, function (error) {
278
265
  console.error("\u274C Failed to preload GLB model ".concat(modelKey, ":"), error);
279
266
  // Remove from loading promises
@@ -311,13 +298,10 @@ var ModelPreloader = /*#__PURE__*/function () {
311
298
  value: function getCachedModel(modelKey) {
312
299
  var useIndexedGeometry = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
313
300
  if (this.modelCache.has(modelKey)) {
314
- console.log("\uD83C\uDFAF Returning cached model: ".concat(modelKey));
315
301
  var cachedData = this.modelCache.get(modelKey);
316
302
 
317
303
  // Handle OBJ models with processed geometry
318
304
  if (cachedData && cachedData.isObjModel && useIndexedGeometry && cachedData.processedGeometry) {
319
- console.log("\uD83D\uDD27 Using indexed BufferGeometry for OBJ: ".concat(modelKey));
320
-
321
305
  // Create a mesh from the processed indexed geometry
322
306
  var mesh = new THREE__namespace.Mesh(cachedData.processedGeometry.clone(), cachedData.materials.clone());
323
307
 
@@ -553,7 +537,7 @@ var ModelPreloader = /*#__PURE__*/function () {
553
537
  }
554
538
 
555
539
  // Model not cached, need to load it
556
- console.log("\uD83D\uDD04 Loading model for library ID ".concat(libraryId, ": ").concat(modelKey));
540
+ // Loading model for library ID
557
541
  this.preloadSingleModel(modelKey).then(function (model) {
558
542
  if (model) {
559
543
  var _clonedModel = model.clone();
@@ -61,7 +61,6 @@ function _attachIODevicesToComponent() {
61
61
  _context.n = 10;
62
62
  break;
63
63
  }
64
- console.log("\uD83D\uDD04 IO device model not in cache, preloading: ".concat(deviceData.modelKey));
65
64
  _context.p = 5;
66
65
  if (!((_modelPreloader$loadi = modelPreloader.loadingPromises) !== null && _modelPreloader$loadi !== void 0 && _modelPreloader$loadi.has(deviceData.modelKey))) {
67
66
  _context.n = 7;
@@ -143,10 +142,6 @@ function _attachIODevicesToComponent() {
143
142
 
144
143
  // Add as child of the component
145
144
  componentModel.add(deviceModel);
146
- console.log("\u2705 Attached IO device: ".concat(attachment.attachmentLabel || attachment.deviceId, " at"), {
147
- position: deviceModel.position,
148
- scale: deviceModel.scale
149
- });
150
145
  _context.n = 13;
151
146
  break;
152
147
  case 12:
@@ -31,7 +31,7 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
31
31
  * Initialize the CentralPlant manager
32
32
  *
33
33
  * @constructor
34
- * @version 0.3.34
34
+ * @version 0.3.36
35
35
  * @updated 2025-10-22
36
36
  *
37
37
  * @description Creates a new CentralPlant instance and initializes internal managers and utilities.
@@ -205,7 +205,8 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
205
205
  key: "setImportedSceneData",
206
206
  value: (function () {
207
207
  var _setImportedSceneData = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(sceneData) {
208
- var _this$importedSceneDa, _this$importedSceneDa2;
208
+ var _this$importedSceneDa, _this$importedSceneDa2, _this$importedSceneDa3, _this$sceneViewer;
209
+ var ioBehavMgr;
209
210
  return _regenerator().w(function (_context2) {
210
211
  while (1) switch (_context2.n) {
211
212
  case 0:
@@ -216,9 +217,21 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
216
217
  console.log('📥 Imported scene data stored in CentralPlant:', {
217
218
  connections: ((_this$importedSceneDa = this.importedSceneData.connections) === null || _this$importedSceneDa === void 0 ? void 0 : _this$importedSceneDa.length) || 0,
218
219
  sceneObjects: ((_this$importedSceneDa2 = this.importedSceneData.scene) === null || _this$importedSceneDa2 === void 0 || (_this$importedSceneDa2 = _this$importedSceneDa2.children) === null || _this$importedSceneDa2 === void 0 ? void 0 : _this$importedSceneDa2.length) || 0,
220
+ behaviors: ((_this$importedSceneDa3 = this.importedSceneData.behaviors) === null || _this$importedSceneDa3 === void 0 ? void 0 : _this$importedSceneDa3.length) || 0,
219
221
  timestamp: new Date().toISOString()
220
222
  });
221
223
 
224
+ // Scene behaviors loaded
225
+
226
+ // Register behaviors with IoBehaviorManager
227
+ ioBehavMgr = (_this$sceneViewer = this.sceneViewer) === null || _this$sceneViewer === void 0 || (_this$sceneViewer = _this$sceneViewer.managers) === null || _this$sceneViewer === void 0 ? void 0 : _this$sceneViewer.ioBehaviorManager;
228
+ if (ioBehavMgr) {
229
+ // Setting cross-component behaviors
230
+ ioBehavMgr.setCrossComponentBehaviors(this.importedSceneData.behaviors || []);
231
+ } else {
232
+ console.warn('[Behavior] ioBehaviorManager not available!');
233
+ }
234
+
222
235
  // Reset component counter based on imported components to avoid ID conflicts
223
236
  this.internals.resetComponentCounter();
224
237
  case 2:
@@ -398,8 +411,8 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
398
411
  }, {
399
412
  key: "selectObject",
400
413
  value: function selectObject(objectOrId) {
401
- var _this$sceneViewer, _object;
402
- if (!((_this$sceneViewer = this.sceneViewer) !== null && _this$sceneViewer !== void 0 && _this$sceneViewer.transformManager)) {
414
+ var _this$sceneViewer2, _object;
415
+ if (!((_this$sceneViewer2 = this.sceneViewer) !== null && _this$sceneViewer2 !== void 0 && _this$sceneViewer2.transformManager)) {
403
416
  console.warn('⚠️ Transform manager not initialized');
404
417
  return false;
405
418
  }
@@ -445,8 +458,8 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
445
458
  }, {
446
459
  key: "toggleObject",
447
460
  value: function toggleObject(objectOrId) {
448
- var _this$sceneViewer2, _object2;
449
- if (!((_this$sceneViewer2 = this.sceneViewer) !== null && _this$sceneViewer2 !== void 0 && _this$sceneViewer2.transformManager)) {
461
+ var _this$sceneViewer3, _object2;
462
+ if (!((_this$sceneViewer3 = this.sceneViewer) !== null && _this$sceneViewer3 !== void 0 && _this$sceneViewer3.transformManager)) {
450
463
  console.warn('⚠️ Transform manager not initialized');
451
464
  return false;
452
465
  }
@@ -482,8 +495,8 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
482
495
  }, {
483
496
  key: "deselectObject",
484
497
  value: function deselectObject() {
485
- var _this$sceneViewer3;
486
- if (!((_this$sceneViewer3 = this.sceneViewer) !== null && _this$sceneViewer3 !== void 0 && _this$sceneViewer3.transformManager)) {
498
+ var _this$sceneViewer4;
499
+ if (!((_this$sceneViewer4 = this.sceneViewer) !== null && _this$sceneViewer4 !== void 0 && _this$sceneViewer4.transformManager)) {
487
500
  console.warn('⚠️ Transform manager not initialized');
488
501
  return false;
489
502
  }
@@ -712,7 +725,6 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
712
725
 
713
726
  // Enable drag functionality for the specific element
714
727
  this.sceneViewer.managers.componentDragManager.enableElementDrag(element, componentId);
715
- console.log("\u2705 enableDragDrop(): Enabled drag and drop for ".concat(componentId));
716
728
  return true;
717
729
  } catch (error) {
718
730
  console.error('❌ enableDragDrop(): Error enabling drag and drop:', error);
@@ -748,7 +760,6 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
748
760
  }
749
761
  try {
750
762
  this.sceneViewer.managers.componentDragManager.disableElementDrag(element);
751
- console.log('✅ disableDragDrop(): Disabled drag and drop for element');
752
763
  return true;
753
764
  } catch (error) {
754
765
  console.error('❌ disableDragDrop(): Error disabling drag and drop:', error);
@@ -782,7 +793,6 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
782
793
  if (this.sceneViewer.managers.componentDragManager) {
783
794
  this.sceneViewer.managers.componentDragManager.setEnabled(enabled);
784
795
  }
785
- console.log("\u2705 setDragDropEnabled(): Drag and drop ".concat(enabled ? 'enabled' : 'disabled'));
786
796
  return true;
787
797
  } catch (error) {
788
798
  console.error('❌ setDragDropEnabled(): Error setting drag and drop state:', error);
@@ -1097,9 +1107,9 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
1097
1107
  }, {
1098
1108
  key: "setIoDeviceState",
1099
1109
  value: function setIoDeviceState(attachmentId, stateId, value, parentUuid) {
1100
- var _this$sceneViewer4, _this$sceneViewer5, _this$sceneViewer6;
1110
+ var _this$sceneViewer5, _this$sceneViewer6, _this$sceneViewer7;
1101
1111
  // 1. Persist via state adapter if one has been configured
1102
- var stateAdapter = (_this$sceneViewer4 = this.sceneViewer) === null || _this$sceneViewer4 === void 0 || (_this$sceneViewer4 = _this$sceneViewer4.managers) === null || _this$sceneViewer4 === void 0 || (_this$sceneViewer4 = _this$sceneViewer4.componentTooltipManager) === null || _this$sceneViewer4 === void 0 ? void 0 : _this$sceneViewer4._stateAdapter;
1112
+ var stateAdapter = (_this$sceneViewer5 = this.sceneViewer) === null || _this$sceneViewer5 === void 0 || (_this$sceneViewer5 = _this$sceneViewer5.managers) === null || _this$sceneViewer5 === void 0 || (_this$sceneViewer5 = _this$sceneViewer5.componentTooltipManager) === null || _this$sceneViewer5 === void 0 ? void 0 : _this$sceneViewer5._stateAdapter;
1103
1113
  if (stateAdapter !== null && stateAdapter !== void 0 && stateAdapter.setState) {
1104
1114
  var scopedKey = parentUuid ? "".concat(parentUuid, "::").concat(attachmentId) : attachmentId;
1105
1115
  try {
@@ -1110,10 +1120,19 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
1110
1120
  }
1111
1121
 
1112
1122
  // 2. Apply io-behavior changes
1113
- (_this$sceneViewer5 = this.sceneViewer) === null || _this$sceneViewer5 === void 0 || (_this$sceneViewer5 = _this$sceneViewer5.managers) === null || _this$sceneViewer5 === void 0 || (_this$sceneViewer5 = _this$sceneViewer5.ioBehaviorManager) === null || _this$sceneViewer5 === void 0 || _this$sceneViewer5.triggerState(attachmentId, stateId, value, parentUuid);
1123
+ var ioBehavMgr = (_this$sceneViewer6 = this.sceneViewer) === null || _this$sceneViewer6 === void 0 || (_this$sceneViewer6 = _this$sceneViewer6.managers) === null || _this$sceneViewer6 === void 0 ? void 0 : _this$sceneViewer6.ioBehaviorManager;
1124
+ if (ioBehavMgr) {
1125
+ var _this$importedSceneDa4;
1126
+ ioBehavMgr.triggerState(attachmentId, stateId, value, parentUuid);
1127
+
1128
+ // Evaluate cross-component behaviors if they exist in the imported scene
1129
+ if ((_this$importedSceneDa4 = this.importedSceneData) !== null && _this$importedSceneDa4 !== void 0 && _this$importedSceneDa4.behaviors) {
1130
+ ioBehavMgr.triggerCrossComponentBehaviors(this.importedSceneData.behaviors, parentUuid, attachmentId, stateId, value);
1131
+ }
1132
+ }
1114
1133
 
1115
1134
  // 3. Emit event for host apps that don't use the state adapter (e.g. cp3d-viewer)
1116
- (_this$sceneViewer6 = this.sceneViewer) === null || _this$sceneViewer6 === void 0 || _this$sceneViewer6.emit('io-device-state-changed', {
1135
+ (_this$sceneViewer7 = this.sceneViewer) === null || _this$sceneViewer7 === void 0 || _this$sceneViewer7.emit('io-device-state-changed', {
1117
1136
  attachmentId: attachmentId,
1118
1137
  stateId: stateId,
1119
1138
  value: value,
@@ -1135,8 +1154,8 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
1135
1154
  }, {
1136
1155
  key: "getSceneAttachments",
1137
1156
  value: function getSceneAttachments() {
1138
- var _this$sceneViewer7;
1139
- var scene = (_this$sceneViewer7 = this.sceneViewer) === null || _this$sceneViewer7 === void 0 ? void 0 : _this$sceneViewer7.scene;
1157
+ var _this$sceneViewer8;
1158
+ var scene = (_this$sceneViewer8 = this.sceneViewer) === null || _this$sceneViewer8 === void 0 ? void 0 : _this$sceneViewer8.scene;
1140
1159
  if (!scene) return [];
1141
1160
  var results = [];
1142
1161
  scene.traverse(function (obj) {
@@ -2763,7 +2782,12 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
2763
2782
  }, {
2764
2783
  key: "clearScene",
2765
2784
  value: function clearScene() {
2785
+ var _this$sceneViewer9;
2766
2786
  this.importedSceneData = null;
2787
+ var ioBehavMgr = (_this$sceneViewer9 = this.sceneViewer) === null || _this$sceneViewer9 === void 0 || (_this$sceneViewer9 = _this$sceneViewer9.managers) === null || _this$sceneViewer9 === void 0 ? void 0 : _this$sceneViewer9.ioBehaviorManager;
2788
+ if (ioBehavMgr) {
2789
+ ioBehavMgr.setCrossComponentBehaviors([]);
2790
+ }
2767
2791
  if (this.sceneViewer && this.sceneViewer.scene) {
2768
2792
  this.sceneViewer.scene.clear();
2769
2793
  }
@@ -212,12 +212,10 @@ var CentralPlantInternals = /*#__PURE__*/function () {
212
212
  if (this.centralPlant.sceneViewer.$refs.container && this.centralPlant.sceneViewer.camera && this.centralPlant.sceneViewer.scene) {
213
213
  this.centralPlant.managers.tooltipsManager = new SceneTooltipsManager(this.centralPlant.sceneViewer.$refs.container, this.centralPlant.sceneViewer.camera, this.centralPlant.sceneViewer.scene);
214
214
  this.centralPlant.sceneViewer.tooltipsManager = this.centralPlant.managers.tooltipsManager;
215
- console.log('🔍 Tooltip manager initialized:', this.centralPlant.managers.tooltipsManager);
216
215
 
217
216
  // Initialize the component tooltip manager (screen-space tooltip on selection)
218
217
  this.centralPlant.managers.componentTooltipManager = new ComponentTooltipManager(this.centralPlant.sceneViewer);
219
218
  this.centralPlant.sceneViewer.componentTooltipManager = this.centralPlant.managers.componentTooltipManager;
220
- console.log('🔍 Component tooltip manager initialized');
221
219
  }
222
220
  }
223
221
 
@@ -1150,6 +1148,12 @@ var CentralPlantInternals = /*#__PURE__*/function () {
1150
1148
  for (var _i = 0, _Object$entries = Object.entries(componentData.attachedDevices); _i < _Object$entries.length; _i++) {
1151
1149
  if (_loop()) continue;
1152
1150
  }
1151
+
1152
+ // Register component-level behaviors (intra-component io-device linking)
1153
+ if (componentData.behaviors && componentData.behaviors.length > 0) {
1154
+ // Registering ${componentData.behaviors.length} component-level behavior(s)
1155
+ ioBehavMgr.registerComponentBehaviors(componentId, componentData.behaviors);
1156
+ }
1153
1157
  }
1154
1158
  }
1155
1159