@2112-lab/central-plant 0.3.17 → 0.3.19

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.
@@ -20554,6 +20554,114 @@ var ComponentDataManager = /*#__PURE__*/function (_BaseDisposable) {
20554
20554
  }]);
20555
20555
  }(BaseDisposable);
20556
20556
 
20557
+ /**
20558
+ * Utility function to update userData.direction for components after 90-degree rotation
20559
+ * This function handles the direction vector transformation for connectors when their parent component is rotated
20560
+ *
20561
+ * @param {THREE.Object3D} component - The component that was rotated
20562
+ * @param {string} axis - The axis of rotation ('x', 'y', or 'z')
20563
+ * @param {number} degrees - The rotation angle in degrees (should be multiple of 90)
20564
+ */
20565
+ function updateDirectionAfterRotation(component, axis, degrees) {
20566
+ if (!component) {
20567
+ console.warn('⚠️ updateDirectionAfterRotation: No component provided');
20568
+ return;
20569
+ }
20570
+
20571
+ // Only handle 90-degree increments
20572
+ if (degrees % 90 !== 0) {
20573
+ console.warn('⚠️ updateDirectionAfterRotation: Only 90-degree increments are supported');
20574
+ return;
20575
+ }
20576
+
20577
+ // Normalize degrees to 0-360 range
20578
+ var normalizedDegrees = (degrees % 360 + 360) % 360;
20579
+ console.log("\uD83D\uDD04 Updating direction vectors for ".concat(component.name || component.uuid, " after ").concat(degrees, "\xB0 rotation around ").concat(axis, " axis"));
20580
+
20581
+ // Traverse all children (connectors) and update their direction vectors
20582
+ component.traverse(function (child) {
20583
+ var _child$userData, _child$userData2;
20584
+ var childType = ((_child$userData = child.userData) === null || _child$userData === void 0 ? void 0 : _child$userData.objectType) || ((_child$userData2 = child.userData) === null || _child$userData2 === void 0 ? void 0 : _child$userData2.objectType);
20585
+ if (child.userData && Array.isArray(child.userData.direction) && childType === 'connector') {
20586
+ var originalDirection = _toConsumableArray(child.userData.direction);
20587
+ var newDirection = rotateDirectionVector(originalDirection, axis, normalizedDegrees);
20588
+
20589
+ // Update the direction
20590
+ child.userData.direction = newDirection;
20591
+ console.log("\uD83D\uDCCD Updated connector ".concat(child.name || child.uuid, " direction:"), {
20592
+ original: originalDirection,
20593
+ new: newDirection,
20594
+ rotationAxis: axis,
20595
+ rotationDegrees: degrees
20596
+ });
20597
+ }
20598
+ });
20599
+ }
20600
+
20601
+ /**
20602
+ * Rotate a direction vector by 90-degree increments around a specific axis
20603
+ *
20604
+ * @param {Array<number>} direction - The original direction vector [x, y, z]
20605
+ * @param {string} axis - The axis of rotation ('x', 'y', or 'z')
20606
+ * @param {number} degrees - The rotation angle in degrees (must be multiple of 90)
20607
+ * @returns {Array<number>} The new direction vector [x, y, z]
20608
+ */
20609
+ function rotateDirectionVector(direction, axis, degrees) {
20610
+ if (!Array.isArray(direction) || direction.length !== 3) {
20611
+ console.warn('⚠️ rotateDirectionVector: Invalid direction vector');
20612
+ return direction;
20613
+ }
20614
+ var _direction = _slicedToArray(direction, 3),
20615
+ x = _direction[0],
20616
+ y = _direction[1],
20617
+ z = _direction[2];
20618
+ var steps = degrees / 90; // Number of 90-degree steps
20619
+
20620
+ for (var i = 0; i < steps; i++) {
20621
+ var newX = x,
20622
+ newY = y,
20623
+ newZ = z;
20624
+ switch (axis) {
20625
+ case 'x':
20626
+ // Rotation around X-axis in Z-up system with flipped Y: Y becomes -Z, Z becomes Y
20627
+ newY = -z;
20628
+ newZ = y;
20629
+ break;
20630
+ case 'y':
20631
+ // Rotation around Y-axis in Z-up system with flipped Y: X becomes Z, Z becomes -X
20632
+ newX = z;
20633
+ newZ = -x;
20634
+ break;
20635
+ case 'z':
20636
+ // Rotation around Z-axis in Z-up system with flipped Y: X becomes -Y, Y becomes X
20637
+ newX = -y;
20638
+ newY = x;
20639
+ break;
20640
+ default:
20641
+ console.warn("\u26A0\uFE0F rotateDirectionVector: Invalid axis '".concat(axis, "'"));
20642
+ return direction;
20643
+ }
20644
+ x = newX;
20645
+ y = newY;
20646
+ z = newZ;
20647
+ }
20648
+ return [x, y, z];
20649
+ }
20650
+
20651
+ /**
20652
+ * Example usage in your rotate method:
20653
+ *
20654
+ * // After applying rotation to the component
20655
+ * component.rotation[axis] += radians
20656
+ *
20657
+ * // Update direction vectors for connectors
20658
+ * updateDirectionAfterRotation(component, axis, value)
20659
+ *
20660
+ * // Update matrices
20661
+ * component.updateMatrix()
20662
+ * component.updateMatrixWorld(true)
20663
+ */
20664
+
20557
20665
  var TransformOperationsManager = /*#__PURE__*/function () {
20558
20666
  /**
20559
20667
  * @param {Object} sceneViewer - The scene viewer instance
@@ -21245,16 +21353,9 @@ var TransformOperationsManager = /*#__PURE__*/function () {
21245
21353
  if (!component || degrees % 90 !== 0) {
21246
21354
  return;
21247
21355
  }
21248
- console.log("\uD83D\uDD04 Updating connector directions after ".concat(degrees, "\xB0 rotation around ").concat(axis, " axis"));
21249
21356
 
21250
- // Simple approach: just log that directions may need manual verification
21251
- // In most cases, Three.js world matrices handle the actual positioning correctly
21252
- component.traverse(function (child) {
21253
- var _child$userData5, _child$userData6;
21254
- if (((_child$userData5 = child.userData) === null || _child$userData5 === void 0 ? void 0 : _child$userData5.objectType) === 'connector' && (_child$userData6 = child.userData) !== null && _child$userData6 !== void 0 && _child$userData6.direction) {
21255
- console.log("\uD83D\uDCCD Connector ".concat(child.uuid, " direction may need verification after rotation"));
21256
- }
21257
- });
21357
+ // Use the direction utility to update direction vectors on Three.js connector objects
21358
+ updateDirectionAfterRotation(component, axis, degrees);
21258
21359
  }
21259
21360
 
21260
21361
  /**
@@ -21408,9 +21509,9 @@ var TransformOperationsManager = /*#__PURE__*/function () {
21408
21509
 
21409
21510
  // Traverse scene to find all connectors
21410
21511
  this.sceneViewer.scene.traverse(function (child) {
21411
- var _child$userData7;
21512
+ var _child$userData5;
21412
21513
  // Check if this is a connector (component connector or manual segment connector)
21413
- if (((_child$userData7 = child.userData) === null || _child$userData7 === void 0 ? void 0 : _child$userData7.objectType) === 'connector') {
21514
+ if (((_child$userData5 = child.userData) === null || _child$userData5 === void 0 ? void 0 : _child$userData5.objectType) === 'connector') {
21414
21515
  // Get world position of connector
21415
21516
  var connectorWorldPos = new THREE__namespace.Vector3();
21416
21517
  child.getWorldPosition(connectorWorldPos);
@@ -21461,8 +21562,8 @@ var TransformOperationsManager = /*#__PURE__*/function () {
21461
21562
  // Find all child connectors of the segment in the Three.js scene
21462
21563
  var connectors = [];
21463
21564
  segment.traverse(function (child) {
21464
- var _child$userData8;
21465
- if (((_child$userData8 = child.userData) === null || _child$userData8 === void 0 ? void 0 : _child$userData8.objectType) === 'segment-connector') {
21565
+ var _child$userData6;
21566
+ if (((_child$userData6 = child.userData) === null || _child$userData6 === void 0 ? void 0 : _child$userData6.objectType) === 'segment-connector') {
21466
21567
  connectors.push(child);
21467
21568
  }
21468
21569
  });
@@ -21526,17 +21627,17 @@ var TransformOperationsManager = /*#__PURE__*/function () {
21526
21627
 
21527
21628
  // Check all segments in the scene
21528
21629
  this.sceneViewer.scene.traverse(function (child) {
21529
- var _child$userData9, _child$userData0;
21630
+ var _child$userData7, _child$userData8;
21530
21631
  // Skip the segment itself
21531
21632
  if (child.uuid === segment.uuid) {
21532
21633
  return;
21533
21634
  }
21534
21635
 
21535
21636
  // Only check computed segments in the scene
21536
- if (((_child$userData9 = child.userData) === null || _child$userData9 === void 0 ? void 0 : _child$userData9.objectType) === 'segment' && (_child$userData0 = child.userData) !== null && _child$userData0 !== void 0 && _child$userData0.isDeclared) {
21537
- var _segment$userData6, _child$userData1, _segment$userData7, _child$userData10;
21637
+ if (((_child$userData7 = child.userData) === null || _child$userData7 === void 0 ? void 0 : _child$userData7.objectType) === 'segment' && (_child$userData8 = child.userData) !== null && _child$userData8 !== void 0 && _child$userData8.isDeclared) {
21638
+ var _segment$userData6, _child$userData9, _segment$userData7, _child$userData0;
21538
21639
  // Check if segments are part of the same connection path
21539
- var sameConnection = ((_segment$userData6 = segment.userData) === null || _segment$userData6 === void 0 ? void 0 : _segment$userData6.pathFrom) === ((_child$userData1 = child.userData) === null || _child$userData1 === void 0 ? void 0 : _child$userData1.pathFrom) && ((_segment$userData7 = segment.userData) === null || _segment$userData7 === void 0 ? void 0 : _segment$userData7.pathTo) === ((_child$userData10 = child.userData) === null || _child$userData10 === void 0 ? void 0 : _child$userData10.pathTo);
21640
+ var sameConnection = ((_segment$userData6 = segment.userData) === null || _segment$userData6 === void 0 ? void 0 : _segment$userData6.pathFrom) === ((_child$userData9 = child.userData) === null || _child$userData9 === void 0 ? void 0 : _child$userData9.pathFrom) && ((_segment$userData7 = segment.userData) === null || _segment$userData7 === void 0 ? void 0 : _segment$userData7.pathTo) === ((_child$userData0 = child.userData) === null || _child$userData0 === void 0 ? void 0 : _child$userData0.pathTo);
21540
21641
 
21541
21642
  // Get endpoints of the other segment (use stored endpoints if available)
21542
21643
  var otherEndpoints = _this2.getSegmentEndpoints(child);
@@ -21757,11 +21858,11 @@ var TransformOperationsManager = /*#__PURE__*/function () {
21757
21858
 
21758
21859
  // Traverse scene to find all component connectors
21759
21860
  this.sceneViewer.scene.traverse(function (child) {
21760
- var _child$userData11;
21861
+ var _child$userData1;
21761
21862
  if (collision) return; // Stop if collision already found
21762
21863
 
21763
21864
  // Check if this is a component connector (not a segment-connector)
21764
- if (((_child$userData11 = child.userData) === null || _child$userData11 === void 0 ? void 0 : _child$userData11.objectType) === 'connector') {
21865
+ if (((_child$userData1 = child.userData) === null || _child$userData1 === void 0 ? void 0 : _child$userData1.objectType) === 'connector') {
21765
21866
  var _segment$userData10, _segment$userData11;
21766
21867
  // Skip connectors that are connected to this segment (pathFrom or pathTo)
21767
21868
  var segmentPathFrom = (_segment$userData10 = segment.userData) === null || _segment$userData10 === void 0 ? void 0 : _segment$userData10.pathFrom;
@@ -21875,9 +21976,9 @@ var TransformOperationsManager = /*#__PURE__*/function () {
21875
21976
 
21876
21977
  // Traverse scene to find all component connectors
21877
21978
  this.sceneViewer.scene.traverse(function (child) {
21878
- var _child$userData12;
21979
+ var _child$userData10;
21879
21980
  // Check if this is a component connector (not a segment-connector)
21880
- if (((_child$userData12 = child.userData) === null || _child$userData12 === void 0 ? void 0 : _child$userData12.objectType) === 'connector') {
21981
+ if (((_child$userData10 = child.userData) === null || _child$userData10 === void 0 ? void 0 : _child$userData10.objectType) === 'connector') {
21881
21982
  // Get world position of connector
21882
21983
  var connectorWorldPos = new THREE__namespace.Vector3();
21883
21984
  child.getWorldPosition(connectorWorldPos);
@@ -21934,11 +22035,11 @@ var TransformOperationsManager = /*#__PURE__*/function () {
21934
22035
 
21935
22036
  // Traverse scene to find all components
21936
22037
  this.sceneViewer.scene.traverse(function (child) {
21937
- var _child$userData13, _child$userData14;
22038
+ var _child$userData11, _child$userData12;
21938
22039
  if (collision) return; // Stop if collision already found
21939
22040
 
21940
22041
  // Check if this is a component (equipment)
21941
- if (((_child$userData13 = child.userData) === null || _child$userData13 === void 0 ? void 0 : _child$userData13.objectType) === 'component' && (_child$userData14 = child.userData) !== null && _child$userData14 !== void 0 && _child$userData14.libraryId) {
22042
+ if (((_child$userData11 = child.userData) === null || _child$userData11 === void 0 ? void 0 : _child$userData11.objectType) === 'component' && (_child$userData12 = child.userData) !== null && _child$userData12 !== void 0 && _child$userData12.libraryId) {
21942
22043
  // Create bounding box for the component
21943
22044
  var componentBBox = new THREE__namespace.Box3().setFromObject(child);
21944
22045
 
@@ -21977,11 +22078,11 @@ var TransformOperationsManager = /*#__PURE__*/function () {
21977
22078
 
21978
22079
  // Traverse scene to find all manual segments (isDeclared === true)
21979
22080
  this.sceneViewer.scene.traverse(function (child) {
21980
- var _child$userData15, _child$userData16;
22081
+ var _child$userData13, _child$userData14;
21981
22082
  if (collision) return; // Stop if collision already found
21982
22083
 
21983
22084
  // Only check manual segments (isDeclared === true)
21984
- if (((_child$userData15 = child.userData) === null || _child$userData15 === void 0 ? void 0 : _child$userData15.objectType) === 'segment' && ((_child$userData16 = child.userData) === null || _child$userData16 === void 0 ? void 0 : _child$userData16.isDeclared) === true) {
22085
+ if (((_child$userData13 = child.userData) === null || _child$userData13 === void 0 ? void 0 : _child$userData13.objectType) === 'segment' && ((_child$userData14 = child.userData) === null || _child$userData14 === void 0 ? void 0 : _child$userData14.isDeclared) === true) {
21985
22086
  // Get segment endpoints
21986
22087
  var segmentEndpoints = _this3.getSegmentEndpoints(child);
21987
22088
 
@@ -22070,11 +22171,11 @@ var TransformOperationsManager = /*#__PURE__*/function () {
22070
22171
 
22071
22172
  // Traverse scene to find all manual segments (isDeclared === true)
22072
22173
  this.sceneViewer.scene.traverse(function (child) {
22073
- var _child$userData17, _child$userData18;
22174
+ var _child$userData15, _child$userData16;
22074
22175
  if (collision) return; // Stop if collision already found
22075
22176
 
22076
22177
  // Only check manual segments (isDeclared === true)
22077
- if (((_child$userData17 = child.userData) === null || _child$userData17 === void 0 ? void 0 : _child$userData17.objectType) === 'segment' && ((_child$userData18 = child.userData) === null || _child$userData18 === void 0 ? void 0 : _child$userData18.isDeclared) === true) {
22178
+ if (((_child$userData15 = child.userData) === null || _child$userData15 === void 0 ? void 0 : _child$userData15.objectType) === 'segment' && ((_child$userData16 = child.userData) === null || _child$userData16 === void 0 ? void 0 : _child$userData16.isDeclared) === true) {
22078
22179
  // Get segment endpoints
22079
22180
  var segmentEndpoints = _this4.getSegmentEndpoints(child);
22080
22181
 
@@ -22131,11 +22232,11 @@ var TransformOperationsManager = /*#__PURE__*/function () {
22131
22232
 
22132
22233
  // Traverse scene to find all components
22133
22234
  this.sceneViewer.scene.traverse(function (child) {
22134
- var _child$userData19, _child$userData20;
22235
+ var _child$userData17, _child$userData18;
22135
22236
  if (collision) return; // Stop if collision already found
22136
22237
 
22137
22238
  // Check if this is a component (equipment)
22138
- if (((_child$userData19 = child.userData) === null || _child$userData19 === void 0 ? void 0 : _child$userData19.objectType) === 'component' && (_child$userData20 = child.userData) !== null && _child$userData20 !== void 0 && _child$userData20.libraryId) {
22239
+ if (((_child$userData17 = child.userData) === null || _child$userData17 === void 0 ? void 0 : _child$userData17.objectType) === 'component' && (_child$userData18 = child.userData) !== null && _child$userData18 !== void 0 && _child$userData18.libraryId) {
22139
22240
  // Try to get worldBoundingBox from userData first (most up-to-date)
22140
22241
  var bbox = null;
22141
22242
  if (child.userData.worldBoundingBox) {
@@ -22280,8 +22381,8 @@ var TransformOperationsManager = /*#__PURE__*/function () {
22280
22381
  // Get the moved segment's connectors
22281
22382
  var movedConnectors = [];
22282
22383
  movedSegment.traverse(function (child) {
22283
- var _child$userData21;
22284
- if (((_child$userData21 = child.userData) === null || _child$userData21 === void 0 ? void 0 : _child$userData21.objectType) === 'segment-connector') {
22384
+ var _child$userData19;
22385
+ if (((_child$userData19 = child.userData) === null || _child$userData19 === void 0 ? void 0 : _child$userData19.objectType) === 'segment-connector') {
22285
22386
  movedConnectors.push(child);
22286
22387
  }
22287
22388
  });
@@ -22351,8 +22452,8 @@ var TransformOperationsManager = /*#__PURE__*/function () {
22351
22452
  // Get all connectors of the adjacent segment
22352
22453
  var adjacentConnectors = [];
22353
22454
  adjacentSegment.traverse(function (child) {
22354
- var _child$userData22;
22355
- if (((_child$userData22 = child.userData) === null || _child$userData22 === void 0 ? void 0 : _child$userData22.objectType) === 'segment-connector') {
22455
+ var _child$userData20;
22456
+ if (((_child$userData20 = child.userData) === null || _child$userData20 === void 0 ? void 0 : _child$userData20.objectType) === 'segment-connector') {
22356
22457
  adjacentConnectors.push(child);
22357
22458
  }
22358
22459
  });
@@ -22475,8 +22576,8 @@ var TransformOperationsManager = /*#__PURE__*/function () {
22475
22576
  // Also update child connectors' positions if they exist
22476
22577
  if (sceneDataComponent.children) {
22477
22578
  sceneDataComponent.children.forEach(function (child) {
22478
- var _child$userData23;
22479
- if (((_child$userData23 = child.userData) === null || _child$userData23 === void 0 ? void 0 : _child$userData23.objectType) === 'connector') {
22579
+ var _child$userData21;
22580
+ if (((_child$userData21 = child.userData) === null || _child$userData21 === void 0 ? void 0 : _child$userData21.objectType) === 'connector') {
22480
22581
  // Find the actual connector object in the scene
22481
22582
  var connectorObj = component.children.find(function (c) {
22482
22583
  var _c$userData;
@@ -22538,14 +22639,15 @@ var TransformOperationsManager = /*#__PURE__*/function () {
22538
22639
  // Also update child connectors' positions if they exist (rotation moves them in world space)
22539
22640
  if (sceneDataComponent.children) {
22540
22641
  sceneDataComponent.children.forEach(function (child) {
22541
- var _child$userData24;
22542
- if (((_child$userData24 = child.userData) === null || _child$userData24 === void 0 ? void 0 : _child$userData24.objectType) === 'connector') {
22642
+ var _child$userData22;
22643
+ if (((_child$userData22 = child.userData) === null || _child$userData22 === void 0 ? void 0 : _child$userData22.objectType) === 'connector') {
22543
22644
  // Find the actual connector object in the scene
22544
22645
  var connectorObj = component.children.find(function (c) {
22545
22646
  var _c$userData2;
22546
22647
  return c.uuid === child.uuid || ((_c$userData2 = c.userData) === null || _c$userData2 === void 0 ? void 0 : _c$userData2.originalUuid) === child.uuid;
22547
22648
  });
22548
22649
  if (connectorObj) {
22650
+ var _connectorObj$userDat;
22549
22651
  // Get world position of connector
22550
22652
  var worldPos = new THREE__namespace.Vector3();
22551
22653
  connectorObj.getWorldPosition(worldPos);
@@ -22556,6 +22658,12 @@ var TransformOperationsManager = /*#__PURE__*/function () {
22556
22658
  }
22557
22659
  child.userData.position = [cleanValue(worldPos.x), cleanValue(worldPos.y), cleanValue(worldPos.z)];
22558
22660
  console.log(" \u21B3 Updated child connector ".concat(child.uuid, " position to [").concat(child.userData.position.join(', '), "]"));
22661
+
22662
+ // Update connector's direction in scene data from the Three.js object
22663
+ if ((_connectorObj$userDat = connectorObj.userData) !== null && _connectorObj$userDat !== void 0 && _connectorObj$userDat.direction && Array.isArray(connectorObj.userData.direction)) {
22664
+ child.userData.direction = _toConsumableArray(connectorObj.userData.direction);
22665
+ console.log(" \u21B3 Updated child connector ".concat(child.uuid, " direction to [").concat(child.userData.direction.join(', '), "]"));
22666
+ }
22559
22667
  }
22560
22668
  }
22561
22669
  });
@@ -22868,8 +22976,8 @@ var TransformOperationsManager = /*#__PURE__*/function () {
22868
22976
  // Check if either external connector belongs to the active segment
22869
22977
  var activeSegmentConnectors = [];
22870
22978
  activeSegment.traverse(function (child) {
22871
- var _child$userData25;
22872
- if (((_child$userData25 = child.userData) === null || _child$userData25 === void 0 ? void 0 : _child$userData25.objectType) === 'segment-connector') {
22979
+ var _child$userData23;
22980
+ if (((_child$userData23 = child.userData) === null || _child$userData23 === void 0 ? void 0 : _child$userData23.objectType) === 'segment-connector') {
22873
22981
  activeSegmentConnectors.push(child.uuid);
22874
22982
  }
22875
22983
  });
@@ -22917,8 +23025,8 @@ var TransformOperationsManager = /*#__PURE__*/function () {
22917
23025
  // Get all connectors of the active segment
22918
23026
  var activeConnectors = [];
22919
23027
  activeSegment.traverse(function (child) {
22920
- var _child$userData26;
22921
- if (((_child$userData26 = child.userData) === null || _child$userData26 === void 0 ? void 0 : _child$userData26.objectType) === 'segment-connector') {
23028
+ var _child$userData24;
23029
+ if (((_child$userData24 = child.userData) === null || _child$userData24 === void 0 ? void 0 : _child$userData24.objectType) === 'segment-connector') {
22922
23030
  activeConnectors.push(child);
22923
23031
  }
22924
23032
  });
@@ -31449,15 +31557,23 @@ var ModelManager = /*#__PURE__*/function () {
31449
31557
  if (child.userData) {
31450
31558
  clonedConnector.userData = _objectSpread2({}, child.userData);
31451
31559
 
31452
- // Deep copy critical data
31560
+ // Deep copy critical data - handle both array [x,y,z] and object {x,y,z} formats
31453
31561
  if (child.userData.worldBoundingBox) {
31562
+ var wbb = child.userData.worldBoundingBox;
31454
31563
  clonedConnector.userData.worldBoundingBox = {
31455
- min: _toConsumableArray(child.userData.worldBoundingBox.min),
31456
- max: _toConsumableArray(child.userData.worldBoundingBox.max)
31564
+ min: Array.isArray(wbb.min) ? _toConsumableArray(wbb.min) : _objectSpread2({}, wbb.min),
31565
+ max: Array.isArray(wbb.max) ? _toConsumableArray(wbb.max) : _objectSpread2({}, wbb.max)
31457
31566
  };
31458
31567
  }
31459
31568
  if (child.userData.direction) {
31460
- clonedConnector.userData.direction = _toConsumableArray(child.userData.direction);
31569
+ // Handle both array [x,y,z] and object {x,y,z} formats
31570
+ if (Array.isArray(child.userData.direction)) {
31571
+ clonedConnector.userData.direction = _toConsumableArray(child.userData.direction);
31572
+ } else if (_typeof(child.userData.direction) === 'object') {
31573
+ clonedConnector.userData.direction = _objectSpread2({}, child.userData.direction);
31574
+ } else {
31575
+ clonedConnector.userData.direction = child.userData.direction;
31576
+ }
31461
31577
  }
31462
31578
 
31463
31579
  // Set originalUuid to match the actual uuid (maintains consistency)
@@ -38822,7 +38938,7 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
38822
38938
  * Initialize the CentralPlant manager
38823
38939
  *
38824
38940
  * @constructor
38825
- * @version 0.3.17
38941
+ * @version 0.3.19
38826
38942
  * @updated 2025-10-22
38827
38943
  *
38828
38944
  * @description Creates a new CentralPlant instance and initializes internal managers and utilities.
@@ -46064,12 +46180,14 @@ function _measureS3Transfer() {
46064
46180
  var fileSize,
46065
46181
  startTime,
46066
46182
  executeTransfer,
46183
+ isExpiredToken,
46067
46184
  Auth,
46068
46185
  endTime,
46069
46186
  duration,
46070
46187
  _args2 = arguments,
46071
46188
  _t,
46072
- _t2;
46189
+ _t2,
46190
+ _t3;
46073
46191
  return _regenerator().w(function (_context2) {
46074
46192
  while (1) switch (_context2.n) {
46075
46193
  case 0:
@@ -46110,8 +46228,12 @@ function _measureS3Transfer() {
46110
46228
  case 3:
46111
46229
  _context2.p = 3;
46112
46230
  _t = _context2.v;
46113
- if (!(_t.code === 'ExpiredToken' || _t.message && _t.message.includes('ExpiredToken'))) {
46114
- _context2.n = 8;
46231
+ // Check for ExpiredToken error.
46232
+ // AWS SDK v3 (used by Amplify v5) sets error.name, not error.code.
46233
+ // error.message is 'The provided token has expired.' (no 'ExpiredToken' substring).
46234
+ isExpiredToken = _t.code === 'ExpiredToken' || _t.Code === 'ExpiredToken' || _t.name === 'ExpiredToken' || _t.message && _t.message.toLowerCase().includes('token has expired');
46235
+ if (!isExpiredToken) {
46236
+ _context2.n = 12;
46115
46237
  break;
46116
46238
  }
46117
46239
  console.warn("\u26A0\uFE0F Token expired during ".concat(operation, ". Attempting session refresh and retry..."));
@@ -46124,35 +46246,50 @@ function _measureS3Transfer() {
46124
46246
  throw _t;
46125
46247
  case 4:
46126
46248
  _context2.p = 4;
46127
- _context2.n = 5;
46249
+ _context2.p = 5;
46250
+ _context2.n = 6;
46251
+ return Auth.currentSession();
46252
+ case 6:
46253
+ console.log("\u2705 User Pool session refreshed for ".concat(operation, "."));
46254
+ _context2.n = 8;
46255
+ break;
46256
+ case 7:
46257
+ _context2.p = 7;
46258
+ _t2 = _context2.v;
46259
+ // If currentSession() fails the refresh token itself is expired —
46260
+ // the user needs to sign in again. Surface that immediately.
46261
+ console.error("\u274C Failed to refresh User Pool session during ".concat(operation, ":"), _t2);
46262
+ throw _t2;
46263
+ case 8:
46264
+ _context2.n = 9;
46128
46265
  return Auth.currentCredentials({
46129
46266
  bypassCache: true
46130
46267
  });
46131
- case 5:
46132
- console.log("\u2705 Session refreshed. Retrying ".concat(operation, "..."));
46268
+ case 9:
46269
+ console.log("\u2705 STS credentials refreshed. Retrying ".concat(operation, "..."));
46133
46270
 
46134
46271
  // Reset timer for the retry
46135
46272
  startTime = performance.now();
46136
- _context2.n = 6;
46273
+ _context2.n = 10;
46137
46274
  return executeTransfer();
46138
- case 6:
46275
+ case 10:
46139
46276
  return _context2.a(2, _context2.v);
46140
- case 7:
46141
- _context2.p = 7;
46142
- _t2 = _context2.v;
46143
- console.error("\u274C Retry failed for ".concat(operation, ":"), _t2);
46277
+ case 11:
46278
+ _context2.p = 11;
46279
+ _t3 = _context2.v;
46280
+ console.error("\u274C Retry failed for ".concat(operation, ":"), _t3);
46144
46281
  // If retry fails, throw the Retry Error (likely unrelated or persistent auth issue)
46145
- throw _t2;
46146
- case 8:
46282
+ throw _t3;
46283
+ case 12:
46147
46284
  // Standard error handling for non-expired tokens (or if logic above didn't catch it)
46148
46285
  endTime = performance.now();
46149
46286
  duration = ((endTime - startTime) / 1000).toFixed(3);
46150
46287
  console.error("\u274C S3 ".concat(operation, " failed after ").concat(duration, "s:"), _t);
46151
46288
  throw _t;
46152
- case 9:
46289
+ case 13:
46153
46290
  return _context2.a(2);
46154
46291
  }
46155
- }, _callee2, null, [[4, 7], [1, 3]]);
46292
+ }, _callee2, null, [[5, 7], [4, 11], [1, 3]]);
46156
46293
  }));
46157
46294
  return _measureS3Transfer.apply(this, arguments);
46158
46295
  }
@@ -35,7 +35,7 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
35
35
  * Initialize the CentralPlant manager
36
36
  *
37
37
  * @constructor
38
- * @version 0.3.17
38
+ * @version 0.3.19
39
39
  * @updated 2025-10-22
40
40
  *
41
41
  * @description Creates a new CentralPlant instance and initializes internal managers and utilities.
@@ -0,0 +1,115 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
6
+
7
+ /**
8
+ * Utility function to update userData.direction for components after 90-degree rotation
9
+ * This function handles the direction vector transformation for connectors when their parent component is rotated
10
+ *
11
+ * @param {THREE.Object3D} component - The component that was rotated
12
+ * @param {string} axis - The axis of rotation ('x', 'y', or 'z')
13
+ * @param {number} degrees - The rotation angle in degrees (should be multiple of 90)
14
+ */
15
+ function updateDirectionAfterRotation(component, axis, degrees) {
16
+ if (!component) {
17
+ console.warn('⚠️ updateDirectionAfterRotation: No component provided');
18
+ return;
19
+ }
20
+
21
+ // Only handle 90-degree increments
22
+ if (degrees % 90 !== 0) {
23
+ console.warn('⚠️ updateDirectionAfterRotation: Only 90-degree increments are supported');
24
+ return;
25
+ }
26
+
27
+ // Normalize degrees to 0-360 range
28
+ var normalizedDegrees = (degrees % 360 + 360) % 360;
29
+ console.log("\uD83D\uDD04 Updating direction vectors for ".concat(component.name || component.uuid, " after ").concat(degrees, "\xB0 rotation around ").concat(axis, " axis"));
30
+
31
+ // Traverse all children (connectors) and update their direction vectors
32
+ component.traverse(function (child) {
33
+ var _child$userData, _child$userData2;
34
+ var childType = ((_child$userData = child.userData) === null || _child$userData === void 0 ? void 0 : _child$userData.objectType) || ((_child$userData2 = child.userData) === null || _child$userData2 === void 0 ? void 0 : _child$userData2.objectType);
35
+ if (child.userData && Array.isArray(child.userData.direction) && childType === 'connector') {
36
+ var originalDirection = _rollupPluginBabelHelpers.toConsumableArray(child.userData.direction);
37
+ var newDirection = rotateDirectionVector(originalDirection, axis, normalizedDegrees);
38
+
39
+ // Update the direction
40
+ child.userData.direction = newDirection;
41
+ console.log("\uD83D\uDCCD Updated connector ".concat(child.name || child.uuid, " direction:"), {
42
+ original: originalDirection,
43
+ new: newDirection,
44
+ rotationAxis: axis,
45
+ rotationDegrees: degrees
46
+ });
47
+ }
48
+ });
49
+ }
50
+
51
+ /**
52
+ * Rotate a direction vector by 90-degree increments around a specific axis
53
+ *
54
+ * @param {Array<number>} direction - The original direction vector [x, y, z]
55
+ * @param {string} axis - The axis of rotation ('x', 'y', or 'z')
56
+ * @param {number} degrees - The rotation angle in degrees (must be multiple of 90)
57
+ * @returns {Array<number>} The new direction vector [x, y, z]
58
+ */
59
+ function rotateDirectionVector(direction, axis, degrees) {
60
+ if (!Array.isArray(direction) || direction.length !== 3) {
61
+ console.warn('⚠️ rotateDirectionVector: Invalid direction vector');
62
+ return direction;
63
+ }
64
+ var _direction = _rollupPluginBabelHelpers.slicedToArray(direction, 3),
65
+ x = _direction[0],
66
+ y = _direction[1],
67
+ z = _direction[2];
68
+ var steps = degrees / 90; // Number of 90-degree steps
69
+
70
+ for (var i = 0; i < steps; i++) {
71
+ var newX = x,
72
+ newY = y,
73
+ newZ = z;
74
+ switch (axis) {
75
+ case 'x':
76
+ // Rotation around X-axis in Z-up system with flipped Y: Y becomes -Z, Z becomes Y
77
+ newY = -z;
78
+ newZ = y;
79
+ break;
80
+ case 'y':
81
+ // Rotation around Y-axis in Z-up system with flipped Y: X becomes Z, Z becomes -X
82
+ newX = z;
83
+ newZ = -x;
84
+ break;
85
+ case 'z':
86
+ // Rotation around Z-axis in Z-up system with flipped Y: X becomes -Y, Y becomes X
87
+ newX = -y;
88
+ newY = x;
89
+ break;
90
+ default:
91
+ console.warn("\u26A0\uFE0F rotateDirectionVector: Invalid axis '".concat(axis, "'"));
92
+ return direction;
93
+ }
94
+ x = newX;
95
+ y = newY;
96
+ z = newZ;
97
+ }
98
+ return [x, y, z];
99
+ }
100
+
101
+ /**
102
+ * Example usage in your rotate method:
103
+ *
104
+ * // After applying rotation to the component
105
+ * component.rotation[axis] += radians
106
+ *
107
+ * // Update direction vectors for connectors
108
+ * updateDirectionAfterRotation(component, axis, value)
109
+ *
110
+ * // Update matrices
111
+ * component.updateMatrix()
112
+ * component.updateMatrixWorld(true)
113
+ */
114
+
115
+ exports.updateDirectionAfterRotation = updateDirectionAfterRotation;