@2112-lab/central-plant 0.3.44 → 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
@@ -27898,7 +27900,7 @@ var PathRenderingManager = /*#__PURE__*/function (_BaseDisposable) {
27898
27900
  }]);
27899
27901
  }(BaseDisposable);
27900
27902
 
27901
- var _excluded$2 = ["direction"];
27903
+ var _excluded$1 = ["direction"];
27902
27904
  var ConnectorManager = /*#__PURE__*/function (_BaseDisposable) {
27903
27905
  function ConnectorManager(sceneViewer) {
27904
27906
  var _this;
@@ -28043,7 +28045,7 @@ var ConnectorManager = /*#__PURE__*/function (_BaseDisposable) {
28043
28045
  // Filter out 'direction' attribute - manual segment connectors don't need it
28044
28046
  var _ref = connector.userData || {};
28045
28047
  _ref.direction;
28046
- var cleanedUserData = _objectWithoutProperties(_ref, _excluded$2);
28048
+ var cleanedUserData = _objectWithoutProperties(_ref, _excluded$1);
28047
28049
  var sceneDataConnector = {
28048
28050
  uuid: connector.uuid,
28049
28051
  userData: _objectSpread2(_objectSpread2({}, cleanedUserData), {}, {
@@ -32810,7 +32812,7 @@ var SceneClearingUtility = /*#__PURE__*/function () {
32810
32812
  }]);
32811
32813
  }();
32812
32814
 
32813
- var _excluded$1 = ["direction"],
32815
+ var _excluded = ["direction"],
32814
32816
  _excluded2 = ["direction"];
32815
32817
  var SceneOperationsManager = /*#__PURE__*/function () {
32816
32818
  function SceneOperationsManager(sceneViewer) {
@@ -33399,7 +33401,7 @@ var SceneOperationsManager = /*#__PURE__*/function () {
33399
33401
  // Initialize userData (filter out 'direction' - manual segment connectors don't need it)
33400
33402
  var _ref = connectorData.userData || {};
33401
33403
  _ref.direction;
33402
- var _cleanedUserData = _objectWithoutProperties(_ref, _excluded$1);
33404
+ var _cleanedUserData = _objectWithoutProperties(_ref, _excluded);
33403
33405
  _connectorMesh.userData = _objectSpread2(_objectSpread2({}, _cleanedUserData), {}, {
33404
33406
  originalUuid: connectorData.uuid,
33405
33407
  objectType: 'segment-connector',
@@ -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) {
@@ -37881,7 +37963,14 @@ function modelOffsetToWorldDelta(modelRoot, offset, customQuat) {
37881
37963
  function applyModelRootTranslation(mesh, modelRoot, origLocalPos, modelOffset, customQuat) {
37882
37964
  if (!mesh || !modelRoot || !origLocalPos) return;
37883
37965
  mesh.position.copy(origLocalPos);
37884
- mesh.updateMatrixWorld(true);
37966
+
37967
+ // Ensure all ancestors are updated so getWorldPosition is accurate
37968
+ // even if a parent component was recently moved.
37969
+ if (typeof mesh.updateWorldMatrix === 'function') {
37970
+ mesh.updateWorldMatrix(true, false);
37971
+ } else {
37972
+ mesh.updateMatrixWorld(true);
37973
+ }
37885
37974
  var origWorldPos = new THREE__namespace.Vector3();
37886
37975
  mesh.getWorldPosition(origWorldPos);
37887
37976
  var newWorldPos = origWorldPos.add(modelOffsetToWorldDelta(modelRoot, modelOffset, customQuat));
@@ -37928,6 +38017,13 @@ var IoBehaviorManager = /*#__PURE__*/function (_BaseDisposable) {
37928
38017
  /** @type {Map<string, Object[]>} cache key → data point definitions */
37929
38018
  _this._dataPointsCache = new Map();
37930
38019
 
38020
+ // Listen for object transformations to invalidate world-pose caches
38021
+ if (_this.sceneViewer && typeof _this.sceneViewer.on === 'function') {
38022
+ _this.sceneViewer.on('objectTransformed', function () {
38023
+ return _this.invalidateCaches();
38024
+ });
38025
+ }
38026
+
37931
38027
  /**
37932
38028
  * Injected by the host application to read and write I/O device state.
37933
38029
  * Set via configure(). Shape:
@@ -37989,6 +38085,13 @@ var IoBehaviorManager = /*#__PURE__*/function (_BaseDisposable) {
37989
38085
  console.warn("[IoBehaviorManager] Could not find mesh for animation \"".concat(anim.name || anim.stateVariable, "\" (uuid: ").concat(anim.meshUuid, ", name: \"").concat(anim.meshName, "\")"));
37990
38086
  continue;
37991
38087
  }
38088
+
38089
+ // Ensure world matrix is fresh before capturing rest world pose
38090
+ if (typeof mesh.updateWorldMatrix === 'function') {
38091
+ mesh.updateWorldMatrix(true, false);
38092
+ } else {
38093
+ mesh.updateMatrixWorld(true);
38094
+ }
37992
38095
  var worldPos = new THREE__namespace.Vector3();
37993
38096
  mesh.getWorldPosition(worldPos);
37994
38097
  var worldQuat = new THREE__namespace.Quaternion();
@@ -38579,6 +38682,40 @@ var IoBehaviorManager = /*#__PURE__*/function (_BaseDisposable) {
38579
38682
  this._attachmentParentMap.clear();
38580
38683
  this._dataPointsCache.clear();
38581
38684
  }
38685
+
38686
+ /**
38687
+ * Invalidate world-space pose caches for all registered entries.
38688
+ * Call this when components are moved or rotated to ensure behaviors
38689
+ * recalculate their world-space rest pose.
38690
+ */
38691
+ }, {
38692
+ key: "invalidateCaches",
38693
+ value: function invalidateCaches() {
38694
+ var _iterator9 = _createForOfIteratorHelper(this._entries.values()),
38695
+ _step9;
38696
+ try {
38697
+ for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
38698
+ var entryList = _step9.value;
38699
+ var _iterator0 = _createForOfIteratorHelper(entryList),
38700
+ _step0;
38701
+ try {
38702
+ for (_iterator0.s(); !(_step0 = _iterator0.n()).done;) {
38703
+ var entry = _step0.value;
38704
+ delete entry._restWorldCache;
38705
+ }
38706
+ } catch (err) {
38707
+ _iterator0.e(err);
38708
+ } finally {
38709
+ _iterator0.f();
38710
+ }
38711
+ }
38712
+ } catch (err) {
38713
+ _iterator9.e(err);
38714
+ } finally {
38715
+ _iterator9.f();
38716
+ }
38717
+ this._dataPointsCache.clear();
38718
+ }
38582
38719
  }, {
38583
38720
  key: "dispose",
38584
38721
  value: function dispose() {
@@ -38657,11 +38794,11 @@ var IoBehaviorManager = /*#__PURE__*/function (_BaseDisposable) {
38657
38794
  var mapping = this._resolveMapping(anim, value);
38658
38795
  if (!mapping) return;
38659
38796
  var types = anim.transformTypes || [];
38660
- var _iterator9 = _createForOfIteratorHelper(types),
38661
- _step9;
38797
+ var _iterator1 = _createForOfIteratorHelper(types),
38798
+ _step1;
38662
38799
  try {
38663
- for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
38664
- var type = _step9.value;
38800
+ for (_iterator1.s(); !(_step1 = _iterator1.n()).done;) {
38801
+ var type = _step1.value;
38665
38802
  if (type === 'translation') {
38666
38803
  this._applyTranslation(entry, mapping.transform);
38667
38804
  } else if (type === 'rotation') {
@@ -38671,9 +38808,9 @@ var IoBehaviorManager = /*#__PURE__*/function (_BaseDisposable) {
38671
38808
  }
38672
38809
  }
38673
38810
  } catch (err) {
38674
- _iterator9.e(err);
38811
+ _iterator1.e(err);
38675
38812
  } finally {
38676
- _iterator9.f();
38813
+ _iterator1.f();
38677
38814
  }
38678
38815
  }
38679
38816
 
@@ -38833,7 +38970,14 @@ var IoBehaviorManager = /*#__PURE__*/function (_BaseDisposable) {
38833
38970
  var savedQuat = mesh.quaternion.clone();
38834
38971
  mesh.position.copy(origPos);
38835
38972
  mesh.rotation.copy(origRot);
38836
- mesh.updateMatrixWorld(true);
38973
+
38974
+ // Ensure all ancestors are updated so getWorldPosition is accurate
38975
+ // even if a parent component was recently moved.
38976
+ if (typeof mesh.updateWorldMatrix === 'function') {
38977
+ mesh.updateWorldMatrix(true, false);
38978
+ } else {
38979
+ mesh.updateMatrixWorld(true);
38980
+ }
38837
38981
  var origWorldPos = new THREE__namespace.Vector3();
38838
38982
  mesh.getWorldPosition(origWorldPos);
38839
38983
  var origWorldQuat = new THREE__namespace.Quaternion();
@@ -39336,6 +39480,7 @@ var CentralPlantInternals = /*#__PURE__*/function () {
39336
39480
  this.centralPlant.managers.keyboardControlsManager = new KeyboardControlsManager(this.centralPlant.sceneViewer);
39337
39481
  this.centralPlant.managers.pathfindingManager = new PathfindingManager(this.centralPlant.sceneViewer);
39338
39482
  this.centralPlant.managers.pathFlowManager = new PathFlowManager(this.centralPlant.sceneViewer);
39483
+ this.centralPlant.managers.collisionManager = new CollisionManager(this.centralPlant.sceneViewer);
39339
39484
  this.centralPlant.managers.sceneOperationsManager = new SceneOperationsManager(this.centralPlant.sceneViewer);
39340
39485
  this.centralPlant.managers.animationManager = new AnimationManager(this.centralPlant.sceneViewer);
39341
39486
  this.centralPlant.managers.cameraControlsManager = new CameraControlsManager(this.centralPlant.sceneViewer);
@@ -40774,7 +40919,7 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
40774
40919
  * Initialize the CentralPlant manager
40775
40920
  *
40776
40921
  * @constructor
40777
- * @version 0.3.44
40922
+ * @version 0.3.46
40778
40923
  * @updated 2025-10-22
40779
40924
  *
40780
40925
  * @description Creates a new CentralPlant instance and initializes internal managers and utilities.
@@ -40912,6 +41057,32 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
40912
41057
  return this.internals.attachToComponent();
40913
41058
  }
40914
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
+
40915
41086
  /**
40916
41087
  * Initialize specific managers that need to be created after scene setup
40917
41088
  * @returns {boolean} True if post-scene managers were initialized successfully, false otherwise
@@ -41592,6 +41763,104 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
41592
41763
  return this.internals.addConnection(fromConnectorId, toConnectorId);
41593
41764
  }
41594
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
+ }()
41595
41864
  /**
41596
41865
  * Remove a connection between two component connectors
41597
41866
  * @param {string} fromConnectorId - The UUID of the source connector
@@ -41613,6 +41882,7 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
41613
41882
  * centralPlant.updatePaths();
41614
41883
  * }
41615
41884
  */
41885
+ )
41616
41886
  }, {
41617
41887
  key: "removeConnection",
41618
41888
  value: function removeConnection(fromConnectorId, toConnectorId) {
@@ -41817,8 +42087,8 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
41817
42087
  }, {
41818
42088
  key: "_dispatchIoState",
41819
42089
  value: function _dispatchIoState(attachmentId, stateId, value, parentUuid) {
41820
- var _this$managers, _this$sceneViewer4, _this$sceneViewer5, _this$managers2, _this$sceneViewer6, _this$sceneViewer7, _this$sceneViewer8;
41821
- 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);
41822
42092
  var stateAdapter = tooltipMgr === null || tooltipMgr === void 0 ? void 0 : tooltipMgr._stateAdapter;
41823
42093
  if (stateAdapter !== null && stateAdapter !== void 0 && stateAdapter.setState) {
41824
42094
  var scopedKey = getScopedAttachmentKey(attachmentId, parentUuid);
@@ -41828,11 +42098,11 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
41828
42098
  console.warn('⚠️ _dispatchIoState(): stateAdapter.setState() threw:', err);
41829
42099
  }
41830
42100
  }
41831
- 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);
41832
42102
  if (ioBehavMgr) {
41833
42103
  ioBehavMgr.triggerState(attachmentId, stateId, value, parentUuid);
41834
42104
  }
41835
- (_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', {
41836
42106
  attachmentId: attachmentId,
41837
42107
  stateId: stateId,
41838
42108
  value: value,
@@ -41847,16 +42117,16 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
41847
42117
  }, {
41848
42118
  key: "configureStateAdapter",
41849
42119
  value: function configureStateAdapter(stateAdapter) {
41850
- var _this$managers3, _this$sceneViewer9, _this$managers4, _this$sceneViewer1, _this$sceneViewer10;
41851
- 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);
41852
42122
  if (tooltipMgr !== null && tooltipMgr !== void 0 && tooltipMgr.configure) {
41853
- var _this$sceneViewer0;
42123
+ var _this$sceneViewer1;
41854
42124
  tooltipMgr.configure(stateAdapter);
41855
- 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) {
41856
42126
  this.sceneViewer.managers.componentTooltipManager = tooltipMgr;
41857
42127
  }
41858
42128
  }
41859
- 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);
41860
42130
  if (ioBehavMgr !== null && ioBehavMgr !== void 0 && ioBehavMgr.configure) {
41861
42131
  ioBehavMgr.configure(stateAdapter);
41862
42132
  }
@@ -41891,13 +42161,13 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
41891
42161
  }, {
41892
42162
  key: "getSceneAttachments",
41893
42163
  value: function getSceneAttachments() {
41894
- var _this$sceneViewer11;
41895
- 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;
41896
42166
  if (!scene) return [];
41897
42167
  var results = [];
41898
42168
  scene.traverse(function (obj) {
41899
- var _obj$userData;
41900
- 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') {
41901
42171
  var _parent$userData;
41902
42172
  var attachmentId = obj.userData.attachmentId || obj.name || obj.uuid;
41903
42173
  var label = obj.userData.attachmentLabel || attachmentId;
@@ -41957,9 +42227,9 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
41957
42227
  }, {
41958
42228
  key: "getIoDevices",
41959
42229
  value: function getIoDevices() {
41960
- var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
41961
- _ref$source = _ref.source,
41962
- 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;
41963
42233
  var mp = this.getUtility('modelPreloader');
41964
42234
  var dict = mp === null || mp === void 0 ? void 0 : mp.componentDictionary;
41965
42235
  if (!dict) {
@@ -41995,8 +42265,8 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
41995
42265
  }, {
41996
42266
  key: "getIoDeviceUsage",
41997
42267
  value: function getIoDeviceUsage() {
41998
- var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
41999
- deviceUuid = _ref2.deviceUuid;
42268
+ var _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
42269
+ deviceUuid = _ref3.deviceUuid;
42000
42270
  if (!deviceUuid) {
42001
42271
  console.warn('⚠️ getIoDeviceUsage(): deviceUuid is required');
42002
42272
  return [];
@@ -42047,38 +42317,38 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
42047
42317
  }, {
42048
42318
  key: "createSmartComponent",
42049
42319
  value: (function () {
42050
- var _createSmartComponent = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3() {
42051
- var _ref3,
42320
+ var _createSmartComponent = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4() {
42321
+ var _ref4,
42052
42322
  componentUuid,
42053
42323
  name,
42054
42324
  attachments,
42055
42325
  thumbnailBlob,
42056
42326
  newAsset,
42057
42327
  mp,
42058
- _args3 = arguments;
42059
- return _regenerator().w(function (_context3) {
42060
- while (1) switch (_context3.n) {
42328
+ _args4 = arguments;
42329
+ return _regenerator().w(function (_context4) {
42330
+ while (1) switch (_context4.n) {
42061
42331
  case 0:
42062
- _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;
42063
42333
  if (this.assetService) {
42064
- _context3.n = 1;
42334
+ _context4.n = 1;
42065
42335
  break;
42066
42336
  }
42067
42337
  throw new Error('createSmartComponent(): no asset service set — call setAssetService() first');
42068
42338
  case 1:
42069
42339
  if (componentUuid) {
42070
- _context3.n = 2;
42340
+ _context4.n = 2;
42071
42341
  break;
42072
42342
  }
42073
42343
  throw new Error('createSmartComponent(): componentUuid is required');
42074
42344
  case 2:
42075
42345
  if (!(!Array.isArray(attachments) || attachments.length === 0)) {
42076
- _context3.n = 3;
42346
+ _context4.n = 3;
42077
42347
  break;
42078
42348
  }
42079
42349
  throw new Error('createSmartComponent(): at least one attachment is required');
42080
42350
  case 3:
42081
- _context3.n = 4;
42351
+ _context4.n = 4;
42082
42352
  return this.assetService.createSmartComponent({
42083
42353
  componentUuid: componentUuid,
42084
42354
  name: name,
@@ -42086,7 +42356,7 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
42086
42356
  thumbnailBlob: thumbnailBlob
42087
42357
  });
42088
42358
  case 4:
42089
- newAsset = _context3.v;
42359
+ newAsset = _context4.v;
42090
42360
  // Register in model preloader dictionary so addComponent() can use it immediately
42091
42361
  mp = this.getUtility('modelPreloader');
42092
42362
  if (mp !== null && mp !== void 0 && mp.componentDictionary && newAsset !== null && newAsset !== void 0 && newAsset.uuid) {
@@ -42095,9 +42365,9 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
42095
42365
  });
42096
42366
  console.log("\u2705 createSmartComponent(): registered \"".concat(newAsset.name, "\" in component dictionary"));
42097
42367
  }
42098
- return _context3.a(2, newAsset);
42368
+ return _context4.a(2, newAsset);
42099
42369
  }
42100
- }, _callee3, this);
42370
+ }, _callee4, this);
42101
42371
  }));
42102
42372
  function createSmartComponent() {
42103
42373
  return _createSmartComponent.apply(this, arguments);
@@ -42131,42 +42401,42 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
42131
42401
  }, {
42132
42402
  key: "addComponentAttachment",
42133
42403
  value: (function () {
42134
- var _addComponentAttachment = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4() {
42135
- var _ref4,
42404
+ var _addComponentAttachment = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5() {
42405
+ var _ref5,
42136
42406
  componentUuid,
42137
42407
  attachment,
42138
42408
  updatedAsset,
42139
42409
  mp,
42140
- _args4 = arguments;
42141
- return _regenerator().w(function (_context4) {
42142
- while (1) switch (_context4.n) {
42410
+ _args5 = arguments;
42411
+ return _regenerator().w(function (_context5) {
42412
+ while (1) switch (_context5.n) {
42143
42413
  case 0:
42144
- _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;
42145
42415
  if (this.assetService) {
42146
- _context4.n = 1;
42416
+ _context5.n = 1;
42147
42417
  break;
42148
42418
  }
42149
42419
  throw new Error('addComponentAttachment(): no asset service set — call setAssetService() first');
42150
42420
  case 1:
42151
42421
  if (componentUuid) {
42152
- _context4.n = 2;
42422
+ _context5.n = 2;
42153
42423
  break;
42154
42424
  }
42155
42425
  throw new Error('addComponentAttachment(): componentUuid is required');
42156
42426
  case 2:
42157
42427
  if (!(!(attachment !== null && attachment !== void 0 && attachment.attachmentId) || !(attachment !== null && attachment !== void 0 && attachment.deviceId))) {
42158
- _context4.n = 3;
42428
+ _context5.n = 3;
42159
42429
  break;
42160
42430
  }
42161
42431
  throw new Error('addComponentAttachment(): attachment must have attachmentId and deviceId');
42162
42432
  case 3:
42163
- _context4.n = 4;
42433
+ _context5.n = 4;
42164
42434
  return this.assetService.addComponentAttachment({
42165
42435
  componentUuid: componentUuid,
42166
42436
  attachment: attachment
42167
42437
  });
42168
42438
  case 4:
42169
- updatedAsset = _context4.v;
42439
+ updatedAsset = _context5.v;
42170
42440
  // Sync component dictionary
42171
42441
  mp = this.getUtility('modelPreloader');
42172
42442
  if (mp !== null && mp !== void 0 && mp.componentDictionary && updatedAsset !== null && updatedAsset !== void 0 && updatedAsset.uuid) {
@@ -42174,9 +42444,9 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
42174
42444
  id: updatedAsset.uuid
42175
42445
  });
42176
42446
  }
42177
- return _context4.a(2, updatedAsset);
42447
+ return _context5.a(2, updatedAsset);
42178
42448
  }
42179
- }, _callee4, this);
42449
+ }, _callee5, this);
42180
42450
  }));
42181
42451
  function addComponentAttachment() {
42182
42452
  return _addComponentAttachment.apply(this, arguments);
@@ -42202,42 +42472,42 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
42202
42472
  }, {
42203
42473
  key: "removeComponentAttachment",
42204
42474
  value: (function () {
42205
- var _removeComponentAttachment = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5() {
42206
- var _ref5,
42475
+ var _removeComponentAttachment = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6() {
42476
+ var _ref6,
42207
42477
  componentUuid,
42208
42478
  attachmentId,
42209
42479
  updatedAsset,
42210
42480
  mp,
42211
- _args5 = arguments;
42212
- return _regenerator().w(function (_context5) {
42213
- while (1) switch (_context5.n) {
42481
+ _args6 = arguments;
42482
+ return _regenerator().w(function (_context6) {
42483
+ while (1) switch (_context6.n) {
42214
42484
  case 0:
42215
- _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;
42216
42486
  if (this.assetService) {
42217
- _context5.n = 1;
42487
+ _context6.n = 1;
42218
42488
  break;
42219
42489
  }
42220
42490
  throw new Error('removeComponentAttachment(): no asset service set — call setAssetService() first');
42221
42491
  case 1:
42222
42492
  if (componentUuid) {
42223
- _context5.n = 2;
42493
+ _context6.n = 2;
42224
42494
  break;
42225
42495
  }
42226
42496
  throw new Error('removeComponentAttachment(): componentUuid is required');
42227
42497
  case 2:
42228
42498
  if (attachmentId) {
42229
- _context5.n = 3;
42499
+ _context6.n = 3;
42230
42500
  break;
42231
42501
  }
42232
42502
  throw new Error('removeComponentAttachment(): attachmentId is required');
42233
42503
  case 3:
42234
- _context5.n = 4;
42504
+ _context6.n = 4;
42235
42505
  return this.assetService.removeComponentAttachment({
42236
42506
  componentUuid: componentUuid,
42237
42507
  attachmentId: attachmentId
42238
42508
  });
42239
42509
  case 4:
42240
- updatedAsset = _context5.v;
42510
+ updatedAsset = _context6.v;
42241
42511
  // Sync component dictionary
42242
42512
  mp = this.getUtility('modelPreloader');
42243
42513
  if (mp !== null && mp !== void 0 && mp.componentDictionary && updatedAsset !== null && updatedAsset !== void 0 && updatedAsset.uuid) {
@@ -42245,9 +42515,9 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
42245
42515
  id: updatedAsset.uuid
42246
42516
  });
42247
42517
  }
42248
- return _context5.a(2, updatedAsset);
42518
+ return _context6.a(2, updatedAsset);
42249
42519
  }
42250
- }, _callee5, this);
42520
+ }, _callee6, this);
42251
42521
  }));
42252
42522
  function removeComponentAttachment() {
42253
42523
  return _removeComponentAttachment.apply(this, arguments);
@@ -42440,41 +42710,41 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
42440
42710
  }, {
42441
42711
  key: "getComponents",
42442
42712
  value: (function () {
42443
- var _getComponents = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6() {
42713
+ var _getComponents = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7() {
42444
42714
  var options,
42445
42715
  validation,
42446
42716
  enhancedOptions,
42447
- _args6 = arguments,
42717
+ _args7 = arguments,
42448
42718
  _t;
42449
- return _regenerator().w(function (_context6) {
42450
- while (1) switch (_context6.n) {
42719
+ return _regenerator().w(function (_context7) {
42720
+ while (1) switch (_context7.n) {
42451
42721
  case 0:
42452
- options = _args6.length > 0 && _args6[0] !== undefined ? _args6[0] : {};
42722
+ options = _args7.length > 0 && _args7[0] !== undefined ? _args7[0] : {};
42453
42723
  // Validate filter options using centralized validator
42454
42724
  validation = this.internals.validator.validateComponentFilter(options);
42455
42725
  if (validation.isValid) {
42456
- _context6.n = 1;
42726
+ _context7.n = 1;
42457
42727
  break;
42458
42728
  }
42459
42729
  console.warn('⚠️ getComponents(): Invalid filter options provided:', validation.message);
42460
- return _context6.a(2, []);
42730
+ return _context7.a(2, []);
42461
42731
  case 1:
42462
- _context6.p = 1;
42732
+ _context7.p = 1;
42463
42733
  // Always include metadata
42464
42734
  enhancedOptions = _objectSpread2(_objectSpread2({}, options), {}, {
42465
42735
  includeMetadata: true
42466
42736
  });
42467
- _context6.n = 2;
42737
+ _context7.n = 2;
42468
42738
  return this.managers.componentDataManager.getDictionaryComponents(enhancedOptions);
42469
42739
  case 2:
42470
- return _context6.a(2, _context6.v);
42740
+ return _context7.a(2, _context7.v);
42471
42741
  case 3:
42472
- _context6.p = 3;
42473
- _t = _context6.v;
42742
+ _context7.p = 3;
42743
+ _t = _context7.v;
42474
42744
  console.error('❌ getDictionaryComponents(): Error retrieving available components:', _t);
42475
- return _context6.a(2, []);
42745
+ return _context7.a(2, []);
42476
42746
  }
42477
- }, _callee6, this, [[1, 3]]);
42747
+ }, _callee7, this, [[1, 3]]);
42478
42748
  }));
42479
42749
  function getComponents() {
42480
42750
  return _getComponents.apply(this, arguments);
@@ -42577,23 +42847,23 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
42577
42847
  }, {
42578
42848
  key: "extendComponentDictionary",
42579
42849
  value: (function () {
42580
- var _extendComponentDictionary = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7(additionalComponents) {
42581
- return _regenerator().w(function (_context7) {
42582
- 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) {
42583
42853
  case 0:
42584
42854
  if (this.managers.componentDataManager) {
42585
- _context7.n = 1;
42855
+ _context8.n = 1;
42586
42856
  break;
42587
42857
  }
42588
42858
  console.warn('⚠️ extendComponentDictionary(): Component data manager not available');
42589
- return _context7.a(2, false);
42859
+ return _context8.a(2, false);
42590
42860
  case 1:
42591
- _context7.n = 2;
42861
+ _context8.n = 2;
42592
42862
  return this.managers.componentDataManager.extendComponentDictionary(additionalComponents);
42593
42863
  case 2:
42594
- return _context7.a(2, _context7.v);
42864
+ return _context8.a(2, _context8.v);
42595
42865
  }
42596
- }, _callee7, this);
42866
+ }, _callee8, this);
42597
42867
  }));
42598
42868
  function extendComponentDictionary(_x3) {
42599
42869
  return _extendComponentDictionary.apply(this, arguments);
@@ -42667,23 +42937,23 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
42667
42937
  }, {
42668
42938
  key: "removeS3Components",
42669
42939
  value: (function () {
42670
- var _removeS3Components = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8() {
42671
- return _regenerator().w(function (_context8) {
42672
- 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) {
42673
42943
  case 0:
42674
42944
  if (this.managers.componentDataManager) {
42675
- _context8.n = 1;
42945
+ _context9.n = 1;
42676
42946
  break;
42677
42947
  }
42678
42948
  console.warn('⚠️ removeS3Components(): Component data manager not available');
42679
- return _context8.a(2, false);
42949
+ return _context9.a(2, false);
42680
42950
  case 1:
42681
- _context8.n = 2;
42951
+ _context9.n = 2;
42682
42952
  return this.managers.componentDataManager.removeS3Components();
42683
42953
  case 2:
42684
- return _context8.a(2, _context8.v);
42954
+ return _context9.a(2, _context9.v);
42685
42955
  }
42686
- }, _callee8, this);
42956
+ }, _callee9, this);
42687
42957
  }));
42688
42958
  function removeS3Components() {
42689
42959
  return _removeS3Components.apply(this, arguments);
@@ -42707,23 +42977,23 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
42707
42977
  }, {
42708
42978
  key: "removeComponentFromDictionary",
42709
42979
  value: (function () {
42710
- var _removeComponentFromDictionary = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9(componentKey) {
42711
- return _regenerator().w(function (_context9) {
42712
- 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) {
42713
42983
  case 0:
42714
42984
  if (this.managers.componentDataManager) {
42715
- _context9.n = 1;
42985
+ _context0.n = 1;
42716
42986
  break;
42717
42987
  }
42718
42988
  console.warn('⚠️ removeComponentFromDictionary(): Component data manager not available');
42719
- return _context9.a(2, false);
42989
+ return _context0.a(2, false);
42720
42990
  case 1:
42721
- _context9.n = 2;
42991
+ _context0.n = 2;
42722
42992
  return this.managers.componentDataManager.removeComponentFromDictionary(componentKey);
42723
42993
  case 2:
42724
- return _context9.a(2, _context9.v);
42994
+ return _context0.a(2, _context0.v);
42725
42995
  }
42726
- }, _callee9, this);
42996
+ }, _callee0, this);
42727
42997
  }));
42728
42998
  function removeComponentFromDictionary(_x4) {
42729
42999
  return _removeComponentFromDictionary.apply(this, arguments);
@@ -42759,8 +43029,8 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
42759
43029
  var componentDictionary = ((_this$managers$compon = this.managers.componentDataManager) === null || _this$managers$compon === void 0 ? void 0 : _this$managers$compon.componentDictionary) || {};
42760
43030
  var missingIds = [];
42761
43031
  sceneData.scene.children.forEach(function (child) {
42762
- var _child$userData;
42763
- 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;
42764
43034
  if (libraryId && !componentDictionary[libraryId]) {
42765
43035
  // Only add unique IDs
42766
43036
  if (!missingIds.includes(libraryId)) {
@@ -42838,8 +43108,8 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
42838
43108
  // If still not found, try finding by originalUuid in userData
42839
43109
  if (!targetObject) {
42840
43110
  this.sceneViewer.scene.traverse(function (child) {
42841
- var _child$userData2;
42842
- 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) {
42843
43113
  targetObject = child;
42844
43114
  return;
42845
43115
  }
@@ -42970,49 +43240,49 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
42970
43240
  }, {
42971
43241
  key: "initialize2DViewport",
42972
43242
  value: function () {
42973
- var _initialize2DViewport = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0(container) {
43243
+ var _initialize2DViewport = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1(container) {
42974
43244
  var viewType,
42975
43245
  instanceKey,
42976
43246
  success,
42977
- _args0 = arguments,
43247
+ _args1 = arguments,
42978
43248
  _t2;
42979
- return _regenerator().w(function (_context0) {
42980
- while (1) switch (_context0.n) {
43249
+ return _regenerator().w(function (_context1) {
43250
+ while (1) switch (_context1.n) {
42981
43251
  case 0:
42982
- viewType = _args0.length > 1 && _args0[1] !== undefined ? _args0[1] : 'top';
42983
- 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;
42984
43254
  if (container) {
42985
- _context0.n = 1;
43255
+ _context1.n = 1;
42986
43256
  break;
42987
43257
  }
42988
43258
  console.warn('⚠️ initialize2DViewport(): No container provided');
42989
- return _context0.a(2, false);
43259
+ return _context1.a(2, false);
42990
43260
  case 1:
42991
43261
  if (this.managers.viewport2DManager) {
42992
- _context0.n = 2;
43262
+ _context1.n = 2;
42993
43263
  break;
42994
43264
  }
42995
43265
  console.warn('⚠️ initialize2DViewport(): Viewport2D manager not available');
42996
- return _context0.a(2, false);
43266
+ return _context1.a(2, false);
42997
43267
  case 2:
42998
- _context0.p = 2;
42999
- _context0.n = 3;
43268
+ _context1.p = 2;
43269
+ _context1.n = 3;
43000
43270
  return this.managers.viewport2DManager.initialize(container, viewType, instanceKey);
43001
43271
  case 3:
43002
- success = _context0.v;
43272
+ success = _context1.v;
43003
43273
  if (success) {
43004
43274
  console.log("\u2705 2D viewport initialized successfully (".concat(viewType, " view, key: ").concat(instanceKey || viewType, ")"));
43005
43275
  } else {
43006
43276
  console.warn("\u26A0\uFE0F Failed to initialize 2D viewport (".concat(viewType, " view)"));
43007
43277
  }
43008
- return _context0.a(2, success);
43278
+ return _context1.a(2, success);
43009
43279
  case 4:
43010
- _context0.p = 4;
43011
- _t2 = _context0.v;
43280
+ _context1.p = 4;
43281
+ _t2 = _context1.v;
43012
43282
  console.error('❌ initialize2DViewport(): Error initializing 2D viewport:', _t2);
43013
- return _context0.a(2, false);
43283
+ return _context1.a(2, false);
43014
43284
  }
43015
- }, _callee0, this, [[2, 4]]);
43285
+ }, _callee1, this, [[2, 4]]);
43016
43286
  }));
43017
43287
  function initialize2DViewport(_x5) {
43018
43288
  return _initialize2DViewport.apply(this, arguments);
@@ -43190,7 +43460,7 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
43190
43460
  }, {
43191
43461
  key: "initializeModelPreloading",
43192
43462
  value: (function () {
43193
- var _initializeModelPreloading = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1() {
43463
+ var _initializeModelPreloading = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10() {
43194
43464
  var basePath,
43195
43465
  normalizedBasePath,
43196
43466
  dictionaryPath,
@@ -43199,13 +43469,13 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
43199
43469
  componentDictionary,
43200
43470
  _modelPreloader2,
43201
43471
  progress,
43202
- _args1 = arguments,
43472
+ _args10 = arguments,
43203
43473
  _t3;
43204
- return _regenerator().w(function (_context1) {
43205
- while (1) switch (_context1.n) {
43474
+ return _regenerator().w(function (_context10) {
43475
+ while (1) switch (_context10.n) {
43206
43476
  case 0:
43207
- basePath = _args1.length > 0 && _args1[0] !== undefined ? _args1[0] : '/library/';
43208
- _context1.p = 1;
43477
+ basePath = _args10.length > 0 && _args10[0] !== undefined ? _args10[0] : '/library/';
43478
+ _context10.p = 1;
43209
43479
  // Ensure basePath ends with a slash
43210
43480
  normalizedBasePath = basePath.endsWith('/') ? basePath : "".concat(basePath, "/");
43211
43481
  dictionaryPath = "".concat(normalizedBasePath, "component-dictionary.json");
@@ -43216,39 +43486,39 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
43216
43486
  console.log("\uFFFD Models path: ".concat(modelsBasePath));
43217
43487
 
43218
43488
  // Load the component dictionary
43219
- _context1.n = 2;
43489
+ _context10.n = 2;
43220
43490
  return fetch(dictionaryPath);
43221
43491
  case 2:
43222
- response = _context1.v;
43492
+ response = _context10.v;
43223
43493
  if (response.ok) {
43224
- _context1.n = 3;
43494
+ _context10.n = 3;
43225
43495
  break;
43226
43496
  }
43227
43497
  throw new Error("Failed to load component dictionary: ".concat(response.status));
43228
43498
  case 3:
43229
- _context1.n = 4;
43499
+ _context10.n = 4;
43230
43500
  return response.json();
43231
43501
  case 4:
43232
- componentDictionary = _context1.v;
43502
+ componentDictionary = _context10.v;
43233
43503
  console.log('📚 Component dictionary loaded:', Object.keys(componentDictionary));
43234
43504
 
43235
43505
  // Start preloading all models with the specified base path
43236
43506
  _modelPreloader2 = this.getUtility('modelPreloader');
43237
- _context1.n = 5;
43507
+ _context10.n = 5;
43238
43508
  return _modelPreloader2.preloadAllModels(componentDictionary, modelsBasePath);
43239
43509
  case 5:
43240
- progress = _context1.v;
43510
+ progress = _context10.v;
43241
43511
  console.log('🎉 Model preloading completed:', progress);
43242
- return _context1.a(2, progress);
43512
+ return _context10.a(2, progress);
43243
43513
  case 6:
43244
- _context1.p = 6;
43245
- _t3 = _context1.v;
43514
+ _context10.p = 6;
43515
+ _t3 = _context10.v;
43246
43516
  console.error('❌ Failed to initialize model preloading:', _t3);
43247
43517
  throw _t3;
43248
43518
  case 7:
43249
- return _context1.a(2);
43519
+ return _context10.a(2);
43250
43520
  }
43251
- }, _callee1, this, [[1, 6]]);
43521
+ }, _callee10, this, [[1, 6]]);
43252
43522
  }));
43253
43523
  function initializeModelPreloading() {
43254
43524
  return _initializeModelPreloading.apply(this, arguments);
@@ -43265,100 +43535,86 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
43265
43535
  }, {
43266
43536
  key: "importScene",
43267
43537
  value: (function () {
43268
- var _importScene = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10(jsonData) {
43269
- var validation, embeddedCount, missingIds, resolved, _t4, _t5;
43270
- return _regenerator().w(function (_context10) {
43271
- while (1) switch (_context10.n) {
43538
+ var _importScene = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee11(jsonData) {
43539
+ var validation, missingIds, resolved, _t4, _t5;
43540
+ return _regenerator().w(function (_context11) {
43541
+ while (1) switch (_context11.n) {
43272
43542
  case 0:
43273
43543
  if (jsonData) {
43274
- _context10.n = 1;
43544
+ _context11.n = 1;
43275
43545
  break;
43276
43546
  }
43277
43547
  console.error('❌ No JSON data provided for import');
43278
- return _context10.a(2, false);
43548
+ return _context11.a(2, false);
43279
43549
  case 1:
43280
- _context10.p = 1;
43550
+ _context11.p = 1;
43281
43551
  // Validate scene data structure
43282
43552
  validation = this.internals.validateAndAnalyzeSceneData(jsonData);
43283
43553
  if (validation.isValid) {
43284
- _context10.n = 2;
43554
+ _context11.n = 2;
43285
43555
  break;
43286
43556
  }
43287
43557
  console.error('❌ Invalid scene data format:', validation.message);
43288
- return _context10.a(2, false);
43558
+ return _context11.a(2, false);
43289
43559
  case 2:
43290
- if (!(jsonData.componentDefinitions && _typeof(jsonData.componentDefinitions) === 'object')) {
43291
- _context10.n = 4;
43292
- break;
43293
- }
43294
- embeddedCount = Object.keys(jsonData.componentDefinitions).length;
43295
- if (!(embeddedCount > 0)) {
43296
- _context10.n = 4;
43297
- break;
43298
- }
43299
- _context10.n = 3;
43300
- return this.extendComponentDictionary(jsonData.componentDefinitions);
43301
- case 3:
43302
- console.log("\uD83D\uDCE6 importScene(): Applied ".concat(embeddedCount, " embedded component definition(s)"));
43303
- case 4:
43304
43560
  if (!this._componentDefinitionResolver) {
43305
- _context10.n = 10;
43561
+ _context11.n = 8;
43306
43562
  break;
43307
43563
  }
43308
43564
  missingIds = this.getMissingLibraryIds(jsonData);
43309
43565
  if (!(missingIds.length > 0)) {
43310
- _context10.n = 10;
43566
+ _context11.n = 8;
43311
43567
  break;
43312
43568
  }
43313
- _context10.p = 5;
43569
+ _context11.p = 3;
43314
43570
  console.log("\uD83D\uDD0D importScene(): Resolving ".concat(missingIds.length, " missing component definition(s)..."));
43315
- _context10.n = 6;
43571
+ _context11.n = 4;
43316
43572
  return this._componentDefinitionResolver(missingIds);
43317
- case 6:
43318
- resolved = _context10.v;
43573
+ case 4:
43574
+ resolved = _context11.v;
43319
43575
  if (!(resolved && _typeof(resolved) === 'object' && Object.keys(resolved).length > 0)) {
43320
- _context10.n = 8;
43576
+ _context11.n = 6;
43321
43577
  break;
43322
43578
  }
43323
- _context10.n = 7;
43579
+ _context11.n = 5;
43324
43580
  return this.extendComponentDictionary(resolved);
43325
- case 7:
43581
+ case 5:
43326
43582
  console.log("\u2705 importScene(): Resolved ".concat(Object.keys(resolved).length, " component definition(s)"));
43327
- case 8:
43328
- _context10.n = 10;
43583
+ case 6:
43584
+ _context11.n = 8;
43329
43585
  break;
43330
- case 9:
43331
- _context10.p = 9;
43332
- _t4 = _context10.v;
43586
+ case 7:
43587
+ _context11.p = 7;
43588
+ _t4 = _context11.v;
43333
43589
  console.warn('⚠️ importScene(): Component definition resolver failed, continuing with existing dictionary:', _t4);
43334
- case 10:
43335
- _context10.n = 11;
43590
+ case 8:
43591
+ _context11.n = 9;
43336
43592
  return this.setImportedSceneData(jsonData);
43337
- case 11:
43593
+ case 9:
43338
43594
  if (!(this.sceneViewer && this.sceneViewer.sceneOperationsManager)) {
43339
- _context10.n = 13;
43595
+ _context11.n = 11;
43340
43596
  break;
43341
43597
  }
43342
- _context10.n = 12;
43598
+ _context11.n = 10;
43343
43599
  return this.sceneViewer.sceneOperationsManager.loadSceneFromData(jsonData);
43344
- case 12:
43600
+ case 10:
43345
43601
  console.log('✅ Scene imported successfully');
43346
- return _context10.a(2, true);
43347
- case 13:
43602
+ return _context11.a(2, true);
43603
+ case 11:
43348
43604
  console.error('❌ SceneViewer not available for scene loading');
43349
- return _context10.a(2, false);
43350
- case 14:
43351
- _context10.n = 16;
43605
+ return _context11.a(2, false);
43606
+ case 12:
43607
+ _context11.n = 14;
43352
43608
  break;
43353
- case 15:
43354
- _context10.p = 15;
43355
- _t5 = _context10.v;
43609
+ case 13:
43610
+ _context11.p = 13;
43611
+ _t5 = _context11.v;
43356
43612
  console.error('❌ Error importing scene:', _t5);
43357
- return _context10.a(2, false);
43358
- case 16:
43359
- return _context10.a(2);
43613
+ return _context11.a(2, false);
43614
+ case 14:
43615
+ return _context11.a(2);
43360
43616
  }
43361
- }, _callee10, this, [[5, 9], [1, 15]]);
43617
+ }, _callee11, this, [[3, 7], [1, 13]]);
43362
43618
  }));
43363
43619
  function importScene(_x6) {
43364
43620
  return _importScene.apply(this, arguments);
@@ -43382,33 +43638,33 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
43382
43638
  }, {
43383
43639
  key: "exportSceneJSON",
43384
43640
  value: (function () {
43385
- var _exportSceneJSON = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee11() {
43641
+ var _exportSceneJSON = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee12() {
43386
43642
  var filename,
43387
- _args11 = arguments,
43643
+ _args12 = arguments,
43388
43644
  _t6;
43389
- return _regenerator().w(function (_context11) {
43390
- while (1) switch (_context11.n) {
43645
+ return _regenerator().w(function (_context12) {
43646
+ while (1) switch (_context12.n) {
43391
43647
  case 0:
43392
- filename = _args11.length > 0 && _args11[0] !== undefined ? _args11[0] : null;
43648
+ filename = _args12.length > 0 && _args12[0] !== undefined ? _args12[0] : null;
43393
43649
  if (this.managers.sceneExportManager) {
43394
- _context11.n = 1;
43650
+ _context12.n = 1;
43395
43651
  break;
43396
43652
  }
43397
43653
  console.error('❌ Scene export manager not available');
43398
- return _context11.a(2, false);
43654
+ return _context12.a(2, false);
43399
43655
  case 1:
43400
- _context11.p = 1;
43401
- _context11.n = 2;
43656
+ _context12.p = 1;
43657
+ _context12.n = 2;
43402
43658
  return this.managers.sceneExportManager.downloadSceneJSON(filename);
43403
43659
  case 2:
43404
- return _context11.a(2, _context11.v);
43660
+ return _context12.a(2, _context12.v);
43405
43661
  case 3:
43406
- _context11.p = 3;
43407
- _t6 = _context11.v;
43662
+ _context12.p = 3;
43663
+ _t6 = _context12.v;
43408
43664
  console.error('❌ Error exporting scene as JSON:', _t6);
43409
- return _context11.a(2, false);
43665
+ return _context12.a(2, false);
43410
43666
  }
43411
- }, _callee11, this, [[1, 3]]);
43667
+ }, _callee12, this, [[1, 3]]);
43412
43668
  }));
43413
43669
  function exportSceneJSON() {
43414
43670
  return _exportSceneJSON.apply(this, arguments);
@@ -43433,33 +43689,33 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
43433
43689
  }, {
43434
43690
  key: "exportSceneGLTF",
43435
43691
  value: (function () {
43436
- var _exportSceneGLTF = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee12() {
43692
+ var _exportSceneGLTF = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee13() {
43437
43693
  var filename,
43438
- _args12 = arguments,
43694
+ _args13 = arguments,
43439
43695
  _t7;
43440
- return _regenerator().w(function (_context12) {
43441
- while (1) switch (_context12.n) {
43696
+ return _regenerator().w(function (_context13) {
43697
+ while (1) switch (_context13.n) {
43442
43698
  case 0:
43443
- filename = _args12.length > 0 && _args12[0] !== undefined ? _args12[0] : null;
43699
+ filename = _args13.length > 0 && _args13[0] !== undefined ? _args13[0] : null;
43444
43700
  if (this.managers.sceneExportManager) {
43445
- _context12.n = 1;
43701
+ _context13.n = 1;
43446
43702
  break;
43447
43703
  }
43448
43704
  console.error('❌ Scene export manager not available');
43449
- return _context12.a(2, false);
43705
+ return _context13.a(2, false);
43450
43706
  case 1:
43451
- _context12.p = 1;
43452
- _context12.n = 2;
43707
+ _context13.p = 1;
43708
+ _context13.n = 2;
43453
43709
  return this.managers.sceneExportManager.exportSceneAsGLTF(filename, false);
43454
43710
  case 2:
43455
- return _context12.a(2, _context12.v);
43711
+ return _context13.a(2, _context13.v);
43456
43712
  case 3:
43457
- _context12.p = 3;
43458
- _t7 = _context12.v;
43713
+ _context13.p = 3;
43714
+ _t7 = _context13.v;
43459
43715
  console.error('❌ Error exporting scene as GLTF:', _t7);
43460
- return _context12.a(2, false);
43716
+ return _context13.a(2, false);
43461
43717
  }
43462
- }, _callee12, this, [[1, 3]]);
43718
+ }, _callee13, this, [[1, 3]]);
43463
43719
  }));
43464
43720
  function exportSceneGLTF() {
43465
43721
  return _exportSceneGLTF.apply(this, arguments);
@@ -43485,33 +43741,33 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
43485
43741
  }, {
43486
43742
  key: "exportSceneGLB",
43487
43743
  value: (function () {
43488
- var _exportSceneGLB = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee13() {
43744
+ var _exportSceneGLB = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee14() {
43489
43745
  var filename,
43490
- _args13 = arguments,
43746
+ _args14 = arguments,
43491
43747
  _t8;
43492
- return _regenerator().w(function (_context13) {
43493
- while (1) switch (_context13.n) {
43748
+ return _regenerator().w(function (_context14) {
43749
+ while (1) switch (_context14.n) {
43494
43750
  case 0:
43495
- filename = _args13.length > 0 && _args13[0] !== undefined ? _args13[0] : null;
43751
+ filename = _args14.length > 0 && _args14[0] !== undefined ? _args14[0] : null;
43496
43752
  if (this.managers.sceneExportManager) {
43497
- _context13.n = 1;
43753
+ _context14.n = 1;
43498
43754
  break;
43499
43755
  }
43500
43756
  console.error('❌ Scene export manager not available');
43501
- return _context13.a(2, false);
43757
+ return _context14.a(2, false);
43502
43758
  case 1:
43503
- _context13.p = 1;
43504
- _context13.n = 2;
43759
+ _context14.p = 1;
43760
+ _context14.n = 2;
43505
43761
  return this.managers.sceneExportManager.exportSceneAsGLB(filename);
43506
43762
  case 2:
43507
- return _context13.a(2, _context13.v);
43763
+ return _context14.a(2, _context14.v);
43508
43764
  case 3:
43509
- _context13.p = 3;
43510
- _t8 = _context13.v;
43765
+ _context14.p = 3;
43766
+ _t8 = _context14.v;
43511
43767
  console.error('❌ Error exporting scene as GLB:', _t8);
43512
- return _context13.a(2, false);
43768
+ return _context14.a(2, false);
43513
43769
  }
43514
- }, _callee13, this, [[1, 3]]);
43770
+ }, _callee14, this, [[1, 3]]);
43515
43771
  }));
43516
43772
  function exportSceneGLB() {
43517
43773
  return _exportSceneGLB.apply(this, arguments);
@@ -43550,16 +43806,16 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
43550
43806
  }, {
43551
43807
  key: "loadSceneFromData",
43552
43808
  value: (function () {
43553
- var _loadSceneFromData = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee14(sceneData) {
43554
- return _regenerator().w(function (_context14) {
43555
- 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) {
43556
43812
  case 0:
43557
- _context14.n = 1;
43813
+ _context15.n = 1;
43558
43814
  return this.setImportedSceneData(sceneData);
43559
43815
  case 1:
43560
- return _context14.a(2, true);
43816
+ return _context15.a(2, true);
43561
43817
  }
43562
- }, _callee14, this);
43818
+ }, _callee15, this);
43563
43819
  }));
43564
43820
  function loadSceneFromData(_x7) {
43565
43821
  return _loadSceneFromData.apply(this, arguments);
@@ -43584,9 +43840,9 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
43584
43840
  }, {
43585
43841
  key: "clearScene",
43586
43842
  value: function clearScene() {
43587
- var _this$sceneViewer12;
43843
+ var _this$sceneViewer13;
43588
43844
  this.importedSceneData = null;
43589
- 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;
43590
43846
  if (ioBehavMgr) {
43591
43847
  ioBehavMgr.setCrossComponentBehaviors([]);
43592
43848
  }
@@ -44996,20 +45252,10 @@ var SceneHierarchyManager = /*#__PURE__*/function (_BaseDisposable) {
44996
45252
  }]);
44997
45253
  }(BaseDisposable);
44998
45254
 
44999
- var _excluded = ["componentDefinitions"];
45000
45255
  /**
45001
- * Helpers for portable demo scene JSON (embedded component definitions).
45256
+ * Helpers for portable demo scene JSON.
45002
45257
  */
45003
45258
 
45004
- function cloneDefinition(def) {
45005
- if (!def || _typeof(def) !== 'object') return null;
45006
- try {
45007
- return JSON.parse(JSON.stringify(def));
45008
- } catch (_unused) {
45009
- return _objectSpread2({}, def);
45010
- }
45011
- }
45012
-
45013
45259
  /**
45014
45260
  * Collect unique library IDs referenced by scene nodes.
45015
45261
  * @param {Object} sceneData
@@ -45031,43 +45277,6 @@ function collectSceneLibraryIds(sceneData) {
45031
45277
  return Array.from(ids);
45032
45278
  }
45033
45279
 
45034
- /**
45035
- * Embed component/device definitions required by a scene into the JSON payload.
45036
- * @param {Object} sceneData
45037
- * @param {Record<string, Object>} componentDictionary
45038
- * @returns {Object}
45039
- */
45040
- function embedComponentDefinitions(sceneData) {
45041
- var componentDictionary = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
45042
- if (!sceneData || _typeof(sceneData) !== 'object') return sceneData;
45043
- var libraryIds = collectSceneLibraryIds(sceneData);
45044
- var componentDefinitions = {};
45045
- var deviceIds = new Set();
45046
- libraryIds.forEach(function (libraryId) {
45047
- var def = componentDictionary[libraryId];
45048
- if (!def) return;
45049
- componentDefinitions[libraryId] = cloneDefinition(def);
45050
- var attachedDevices = def.attachedDevices;
45051
- if (!attachedDevices || _typeof(attachedDevices) !== 'object') return;
45052
- Object.values(attachedDevices).forEach(function (att) {
45053
- if (att !== null && att !== void 0 && att.deviceId) deviceIds.add(att.deviceId);
45054
- });
45055
- });
45056
- deviceIds.forEach(function (deviceId) {
45057
- if (componentDefinitions[deviceId]) return;
45058
- var deviceDef = componentDictionary[deviceId];
45059
- if (deviceDef) componentDefinitions[deviceId] = cloneDefinition(deviceDef);
45060
- });
45061
- if (!Object.keys(componentDefinitions).length) {
45062
- sceneData.componentDefinitions;
45063
- var rest = _objectWithoutProperties(sceneData, _excluded);
45064
- return rest;
45065
- }
45066
- return _objectSpread2(_objectSpread2({}, sceneData), {}, {
45067
- componentDefinitions: componentDefinitions
45068
- });
45069
- }
45070
-
45071
45280
  /**
45072
45281
  * Resolve the live component dictionary from a CentralPlant instance.
45073
45282
  * @param {Object} centralPlant
@@ -49561,7 +49770,6 @@ exports.clearS3Cache = clearS3Cache;
49561
49770
  exports.collectSceneLibraryIds = collectSceneLibraryIds;
49562
49771
  exports.createPathfindingRequest = createPathfindingRequest;
49563
49772
  exports.createTransformControls = createTransformControls;
49564
- exports.embedComponentDefinitions = embedComponentDefinitions;
49565
49773
  exports.findObjectByHardcodedUuid = findObjectByHardcodedUuid;
49566
49774
  exports.formatCacheExpiry = formatCacheExpiry;
49567
49775
  exports.generateUniqueComponentId = generateUniqueComponentId;