@2112-lab/central-plant 0.3.17 → 0.3.18
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.
- package/dist/bundle/index.js +162 -46
- package/dist/cjs/src/core/centralPlant.js +1 -1
- package/dist/cjs/src/helpers/directionUtils.js +115 -0
- package/dist/cjs/src/managers/components/transformOperationsManager.js +42 -41
- package/dist/cjs/src/managers/scene/modelManager.js +12 -4
- package/dist/esm/src/core/centralPlant.js +1 -1
- package/dist/esm/src/helpers/directionUtils.js +111 -0
- package/dist/esm/src/managers/components/transformOperationsManager.js +42 -41
- package/dist/esm/src/managers/scene/modelManager.js +13 -5
- package/package.json +1 -1
package/dist/bundle/index.js
CHANGED
|
@@ -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
|
-
//
|
|
21251
|
-
|
|
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$
|
|
21512
|
+
var _child$userData5;
|
|
21412
21513
|
// Check if this is a connector (component connector or manual segment connector)
|
|
21413
|
-
if (((_child$
|
|
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$
|
|
21465
|
-
if (((_child$
|
|
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$
|
|
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$
|
|
21537
|
-
var _segment$userData6, _child$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
21979
|
+
var _child$userData10;
|
|
21879
21980
|
// Check if this is a component connector (not a segment-connector)
|
|
21880
|
-
if (((_child$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
22284
|
-
if (((_child$
|
|
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$
|
|
22355
|
-
if (((_child$
|
|
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$
|
|
22479
|
-
if (((_child$
|
|
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$
|
|
22542
|
-
if (((_child$
|
|
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$
|
|
22872
|
-
if (((_child$
|
|
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$
|
|
22921
|
-
if (((_child$
|
|
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(
|
|
31456
|
-
max: _toConsumableArray(
|
|
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
|
-
|
|
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.
|
|
38941
|
+
* @version 0.3.18
|
|
38826
38942
|
* @updated 2025-10-22
|
|
38827
38943
|
*
|
|
38828
38944
|
* @description Creates a new CentralPlant instance and initializes internal managers and utilities.
|
|
@@ -35,7 +35,7 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
35
35
|
* Initialize the CentralPlant manager
|
|
36
36
|
*
|
|
37
37
|
* @constructor
|
|
38
|
-
* @version 0.3.
|
|
38
|
+
* @version 0.3.18
|
|
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;
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var _rollupPluginBabelHelpers = require('../../../_virtual/_rollupPluginBabelHelpers.js');
|
|
6
6
|
var THREE = require('three');
|
|
7
|
+
var directionUtils = require('../../helpers/directionUtils.js');
|
|
7
8
|
|
|
8
9
|
function _interopNamespace(e) {
|
|
9
10
|
if (e && e.__esModule) return e;
|
|
@@ -716,16 +717,9 @@ var TransformOperationsManager = /*#__PURE__*/function () {
|
|
|
716
717
|
if (!component || degrees % 90 !== 0) {
|
|
717
718
|
return;
|
|
718
719
|
}
|
|
719
|
-
console.log("\uD83D\uDD04 Updating connector directions after ".concat(degrees, "\xB0 rotation around ").concat(axis, " axis"));
|
|
720
720
|
|
|
721
|
-
//
|
|
722
|
-
|
|
723
|
-
component.traverse(function (child) {
|
|
724
|
-
var _child$userData5, _child$userData6;
|
|
725
|
-
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) {
|
|
726
|
-
console.log("\uD83D\uDCCD Connector ".concat(child.uuid, " direction may need verification after rotation"));
|
|
727
|
-
}
|
|
728
|
-
});
|
|
721
|
+
// Use the direction utility to update direction vectors on Three.js connector objects
|
|
722
|
+
directionUtils.updateDirectionAfterRotation(component, axis, degrees);
|
|
729
723
|
}
|
|
730
724
|
|
|
731
725
|
/**
|
|
@@ -879,9 +873,9 @@ var TransformOperationsManager = /*#__PURE__*/function () {
|
|
|
879
873
|
|
|
880
874
|
// Traverse scene to find all connectors
|
|
881
875
|
this.sceneViewer.scene.traverse(function (child) {
|
|
882
|
-
var _child$
|
|
876
|
+
var _child$userData5;
|
|
883
877
|
// Check if this is a connector (component connector or manual segment connector)
|
|
884
|
-
if (((_child$
|
|
878
|
+
if (((_child$userData5 = child.userData) === null || _child$userData5 === void 0 ? void 0 : _child$userData5.objectType) === 'connector') {
|
|
885
879
|
// Get world position of connector
|
|
886
880
|
var connectorWorldPos = new THREE__namespace.Vector3();
|
|
887
881
|
child.getWorldPosition(connectorWorldPos);
|
|
@@ -932,8 +926,8 @@ var TransformOperationsManager = /*#__PURE__*/function () {
|
|
|
932
926
|
// Find all child connectors of the segment in the Three.js scene
|
|
933
927
|
var connectors = [];
|
|
934
928
|
segment.traverse(function (child) {
|
|
935
|
-
var _child$
|
|
936
|
-
if (((_child$
|
|
929
|
+
var _child$userData6;
|
|
930
|
+
if (((_child$userData6 = child.userData) === null || _child$userData6 === void 0 ? void 0 : _child$userData6.objectType) === 'segment-connector') {
|
|
937
931
|
connectors.push(child);
|
|
938
932
|
}
|
|
939
933
|
});
|
|
@@ -997,17 +991,17 @@ var TransformOperationsManager = /*#__PURE__*/function () {
|
|
|
997
991
|
|
|
998
992
|
// Check all segments in the scene
|
|
999
993
|
this.sceneViewer.scene.traverse(function (child) {
|
|
1000
|
-
var _child$
|
|
994
|
+
var _child$userData7, _child$userData8;
|
|
1001
995
|
// Skip the segment itself
|
|
1002
996
|
if (child.uuid === segment.uuid) {
|
|
1003
997
|
return;
|
|
1004
998
|
}
|
|
1005
999
|
|
|
1006
1000
|
// Only check computed segments in the scene
|
|
1007
|
-
if (((_child$
|
|
1008
|
-
var _segment$userData6, _child$
|
|
1001
|
+
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) {
|
|
1002
|
+
var _segment$userData6, _child$userData9, _segment$userData7, _child$userData0;
|
|
1009
1003
|
// Check if segments are part of the same connection path
|
|
1010
|
-
var sameConnection = ((_segment$userData6 = segment.userData) === null || _segment$userData6 === void 0 ? void 0 : _segment$userData6.pathFrom) === ((_child$
|
|
1004
|
+
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);
|
|
1011
1005
|
|
|
1012
1006
|
// Get endpoints of the other segment (use stored endpoints if available)
|
|
1013
1007
|
var otherEndpoints = _this2.getSegmentEndpoints(child);
|
|
@@ -1228,11 +1222,11 @@ var TransformOperationsManager = /*#__PURE__*/function () {
|
|
|
1228
1222
|
|
|
1229
1223
|
// Traverse scene to find all component connectors
|
|
1230
1224
|
this.sceneViewer.scene.traverse(function (child) {
|
|
1231
|
-
var _child$
|
|
1225
|
+
var _child$userData1;
|
|
1232
1226
|
if (collision) return; // Stop if collision already found
|
|
1233
1227
|
|
|
1234
1228
|
// Check if this is a component connector (not a segment-connector)
|
|
1235
|
-
if (((_child$
|
|
1229
|
+
if (((_child$userData1 = child.userData) === null || _child$userData1 === void 0 ? void 0 : _child$userData1.objectType) === 'connector') {
|
|
1236
1230
|
var _segment$userData10, _segment$userData11;
|
|
1237
1231
|
// Skip connectors that are connected to this segment (pathFrom or pathTo)
|
|
1238
1232
|
var segmentPathFrom = (_segment$userData10 = segment.userData) === null || _segment$userData10 === void 0 ? void 0 : _segment$userData10.pathFrom;
|
|
@@ -1346,9 +1340,9 @@ var TransformOperationsManager = /*#__PURE__*/function () {
|
|
|
1346
1340
|
|
|
1347
1341
|
// Traverse scene to find all component connectors
|
|
1348
1342
|
this.sceneViewer.scene.traverse(function (child) {
|
|
1349
|
-
var _child$
|
|
1343
|
+
var _child$userData10;
|
|
1350
1344
|
// Check if this is a component connector (not a segment-connector)
|
|
1351
|
-
if (((_child$
|
|
1345
|
+
if (((_child$userData10 = child.userData) === null || _child$userData10 === void 0 ? void 0 : _child$userData10.objectType) === 'connector') {
|
|
1352
1346
|
// Get world position of connector
|
|
1353
1347
|
var connectorWorldPos = new THREE__namespace.Vector3();
|
|
1354
1348
|
child.getWorldPosition(connectorWorldPos);
|
|
@@ -1405,11 +1399,11 @@ var TransformOperationsManager = /*#__PURE__*/function () {
|
|
|
1405
1399
|
|
|
1406
1400
|
// Traverse scene to find all components
|
|
1407
1401
|
this.sceneViewer.scene.traverse(function (child) {
|
|
1408
|
-
var _child$
|
|
1402
|
+
var _child$userData11, _child$userData12;
|
|
1409
1403
|
if (collision) return; // Stop if collision already found
|
|
1410
1404
|
|
|
1411
1405
|
// Check if this is a component (equipment)
|
|
1412
|
-
if (((_child$
|
|
1406
|
+
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) {
|
|
1413
1407
|
// Create bounding box for the component
|
|
1414
1408
|
var componentBBox = new THREE__namespace.Box3().setFromObject(child);
|
|
1415
1409
|
|
|
@@ -1448,11 +1442,11 @@ var TransformOperationsManager = /*#__PURE__*/function () {
|
|
|
1448
1442
|
|
|
1449
1443
|
// Traverse scene to find all manual segments (isDeclared === true)
|
|
1450
1444
|
this.sceneViewer.scene.traverse(function (child) {
|
|
1451
|
-
var _child$
|
|
1445
|
+
var _child$userData13, _child$userData14;
|
|
1452
1446
|
if (collision) return; // Stop if collision already found
|
|
1453
1447
|
|
|
1454
1448
|
// Only check manual segments (isDeclared === true)
|
|
1455
|
-
if (((_child$
|
|
1449
|
+
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) {
|
|
1456
1450
|
// Get segment endpoints
|
|
1457
1451
|
var segmentEndpoints = _this3.getSegmentEndpoints(child);
|
|
1458
1452
|
|
|
@@ -1541,11 +1535,11 @@ var TransformOperationsManager = /*#__PURE__*/function () {
|
|
|
1541
1535
|
|
|
1542
1536
|
// Traverse scene to find all manual segments (isDeclared === true)
|
|
1543
1537
|
this.sceneViewer.scene.traverse(function (child) {
|
|
1544
|
-
var _child$
|
|
1538
|
+
var _child$userData15, _child$userData16;
|
|
1545
1539
|
if (collision) return; // Stop if collision already found
|
|
1546
1540
|
|
|
1547
1541
|
// Only check manual segments (isDeclared === true)
|
|
1548
|
-
if (((_child$
|
|
1542
|
+
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) {
|
|
1549
1543
|
// Get segment endpoints
|
|
1550
1544
|
var segmentEndpoints = _this4.getSegmentEndpoints(child);
|
|
1551
1545
|
|
|
@@ -1602,11 +1596,11 @@ var TransformOperationsManager = /*#__PURE__*/function () {
|
|
|
1602
1596
|
|
|
1603
1597
|
// Traverse scene to find all components
|
|
1604
1598
|
this.sceneViewer.scene.traverse(function (child) {
|
|
1605
|
-
var _child$
|
|
1599
|
+
var _child$userData17, _child$userData18;
|
|
1606
1600
|
if (collision) return; // Stop if collision already found
|
|
1607
1601
|
|
|
1608
1602
|
// Check if this is a component (equipment)
|
|
1609
|
-
if (((_child$
|
|
1603
|
+
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) {
|
|
1610
1604
|
// Try to get worldBoundingBox from userData first (most up-to-date)
|
|
1611
1605
|
var bbox = null;
|
|
1612
1606
|
if (child.userData.worldBoundingBox) {
|
|
@@ -1751,8 +1745,8 @@ var TransformOperationsManager = /*#__PURE__*/function () {
|
|
|
1751
1745
|
// Get the moved segment's connectors
|
|
1752
1746
|
var movedConnectors = [];
|
|
1753
1747
|
movedSegment.traverse(function (child) {
|
|
1754
|
-
var _child$
|
|
1755
|
-
if (((_child$
|
|
1748
|
+
var _child$userData19;
|
|
1749
|
+
if (((_child$userData19 = child.userData) === null || _child$userData19 === void 0 ? void 0 : _child$userData19.objectType) === 'segment-connector') {
|
|
1756
1750
|
movedConnectors.push(child);
|
|
1757
1751
|
}
|
|
1758
1752
|
});
|
|
@@ -1822,8 +1816,8 @@ var TransformOperationsManager = /*#__PURE__*/function () {
|
|
|
1822
1816
|
// Get all connectors of the adjacent segment
|
|
1823
1817
|
var adjacentConnectors = [];
|
|
1824
1818
|
adjacentSegment.traverse(function (child) {
|
|
1825
|
-
var _child$
|
|
1826
|
-
if (((_child$
|
|
1819
|
+
var _child$userData20;
|
|
1820
|
+
if (((_child$userData20 = child.userData) === null || _child$userData20 === void 0 ? void 0 : _child$userData20.objectType) === 'segment-connector') {
|
|
1827
1821
|
adjacentConnectors.push(child);
|
|
1828
1822
|
}
|
|
1829
1823
|
});
|
|
@@ -1946,8 +1940,8 @@ var TransformOperationsManager = /*#__PURE__*/function () {
|
|
|
1946
1940
|
// Also update child connectors' positions if they exist
|
|
1947
1941
|
if (sceneDataComponent.children) {
|
|
1948
1942
|
sceneDataComponent.children.forEach(function (child) {
|
|
1949
|
-
var _child$
|
|
1950
|
-
if (((_child$
|
|
1943
|
+
var _child$userData21;
|
|
1944
|
+
if (((_child$userData21 = child.userData) === null || _child$userData21 === void 0 ? void 0 : _child$userData21.objectType) === 'connector') {
|
|
1951
1945
|
// Find the actual connector object in the scene
|
|
1952
1946
|
var connectorObj = component.children.find(function (c) {
|
|
1953
1947
|
var _c$userData;
|
|
@@ -2009,14 +2003,15 @@ var TransformOperationsManager = /*#__PURE__*/function () {
|
|
|
2009
2003
|
// Also update child connectors' positions if they exist (rotation moves them in world space)
|
|
2010
2004
|
if (sceneDataComponent.children) {
|
|
2011
2005
|
sceneDataComponent.children.forEach(function (child) {
|
|
2012
|
-
var _child$
|
|
2013
|
-
if (((_child$
|
|
2006
|
+
var _child$userData22;
|
|
2007
|
+
if (((_child$userData22 = child.userData) === null || _child$userData22 === void 0 ? void 0 : _child$userData22.objectType) === 'connector') {
|
|
2014
2008
|
// Find the actual connector object in the scene
|
|
2015
2009
|
var connectorObj = component.children.find(function (c) {
|
|
2016
2010
|
var _c$userData2;
|
|
2017
2011
|
return c.uuid === child.uuid || ((_c$userData2 = c.userData) === null || _c$userData2 === void 0 ? void 0 : _c$userData2.originalUuid) === child.uuid;
|
|
2018
2012
|
});
|
|
2019
2013
|
if (connectorObj) {
|
|
2014
|
+
var _connectorObj$userDat;
|
|
2020
2015
|
// Get world position of connector
|
|
2021
2016
|
var worldPos = new THREE__namespace.Vector3();
|
|
2022
2017
|
connectorObj.getWorldPosition(worldPos);
|
|
@@ -2027,6 +2022,12 @@ var TransformOperationsManager = /*#__PURE__*/function () {
|
|
|
2027
2022
|
}
|
|
2028
2023
|
child.userData.position = [cleanValue(worldPos.x), cleanValue(worldPos.y), cleanValue(worldPos.z)];
|
|
2029
2024
|
console.log(" \u21B3 Updated child connector ".concat(child.uuid, " position to [").concat(child.userData.position.join(', '), "]"));
|
|
2025
|
+
|
|
2026
|
+
// Update connector's direction in scene data from the Three.js object
|
|
2027
|
+
if ((_connectorObj$userDat = connectorObj.userData) !== null && _connectorObj$userDat !== void 0 && _connectorObj$userDat.direction && Array.isArray(connectorObj.userData.direction)) {
|
|
2028
|
+
child.userData.direction = _rollupPluginBabelHelpers.toConsumableArray(connectorObj.userData.direction);
|
|
2029
|
+
console.log(" \u21B3 Updated child connector ".concat(child.uuid, " direction to [").concat(child.userData.direction.join(', '), "]"));
|
|
2030
|
+
}
|
|
2030
2031
|
}
|
|
2031
2032
|
}
|
|
2032
2033
|
});
|
|
@@ -2339,8 +2340,8 @@ var TransformOperationsManager = /*#__PURE__*/function () {
|
|
|
2339
2340
|
// Check if either external connector belongs to the active segment
|
|
2340
2341
|
var activeSegmentConnectors = [];
|
|
2341
2342
|
activeSegment.traverse(function (child) {
|
|
2342
|
-
var _child$
|
|
2343
|
-
if (((_child$
|
|
2343
|
+
var _child$userData23;
|
|
2344
|
+
if (((_child$userData23 = child.userData) === null || _child$userData23 === void 0 ? void 0 : _child$userData23.objectType) === 'segment-connector') {
|
|
2344
2345
|
activeSegmentConnectors.push(child.uuid);
|
|
2345
2346
|
}
|
|
2346
2347
|
});
|
|
@@ -2388,8 +2389,8 @@ var TransformOperationsManager = /*#__PURE__*/function () {
|
|
|
2388
2389
|
// Get all connectors of the active segment
|
|
2389
2390
|
var activeConnectors = [];
|
|
2390
2391
|
activeSegment.traverse(function (child) {
|
|
2391
|
-
var _child$
|
|
2392
|
-
if (((_child$
|
|
2392
|
+
var _child$userData24;
|
|
2393
|
+
if (((_child$userData24 = child.userData) === null || _child$userData24 === void 0 ? void 0 : _child$userData24.objectType) === 'segment-connector') {
|
|
2393
2394
|
activeConnectors.push(child);
|
|
2394
2395
|
}
|
|
2395
2396
|
});
|
|
@@ -171,15 +171,23 @@ var ModelManager = /*#__PURE__*/function () {
|
|
|
171
171
|
if (child.userData) {
|
|
172
172
|
clonedConnector.userData = _rollupPluginBabelHelpers.objectSpread2({}, child.userData);
|
|
173
173
|
|
|
174
|
-
// Deep copy critical data
|
|
174
|
+
// Deep copy critical data - handle both array [x,y,z] and object {x,y,z} formats
|
|
175
175
|
if (child.userData.worldBoundingBox) {
|
|
176
|
+
var wbb = child.userData.worldBoundingBox;
|
|
176
177
|
clonedConnector.userData.worldBoundingBox = {
|
|
177
|
-
min: _rollupPluginBabelHelpers.toConsumableArray(
|
|
178
|
-
max: _rollupPluginBabelHelpers.toConsumableArray(
|
|
178
|
+
min: Array.isArray(wbb.min) ? _rollupPluginBabelHelpers.toConsumableArray(wbb.min) : _rollupPluginBabelHelpers.objectSpread2({}, wbb.min),
|
|
179
|
+
max: Array.isArray(wbb.max) ? _rollupPluginBabelHelpers.toConsumableArray(wbb.max) : _rollupPluginBabelHelpers.objectSpread2({}, wbb.max)
|
|
179
180
|
};
|
|
180
181
|
}
|
|
181
182
|
if (child.userData.direction) {
|
|
182
|
-
|
|
183
|
+
// Handle both array [x,y,z] and object {x,y,z} formats
|
|
184
|
+
if (Array.isArray(child.userData.direction)) {
|
|
185
|
+
clonedConnector.userData.direction = _rollupPluginBabelHelpers.toConsumableArray(child.userData.direction);
|
|
186
|
+
} else if (_rollupPluginBabelHelpers["typeof"](child.userData.direction) === 'object') {
|
|
187
|
+
clonedConnector.userData.direction = _rollupPluginBabelHelpers.objectSpread2({}, child.userData.direction);
|
|
188
|
+
} else {
|
|
189
|
+
clonedConnector.userData.direction = child.userData.direction;
|
|
190
|
+
}
|
|
183
191
|
}
|
|
184
192
|
|
|
185
193
|
// Set originalUuid to match the actual uuid (maintains consistency)
|
|
@@ -31,7 +31,7 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
31
31
|
* Initialize the CentralPlant manager
|
|
32
32
|
*
|
|
33
33
|
* @constructor
|
|
34
|
-
* @version 0.3.
|
|
34
|
+
* @version 0.3.18
|
|
35
35
|
* @updated 2025-10-22
|
|
36
36
|
*
|
|
37
37
|
* @description Creates a new CentralPlant instance and initializes internal managers and utilities.
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { toConsumableArray as _toConsumableArray, slicedToArray as _slicedToArray } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Utility function to update userData.direction for components after 90-degree rotation
|
|
5
|
+
* This function handles the direction vector transformation for connectors when their parent component is rotated
|
|
6
|
+
*
|
|
7
|
+
* @param {THREE.Object3D} component - The component that was rotated
|
|
8
|
+
* @param {string} axis - The axis of rotation ('x', 'y', or 'z')
|
|
9
|
+
* @param {number} degrees - The rotation angle in degrees (should be multiple of 90)
|
|
10
|
+
*/
|
|
11
|
+
function updateDirectionAfterRotation(component, axis, degrees) {
|
|
12
|
+
if (!component) {
|
|
13
|
+
console.warn('⚠️ updateDirectionAfterRotation: No component provided');
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// Only handle 90-degree increments
|
|
18
|
+
if (degrees % 90 !== 0) {
|
|
19
|
+
console.warn('⚠️ updateDirectionAfterRotation: Only 90-degree increments are supported');
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// Normalize degrees to 0-360 range
|
|
24
|
+
var normalizedDegrees = (degrees % 360 + 360) % 360;
|
|
25
|
+
console.log("\uD83D\uDD04 Updating direction vectors for ".concat(component.name || component.uuid, " after ").concat(degrees, "\xB0 rotation around ").concat(axis, " axis"));
|
|
26
|
+
|
|
27
|
+
// Traverse all children (connectors) and update their direction vectors
|
|
28
|
+
component.traverse(function (child) {
|
|
29
|
+
var _child$userData, _child$userData2;
|
|
30
|
+
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);
|
|
31
|
+
if (child.userData && Array.isArray(child.userData.direction) && childType === 'connector') {
|
|
32
|
+
var originalDirection = _toConsumableArray(child.userData.direction);
|
|
33
|
+
var newDirection = rotateDirectionVector(originalDirection, axis, normalizedDegrees);
|
|
34
|
+
|
|
35
|
+
// Update the direction
|
|
36
|
+
child.userData.direction = newDirection;
|
|
37
|
+
console.log("\uD83D\uDCCD Updated connector ".concat(child.name || child.uuid, " direction:"), {
|
|
38
|
+
original: originalDirection,
|
|
39
|
+
new: newDirection,
|
|
40
|
+
rotationAxis: axis,
|
|
41
|
+
rotationDegrees: degrees
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Rotate a direction vector by 90-degree increments around a specific axis
|
|
49
|
+
*
|
|
50
|
+
* @param {Array<number>} direction - The original direction vector [x, y, z]
|
|
51
|
+
* @param {string} axis - The axis of rotation ('x', 'y', or 'z')
|
|
52
|
+
* @param {number} degrees - The rotation angle in degrees (must be multiple of 90)
|
|
53
|
+
* @returns {Array<number>} The new direction vector [x, y, z]
|
|
54
|
+
*/
|
|
55
|
+
function rotateDirectionVector(direction, axis, degrees) {
|
|
56
|
+
if (!Array.isArray(direction) || direction.length !== 3) {
|
|
57
|
+
console.warn('⚠️ rotateDirectionVector: Invalid direction vector');
|
|
58
|
+
return direction;
|
|
59
|
+
}
|
|
60
|
+
var _direction = _slicedToArray(direction, 3),
|
|
61
|
+
x = _direction[0],
|
|
62
|
+
y = _direction[1],
|
|
63
|
+
z = _direction[2];
|
|
64
|
+
var steps = degrees / 90; // Number of 90-degree steps
|
|
65
|
+
|
|
66
|
+
for (var i = 0; i < steps; i++) {
|
|
67
|
+
var newX = x,
|
|
68
|
+
newY = y,
|
|
69
|
+
newZ = z;
|
|
70
|
+
switch (axis) {
|
|
71
|
+
case 'x':
|
|
72
|
+
// Rotation around X-axis in Z-up system with flipped Y: Y becomes -Z, Z becomes Y
|
|
73
|
+
newY = -z;
|
|
74
|
+
newZ = y;
|
|
75
|
+
break;
|
|
76
|
+
case 'y':
|
|
77
|
+
// Rotation around Y-axis in Z-up system with flipped Y: X becomes Z, Z becomes -X
|
|
78
|
+
newX = z;
|
|
79
|
+
newZ = -x;
|
|
80
|
+
break;
|
|
81
|
+
case 'z':
|
|
82
|
+
// Rotation around Z-axis in Z-up system with flipped Y: X becomes -Y, Y becomes X
|
|
83
|
+
newX = -y;
|
|
84
|
+
newY = x;
|
|
85
|
+
break;
|
|
86
|
+
default:
|
|
87
|
+
console.warn("\u26A0\uFE0F rotateDirectionVector: Invalid axis '".concat(axis, "'"));
|
|
88
|
+
return direction;
|
|
89
|
+
}
|
|
90
|
+
x = newX;
|
|
91
|
+
y = newY;
|
|
92
|
+
z = newZ;
|
|
93
|
+
}
|
|
94
|
+
return [x, y, z];
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Example usage in your rotate method:
|
|
99
|
+
*
|
|
100
|
+
* // After applying rotation to the component
|
|
101
|
+
* component.rotation[axis] += radians
|
|
102
|
+
*
|
|
103
|
+
* // Update direction vectors for connectors
|
|
104
|
+
* updateDirectionAfterRotation(component, axis, value)
|
|
105
|
+
*
|
|
106
|
+
* // Update matrices
|
|
107
|
+
* component.updateMatrix()
|
|
108
|
+
* component.updateMatrixWorld(true)
|
|
109
|
+
*/
|
|
110
|
+
|
|
111
|
+
export { updateDirectionAfterRotation };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createClass as _createClass, createForOfIteratorHelper as _createForOfIteratorHelper, construct as _construct, toConsumableArray as _toConsumableArray, slicedToArray as _slicedToArray, classCallCheck as _classCallCheck } from '../../../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
2
|
import * as THREE from 'three';
|
|
3
|
+
import { updateDirectionAfterRotation } from '../../helpers/directionUtils.js';
|
|
3
4
|
|
|
4
5
|
var TransformOperationsManager = /*#__PURE__*/function () {
|
|
5
6
|
/**
|
|
@@ -692,16 +693,9 @@ var TransformOperationsManager = /*#__PURE__*/function () {
|
|
|
692
693
|
if (!component || degrees % 90 !== 0) {
|
|
693
694
|
return;
|
|
694
695
|
}
|
|
695
|
-
console.log("\uD83D\uDD04 Updating connector directions after ".concat(degrees, "\xB0 rotation around ").concat(axis, " axis"));
|
|
696
696
|
|
|
697
|
-
//
|
|
698
|
-
|
|
699
|
-
component.traverse(function (child) {
|
|
700
|
-
var _child$userData5, _child$userData6;
|
|
701
|
-
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) {
|
|
702
|
-
console.log("\uD83D\uDCCD Connector ".concat(child.uuid, " direction may need verification after rotation"));
|
|
703
|
-
}
|
|
704
|
-
});
|
|
697
|
+
// Use the direction utility to update direction vectors on Three.js connector objects
|
|
698
|
+
updateDirectionAfterRotation(component, axis, degrees);
|
|
705
699
|
}
|
|
706
700
|
|
|
707
701
|
/**
|
|
@@ -855,9 +849,9 @@ var TransformOperationsManager = /*#__PURE__*/function () {
|
|
|
855
849
|
|
|
856
850
|
// Traverse scene to find all connectors
|
|
857
851
|
this.sceneViewer.scene.traverse(function (child) {
|
|
858
|
-
var _child$
|
|
852
|
+
var _child$userData5;
|
|
859
853
|
// Check if this is a connector (component connector or manual segment connector)
|
|
860
|
-
if (((_child$
|
|
854
|
+
if (((_child$userData5 = child.userData) === null || _child$userData5 === void 0 ? void 0 : _child$userData5.objectType) === 'connector') {
|
|
861
855
|
// Get world position of connector
|
|
862
856
|
var connectorWorldPos = new THREE.Vector3();
|
|
863
857
|
child.getWorldPosition(connectorWorldPos);
|
|
@@ -908,8 +902,8 @@ var TransformOperationsManager = /*#__PURE__*/function () {
|
|
|
908
902
|
// Find all child connectors of the segment in the Three.js scene
|
|
909
903
|
var connectors = [];
|
|
910
904
|
segment.traverse(function (child) {
|
|
911
|
-
var _child$
|
|
912
|
-
if (((_child$
|
|
905
|
+
var _child$userData6;
|
|
906
|
+
if (((_child$userData6 = child.userData) === null || _child$userData6 === void 0 ? void 0 : _child$userData6.objectType) === 'segment-connector') {
|
|
913
907
|
connectors.push(child);
|
|
914
908
|
}
|
|
915
909
|
});
|
|
@@ -973,17 +967,17 @@ var TransformOperationsManager = /*#__PURE__*/function () {
|
|
|
973
967
|
|
|
974
968
|
// Check all segments in the scene
|
|
975
969
|
this.sceneViewer.scene.traverse(function (child) {
|
|
976
|
-
var _child$
|
|
970
|
+
var _child$userData7, _child$userData8;
|
|
977
971
|
// Skip the segment itself
|
|
978
972
|
if (child.uuid === segment.uuid) {
|
|
979
973
|
return;
|
|
980
974
|
}
|
|
981
975
|
|
|
982
976
|
// Only check computed segments in the scene
|
|
983
|
-
if (((_child$
|
|
984
|
-
var _segment$userData6, _child$
|
|
977
|
+
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) {
|
|
978
|
+
var _segment$userData6, _child$userData9, _segment$userData7, _child$userData0;
|
|
985
979
|
// Check if segments are part of the same connection path
|
|
986
|
-
var sameConnection = ((_segment$userData6 = segment.userData) === null || _segment$userData6 === void 0 ? void 0 : _segment$userData6.pathFrom) === ((_child$
|
|
980
|
+
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);
|
|
987
981
|
|
|
988
982
|
// Get endpoints of the other segment (use stored endpoints if available)
|
|
989
983
|
var otherEndpoints = _this2.getSegmentEndpoints(child);
|
|
@@ -1204,11 +1198,11 @@ var TransformOperationsManager = /*#__PURE__*/function () {
|
|
|
1204
1198
|
|
|
1205
1199
|
// Traverse scene to find all component connectors
|
|
1206
1200
|
this.sceneViewer.scene.traverse(function (child) {
|
|
1207
|
-
var _child$
|
|
1201
|
+
var _child$userData1;
|
|
1208
1202
|
if (collision) return; // Stop if collision already found
|
|
1209
1203
|
|
|
1210
1204
|
// Check if this is a component connector (not a segment-connector)
|
|
1211
|
-
if (((_child$
|
|
1205
|
+
if (((_child$userData1 = child.userData) === null || _child$userData1 === void 0 ? void 0 : _child$userData1.objectType) === 'connector') {
|
|
1212
1206
|
var _segment$userData10, _segment$userData11;
|
|
1213
1207
|
// Skip connectors that are connected to this segment (pathFrom or pathTo)
|
|
1214
1208
|
var segmentPathFrom = (_segment$userData10 = segment.userData) === null || _segment$userData10 === void 0 ? void 0 : _segment$userData10.pathFrom;
|
|
@@ -1322,9 +1316,9 @@ var TransformOperationsManager = /*#__PURE__*/function () {
|
|
|
1322
1316
|
|
|
1323
1317
|
// Traverse scene to find all component connectors
|
|
1324
1318
|
this.sceneViewer.scene.traverse(function (child) {
|
|
1325
|
-
var _child$
|
|
1319
|
+
var _child$userData10;
|
|
1326
1320
|
// Check if this is a component connector (not a segment-connector)
|
|
1327
|
-
if (((_child$
|
|
1321
|
+
if (((_child$userData10 = child.userData) === null || _child$userData10 === void 0 ? void 0 : _child$userData10.objectType) === 'connector') {
|
|
1328
1322
|
// Get world position of connector
|
|
1329
1323
|
var connectorWorldPos = new THREE.Vector3();
|
|
1330
1324
|
child.getWorldPosition(connectorWorldPos);
|
|
@@ -1381,11 +1375,11 @@ var TransformOperationsManager = /*#__PURE__*/function () {
|
|
|
1381
1375
|
|
|
1382
1376
|
// Traverse scene to find all components
|
|
1383
1377
|
this.sceneViewer.scene.traverse(function (child) {
|
|
1384
|
-
var _child$
|
|
1378
|
+
var _child$userData11, _child$userData12;
|
|
1385
1379
|
if (collision) return; // Stop if collision already found
|
|
1386
1380
|
|
|
1387
1381
|
// Check if this is a component (equipment)
|
|
1388
|
-
if (((_child$
|
|
1382
|
+
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) {
|
|
1389
1383
|
// Create bounding box for the component
|
|
1390
1384
|
var componentBBox = new THREE.Box3().setFromObject(child);
|
|
1391
1385
|
|
|
@@ -1424,11 +1418,11 @@ var TransformOperationsManager = /*#__PURE__*/function () {
|
|
|
1424
1418
|
|
|
1425
1419
|
// Traverse scene to find all manual segments (isDeclared === true)
|
|
1426
1420
|
this.sceneViewer.scene.traverse(function (child) {
|
|
1427
|
-
var _child$
|
|
1421
|
+
var _child$userData13, _child$userData14;
|
|
1428
1422
|
if (collision) return; // Stop if collision already found
|
|
1429
1423
|
|
|
1430
1424
|
// Only check manual segments (isDeclared === true)
|
|
1431
|
-
if (((_child$
|
|
1425
|
+
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) {
|
|
1432
1426
|
// Get segment endpoints
|
|
1433
1427
|
var segmentEndpoints = _this3.getSegmentEndpoints(child);
|
|
1434
1428
|
|
|
@@ -1517,11 +1511,11 @@ var TransformOperationsManager = /*#__PURE__*/function () {
|
|
|
1517
1511
|
|
|
1518
1512
|
// Traverse scene to find all manual segments (isDeclared === true)
|
|
1519
1513
|
this.sceneViewer.scene.traverse(function (child) {
|
|
1520
|
-
var _child$
|
|
1514
|
+
var _child$userData15, _child$userData16;
|
|
1521
1515
|
if (collision) return; // Stop if collision already found
|
|
1522
1516
|
|
|
1523
1517
|
// Only check manual segments (isDeclared === true)
|
|
1524
|
-
if (((_child$
|
|
1518
|
+
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) {
|
|
1525
1519
|
// Get segment endpoints
|
|
1526
1520
|
var segmentEndpoints = _this4.getSegmentEndpoints(child);
|
|
1527
1521
|
|
|
@@ -1578,11 +1572,11 @@ var TransformOperationsManager = /*#__PURE__*/function () {
|
|
|
1578
1572
|
|
|
1579
1573
|
// Traverse scene to find all components
|
|
1580
1574
|
this.sceneViewer.scene.traverse(function (child) {
|
|
1581
|
-
var _child$
|
|
1575
|
+
var _child$userData17, _child$userData18;
|
|
1582
1576
|
if (collision) return; // Stop if collision already found
|
|
1583
1577
|
|
|
1584
1578
|
// Check if this is a component (equipment)
|
|
1585
|
-
if (((_child$
|
|
1579
|
+
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) {
|
|
1586
1580
|
// Try to get worldBoundingBox from userData first (most up-to-date)
|
|
1587
1581
|
var bbox = null;
|
|
1588
1582
|
if (child.userData.worldBoundingBox) {
|
|
@@ -1727,8 +1721,8 @@ var TransformOperationsManager = /*#__PURE__*/function () {
|
|
|
1727
1721
|
// Get the moved segment's connectors
|
|
1728
1722
|
var movedConnectors = [];
|
|
1729
1723
|
movedSegment.traverse(function (child) {
|
|
1730
|
-
var _child$
|
|
1731
|
-
if (((_child$
|
|
1724
|
+
var _child$userData19;
|
|
1725
|
+
if (((_child$userData19 = child.userData) === null || _child$userData19 === void 0 ? void 0 : _child$userData19.objectType) === 'segment-connector') {
|
|
1732
1726
|
movedConnectors.push(child);
|
|
1733
1727
|
}
|
|
1734
1728
|
});
|
|
@@ -1798,8 +1792,8 @@ var TransformOperationsManager = /*#__PURE__*/function () {
|
|
|
1798
1792
|
// Get all connectors of the adjacent segment
|
|
1799
1793
|
var adjacentConnectors = [];
|
|
1800
1794
|
adjacentSegment.traverse(function (child) {
|
|
1801
|
-
var _child$
|
|
1802
|
-
if (((_child$
|
|
1795
|
+
var _child$userData20;
|
|
1796
|
+
if (((_child$userData20 = child.userData) === null || _child$userData20 === void 0 ? void 0 : _child$userData20.objectType) === 'segment-connector') {
|
|
1803
1797
|
adjacentConnectors.push(child);
|
|
1804
1798
|
}
|
|
1805
1799
|
});
|
|
@@ -1922,8 +1916,8 @@ var TransformOperationsManager = /*#__PURE__*/function () {
|
|
|
1922
1916
|
// Also update child connectors' positions if they exist
|
|
1923
1917
|
if (sceneDataComponent.children) {
|
|
1924
1918
|
sceneDataComponent.children.forEach(function (child) {
|
|
1925
|
-
var _child$
|
|
1926
|
-
if (((_child$
|
|
1919
|
+
var _child$userData21;
|
|
1920
|
+
if (((_child$userData21 = child.userData) === null || _child$userData21 === void 0 ? void 0 : _child$userData21.objectType) === 'connector') {
|
|
1927
1921
|
// Find the actual connector object in the scene
|
|
1928
1922
|
var connectorObj = component.children.find(function (c) {
|
|
1929
1923
|
var _c$userData;
|
|
@@ -1985,14 +1979,15 @@ var TransformOperationsManager = /*#__PURE__*/function () {
|
|
|
1985
1979
|
// Also update child connectors' positions if they exist (rotation moves them in world space)
|
|
1986
1980
|
if (sceneDataComponent.children) {
|
|
1987
1981
|
sceneDataComponent.children.forEach(function (child) {
|
|
1988
|
-
var _child$
|
|
1989
|
-
if (((_child$
|
|
1982
|
+
var _child$userData22;
|
|
1983
|
+
if (((_child$userData22 = child.userData) === null || _child$userData22 === void 0 ? void 0 : _child$userData22.objectType) === 'connector') {
|
|
1990
1984
|
// Find the actual connector object in the scene
|
|
1991
1985
|
var connectorObj = component.children.find(function (c) {
|
|
1992
1986
|
var _c$userData2;
|
|
1993
1987
|
return c.uuid === child.uuid || ((_c$userData2 = c.userData) === null || _c$userData2 === void 0 ? void 0 : _c$userData2.originalUuid) === child.uuid;
|
|
1994
1988
|
});
|
|
1995
1989
|
if (connectorObj) {
|
|
1990
|
+
var _connectorObj$userDat;
|
|
1996
1991
|
// Get world position of connector
|
|
1997
1992
|
var worldPos = new THREE.Vector3();
|
|
1998
1993
|
connectorObj.getWorldPosition(worldPos);
|
|
@@ -2003,6 +1998,12 @@ var TransformOperationsManager = /*#__PURE__*/function () {
|
|
|
2003
1998
|
}
|
|
2004
1999
|
child.userData.position = [cleanValue(worldPos.x), cleanValue(worldPos.y), cleanValue(worldPos.z)];
|
|
2005
2000
|
console.log(" \u21B3 Updated child connector ".concat(child.uuid, " position to [").concat(child.userData.position.join(', '), "]"));
|
|
2001
|
+
|
|
2002
|
+
// Update connector's direction in scene data from the Three.js object
|
|
2003
|
+
if ((_connectorObj$userDat = connectorObj.userData) !== null && _connectorObj$userDat !== void 0 && _connectorObj$userDat.direction && Array.isArray(connectorObj.userData.direction)) {
|
|
2004
|
+
child.userData.direction = _toConsumableArray(connectorObj.userData.direction);
|
|
2005
|
+
console.log(" \u21B3 Updated child connector ".concat(child.uuid, " direction to [").concat(child.userData.direction.join(', '), "]"));
|
|
2006
|
+
}
|
|
2006
2007
|
}
|
|
2007
2008
|
}
|
|
2008
2009
|
});
|
|
@@ -2315,8 +2316,8 @@ var TransformOperationsManager = /*#__PURE__*/function () {
|
|
|
2315
2316
|
// Check if either external connector belongs to the active segment
|
|
2316
2317
|
var activeSegmentConnectors = [];
|
|
2317
2318
|
activeSegment.traverse(function (child) {
|
|
2318
|
-
var _child$
|
|
2319
|
-
if (((_child$
|
|
2319
|
+
var _child$userData23;
|
|
2320
|
+
if (((_child$userData23 = child.userData) === null || _child$userData23 === void 0 ? void 0 : _child$userData23.objectType) === 'segment-connector') {
|
|
2320
2321
|
activeSegmentConnectors.push(child.uuid);
|
|
2321
2322
|
}
|
|
2322
2323
|
});
|
|
@@ -2364,8 +2365,8 @@ var TransformOperationsManager = /*#__PURE__*/function () {
|
|
|
2364
2365
|
// Get all connectors of the active segment
|
|
2365
2366
|
var activeConnectors = [];
|
|
2366
2367
|
activeSegment.traverse(function (child) {
|
|
2367
|
-
var _child$
|
|
2368
|
-
if (((_child$
|
|
2368
|
+
var _child$userData24;
|
|
2369
|
+
if (((_child$userData24 = child.userData) === null || _child$userData24 === void 0 ? void 0 : _child$userData24.objectType) === 'segment-connector') {
|
|
2369
2370
|
activeConnectors.push(child);
|
|
2370
2371
|
}
|
|
2371
2372
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createClass as _createClass, objectSpread2 as _objectSpread2, toConsumableArray as _toConsumableArray, classCallCheck as _classCallCheck, asyncToGenerator as _asyncToGenerator, regenerator as _regenerator, createForOfIteratorHelper as _createForOfIteratorHelper
|
|
1
|
+
import { createClass as _createClass, objectSpread2 as _objectSpread2, toConsumableArray as _toConsumableArray, typeof as _typeof, classCallCheck as _classCallCheck, asyncToGenerator as _asyncToGenerator, regenerator as _regenerator, createForOfIteratorHelper as _createForOfIteratorHelper } from '../../../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
2
|
import * as THREE from 'three';
|
|
3
3
|
import { attachIODevicesToComponent } from '../../utils/ioDeviceUtils.js';
|
|
4
4
|
import modelPreloader from '../../rendering/modelPreloader.js';
|
|
@@ -147,15 +147,23 @@ var ModelManager = /*#__PURE__*/function () {
|
|
|
147
147
|
if (child.userData) {
|
|
148
148
|
clonedConnector.userData = _objectSpread2({}, child.userData);
|
|
149
149
|
|
|
150
|
-
// Deep copy critical data
|
|
150
|
+
// Deep copy critical data - handle both array [x,y,z] and object {x,y,z} formats
|
|
151
151
|
if (child.userData.worldBoundingBox) {
|
|
152
|
+
var wbb = child.userData.worldBoundingBox;
|
|
152
153
|
clonedConnector.userData.worldBoundingBox = {
|
|
153
|
-
min: _toConsumableArray(
|
|
154
|
-
max: _toConsumableArray(
|
|
154
|
+
min: Array.isArray(wbb.min) ? _toConsumableArray(wbb.min) : _objectSpread2({}, wbb.min),
|
|
155
|
+
max: Array.isArray(wbb.max) ? _toConsumableArray(wbb.max) : _objectSpread2({}, wbb.max)
|
|
155
156
|
};
|
|
156
157
|
}
|
|
157
158
|
if (child.userData.direction) {
|
|
158
|
-
|
|
159
|
+
// Handle both array [x,y,z] and object {x,y,z} formats
|
|
160
|
+
if (Array.isArray(child.userData.direction)) {
|
|
161
|
+
clonedConnector.userData.direction = _toConsumableArray(child.userData.direction);
|
|
162
|
+
} else if (_typeof(child.userData.direction) === 'object') {
|
|
163
|
+
clonedConnector.userData.direction = _objectSpread2({}, child.userData.direction);
|
|
164
|
+
} else {
|
|
165
|
+
clonedConnector.userData.direction = child.userData.direction;
|
|
166
|
+
}
|
|
159
167
|
}
|
|
160
168
|
|
|
161
169
|
// Set originalUuid to match the actual uuid (maintains consistency)
|