@2112-lab/central-plant 0.3.45 → 0.3.46

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.
@@ -11931,6 +11931,8 @@ var SceneExportManager = /*#__PURE__*/function () {
11931
11931
  // Internal tracking - not needed in export
11932
11932
  'initialPosition',
11933
11933
  // Internal tracking - not needed in export
11934
+ 'attachedDevices',
11935
+ // Stored in smart component dictionary, not scene JSON
11934
11936
  // Exclude internal segment tracking properties
11935
11937
  'segmentId',
11936
11938
  // Internal tracking
@@ -34115,55 +34117,20 @@ var SceneOperationsManager = /*#__PURE__*/function () {
34115
34117
  y: componentModel.scale.y,
34116
34118
  z: componentModel.scale.z
34117
34119
  },
34118
- userData: _objectSpread2(_objectSpread2({}, componentModel.userData), {}, {
34120
+ userData: _objectSpread2(_objectSpread2({}, function () {
34121
+ var ud = _objectSpread2({}, componentModel.userData);
34122
+ delete ud.attachedDevices; // Instance data belongs in dictionary, not scene JSON
34123
+ delete ud.isDeclared; // Runtime flag
34124
+ delete ud.originalUuid; // Runtime tracking
34125
+ return ud;
34126
+ }()), {}, {
34119
34127
  worldBoundingBox: {
34120
34128
  min: boundingBox.min.toArray(),
34121
34129
  max: boundingBox.max.toArray()
34122
34130
  }
34123
- }),
34124
- children: []
34131
+ })
34125
34132
  };
34126
34133
 
34127
- // Process children (connectors, etc.) if they exist
34128
- if (componentModel.children && componentModel.children.length > 0) {
34129
- componentModel.children.forEach(function (child) {
34130
- var _child$userData0, _child$userData1;
34131
- var childType = ((_child$userData0 = child.userData) === null || _child$userData0 === void 0 ? void 0 : _child$userData0.objectType) || ((_child$userData1 = child.userData) === null || _child$userData1 === void 0 ? void 0 : _child$userData1.objectType);
34132
- if (childType === 'connector') {
34133
- var _child$geometry;
34134
- var childBoundingBox = new THREE__namespace.Box3().setFromObject(child);
34135
- var childSceneData = {
34136
- uuid: child.uuid,
34137
- name: child.name,
34138
- type: child.type,
34139
- position: {
34140
- x: child.position.x,
34141
- y: child.position.y,
34142
- z: child.position.z
34143
- },
34144
- rotation: {
34145
- x: THREE__namespace.MathUtils.radToDeg(child.rotation.x),
34146
- y: THREE__namespace.MathUtils.radToDeg(child.rotation.y),
34147
- z: THREE__namespace.MathUtils.radToDeg(child.rotation.z)
34148
- },
34149
- scale: {
34150
- x: child.scale.x,
34151
- y: child.scale.y,
34152
- z: child.scale.z
34153
- },
34154
- userData: _objectSpread2(_objectSpread2({}, child.userData), {}, {
34155
- worldBoundingBox: {
34156
- min: childBoundingBox.min.toArray(),
34157
- max: childBoundingBox.max.toArray()
34158
- }
34159
- }),
34160
- geometry: ((_child$geometry = child.geometry) === null || _child$geometry === void 0 ? void 0 : _child$geometry.uuid) || 'CONNECTOR-GEO'
34161
- };
34162
- componentSceneData.children.push(childSceneData);
34163
- }
34164
- });
34165
- }
34166
-
34167
34134
  // Add the component to the scene data
34168
34135
  if (!currentSceneData.scene.children) {
34169
34136
  currentSceneData.scene.children = [];
@@ -34172,7 +34139,6 @@ var SceneOperationsManager = /*#__PURE__*/function () {
34172
34139
  console.log('✅ addComponentToSceneData: Component added to scene data successfully', {
34173
34140
  componentId: componentModel.uuid,
34174
34141
  libraryId: (_componentModel$userD = componentModel.userData) === null || _componentModel$userD === void 0 ? void 0 : _componentModel$userD.libraryId,
34175
- childrenCount: componentSceneData.children.length,
34176
34142
  totalSceneChildren: currentSceneData.scene.children.length
34177
34143
  });
34178
34144
  return true;
@@ -34213,8 +34179,8 @@ var SceneOperationsManager = /*#__PURE__*/function () {
34213
34179
  if (segment.children && segment.children.length > 0) {
34214
34180
  var childrenToRemove = _toConsumableArray(segment.children);
34215
34181
  childrenToRemove.forEach(function (child) {
34216
- var _child$userData10;
34217
- if ((_child$userData10 = child.userData) !== null && _child$userData10 !== void 0 && _child$userData10.isPipeElbow) {
34182
+ var _child$userData0;
34183
+ if ((_child$userData0 = child.userData) !== null && _child$userData0 !== void 0 && _child$userData0.isPipeElbow) {
34218
34184
  console.log("\uD83D\uDDD1\uFE0F Removing elbow child from segment before manualization: ".concat(child.uuid));
34219
34185
  segment.remove(child);
34220
34186
  if (child.geometry) child.geometry.dispose();
@@ -34534,6 +34500,121 @@ var SceneOperationsManager = /*#__PURE__*/function () {
34534
34500
  }]);
34535
34501
  }();
34536
34502
 
34503
+ var CollisionManager = /*#__PURE__*/function () {
34504
+ /**
34505
+ * @param {Object} sceneViewer - The scene viewer instance
34506
+ */
34507
+ function CollisionManager(sceneViewer) {
34508
+ _classCallCheck(this, CollisionManager);
34509
+ this.sceneViewer = sceneViewer;
34510
+ }
34511
+
34512
+ /**
34513
+ * Check if a given object overlaps with any other relevant objects in the scene.
34514
+ * @param {THREE.Object3D} object - The object to check for collisions
34515
+ * @param {Array<string>} excludeTypes - Object types to exclude from checking (e.g. ['ground'])
34516
+ * @returns {Object|null} Collision info {object, objectType} if collision detected, null otherwise
34517
+ */
34518
+ return _createClass(CollisionManager, [{
34519
+ key: "checkCollision",
34520
+ value: function checkCollision(object) {
34521
+ var _this$sceneViewer,
34522
+ _this = this;
34523
+ var excludeTypes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ['isBaseGround', 'isBaseGrid', 'isBrickWall'];
34524
+ if (!((_this$sceneViewer = this.sceneViewer) !== null && _this$sceneViewer !== void 0 && _this$sceneViewer.scene) || !object) return null;
34525
+
34526
+ // Compute high-quality bounding box for the object being checked
34527
+ // We use setFromObject here because the target object just moved
34528
+ var objectBBox = new THREE__namespace.Box3().setFromObject(object);
34529
+
34530
+ // Narrow down potential colliders
34531
+ var collisionDetected = null;
34532
+
34533
+ // Optimization: Only check the root-level CP objects to avoid O(N^2) complexity with meshes
34534
+ this.sceneViewer.scene.traverse(function (child) {
34535
+ var _child$userData, _child$userData2, _child$userData3, _child$userData4, _child$userData5;
34536
+ if (collisionDetected) return; // Short circuit
34537
+
34538
+ // Skip the object itself and its descendants
34539
+ if (child === object || _this._isDescendantOf(object, child)) return;
34540
+
34541
+ // Filter by CP object types at the root level (skip internal meshes during traverse)
34542
+ var isCPRootObject = ((_child$userData = child.userData) === null || _child$userData === void 0 ? void 0 : _child$userData.objectType) === 'component' || ((_child$userData2 = child.userData) === null || _child$userData2 === void 0 ? void 0 : _child$userData2.objectType) === 'segment' || ((_child$userData3 = child.userData) === null || _child$userData3 === void 0 ? void 0 : _child$userData3.objectType) === 'gateway' || ((_child$userData4 = child.userData) === null || _child$userData4 === void 0 ? void 0 : _child$userData4.objectType) === 'connector' || ((_child$userData5 = child.userData) === null || _child$userData5 === void 0 ? void 0 : _child$userData5.ioConfig); // IO Device
34543
+
34544
+ if (isCPRootObject && !_this._shouldExclude(child, excludeTypes)) {
34545
+ // Use cached worldBoundingBox if available, otherwise compute it (and cache it)
34546
+ var childBBox;
34547
+ if (child.userData.worldBoundingBox && !child.userData.isMoving) {
34548
+ var _min$x, _min$y, _min$z, _max$x, _max$y, _max$z;
34549
+ // Use stored worldBoundingBox (handles array or Box3 format)
34550
+ var min = child.userData.worldBoundingBox.min;
34551
+ var max = child.userData.worldBoundingBox.max;
34552
+ childBBox = new THREE__namespace.Box3(new THREE__namespace.Vector3((_min$x = min.x) !== null && _min$x !== void 0 ? _min$x : min[0], (_min$y = min.y) !== null && _min$y !== void 0 ? _min$y : min[1], (_min$z = min.z) !== null && _min$z !== void 0 ? _min$z : min[2]), new THREE__namespace.Vector3((_max$x = max.x) !== null && _max$x !== void 0 ? _max$x : max[0], (_max$y = max.y) !== null && _max$y !== void 0 ? _max$y : max[1], (_max$z = max.z) !== null && _max$z !== void 0 ? _max$z : max[2]));
34553
+ } else {
34554
+ // Fallback to high-quality computation for moving objects or first-time checks
34555
+ childBBox = new THREE__namespace.Box3().setFromObject(child);
34556
+
34557
+ // Cache the result for next time (non-moving objects)
34558
+ if (!child.userData.isMoving) {
34559
+ child.userData.worldBoundingBox = {
34560
+ min: [childBBox.min.x, childBBox.min.y, childBBox.min.z],
34561
+ max: [childBBox.max.x, childBBox.max.y, childBBox.max.z]
34562
+ };
34563
+ }
34564
+ }
34565
+ if (objectBBox.intersectsBox(childBBox)) {
34566
+ collisionDetected = {
34567
+ object: child,
34568
+ objectType: child.userData.objectType,
34569
+ uuid: child.uuid,
34570
+ name: child.name || child.userData.libraryId || child.uuid
34571
+ };
34572
+ }
34573
+ }
34574
+ });
34575
+ return collisionDetected;
34576
+ }
34577
+
34578
+ /**
34579
+ * Helper to check if a node is a descendant of a specific parent
34580
+ * @private
34581
+ */
34582
+ }, {
34583
+ key: "_isDescendantOf",
34584
+ value: function _isDescendantOf(parent, child) {
34585
+ var node = child.parent;
34586
+ while (node !== null) {
34587
+ if (node === parent) return true;
34588
+ node = node.parent;
34589
+ }
34590
+ return false;
34591
+ }
34592
+
34593
+ /**
34594
+ * Helper to determine if an object should be excluded from collision checking
34595
+ * @private
34596
+ */
34597
+ }, {
34598
+ key: "_shouldExclude",
34599
+ value: function _shouldExclude(object, excludeTypes) {
34600
+ if (object.userData.isPreview) return true;
34601
+ var _iterator = _createForOfIteratorHelper(excludeTypes),
34602
+ _step;
34603
+ try {
34604
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
34605
+ var type = _step.value;
34606
+ if (object.userData[type]) return true;
34607
+ }
34608
+ } catch (err) {
34609
+ _iterator.e(err);
34610
+ } finally {
34611
+ _iterator.f();
34612
+ }
34613
+ return false;
34614
+ }
34615
+ }]);
34616
+ }();
34617
+
34537
34618
  var AnimationManager = /*#__PURE__*/function (_BaseDisposable) {
34538
34619
  function AnimationManager(sceneViewer) {
34539
34620
  var _this;
@@ -35409,6 +35490,7 @@ var ComponentDragManager = /*#__PURE__*/function (_BaseDisposable) {
35409
35490
  // Find intersection with ground plane
35410
35491
  var intersection = this.raycaster.ray.intersectPlane(this.dropPlane, this.dropIntersection);
35411
35492
  if (intersection) {
35493
+ var _this$sceneViewer$col;
35412
35494
  // Apply 0.5 unit transform snapping to intersection point
35413
35495
  var snappedPosition = this._applyTransformSnap(intersection);
35414
35496
  this.dragData.previewObject.position.copy(snappedPosition);
@@ -35416,7 +35498,7 @@ var ComponentDragManager = /*#__PURE__*/function (_BaseDisposable) {
35416
35498
 
35417
35499
  // Check for overlap and update color accordingly
35418
35500
  var wasOverlapping = this.dragData.isOverlapping;
35419
- this.dragData.isOverlapping = this._checkBoundingBoxOverlap();
35501
+ this.dragData.isOverlapping = !!((_this$sceneViewer$col = this.sceneViewer.collisionManager) !== null && _this$sceneViewer$col !== void 0 && _this$sceneViewer$col.checkCollision(this.dragData.previewObject));
35420
35502
 
35421
35503
  // Update color if overlap state changed
35422
35504
  if (wasOverlapping !== this.dragData.isOverlapping) {
@@ -39398,6 +39480,7 @@ var CentralPlantInternals = /*#__PURE__*/function () {
39398
39480
  this.centralPlant.managers.keyboardControlsManager = new KeyboardControlsManager(this.centralPlant.sceneViewer);
39399
39481
  this.centralPlant.managers.pathfindingManager = new PathfindingManager(this.centralPlant.sceneViewer);
39400
39482
  this.centralPlant.managers.pathFlowManager = new PathFlowManager(this.centralPlant.sceneViewer);
39483
+ this.centralPlant.managers.collisionManager = new CollisionManager(this.centralPlant.sceneViewer);
39401
39484
  this.centralPlant.managers.sceneOperationsManager = new SceneOperationsManager(this.centralPlant.sceneViewer);
39402
39485
  this.centralPlant.managers.animationManager = new AnimationManager(this.centralPlant.sceneViewer);
39403
39486
  this.centralPlant.managers.cameraControlsManager = new CameraControlsManager(this.centralPlant.sceneViewer);
@@ -40836,7 +40919,7 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
40836
40919
  * Initialize the CentralPlant manager
40837
40920
  *
40838
40921
  * @constructor
40839
- * @version 0.3.45
40922
+ * @version 0.3.46
40840
40923
  * @updated 2025-10-22
40841
40924
  *
40842
40925
  * @description Creates a new CentralPlant instance and initializes internal managers and utilities.
@@ -40974,6 +41057,32 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
40974
41057
  return this.internals.attachToComponent();
40975
41058
  }
40976
41059
 
41060
+ /**
41061
+ * Check if an object in the scene collides with any other objects
41062
+ * @param {string} objectId - The UUID or originalUuid of the object to check
41063
+ * @returns {Object|null} Collision info if detected, null otherwise
41064
+ */
41065
+ }, {
41066
+ key: "checkCollision",
41067
+ value: function checkCollision(objectId) {
41068
+ if (!this.sceneViewer || !this.managers.collisionManager) {
41069
+ console.warn('⚠️ checkCollision(): Scene viewer or collision manager not available');
41070
+ return null;
41071
+ }
41072
+ var targetObject = null;
41073
+ this.sceneViewer.scene.traverse(function (child) {
41074
+ var _child$userData;
41075
+ if (child.uuid === objectId || ((_child$userData = child.userData) === null || _child$userData === void 0 ? void 0 : _child$userData.originalUuid) === objectId) {
41076
+ targetObject = child;
41077
+ }
41078
+ });
41079
+ if (!targetObject) {
41080
+ console.warn("\u26A0\uFE0F checkCollision(): Object with ID '".concat(objectId, "' not found"));
41081
+ return null;
41082
+ }
41083
+ return this.managers.collisionManager.checkCollision(targetObject);
41084
+ }
41085
+
40977
41086
  /**
40978
41087
  * Initialize specific managers that need to be created after scene setup
40979
41088
  * @returns {boolean} True if post-scene managers were initialized successfully, false otherwise
@@ -41654,6 +41763,104 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
41654
41763
  return this.internals.addConnection(fromConnectorId, toConnectorId);
41655
41764
  }
41656
41765
 
41766
+ /**
41767
+ * Randomly connect available component connectors in the scene.
41768
+ * Attempts to pair as many free connectors as possible.
41769
+ * @returns {Array<Object>} List of added connections.
41770
+ */
41771
+ }, {
41772
+ key: "addRandomConnections",
41773
+ value: (function () {
41774
+ var _addRandomConnections = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3() {
41775
+ var _this$sceneViewer4;
41776
+ var connectors, scene, currentConns, busyConnectorIds, freeConnectors, i, j, _ref, added, from, _i, to, isCompatible, isDifferentParent, conn;
41777
+ return _regenerator().w(function (_context3) {
41778
+ while (1) switch (_context3.n) {
41779
+ case 0:
41780
+ connectors = [];
41781
+ scene = (_this$sceneViewer4 = this.sceneViewer) === null || _this$sceneViewer4 === void 0 ? void 0 : _this$sceneViewer4.scene;
41782
+ if (scene) {
41783
+ _context3.n = 1;
41784
+ break;
41785
+ }
41786
+ return _context3.a(2, []);
41787
+ case 1:
41788
+ // Find all free connectors in the scene
41789
+ scene.traverse(function (obj) {
41790
+ var _obj$userData;
41791
+ if (((_obj$userData = obj.userData) === null || _obj$userData === void 0 ? void 0 : _obj$userData.objectType) === 'connector' && obj.uuid) {
41792
+ connectors.push({
41793
+ uuid: obj.uuid,
41794
+ flow: obj.userData.flow || 'bi',
41795
+ parent: obj.parent
41796
+ });
41797
+ }
41798
+ });
41799
+
41800
+ // Get current connections to avoid double-connecting
41801
+ currentConns = this.getConnections();
41802
+ busyConnectorIds = new Set();
41803
+ currentConns.forEach(function (conn) {
41804
+ busyConnectorIds.add(conn.from);
41805
+ busyConnectorIds.add(conn.to);
41806
+ });
41807
+ freeConnectors = connectors.filter(function (c) {
41808
+ return !busyConnectorIds.has(c.uuid);
41809
+ }); // Shuffle free connectors
41810
+ for (i = freeConnectors.length - 1; i > 0; i--) {
41811
+ j = Math.floor(Math.random() * (i + 1));
41812
+ _ref = [freeConnectors[j], freeConnectors[i]];
41813
+ freeConnectors[i] = _ref[0];
41814
+ freeConnectors[j] = _ref[1];
41815
+ }
41816
+ added = []; // Greedy pairing
41817
+ case 2:
41818
+ if (!(freeConnectors.length >= 2)) {
41819
+ _context3.n = 6;
41820
+ break;
41821
+ }
41822
+ from = freeConnectors.pop();
41823
+ _i = 0;
41824
+ case 3:
41825
+ if (!(_i < freeConnectors.length)) {
41826
+ _context3.n = 5;
41827
+ break;
41828
+ }
41829
+ to = freeConnectors[_i]; // Basic flow compatibility check (CentralPlantInternals.addConnection does this too)
41830
+ isCompatible = from.flow === 'bi' || to.flow === 'bi' || from.flow !== to.flow;
41831
+ isDifferentParent = from.parent !== to.parent;
41832
+ if (!(isCompatible && isDifferentParent)) {
41833
+ _context3.n = 4;
41834
+ break;
41835
+ }
41836
+ conn = this.addConnection(from.uuid, to.uuid);
41837
+ if (!conn) {
41838
+ _context3.n = 4;
41839
+ break;
41840
+ }
41841
+ added.push(conn);
41842
+ freeConnectors.splice(_i, 1);
41843
+ return _context3.a(3, 5);
41844
+ case 4:
41845
+ _i++;
41846
+ _context3.n = 3;
41847
+ break;
41848
+ case 5:
41849
+ _context3.n = 2;
41850
+ break;
41851
+ case 6:
41852
+ if (added.length > 0) {
41853
+ this.updatePaths();
41854
+ }
41855
+ return _context3.a(2, added);
41856
+ }
41857
+ }, _callee3, this);
41858
+ }));
41859
+ function addRandomConnections() {
41860
+ return _addRandomConnections.apply(this, arguments);
41861
+ }
41862
+ return addRandomConnections;
41863
+ }()
41657
41864
  /**
41658
41865
  * Remove a connection between two component connectors
41659
41866
  * @param {string} fromConnectorId - The UUID of the source connector
@@ -41675,6 +41882,7 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
41675
41882
  * centralPlant.updatePaths();
41676
41883
  * }
41677
41884
  */
41885
+ )
41678
41886
  }, {
41679
41887
  key: "removeConnection",
41680
41888
  value: function removeConnection(fromConnectorId, toConnectorId) {
@@ -41879,8 +42087,8 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
41879
42087
  }, {
41880
42088
  key: "_dispatchIoState",
41881
42089
  value: function _dispatchIoState(attachmentId, stateId, value, parentUuid) {
41882
- var _this$managers, _this$sceneViewer4, _this$sceneViewer5, _this$managers2, _this$sceneViewer6, _this$sceneViewer7, _this$sceneViewer8;
41883
- var tooltipMgr = ((_this$managers = this.managers) === null || _this$managers === void 0 ? void 0 : _this$managers.componentTooltipManager) || ((_this$sceneViewer4 = this.sceneViewer) === null || _this$sceneViewer4 === void 0 ? void 0 : _this$sceneViewer4.componentTooltipManager) || ((_this$sceneViewer5 = this.sceneViewer) === null || _this$sceneViewer5 === void 0 || (_this$sceneViewer5 = _this$sceneViewer5.managers) === null || _this$sceneViewer5 === void 0 ? void 0 : _this$sceneViewer5.componentTooltipManager);
42090
+ var _this$managers, _this$sceneViewer5, _this$sceneViewer6, _this$managers2, _this$sceneViewer7, _this$sceneViewer8, _this$sceneViewer9;
42091
+ var tooltipMgr = ((_this$managers = this.managers) === null || _this$managers === void 0 ? void 0 : _this$managers.componentTooltipManager) || ((_this$sceneViewer5 = this.sceneViewer) === null || _this$sceneViewer5 === void 0 ? void 0 : _this$sceneViewer5.componentTooltipManager) || ((_this$sceneViewer6 = this.sceneViewer) === null || _this$sceneViewer6 === void 0 || (_this$sceneViewer6 = _this$sceneViewer6.managers) === null || _this$sceneViewer6 === void 0 ? void 0 : _this$sceneViewer6.componentTooltipManager);
41884
42092
  var stateAdapter = tooltipMgr === null || tooltipMgr === void 0 ? void 0 : tooltipMgr._stateAdapter;
41885
42093
  if (stateAdapter !== null && stateAdapter !== void 0 && stateAdapter.setState) {
41886
42094
  var scopedKey = getScopedAttachmentKey(attachmentId, parentUuid);
@@ -41890,11 +42098,11 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
41890
42098
  console.warn('⚠️ _dispatchIoState(): stateAdapter.setState() threw:', err);
41891
42099
  }
41892
42100
  }
41893
- var ioBehavMgr = ((_this$managers2 = this.managers) === null || _this$managers2 === void 0 ? void 0 : _this$managers2.ioBehaviorManager) || ((_this$sceneViewer6 = this.sceneViewer) === null || _this$sceneViewer6 === void 0 || (_this$sceneViewer6 = _this$sceneViewer6.managers) === null || _this$sceneViewer6 === void 0 ? void 0 : _this$sceneViewer6.ioBehaviorManager) || ((_this$sceneViewer7 = this.sceneViewer) === null || _this$sceneViewer7 === void 0 ? void 0 : _this$sceneViewer7.ioBehaviorManager);
42101
+ var ioBehavMgr = ((_this$managers2 = this.managers) === null || _this$managers2 === void 0 ? void 0 : _this$managers2.ioBehaviorManager) || ((_this$sceneViewer7 = this.sceneViewer) === null || _this$sceneViewer7 === void 0 || (_this$sceneViewer7 = _this$sceneViewer7.managers) === null || _this$sceneViewer7 === void 0 ? void 0 : _this$sceneViewer7.ioBehaviorManager) || ((_this$sceneViewer8 = this.sceneViewer) === null || _this$sceneViewer8 === void 0 ? void 0 : _this$sceneViewer8.ioBehaviorManager);
41894
42102
  if (ioBehavMgr) {
41895
42103
  ioBehavMgr.triggerState(attachmentId, stateId, value, parentUuid);
41896
42104
  }
41897
- (_this$sceneViewer8 = this.sceneViewer) === null || _this$sceneViewer8 === void 0 || _this$sceneViewer8.emit('io-device-state-changed', {
42105
+ (_this$sceneViewer9 = this.sceneViewer) === null || _this$sceneViewer9 === void 0 || _this$sceneViewer9.emit('io-device-state-changed', {
41898
42106
  attachmentId: attachmentId,
41899
42107
  stateId: stateId,
41900
42108
  value: value,
@@ -41909,16 +42117,16 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
41909
42117
  }, {
41910
42118
  key: "configureStateAdapter",
41911
42119
  value: function configureStateAdapter(stateAdapter) {
41912
- var _this$managers3, _this$sceneViewer9, _this$managers4, _this$sceneViewer1, _this$sceneViewer10;
41913
- var tooltipMgr = ((_this$managers3 = this.managers) === null || _this$managers3 === void 0 ? void 0 : _this$managers3.componentTooltipManager) || ((_this$sceneViewer9 = this.sceneViewer) === null || _this$sceneViewer9 === void 0 ? void 0 : _this$sceneViewer9.componentTooltipManager);
42120
+ var _this$managers3, _this$sceneViewer0, _this$managers4, _this$sceneViewer10, _this$sceneViewer11;
42121
+ var tooltipMgr = ((_this$managers3 = this.managers) === null || _this$managers3 === void 0 ? void 0 : _this$managers3.componentTooltipManager) || ((_this$sceneViewer0 = this.sceneViewer) === null || _this$sceneViewer0 === void 0 ? void 0 : _this$sceneViewer0.componentTooltipManager);
41914
42122
  if (tooltipMgr !== null && tooltipMgr !== void 0 && tooltipMgr.configure) {
41915
- var _this$sceneViewer0;
42123
+ var _this$sceneViewer1;
41916
42124
  tooltipMgr.configure(stateAdapter);
41917
- if ((_this$sceneViewer0 = this.sceneViewer) !== null && _this$sceneViewer0 !== void 0 && _this$sceneViewer0.managers) {
42125
+ if ((_this$sceneViewer1 = this.sceneViewer) !== null && _this$sceneViewer1 !== void 0 && _this$sceneViewer1.managers) {
41918
42126
  this.sceneViewer.managers.componentTooltipManager = tooltipMgr;
41919
42127
  }
41920
42128
  }
41921
- var ioBehavMgr = ((_this$managers4 = this.managers) === null || _this$managers4 === void 0 ? void 0 : _this$managers4.ioBehaviorManager) || ((_this$sceneViewer1 = this.sceneViewer) === null || _this$sceneViewer1 === void 0 || (_this$sceneViewer1 = _this$sceneViewer1.managers) === null || _this$sceneViewer1 === void 0 ? void 0 : _this$sceneViewer1.ioBehaviorManager) || ((_this$sceneViewer10 = this.sceneViewer) === null || _this$sceneViewer10 === void 0 ? void 0 : _this$sceneViewer10.ioBehaviorManager);
42129
+ var ioBehavMgr = ((_this$managers4 = this.managers) === null || _this$managers4 === void 0 ? void 0 : _this$managers4.ioBehaviorManager) || ((_this$sceneViewer10 = this.sceneViewer) === null || _this$sceneViewer10 === void 0 || (_this$sceneViewer10 = _this$sceneViewer10.managers) === null || _this$sceneViewer10 === void 0 ? void 0 : _this$sceneViewer10.ioBehaviorManager) || ((_this$sceneViewer11 = this.sceneViewer) === null || _this$sceneViewer11 === void 0 ? void 0 : _this$sceneViewer11.ioBehaviorManager);
41922
42130
  if (ioBehavMgr !== null && ioBehavMgr !== void 0 && ioBehavMgr.configure) {
41923
42131
  ioBehavMgr.configure(stateAdapter);
41924
42132
  }
@@ -41953,13 +42161,13 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
41953
42161
  }, {
41954
42162
  key: "getSceneAttachments",
41955
42163
  value: function getSceneAttachments() {
41956
- var _this$sceneViewer11;
41957
- var scene = (_this$sceneViewer11 = this.sceneViewer) === null || _this$sceneViewer11 === void 0 ? void 0 : _this$sceneViewer11.scene;
42164
+ var _this$sceneViewer12;
42165
+ var scene = (_this$sceneViewer12 = this.sceneViewer) === null || _this$sceneViewer12 === void 0 ? void 0 : _this$sceneViewer12.scene;
41958
42166
  if (!scene) return [];
41959
42167
  var results = [];
41960
42168
  scene.traverse(function (obj) {
41961
- var _obj$userData;
41962
- if (((_obj$userData = obj.userData) === null || _obj$userData === void 0 ? void 0 : _obj$userData.objectType) === 'io-device') {
42169
+ var _obj$userData2;
42170
+ if (((_obj$userData2 = obj.userData) === null || _obj$userData2 === void 0 ? void 0 : _obj$userData2.objectType) === 'io-device') {
41963
42171
  var _parent$userData;
41964
42172
  var attachmentId = obj.userData.attachmentId || obj.name || obj.uuid;
41965
42173
  var label = obj.userData.attachmentLabel || attachmentId;
@@ -42019,9 +42227,9 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
42019
42227
  }, {
42020
42228
  key: "getIoDevices",
42021
42229
  value: function getIoDevices() {
42022
- var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
42023
- _ref$source = _ref.source,
42024
- source = _ref$source === void 0 ? 'all' : _ref$source;
42230
+ var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
42231
+ _ref2$source = _ref2.source,
42232
+ source = _ref2$source === void 0 ? 'all' : _ref2$source;
42025
42233
  var mp = this.getUtility('modelPreloader');
42026
42234
  var dict = mp === null || mp === void 0 ? void 0 : mp.componentDictionary;
42027
42235
  if (!dict) {
@@ -42057,8 +42265,8 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
42057
42265
  }, {
42058
42266
  key: "getIoDeviceUsage",
42059
42267
  value: function getIoDeviceUsage() {
42060
- var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
42061
- deviceUuid = _ref2.deviceUuid;
42268
+ var _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
42269
+ deviceUuid = _ref3.deviceUuid;
42062
42270
  if (!deviceUuid) {
42063
42271
  console.warn('⚠️ getIoDeviceUsage(): deviceUuid is required');
42064
42272
  return [];
@@ -42109,38 +42317,38 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
42109
42317
  }, {
42110
42318
  key: "createSmartComponent",
42111
42319
  value: (function () {
42112
- var _createSmartComponent = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3() {
42113
- var _ref3,
42320
+ var _createSmartComponent = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4() {
42321
+ var _ref4,
42114
42322
  componentUuid,
42115
42323
  name,
42116
42324
  attachments,
42117
42325
  thumbnailBlob,
42118
42326
  newAsset,
42119
42327
  mp,
42120
- _args3 = arguments;
42121
- return _regenerator().w(function (_context3) {
42122
- while (1) switch (_context3.n) {
42328
+ _args4 = arguments;
42329
+ return _regenerator().w(function (_context4) {
42330
+ while (1) switch (_context4.n) {
42123
42331
  case 0:
42124
- _ref3 = _args3.length > 0 && _args3[0] !== undefined ? _args3[0] : {}, componentUuid = _ref3.componentUuid, name = _ref3.name, attachments = _ref3.attachments, thumbnailBlob = _ref3.thumbnailBlob;
42332
+ _ref4 = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : {}, componentUuid = _ref4.componentUuid, name = _ref4.name, attachments = _ref4.attachments, thumbnailBlob = _ref4.thumbnailBlob;
42125
42333
  if (this.assetService) {
42126
- _context3.n = 1;
42334
+ _context4.n = 1;
42127
42335
  break;
42128
42336
  }
42129
42337
  throw new Error('createSmartComponent(): no asset service set — call setAssetService() first');
42130
42338
  case 1:
42131
42339
  if (componentUuid) {
42132
- _context3.n = 2;
42340
+ _context4.n = 2;
42133
42341
  break;
42134
42342
  }
42135
42343
  throw new Error('createSmartComponent(): componentUuid is required');
42136
42344
  case 2:
42137
42345
  if (!(!Array.isArray(attachments) || attachments.length === 0)) {
42138
- _context3.n = 3;
42346
+ _context4.n = 3;
42139
42347
  break;
42140
42348
  }
42141
42349
  throw new Error('createSmartComponent(): at least one attachment is required');
42142
42350
  case 3:
42143
- _context3.n = 4;
42351
+ _context4.n = 4;
42144
42352
  return this.assetService.createSmartComponent({
42145
42353
  componentUuid: componentUuid,
42146
42354
  name: name,
@@ -42148,7 +42356,7 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
42148
42356
  thumbnailBlob: thumbnailBlob
42149
42357
  });
42150
42358
  case 4:
42151
- newAsset = _context3.v;
42359
+ newAsset = _context4.v;
42152
42360
  // Register in model preloader dictionary so addComponent() can use it immediately
42153
42361
  mp = this.getUtility('modelPreloader');
42154
42362
  if (mp !== null && mp !== void 0 && mp.componentDictionary && newAsset !== null && newAsset !== void 0 && newAsset.uuid) {
@@ -42157,9 +42365,9 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
42157
42365
  });
42158
42366
  console.log("\u2705 createSmartComponent(): registered \"".concat(newAsset.name, "\" in component dictionary"));
42159
42367
  }
42160
- return _context3.a(2, newAsset);
42368
+ return _context4.a(2, newAsset);
42161
42369
  }
42162
- }, _callee3, this);
42370
+ }, _callee4, this);
42163
42371
  }));
42164
42372
  function createSmartComponent() {
42165
42373
  return _createSmartComponent.apply(this, arguments);
@@ -42193,42 +42401,42 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
42193
42401
  }, {
42194
42402
  key: "addComponentAttachment",
42195
42403
  value: (function () {
42196
- var _addComponentAttachment = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4() {
42197
- var _ref4,
42404
+ var _addComponentAttachment = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5() {
42405
+ var _ref5,
42198
42406
  componentUuid,
42199
42407
  attachment,
42200
42408
  updatedAsset,
42201
42409
  mp,
42202
- _args4 = arguments;
42203
- return _regenerator().w(function (_context4) {
42204
- while (1) switch (_context4.n) {
42410
+ _args5 = arguments;
42411
+ return _regenerator().w(function (_context5) {
42412
+ while (1) switch (_context5.n) {
42205
42413
  case 0:
42206
- _ref4 = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : {}, componentUuid = _ref4.componentUuid, attachment = _ref4.attachment;
42414
+ _ref5 = _args5.length > 0 && _args5[0] !== undefined ? _args5[0] : {}, componentUuid = _ref5.componentUuid, attachment = _ref5.attachment;
42207
42415
  if (this.assetService) {
42208
- _context4.n = 1;
42416
+ _context5.n = 1;
42209
42417
  break;
42210
42418
  }
42211
42419
  throw new Error('addComponentAttachment(): no asset service set — call setAssetService() first');
42212
42420
  case 1:
42213
42421
  if (componentUuid) {
42214
- _context4.n = 2;
42422
+ _context5.n = 2;
42215
42423
  break;
42216
42424
  }
42217
42425
  throw new Error('addComponentAttachment(): componentUuid is required');
42218
42426
  case 2:
42219
42427
  if (!(!(attachment !== null && attachment !== void 0 && attachment.attachmentId) || !(attachment !== null && attachment !== void 0 && attachment.deviceId))) {
42220
- _context4.n = 3;
42428
+ _context5.n = 3;
42221
42429
  break;
42222
42430
  }
42223
42431
  throw new Error('addComponentAttachment(): attachment must have attachmentId and deviceId');
42224
42432
  case 3:
42225
- _context4.n = 4;
42433
+ _context5.n = 4;
42226
42434
  return this.assetService.addComponentAttachment({
42227
42435
  componentUuid: componentUuid,
42228
42436
  attachment: attachment
42229
42437
  });
42230
42438
  case 4:
42231
- updatedAsset = _context4.v;
42439
+ updatedAsset = _context5.v;
42232
42440
  // Sync component dictionary
42233
42441
  mp = this.getUtility('modelPreloader');
42234
42442
  if (mp !== null && mp !== void 0 && mp.componentDictionary && updatedAsset !== null && updatedAsset !== void 0 && updatedAsset.uuid) {
@@ -42236,9 +42444,9 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
42236
42444
  id: updatedAsset.uuid
42237
42445
  });
42238
42446
  }
42239
- return _context4.a(2, updatedAsset);
42447
+ return _context5.a(2, updatedAsset);
42240
42448
  }
42241
- }, _callee4, this);
42449
+ }, _callee5, this);
42242
42450
  }));
42243
42451
  function addComponentAttachment() {
42244
42452
  return _addComponentAttachment.apply(this, arguments);
@@ -42264,42 +42472,42 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
42264
42472
  }, {
42265
42473
  key: "removeComponentAttachment",
42266
42474
  value: (function () {
42267
- var _removeComponentAttachment = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5() {
42268
- var _ref5,
42475
+ var _removeComponentAttachment = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6() {
42476
+ var _ref6,
42269
42477
  componentUuid,
42270
42478
  attachmentId,
42271
42479
  updatedAsset,
42272
42480
  mp,
42273
- _args5 = arguments;
42274
- return _regenerator().w(function (_context5) {
42275
- while (1) switch (_context5.n) {
42481
+ _args6 = arguments;
42482
+ return _regenerator().w(function (_context6) {
42483
+ while (1) switch (_context6.n) {
42276
42484
  case 0:
42277
- _ref5 = _args5.length > 0 && _args5[0] !== undefined ? _args5[0] : {}, componentUuid = _ref5.componentUuid, attachmentId = _ref5.attachmentId;
42485
+ _ref6 = _args6.length > 0 && _args6[0] !== undefined ? _args6[0] : {}, componentUuid = _ref6.componentUuid, attachmentId = _ref6.attachmentId;
42278
42486
  if (this.assetService) {
42279
- _context5.n = 1;
42487
+ _context6.n = 1;
42280
42488
  break;
42281
42489
  }
42282
42490
  throw new Error('removeComponentAttachment(): no asset service set — call setAssetService() first');
42283
42491
  case 1:
42284
42492
  if (componentUuid) {
42285
- _context5.n = 2;
42493
+ _context6.n = 2;
42286
42494
  break;
42287
42495
  }
42288
42496
  throw new Error('removeComponentAttachment(): componentUuid is required');
42289
42497
  case 2:
42290
42498
  if (attachmentId) {
42291
- _context5.n = 3;
42499
+ _context6.n = 3;
42292
42500
  break;
42293
42501
  }
42294
42502
  throw new Error('removeComponentAttachment(): attachmentId is required');
42295
42503
  case 3:
42296
- _context5.n = 4;
42504
+ _context6.n = 4;
42297
42505
  return this.assetService.removeComponentAttachment({
42298
42506
  componentUuid: componentUuid,
42299
42507
  attachmentId: attachmentId
42300
42508
  });
42301
42509
  case 4:
42302
- updatedAsset = _context5.v;
42510
+ updatedAsset = _context6.v;
42303
42511
  // Sync component dictionary
42304
42512
  mp = this.getUtility('modelPreloader');
42305
42513
  if (mp !== null && mp !== void 0 && mp.componentDictionary && updatedAsset !== null && updatedAsset !== void 0 && updatedAsset.uuid) {
@@ -42307,9 +42515,9 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
42307
42515
  id: updatedAsset.uuid
42308
42516
  });
42309
42517
  }
42310
- return _context5.a(2, updatedAsset);
42518
+ return _context6.a(2, updatedAsset);
42311
42519
  }
42312
- }, _callee5, this);
42520
+ }, _callee6, this);
42313
42521
  }));
42314
42522
  function removeComponentAttachment() {
42315
42523
  return _removeComponentAttachment.apply(this, arguments);
@@ -42502,41 +42710,41 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
42502
42710
  }, {
42503
42711
  key: "getComponents",
42504
42712
  value: (function () {
42505
- var _getComponents = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6() {
42713
+ var _getComponents = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7() {
42506
42714
  var options,
42507
42715
  validation,
42508
42716
  enhancedOptions,
42509
- _args6 = arguments,
42717
+ _args7 = arguments,
42510
42718
  _t;
42511
- return _regenerator().w(function (_context6) {
42512
- while (1) switch (_context6.n) {
42719
+ return _regenerator().w(function (_context7) {
42720
+ while (1) switch (_context7.n) {
42513
42721
  case 0:
42514
- options = _args6.length > 0 && _args6[0] !== undefined ? _args6[0] : {};
42722
+ options = _args7.length > 0 && _args7[0] !== undefined ? _args7[0] : {};
42515
42723
  // Validate filter options using centralized validator
42516
42724
  validation = this.internals.validator.validateComponentFilter(options);
42517
42725
  if (validation.isValid) {
42518
- _context6.n = 1;
42726
+ _context7.n = 1;
42519
42727
  break;
42520
42728
  }
42521
42729
  console.warn('⚠️ getComponents(): Invalid filter options provided:', validation.message);
42522
- return _context6.a(2, []);
42730
+ return _context7.a(2, []);
42523
42731
  case 1:
42524
- _context6.p = 1;
42732
+ _context7.p = 1;
42525
42733
  // Always include metadata
42526
42734
  enhancedOptions = _objectSpread2(_objectSpread2({}, options), {}, {
42527
42735
  includeMetadata: true
42528
42736
  });
42529
- _context6.n = 2;
42737
+ _context7.n = 2;
42530
42738
  return this.managers.componentDataManager.getDictionaryComponents(enhancedOptions);
42531
42739
  case 2:
42532
- return _context6.a(2, _context6.v);
42740
+ return _context7.a(2, _context7.v);
42533
42741
  case 3:
42534
- _context6.p = 3;
42535
- _t = _context6.v;
42742
+ _context7.p = 3;
42743
+ _t = _context7.v;
42536
42744
  console.error('❌ getDictionaryComponents(): Error retrieving available components:', _t);
42537
- return _context6.a(2, []);
42745
+ return _context7.a(2, []);
42538
42746
  }
42539
- }, _callee6, this, [[1, 3]]);
42747
+ }, _callee7, this, [[1, 3]]);
42540
42748
  }));
42541
42749
  function getComponents() {
42542
42750
  return _getComponents.apply(this, arguments);
@@ -42639,23 +42847,23 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
42639
42847
  }, {
42640
42848
  key: "extendComponentDictionary",
42641
42849
  value: (function () {
42642
- var _extendComponentDictionary = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7(additionalComponents) {
42643
- return _regenerator().w(function (_context7) {
42644
- while (1) switch (_context7.n) {
42850
+ var _extendComponentDictionary = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8(additionalComponents) {
42851
+ return _regenerator().w(function (_context8) {
42852
+ while (1) switch (_context8.n) {
42645
42853
  case 0:
42646
42854
  if (this.managers.componentDataManager) {
42647
- _context7.n = 1;
42855
+ _context8.n = 1;
42648
42856
  break;
42649
42857
  }
42650
42858
  console.warn('⚠️ extendComponentDictionary(): Component data manager not available');
42651
- return _context7.a(2, false);
42859
+ return _context8.a(2, false);
42652
42860
  case 1:
42653
- _context7.n = 2;
42861
+ _context8.n = 2;
42654
42862
  return this.managers.componentDataManager.extendComponentDictionary(additionalComponents);
42655
42863
  case 2:
42656
- return _context7.a(2, _context7.v);
42864
+ return _context8.a(2, _context8.v);
42657
42865
  }
42658
- }, _callee7, this);
42866
+ }, _callee8, this);
42659
42867
  }));
42660
42868
  function extendComponentDictionary(_x3) {
42661
42869
  return _extendComponentDictionary.apply(this, arguments);
@@ -42729,23 +42937,23 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
42729
42937
  }, {
42730
42938
  key: "removeS3Components",
42731
42939
  value: (function () {
42732
- var _removeS3Components = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8() {
42733
- return _regenerator().w(function (_context8) {
42734
- while (1) switch (_context8.n) {
42940
+ var _removeS3Components = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9() {
42941
+ return _regenerator().w(function (_context9) {
42942
+ while (1) switch (_context9.n) {
42735
42943
  case 0:
42736
42944
  if (this.managers.componentDataManager) {
42737
- _context8.n = 1;
42945
+ _context9.n = 1;
42738
42946
  break;
42739
42947
  }
42740
42948
  console.warn('⚠️ removeS3Components(): Component data manager not available');
42741
- return _context8.a(2, false);
42949
+ return _context9.a(2, false);
42742
42950
  case 1:
42743
- _context8.n = 2;
42951
+ _context9.n = 2;
42744
42952
  return this.managers.componentDataManager.removeS3Components();
42745
42953
  case 2:
42746
- return _context8.a(2, _context8.v);
42954
+ return _context9.a(2, _context9.v);
42747
42955
  }
42748
- }, _callee8, this);
42956
+ }, _callee9, this);
42749
42957
  }));
42750
42958
  function removeS3Components() {
42751
42959
  return _removeS3Components.apply(this, arguments);
@@ -42769,23 +42977,23 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
42769
42977
  }, {
42770
42978
  key: "removeComponentFromDictionary",
42771
42979
  value: (function () {
42772
- var _removeComponentFromDictionary = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9(componentKey) {
42773
- return _regenerator().w(function (_context9) {
42774
- while (1) switch (_context9.n) {
42980
+ var _removeComponentFromDictionary = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0(componentKey) {
42981
+ return _regenerator().w(function (_context0) {
42982
+ while (1) switch (_context0.n) {
42775
42983
  case 0:
42776
42984
  if (this.managers.componentDataManager) {
42777
- _context9.n = 1;
42985
+ _context0.n = 1;
42778
42986
  break;
42779
42987
  }
42780
42988
  console.warn('⚠️ removeComponentFromDictionary(): Component data manager not available');
42781
- return _context9.a(2, false);
42989
+ return _context0.a(2, false);
42782
42990
  case 1:
42783
- _context9.n = 2;
42991
+ _context0.n = 2;
42784
42992
  return this.managers.componentDataManager.removeComponentFromDictionary(componentKey);
42785
42993
  case 2:
42786
- return _context9.a(2, _context9.v);
42994
+ return _context0.a(2, _context0.v);
42787
42995
  }
42788
- }, _callee9, this);
42996
+ }, _callee0, this);
42789
42997
  }));
42790
42998
  function removeComponentFromDictionary(_x4) {
42791
42999
  return _removeComponentFromDictionary.apply(this, arguments);
@@ -42821,8 +43029,8 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
42821
43029
  var componentDictionary = ((_this$managers$compon = this.managers.componentDataManager) === null || _this$managers$compon === void 0 ? void 0 : _this$managers$compon.componentDictionary) || {};
42822
43030
  var missingIds = [];
42823
43031
  sceneData.scene.children.forEach(function (child) {
42824
- var _child$userData;
42825
- var libraryId = (_child$userData = child.userData) === null || _child$userData === void 0 ? void 0 : _child$userData.libraryId;
43032
+ var _child$userData2;
43033
+ var libraryId = (_child$userData2 = child.userData) === null || _child$userData2 === void 0 ? void 0 : _child$userData2.libraryId;
42826
43034
  if (libraryId && !componentDictionary[libraryId]) {
42827
43035
  // Only add unique IDs
42828
43036
  if (!missingIds.includes(libraryId)) {
@@ -42900,8 +43108,8 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
42900
43108
  // If still not found, try finding by originalUuid in userData
42901
43109
  if (!targetObject) {
42902
43110
  this.sceneViewer.scene.traverse(function (child) {
42903
- var _child$userData2;
42904
- if (((_child$userData2 = child.userData) === null || _child$userData2 === void 0 ? void 0 : _child$userData2.originalUuid) === objectId) {
43111
+ var _child$userData3;
43112
+ if (((_child$userData3 = child.userData) === null || _child$userData3 === void 0 ? void 0 : _child$userData3.originalUuid) === objectId) {
42905
43113
  targetObject = child;
42906
43114
  return;
42907
43115
  }
@@ -43032,49 +43240,49 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
43032
43240
  }, {
43033
43241
  key: "initialize2DViewport",
43034
43242
  value: function () {
43035
- var _initialize2DViewport = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0(container) {
43243
+ var _initialize2DViewport = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1(container) {
43036
43244
  var viewType,
43037
43245
  instanceKey,
43038
43246
  success,
43039
- _args0 = arguments,
43247
+ _args1 = arguments,
43040
43248
  _t2;
43041
- return _regenerator().w(function (_context0) {
43042
- while (1) switch (_context0.n) {
43249
+ return _regenerator().w(function (_context1) {
43250
+ while (1) switch (_context1.n) {
43043
43251
  case 0:
43044
- viewType = _args0.length > 1 && _args0[1] !== undefined ? _args0[1] : 'top';
43045
- instanceKey = _args0.length > 2 && _args0[2] !== undefined ? _args0[2] : null;
43252
+ viewType = _args1.length > 1 && _args1[1] !== undefined ? _args1[1] : 'top';
43253
+ instanceKey = _args1.length > 2 && _args1[2] !== undefined ? _args1[2] : null;
43046
43254
  if (container) {
43047
- _context0.n = 1;
43255
+ _context1.n = 1;
43048
43256
  break;
43049
43257
  }
43050
43258
  console.warn('⚠️ initialize2DViewport(): No container provided');
43051
- return _context0.a(2, false);
43259
+ return _context1.a(2, false);
43052
43260
  case 1:
43053
43261
  if (this.managers.viewport2DManager) {
43054
- _context0.n = 2;
43262
+ _context1.n = 2;
43055
43263
  break;
43056
43264
  }
43057
43265
  console.warn('⚠️ initialize2DViewport(): Viewport2D manager not available');
43058
- return _context0.a(2, false);
43266
+ return _context1.a(2, false);
43059
43267
  case 2:
43060
- _context0.p = 2;
43061
- _context0.n = 3;
43268
+ _context1.p = 2;
43269
+ _context1.n = 3;
43062
43270
  return this.managers.viewport2DManager.initialize(container, viewType, instanceKey);
43063
43271
  case 3:
43064
- success = _context0.v;
43272
+ success = _context1.v;
43065
43273
  if (success) {
43066
43274
  console.log("\u2705 2D viewport initialized successfully (".concat(viewType, " view, key: ").concat(instanceKey || viewType, ")"));
43067
43275
  } else {
43068
43276
  console.warn("\u26A0\uFE0F Failed to initialize 2D viewport (".concat(viewType, " view)"));
43069
43277
  }
43070
- return _context0.a(2, success);
43278
+ return _context1.a(2, success);
43071
43279
  case 4:
43072
- _context0.p = 4;
43073
- _t2 = _context0.v;
43280
+ _context1.p = 4;
43281
+ _t2 = _context1.v;
43074
43282
  console.error('❌ initialize2DViewport(): Error initializing 2D viewport:', _t2);
43075
- return _context0.a(2, false);
43283
+ return _context1.a(2, false);
43076
43284
  }
43077
- }, _callee0, this, [[2, 4]]);
43285
+ }, _callee1, this, [[2, 4]]);
43078
43286
  }));
43079
43287
  function initialize2DViewport(_x5) {
43080
43288
  return _initialize2DViewport.apply(this, arguments);
@@ -43252,7 +43460,7 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
43252
43460
  }, {
43253
43461
  key: "initializeModelPreloading",
43254
43462
  value: (function () {
43255
- var _initializeModelPreloading = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1() {
43463
+ var _initializeModelPreloading = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10() {
43256
43464
  var basePath,
43257
43465
  normalizedBasePath,
43258
43466
  dictionaryPath,
@@ -43261,13 +43469,13 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
43261
43469
  componentDictionary,
43262
43470
  _modelPreloader2,
43263
43471
  progress,
43264
- _args1 = arguments,
43472
+ _args10 = arguments,
43265
43473
  _t3;
43266
- return _regenerator().w(function (_context1) {
43267
- while (1) switch (_context1.n) {
43474
+ return _regenerator().w(function (_context10) {
43475
+ while (1) switch (_context10.n) {
43268
43476
  case 0:
43269
- basePath = _args1.length > 0 && _args1[0] !== undefined ? _args1[0] : '/library/';
43270
- _context1.p = 1;
43477
+ basePath = _args10.length > 0 && _args10[0] !== undefined ? _args10[0] : '/library/';
43478
+ _context10.p = 1;
43271
43479
  // Ensure basePath ends with a slash
43272
43480
  normalizedBasePath = basePath.endsWith('/') ? basePath : "".concat(basePath, "/");
43273
43481
  dictionaryPath = "".concat(normalizedBasePath, "component-dictionary.json");
@@ -43278,39 +43486,39 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
43278
43486
  console.log("\uFFFD Models path: ".concat(modelsBasePath));
43279
43487
 
43280
43488
  // Load the component dictionary
43281
- _context1.n = 2;
43489
+ _context10.n = 2;
43282
43490
  return fetch(dictionaryPath);
43283
43491
  case 2:
43284
- response = _context1.v;
43492
+ response = _context10.v;
43285
43493
  if (response.ok) {
43286
- _context1.n = 3;
43494
+ _context10.n = 3;
43287
43495
  break;
43288
43496
  }
43289
43497
  throw new Error("Failed to load component dictionary: ".concat(response.status));
43290
43498
  case 3:
43291
- _context1.n = 4;
43499
+ _context10.n = 4;
43292
43500
  return response.json();
43293
43501
  case 4:
43294
- componentDictionary = _context1.v;
43502
+ componentDictionary = _context10.v;
43295
43503
  console.log('📚 Component dictionary loaded:', Object.keys(componentDictionary));
43296
43504
 
43297
43505
  // Start preloading all models with the specified base path
43298
43506
  _modelPreloader2 = this.getUtility('modelPreloader');
43299
- _context1.n = 5;
43507
+ _context10.n = 5;
43300
43508
  return _modelPreloader2.preloadAllModels(componentDictionary, modelsBasePath);
43301
43509
  case 5:
43302
- progress = _context1.v;
43510
+ progress = _context10.v;
43303
43511
  console.log('🎉 Model preloading completed:', progress);
43304
- return _context1.a(2, progress);
43512
+ return _context10.a(2, progress);
43305
43513
  case 6:
43306
- _context1.p = 6;
43307
- _t3 = _context1.v;
43514
+ _context10.p = 6;
43515
+ _t3 = _context10.v;
43308
43516
  console.error('❌ Failed to initialize model preloading:', _t3);
43309
43517
  throw _t3;
43310
43518
  case 7:
43311
- return _context1.a(2);
43519
+ return _context10.a(2);
43312
43520
  }
43313
- }, _callee1, this, [[1, 6]]);
43521
+ }, _callee10, this, [[1, 6]]);
43314
43522
  }));
43315
43523
  function initializeModelPreloading() {
43316
43524
  return _initializeModelPreloading.apply(this, arguments);
@@ -43327,86 +43535,86 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
43327
43535
  }, {
43328
43536
  key: "importScene",
43329
43537
  value: (function () {
43330
- var _importScene = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10(jsonData) {
43538
+ var _importScene = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee11(jsonData) {
43331
43539
  var validation, missingIds, resolved, _t4, _t5;
43332
- return _regenerator().w(function (_context10) {
43333
- while (1) switch (_context10.n) {
43540
+ return _regenerator().w(function (_context11) {
43541
+ while (1) switch (_context11.n) {
43334
43542
  case 0:
43335
43543
  if (jsonData) {
43336
- _context10.n = 1;
43544
+ _context11.n = 1;
43337
43545
  break;
43338
43546
  }
43339
43547
  console.error('❌ No JSON data provided for import');
43340
- return _context10.a(2, false);
43548
+ return _context11.a(2, false);
43341
43549
  case 1:
43342
- _context10.p = 1;
43550
+ _context11.p = 1;
43343
43551
  // Validate scene data structure
43344
43552
  validation = this.internals.validateAndAnalyzeSceneData(jsonData);
43345
43553
  if (validation.isValid) {
43346
- _context10.n = 2;
43554
+ _context11.n = 2;
43347
43555
  break;
43348
43556
  }
43349
43557
  console.error('❌ Invalid scene data format:', validation.message);
43350
- return _context10.a(2, false);
43558
+ return _context11.a(2, false);
43351
43559
  case 2:
43352
43560
  if (!this._componentDefinitionResolver) {
43353
- _context10.n = 8;
43561
+ _context11.n = 8;
43354
43562
  break;
43355
43563
  }
43356
43564
  missingIds = this.getMissingLibraryIds(jsonData);
43357
43565
  if (!(missingIds.length > 0)) {
43358
- _context10.n = 8;
43566
+ _context11.n = 8;
43359
43567
  break;
43360
43568
  }
43361
- _context10.p = 3;
43569
+ _context11.p = 3;
43362
43570
  console.log("\uD83D\uDD0D importScene(): Resolving ".concat(missingIds.length, " missing component definition(s)..."));
43363
- _context10.n = 4;
43571
+ _context11.n = 4;
43364
43572
  return this._componentDefinitionResolver(missingIds);
43365
43573
  case 4:
43366
- resolved = _context10.v;
43574
+ resolved = _context11.v;
43367
43575
  if (!(resolved && _typeof(resolved) === 'object' && Object.keys(resolved).length > 0)) {
43368
- _context10.n = 6;
43576
+ _context11.n = 6;
43369
43577
  break;
43370
43578
  }
43371
- _context10.n = 5;
43579
+ _context11.n = 5;
43372
43580
  return this.extendComponentDictionary(resolved);
43373
43581
  case 5:
43374
43582
  console.log("\u2705 importScene(): Resolved ".concat(Object.keys(resolved).length, " component definition(s)"));
43375
43583
  case 6:
43376
- _context10.n = 8;
43584
+ _context11.n = 8;
43377
43585
  break;
43378
43586
  case 7:
43379
- _context10.p = 7;
43380
- _t4 = _context10.v;
43587
+ _context11.p = 7;
43588
+ _t4 = _context11.v;
43381
43589
  console.warn('⚠️ importScene(): Component definition resolver failed, continuing with existing dictionary:', _t4);
43382
43590
  case 8:
43383
- _context10.n = 9;
43591
+ _context11.n = 9;
43384
43592
  return this.setImportedSceneData(jsonData);
43385
43593
  case 9:
43386
43594
  if (!(this.sceneViewer && this.sceneViewer.sceneOperationsManager)) {
43387
- _context10.n = 11;
43595
+ _context11.n = 11;
43388
43596
  break;
43389
43597
  }
43390
- _context10.n = 10;
43598
+ _context11.n = 10;
43391
43599
  return this.sceneViewer.sceneOperationsManager.loadSceneFromData(jsonData);
43392
43600
  case 10:
43393
43601
  console.log('✅ Scene imported successfully');
43394
- return _context10.a(2, true);
43602
+ return _context11.a(2, true);
43395
43603
  case 11:
43396
43604
  console.error('❌ SceneViewer not available for scene loading');
43397
- return _context10.a(2, false);
43605
+ return _context11.a(2, false);
43398
43606
  case 12:
43399
- _context10.n = 14;
43607
+ _context11.n = 14;
43400
43608
  break;
43401
43609
  case 13:
43402
- _context10.p = 13;
43403
- _t5 = _context10.v;
43610
+ _context11.p = 13;
43611
+ _t5 = _context11.v;
43404
43612
  console.error('❌ Error importing scene:', _t5);
43405
- return _context10.a(2, false);
43613
+ return _context11.a(2, false);
43406
43614
  case 14:
43407
- return _context10.a(2);
43615
+ return _context11.a(2);
43408
43616
  }
43409
- }, _callee10, this, [[3, 7], [1, 13]]);
43617
+ }, _callee11, this, [[3, 7], [1, 13]]);
43410
43618
  }));
43411
43619
  function importScene(_x6) {
43412
43620
  return _importScene.apply(this, arguments);
@@ -43430,33 +43638,33 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
43430
43638
  }, {
43431
43639
  key: "exportSceneJSON",
43432
43640
  value: (function () {
43433
- var _exportSceneJSON = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee11() {
43641
+ var _exportSceneJSON = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee12() {
43434
43642
  var filename,
43435
- _args11 = arguments,
43643
+ _args12 = arguments,
43436
43644
  _t6;
43437
- return _regenerator().w(function (_context11) {
43438
- while (1) switch (_context11.n) {
43645
+ return _regenerator().w(function (_context12) {
43646
+ while (1) switch (_context12.n) {
43439
43647
  case 0:
43440
- filename = _args11.length > 0 && _args11[0] !== undefined ? _args11[0] : null;
43648
+ filename = _args12.length > 0 && _args12[0] !== undefined ? _args12[0] : null;
43441
43649
  if (this.managers.sceneExportManager) {
43442
- _context11.n = 1;
43650
+ _context12.n = 1;
43443
43651
  break;
43444
43652
  }
43445
43653
  console.error('❌ Scene export manager not available');
43446
- return _context11.a(2, false);
43654
+ return _context12.a(2, false);
43447
43655
  case 1:
43448
- _context11.p = 1;
43449
- _context11.n = 2;
43656
+ _context12.p = 1;
43657
+ _context12.n = 2;
43450
43658
  return this.managers.sceneExportManager.downloadSceneJSON(filename);
43451
43659
  case 2:
43452
- return _context11.a(2, _context11.v);
43660
+ return _context12.a(2, _context12.v);
43453
43661
  case 3:
43454
- _context11.p = 3;
43455
- _t6 = _context11.v;
43662
+ _context12.p = 3;
43663
+ _t6 = _context12.v;
43456
43664
  console.error('❌ Error exporting scene as JSON:', _t6);
43457
- return _context11.a(2, false);
43665
+ return _context12.a(2, false);
43458
43666
  }
43459
- }, _callee11, this, [[1, 3]]);
43667
+ }, _callee12, this, [[1, 3]]);
43460
43668
  }));
43461
43669
  function exportSceneJSON() {
43462
43670
  return _exportSceneJSON.apply(this, arguments);
@@ -43481,33 +43689,33 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
43481
43689
  }, {
43482
43690
  key: "exportSceneGLTF",
43483
43691
  value: (function () {
43484
- var _exportSceneGLTF = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee12() {
43692
+ var _exportSceneGLTF = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee13() {
43485
43693
  var filename,
43486
- _args12 = arguments,
43694
+ _args13 = arguments,
43487
43695
  _t7;
43488
- return _regenerator().w(function (_context12) {
43489
- while (1) switch (_context12.n) {
43696
+ return _regenerator().w(function (_context13) {
43697
+ while (1) switch (_context13.n) {
43490
43698
  case 0:
43491
- filename = _args12.length > 0 && _args12[0] !== undefined ? _args12[0] : null;
43699
+ filename = _args13.length > 0 && _args13[0] !== undefined ? _args13[0] : null;
43492
43700
  if (this.managers.sceneExportManager) {
43493
- _context12.n = 1;
43701
+ _context13.n = 1;
43494
43702
  break;
43495
43703
  }
43496
43704
  console.error('❌ Scene export manager not available');
43497
- return _context12.a(2, false);
43705
+ return _context13.a(2, false);
43498
43706
  case 1:
43499
- _context12.p = 1;
43500
- _context12.n = 2;
43707
+ _context13.p = 1;
43708
+ _context13.n = 2;
43501
43709
  return this.managers.sceneExportManager.exportSceneAsGLTF(filename, false);
43502
43710
  case 2:
43503
- return _context12.a(2, _context12.v);
43711
+ return _context13.a(2, _context13.v);
43504
43712
  case 3:
43505
- _context12.p = 3;
43506
- _t7 = _context12.v;
43713
+ _context13.p = 3;
43714
+ _t7 = _context13.v;
43507
43715
  console.error('❌ Error exporting scene as GLTF:', _t7);
43508
- return _context12.a(2, false);
43716
+ return _context13.a(2, false);
43509
43717
  }
43510
- }, _callee12, this, [[1, 3]]);
43718
+ }, _callee13, this, [[1, 3]]);
43511
43719
  }));
43512
43720
  function exportSceneGLTF() {
43513
43721
  return _exportSceneGLTF.apply(this, arguments);
@@ -43533,33 +43741,33 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
43533
43741
  }, {
43534
43742
  key: "exportSceneGLB",
43535
43743
  value: (function () {
43536
- var _exportSceneGLB = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee13() {
43744
+ var _exportSceneGLB = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee14() {
43537
43745
  var filename,
43538
- _args13 = arguments,
43746
+ _args14 = arguments,
43539
43747
  _t8;
43540
- return _regenerator().w(function (_context13) {
43541
- while (1) switch (_context13.n) {
43748
+ return _regenerator().w(function (_context14) {
43749
+ while (1) switch (_context14.n) {
43542
43750
  case 0:
43543
- filename = _args13.length > 0 && _args13[0] !== undefined ? _args13[0] : null;
43751
+ filename = _args14.length > 0 && _args14[0] !== undefined ? _args14[0] : null;
43544
43752
  if (this.managers.sceneExportManager) {
43545
- _context13.n = 1;
43753
+ _context14.n = 1;
43546
43754
  break;
43547
43755
  }
43548
43756
  console.error('❌ Scene export manager not available');
43549
- return _context13.a(2, false);
43757
+ return _context14.a(2, false);
43550
43758
  case 1:
43551
- _context13.p = 1;
43552
- _context13.n = 2;
43759
+ _context14.p = 1;
43760
+ _context14.n = 2;
43553
43761
  return this.managers.sceneExportManager.exportSceneAsGLB(filename);
43554
43762
  case 2:
43555
- return _context13.a(2, _context13.v);
43763
+ return _context14.a(2, _context14.v);
43556
43764
  case 3:
43557
- _context13.p = 3;
43558
- _t8 = _context13.v;
43765
+ _context14.p = 3;
43766
+ _t8 = _context14.v;
43559
43767
  console.error('❌ Error exporting scene as GLB:', _t8);
43560
- return _context13.a(2, false);
43768
+ return _context14.a(2, false);
43561
43769
  }
43562
- }, _callee13, this, [[1, 3]]);
43770
+ }, _callee14, this, [[1, 3]]);
43563
43771
  }));
43564
43772
  function exportSceneGLB() {
43565
43773
  return _exportSceneGLB.apply(this, arguments);
@@ -43598,16 +43806,16 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
43598
43806
  }, {
43599
43807
  key: "loadSceneFromData",
43600
43808
  value: (function () {
43601
- var _loadSceneFromData = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee14(sceneData) {
43602
- return _regenerator().w(function (_context14) {
43603
- while (1) switch (_context14.n) {
43809
+ var _loadSceneFromData = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee15(sceneData) {
43810
+ return _regenerator().w(function (_context15) {
43811
+ while (1) switch (_context15.n) {
43604
43812
  case 0:
43605
- _context14.n = 1;
43813
+ _context15.n = 1;
43606
43814
  return this.setImportedSceneData(sceneData);
43607
43815
  case 1:
43608
- return _context14.a(2, true);
43816
+ return _context15.a(2, true);
43609
43817
  }
43610
- }, _callee14, this);
43818
+ }, _callee15, this);
43611
43819
  }));
43612
43820
  function loadSceneFromData(_x7) {
43613
43821
  return _loadSceneFromData.apply(this, arguments);
@@ -43632,9 +43840,9 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
43632
43840
  }, {
43633
43841
  key: "clearScene",
43634
43842
  value: function clearScene() {
43635
- var _this$sceneViewer12;
43843
+ var _this$sceneViewer13;
43636
43844
  this.importedSceneData = null;
43637
- var ioBehavMgr = (_this$sceneViewer12 = this.sceneViewer) === null || _this$sceneViewer12 === void 0 || (_this$sceneViewer12 = _this$sceneViewer12.managers) === null || _this$sceneViewer12 === void 0 ? void 0 : _this$sceneViewer12.ioBehaviorManager;
43845
+ var ioBehavMgr = (_this$sceneViewer13 = this.sceneViewer) === null || _this$sceneViewer13 === void 0 || (_this$sceneViewer13 = _this$sceneViewer13.managers) === null || _this$sceneViewer13 === void 0 ? void 0 : _this$sceneViewer13.ioBehaviorManager;
43638
43846
  if (ioBehavMgr) {
43639
43847
  ioBehavMgr.setCrossComponentBehaviors([]);
43640
43848
  }