@2112-lab/central-plant 0.1.49 → 0.1.51

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.
@@ -3619,58 +3619,74 @@ var TransformControlsManager = /*#__PURE__*/function () {
3619
3619
  };
3620
3620
 
3621
3621
  // Transform end event
3622
- this.eventHandlers.transformEnd = function () {
3623
- _this2.transformState.isTransforming = false;
3624
-
3625
- // Re-enable orbit controls
3626
- if (_this2.orbitControls) {
3627
- _this2.orbitControls.enabled = true;
3628
- }
3622
+ this.eventHandlers.transformEnd = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
3623
+ var hasComponents, _this2$selectedObject, sceneCompleteEvent;
3624
+ return _regenerator().w(function (_context) {
3625
+ while (1) switch (_context.n) {
3626
+ case 0:
3627
+ _this2.transformState.isTransforming = false;
3629
3628
 
3630
- // Apply multi-selection transforms (works for single or multiple objects)
3631
- // This is async but we don't await it to avoid blocking the event handler
3632
- if (_this2.selectedObjects.length > 0 && _this2.multiSelectionGroup) {
3633
- _this2.applyMultiSelectionTransform().catch(function (error) {
3634
- console.error('❌ Error in applyMultiSelectionTransform:', error);
3635
- });
3636
- }
3629
+ // Re-enable orbit controls
3630
+ if (_this2.orbitControls) {
3631
+ _this2.orbitControls.enabled = true;
3632
+ }
3637
3633
 
3638
- // Update paths after translation is complete
3639
- // Only if we translated components (not segments/gateways - they handle paths internally)
3640
- if (_this2.currentMode === 'translate' && _this2.sceneViewer && typeof _this2.sceneViewer.updatePaths === 'function') {
3641
- // Check if any of the selected objects are components (not segments or gateways)
3642
- var hasComponents = _this2.selectedObjects.some(function (obj) {
3643
- return !isSegment(obj) && !isGateway(obj);
3644
- });
3645
- if (hasComponents) {
3646
- console.log('🔄 Updating paths after component translation...');
3647
- try {
3648
- _this2.sceneViewer.updatePaths();
3649
- console.log('✅ Paths updated successfully after translation');
3650
- } catch (error) {
3651
- console.error('❌ Error updating paths after translation:', error);
3652
- }
3653
- } else {
3654
- console.log('â„šī¸ Skipping updatePaths - segments/gateways handle their own path updates');
3634
+ // Apply multi-selection transforms (works for single or multiple objects)
3635
+ // IMPORTANT: We await this to prevent race conditions with updatePaths()
3636
+ if (!(_this2.selectedObjects.length > 0 && _this2.multiSelectionGroup)) {
3637
+ _context.n = 2;
3638
+ break;
3639
+ }
3640
+ _context.n = 1;
3641
+ return _this2.applyMultiSelectionTransform().catch(function (error) {
3642
+ console.error('❌ Error in applyMultiSelectionTransform:', error);
3643
+ });
3644
+ case 1:
3645
+ // applyMultiSelectionTransform() already calls updatePaths() once at the end
3646
+ // so we skip the additional updatePaths() call below
3647
+ console.log('✅ Multi-selection transform complete (updatePaths already called)');
3648
+ _context.n = 3;
3649
+ break;
3650
+ case 2:
3651
+ if (_this2.currentMode === 'translate' && _this2.sceneViewer && typeof _this2.sceneViewer.updatePaths === 'function') {
3652
+ // Update paths after translation is complete
3653
+ // Only if we translated components (not segments/gateways - they handle paths internally)
3654
+ // This branch only executes when NOT in multi-selection mode
3655
+ hasComponents = _this2.selectedObjects.some(function (obj) {
3656
+ return !isSegment(obj) && !isGateway(obj);
3657
+ });
3658
+ if (hasComponents) {
3659
+ console.log('🔄 Updating paths after component translation...');
3660
+ try {
3661
+ _this2.sceneViewer.updatePaths();
3662
+ console.log('✅ Paths updated successfully after translation');
3663
+ } catch (error) {
3664
+ console.error('❌ Error updating paths after translation:', error);
3665
+ }
3666
+ } else {
3667
+ console.log('â„šī¸ Skipping updatePaths - segments/gateways handle their own path updates');
3668
+ }
3669
+ }
3670
+ case 3:
3671
+ // Dispatch custom scene update event after transform completes
3672
+ if (typeof window !== 'undefined') {
3673
+ console.log('📡 Dispatching sceneUpdateComplete event after transform');
3674
+ sceneCompleteEvent = new CustomEvent('sceneUpdateComplete', {
3675
+ detail: {
3676
+ timestamp: Date.now(),
3677
+ transformType: _this2.currentMode,
3678
+ objectName: ((_this2$selectedObject = _this2.selectedObjects[0]) === null || _this2$selectedObject === void 0 ? void 0 : _this2$selectedObject.name) || 'unknown',
3679
+ objectCount: _this2.selectedObjects.length
3680
+ }
3681
+ });
3682
+ window.dispatchEvent(sceneCompleteEvent);
3683
+ }
3684
+ console.log("\u2705 Transform completed: ".concat(_this2.currentMode, " mode"));
3685
+ case 4:
3686
+ return _context.a(2);
3655
3687
  }
3656
- }
3657
-
3658
- // Dispatch custom scene update event after transform completes
3659
- if (typeof window !== 'undefined') {
3660
- var _this2$selectedObject;
3661
- console.log('📡 Dispatching sceneUpdateComplete event after transform');
3662
- var sceneCompleteEvent = new CustomEvent('sceneUpdateComplete', {
3663
- detail: {
3664
- timestamp: Date.now(),
3665
- transformType: _this2.currentMode,
3666
- objectName: ((_this2$selectedObject = _this2.selectedObjects[0]) === null || _this2$selectedObject === void 0 ? void 0 : _this2$selectedObject.name) || 'unknown',
3667
- objectCount: _this2.selectedObjects.length
3668
- }
3669
- });
3670
- window.dispatchEvent(sceneCompleteEvent);
3671
- }
3672
- console.log("\u2705 Transform completed: ".concat(_this2.currentMode, " mode"));
3673
- };
3688
+ }, _callee);
3689
+ }));
3674
3690
  // Transform changing event
3675
3691
  this.eventHandlers.transforming = function () {
3676
3692
  // Apply real-time visual transformation to objects during drag
@@ -3902,7 +3918,7 @@ var TransformControlsManager = /*#__PURE__*/function () {
3902
3918
  }, {
3903
3919
  key: "_isValidSelectableObject",
3904
3920
  value: function _isValidSelectableObject(object) {
3905
- var _object$userData;
3921
+ var _object$userData, _object$userData2;
3906
3922
  // Safety check: ensure object is still valid and in the scene
3907
3923
  if (!object || !object.parent) {
3908
3924
  console.warn('âš ī¸ Selected object is no longer valid or in scene');
@@ -3920,6 +3936,12 @@ var TransformControlsManager = /*#__PURE__*/function () {
3920
3936
  console.warn('âš ī¸ Object is marked as non-selectable (stub segment)');
3921
3937
  return false;
3922
3938
  }
3939
+
3940
+ // Check if object is marked as immutable (computed segments/elbows from pathfinder)
3941
+ if (((_object$userData2 = object.userData) === null || _object$userData2 === void 0 ? void 0 : _object$userData2.immutable) === true) {
3942
+ console.warn('âš ī¸ Object is immutable (computed from pathfinder)');
3943
+ return false;
3944
+ }
3923
3945
  return true;
3924
3946
  }
3925
3947
 
@@ -3959,7 +3981,7 @@ var TransformControlsManager = /*#__PURE__*/function () {
3959
3981
  }, {
3960
3982
  key: "isSelectableObject",
3961
3983
  value: function isSelectableObject(object) {
3962
- var _object$userData2, _object$userData3, _object$userData4, _object$userData5, _object$userData6, _object$userData7, _object$userData8;
3984
+ var _object$userData3, _object$userData4, _object$userData5, _object$userData6, _object$userData7, _object$userData8, _object$userData9, _object$userData0;
3963
3985
  // Basic safety checks
3964
3986
  if (!object || !object.isObject3D) {
3965
3987
  return false;
@@ -3971,25 +3993,30 @@ var TransformControlsManager = /*#__PURE__*/function () {
3971
3993
  }
3972
3994
 
3973
3995
  // Skip helpers and special objects
3974
- var isHelper = object.isHelper || ((_object$userData2 = object.userData) === null || _object$userData2 === void 0 ? void 0 : _object$userData2.isHelper) || ((_object$userData3 = object.userData) === null || _object$userData3 === void 0 ? void 0 : _object$userData3.isBoundingBox);
3975
- var isBaseGround = (_object$userData4 = object.userData) === null || _object$userData4 === void 0 ? void 0 : _object$userData4.isBaseGround;
3976
- var isBrickWall = (_object$userData5 = object.userData) === null || _object$userData5 === void 0 ? void 0 : _object$userData5.isBrickWall;
3996
+ var isHelper = object.isHelper || ((_object$userData3 = object.userData) === null || _object$userData3 === void 0 ? void 0 : _object$userData3.isHelper) || ((_object$userData4 = object.userData) === null || _object$userData4 === void 0 ? void 0 : _object$userData4.isBoundingBox);
3997
+ var isBaseGround = (_object$userData5 = object.userData) === null || _object$userData5 === void 0 ? void 0 : _object$userData5.isBaseGround;
3998
+ var isBrickWall = (_object$userData6 = object.userData) === null || _object$userData6 === void 0 ? void 0 : _object$userData6.isBrickWall;
3977
3999
  if (isHelper || isBaseGround || isBrickWall || !object.visible) {
3978
4000
  return false;
3979
4001
  }
3980
4002
 
3981
4003
  // Skip segment connectors - they should not be selectable for transformation
3982
- if (((_object$userData6 = object.userData) === null || _object$userData6 === void 0 ? void 0 : _object$userData6.objectType) === 'segment-connector') {
4004
+ if (((_object$userData7 = object.userData) === null || _object$userData7 === void 0 ? void 0 : _object$userData7.objectType) === 'segment-connector') {
3983
4005
  return false;
3984
4006
  }
3985
4007
 
3986
4008
  // Check if object has explicit selectable flag set to false
3987
- if (((_object$userData7 = object.userData) === null || _object$userData7 === void 0 ? void 0 : _object$userData7.selectable) === false) {
4009
+ if (((_object$userData8 = object.userData) === null || _object$userData8 === void 0 ? void 0 : _object$userData8.selectable) === false) {
4010
+ return false;
4011
+ }
4012
+
4013
+ // Check if object is marked as immutable (computed segments/elbows from pathfinder)
4014
+ if (((_object$userData9 = object.userData) === null || _object$userData9 === void 0 ? void 0 : _object$userData9.immutable) === true) {
3988
4015
  return false;
3989
4016
  }
3990
4017
 
3991
4018
  // Allow components, gateways, and segments to be selected
3992
- var objectType = (_object$userData8 = object.userData) === null || _object$userData8 === void 0 ? void 0 : _object$userData8.objectType;
4019
+ var objectType = (_object$userData0 = object.userData) === null || _object$userData0 === void 0 ? void 0 : _object$userData0.objectType;
3993
4020
  return objectType === 'component' || objectType === 'gateway' || isSegment(object);
3994
4021
  }
3995
4022
  /**
@@ -4664,7 +4691,7 @@ var TransformControlsManager = /*#__PURE__*/function () {
4664
4691
 
4665
4692
  // Traverse scene to find selectable objects
4666
4693
  this.scene.traverse(function (object) {
4667
- var _object$userData9, _object$userData0;
4694
+ var _object$userData1, _object$userData10;
4668
4695
  // Skip invalid objects and helpers early
4669
4696
  if (!object || !object.isObject3D) {
4670
4697
  return;
@@ -4676,7 +4703,7 @@ var TransformControlsManager = /*#__PURE__*/function () {
4676
4703
  }
4677
4704
 
4678
4705
  // Skip other helpers and special objects
4679
- if (object.isHelper || (_object$userData9 = object.userData) !== null && _object$userData9 !== void 0 && _object$userData9.isHelper || (_object$userData0 = object.userData) !== null && _object$userData0 !== void 0 && _object$userData0.isBoundingBox) {
4706
+ if (object.isHelper || (_object$userData1 = object.userData) !== null && _object$userData1 !== void 0 && _object$userData1.isHelper || (_object$userData10 = object.userData) !== null && _object$userData10 !== void 0 && _object$userData10.isBoundingBox) {
4680
4707
  return;
4681
4708
  }
4682
4709
  try {
@@ -4848,17 +4875,17 @@ var TransformControlsManager = /*#__PURE__*/function () {
4848
4875
  }, {
4849
4876
  key: "applyMultiSelectionTransform",
4850
4877
  value: (function () {
4851
- var _applyMultiSelectionTransform = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
4878
+ var _applyMultiSelectionTransform = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
4852
4879
  var _this9 = this;
4853
- var groupPosition, originalCentroid, positionDelta, deltaX, deltaY, deltaZ, threshold, _this$sceneViewer, segments, gateways, components, transformOpsManager, THROTTLE_DELAY, SEGMENT_DELAY, _throttleDelay, _loop, i, _THROTTLE_DELAY, _SEGMENT_DELAY, _throttleDelay2, _loop2, _i, GATEWAY_THROTTLE, GATEWAY_DELAY, COMPONENT_THROTTLE, COMPONENT_DELAY, throttleDelay, _i2, _gateway$userData, gateway, gatewayId, _i3, _component$userData, component, componentId;
4854
- return _regenerator().w(function (_context3) {
4855
- while (1) switch (_context3.n) {
4880
+ var groupPosition, originalCentroid, positionDelta, deltaX, deltaY, deltaZ, threshold, _this$sceneViewer, _this$sceneViewer2, _this$sceneViewer3, _this$sceneViewer4, _this$sceneViewer5, segments, gateways, components, transformOpsManager, THROTTLE_DELAY, SEGMENT_DELAY, _throttleDelay, _loop, i, _THROTTLE_DELAY, _SEGMENT_DELAY, _throttleDelay2, _loop2, _i, GATEWAY_THROTTLE, GATEWAY_DELAY, COMPONENT_THROTTLE, COMPONENT_DELAY, throttleDelay, _i2, _gateway$userData, gateway, gatewayId, _i3, _component$userData, component, componentId;
4881
+ return _regenerator().w(function (_context4) {
4882
+ while (1) switch (_context4.n) {
4856
4883
  case 0:
4857
4884
  if (!(!this.multiSelectionGroup || this.selectedObjects.length === 0)) {
4858
- _context3.n = 1;
4885
+ _context4.n = 1;
4859
4886
  break;
4860
4887
  }
4861
- return _context3.a(2);
4888
+ return _context4.a(2);
4862
4889
  case 1:
4863
4890
  console.log("\uD83D\uDD27 Applying multi-selection transform to ".concat(this.selectedObjects.length, " objects"));
4864
4891
 
@@ -4887,7 +4914,7 @@ var TransformControlsManager = /*#__PURE__*/function () {
4887
4914
  // Only process if there's a meaningful translation
4888
4915
  threshold = 0.001;
4889
4916
  if (!(this.currentMode === 'translate' && positionDelta.length() > threshold)) {
4890
- _context3.n = 21;
4917
+ _context4.n = 21;
4891
4918
  break;
4892
4919
  }
4893
4920
  // FIRST: Reset all objects to their original positions
@@ -4910,14 +4937,23 @@ var TransformControlsManager = /*#__PURE__*/function () {
4910
4937
  });
4911
4938
  components = this.selectedObjects.filter(function (obj) {
4912
4939
  return !isSegment(obj) && !isGateway(obj);
4913
- }); // BATCH SEGMENT TRANSLATIONS: Call translateSegment with skipPathUpdate=true
4940
+ }); // Debug: Check availability of managers
4941
+ console.log('🔍 Debug - sceneViewer available:', !!this.sceneViewer);
4942
+ console.log('🔍 Debug - sceneViewer.managers available:', !!((_this$sceneViewer = this.sceneViewer) !== null && _this$sceneViewer !== void 0 && _this$sceneViewer.managers));
4943
+ console.log('🔍 Debug - Available managers:', (_this$sceneViewer2 = this.sceneViewer) !== null && _this$sceneViewer2 !== void 0 && _this$sceneViewer2.managers ? Object.keys(this.sceneViewer.managers) : 'none');
4944
+ console.log('🔍 Debug - transformOperationsManager (direct):', !!((_this$sceneViewer3 = this.sceneViewer) !== null && _this$sceneViewer3 !== void 0 && _this$sceneViewer3.transformOperationsManager));
4945
+ console.log('🔍 Debug - transformOperations (managers.transformOperations):', !!((_this$sceneViewer4 = this.sceneViewer) !== null && _this$sceneViewer4 !== void 0 && (_this$sceneViewer4 = _this$sceneViewer4.managers) !== null && _this$sceneViewer4 !== void 0 && _this$sceneViewer4.transformOperations));
4946
+ console.log('🔍 Debug - Segments to translate:', segments.length);
4947
+
4948
+ // BATCH SEGMENT TRANSLATIONS: Call translateSegment with skipPathUpdate=true
4914
4949
  // Process segments SEQUENTIALLY with throttling for maximum stability
4915
- if (!(segments.length > 0 && (_this$sceneViewer = this.sceneViewer) !== null && _this$sceneViewer !== void 0 && (_this$sceneViewer = _this$sceneViewer.managers) !== null && _this$sceneViewer !== void 0 && _this$sceneViewer.transformOperations)) {
4916
- _context3.n = 5;
4950
+ // Access transformOperationsManager directly from sceneViewer (it's attached in attachToComponent)
4951
+ if (!(segments.length > 0 && (_this$sceneViewer5 = this.sceneViewer) !== null && _this$sceneViewer5 !== void 0 && _this$sceneViewer5.transformOperationsManager)) {
4952
+ _context4.n = 5;
4917
4953
  break;
4918
4954
  }
4919
4955
  console.log("\uD83D\uDD27 Batch translating ".concat(segments.length, " segments (sequential with throttling)..."));
4920
- transformOpsManager = this.sceneViewer.managers.transformOperations; // Throttle delay in milliseconds (adjust as needed for stability)
4956
+ transformOpsManager = this.sceneViewer.transformOperationsManager; // Throttle delay in milliseconds (adjust as needed for stability)
4921
4957
  THROTTLE_DELAY = 10; // 10ms between axis operations
4922
4958
  SEGMENT_DELAY = 20; // 20ms between segments
4923
4959
  // Helper function for throttled delay
@@ -4928,13 +4964,13 @@ var TransformControlsManager = /*#__PURE__*/function () {
4928
4964
  }; // Process each segment sequentially with throttling for stability
4929
4965
  _loop = /*#__PURE__*/_regenerator().m(function _loop(i) {
4930
4966
  var segment, _segment$userData, _segment$userData2, segmentId, success, newSegmentId, _segment$userData3, _segment$userData4, _segmentId, _success, _newSegmentId, _segment$userData5, _segment$userData6, _segmentId2, _success2, _newSegmentId2, selectedIndex;
4931
- return _regenerator().w(function (_context) {
4932
- while (1) switch (_context.n) {
4967
+ return _regenerator().w(function (_context2) {
4968
+ while (1) switch (_context2.n) {
4933
4969
  case 0:
4934
4970
  segment = segments[i]; // Call translateSegment API with skipPathUpdate=true to defer path updates
4935
4971
  // IMPORTANT: Refresh segment reference after each axis to handle UUID changes from manualization
4936
4972
  if (!(Math.abs(deltaX) > threshold)) {
4937
- _context.n = 1;
4973
+ _context2.n = 1;
4938
4974
  break;
4939
4975
  }
4940
4976
  segmentId = segment.uuid || ((_segment$userData = segment.userData) === null || _segment$userData === void 0 ? void 0 : _segment$userData.originalUuid);
@@ -4944,7 +4980,7 @@ var TransformControlsManager = /*#__PURE__*/function () {
4944
4980
  }
4945
4981
  // Refresh segment reference by searching for the new UUID or by segmentIndex
4946
4982
  // After manualization, UUID changes from SEGMENT-X to Segment-X
4947
- newSegmentId = (_segment$userData2 = segment.userData) !== null && _segment$userData2 !== void 0 && _segment$userData2.segmentIndex ? "Segment-".concat(segment.userData.segmentIndex) : segmentId;
4983
+ newSegmentId = (_segment$userData2 = segment.userData) !== null && _segment$userData2 !== void 0 && _segment$userData2.segmentIndex ? "SEGMENT-".concat(segment.userData.segmentIndex) : segmentId;
4948
4984
  segment = _this9.sceneViewer.scene.getObjectByProperty('uuid', newSegmentId) || segment;
4949
4985
 
4950
4986
  // Update matrix to ensure geometry is current for next operation
@@ -4952,11 +4988,11 @@ var TransformControlsManager = /*#__PURE__*/function () {
4952
4988
  segment.updateMatrix();
4953
4989
  segment.updateMatrixWorld(true);
4954
4990
  }
4955
- _context.n = 1;
4991
+ _context2.n = 1;
4956
4992
  return _throttleDelay(THROTTLE_DELAY);
4957
4993
  case 1:
4958
4994
  if (!(Math.abs(deltaY) > threshold)) {
4959
- _context.n = 2;
4995
+ _context2.n = 2;
4960
4996
  break;
4961
4997
  }
4962
4998
  _segmentId = segment.uuid || ((_segment$userData3 = segment.userData) === null || _segment$userData3 === void 0 ? void 0 : _segment$userData3.originalUuid);
@@ -4965,7 +5001,7 @@ var TransformControlsManager = /*#__PURE__*/function () {
4965
5001
  console.warn("\u26A0\uFE0F Failed to translate segment ".concat(_segmentId, " on Y axis"));
4966
5002
  }
4967
5003
  // Refresh segment reference by searching for the new UUID
4968
- _newSegmentId = (_segment$userData4 = segment.userData) !== null && _segment$userData4 !== void 0 && _segment$userData4.segmentIndex ? "Segment-".concat(segment.userData.segmentIndex) : _segmentId;
5004
+ _newSegmentId = (_segment$userData4 = segment.userData) !== null && _segment$userData4 !== void 0 && _segment$userData4.segmentIndex ? "SEGMENT-".concat(segment.userData.segmentIndex) : _segmentId;
4969
5005
  segment = _this9.sceneViewer.scene.getObjectByProperty('uuid', _newSegmentId) || segment;
4970
5006
 
4971
5007
  // Update matrix to ensure geometry is current for next operation
@@ -4973,11 +5009,11 @@ var TransformControlsManager = /*#__PURE__*/function () {
4973
5009
  segment.updateMatrix();
4974
5010
  segment.updateMatrixWorld(true);
4975
5011
  }
4976
- _context.n = 2;
5012
+ _context2.n = 2;
4977
5013
  return _throttleDelay(THROTTLE_DELAY);
4978
5014
  case 2:
4979
5015
  if (!(Math.abs(deltaZ) > threshold)) {
4980
- _context.n = 3;
5016
+ _context2.n = 3;
4981
5017
  break;
4982
5018
  }
4983
5019
  _segmentId2 = segment.uuid || ((_segment$userData5 = segment.userData) === null || _segment$userData5 === void 0 ? void 0 : _segment$userData5.originalUuid);
@@ -4986,7 +5022,7 @@ var TransformControlsManager = /*#__PURE__*/function () {
4986
5022
  console.warn("\u26A0\uFE0F Failed to translate segment ".concat(_segmentId2, " on Z axis"));
4987
5023
  }
4988
5024
  // Refresh segment reference by searching for the new UUID
4989
- _newSegmentId2 = (_segment$userData6 = segment.userData) !== null && _segment$userData6 !== void 0 && _segment$userData6.segmentIndex ? "Segment-".concat(segment.userData.segmentIndex) : _segmentId2;
5025
+ _newSegmentId2 = (_segment$userData6 = segment.userData) !== null && _segment$userData6 !== void 0 && _segment$userData6.segmentIndex ? "SEGMENT-".concat(segment.userData.segmentIndex) : _segmentId2;
4990
5026
  segment = _this9.sceneViewer.scene.getObjectByProperty('uuid', _newSegmentId2) || segment;
4991
5027
 
4992
5028
  // Update matrix to ensure geometry is current for next operation
@@ -4994,7 +5030,7 @@ var TransformControlsManager = /*#__PURE__*/function () {
4994
5030
  segment.updateMatrix();
4995
5031
  segment.updateMatrixWorld(true);
4996
5032
  }
4997
- _context.n = 3;
5033
+ _context2.n = 3;
4998
5034
  return _throttleDelay(THROTTLE_DELAY);
4999
5035
  case 3:
5000
5036
  // Update the segment in the selectedObjects array with the refreshed reference
@@ -5014,34 +5050,38 @@ var TransformControlsManager = /*#__PURE__*/function () {
5014
5050
  _this9.selectedObjects[selectedIndex] = segment;
5015
5051
  console.log("\u2705 Updated selectedObjects[".concat(selectedIndex, "] with refreshed segment reference"));
5016
5052
  }
5017
- console.log("\uD83D\uDCE6 Segment ".concat(segment.name, " translated (").concat(i + 1, "/").concat(segments.length, "):"), {
5018
- deltaX: deltaX,
5019
- deltaY: deltaY,
5020
- deltaZ: deltaZ
5021
- });
5053
+ if (segment) {
5054
+ console.log("\uD83D\uDCE6 Segment ".concat(segment.name, " translated (").concat(i + 1, "/").concat(segments.length, "):"), {
5055
+ deltaX: deltaX,
5056
+ deltaY: deltaY,
5057
+ deltaZ: deltaZ
5058
+ });
5059
+ } else {
5060
+ console.warn("\u26A0\uFE0F Segment reference became null after translation (".concat(i + 1, "/").concat(segments.length, ")"));
5061
+ }
5022
5062
 
5023
5063
  // Delay between segments to ensure all updates propagate
5024
5064
  if (!(i < segments.length - 1)) {
5025
- _context.n = 4;
5065
+ _context2.n = 4;
5026
5066
  break;
5027
5067
  }
5028
- _context.n = 4;
5068
+ _context2.n = 4;
5029
5069
  return _throttleDelay(SEGMENT_DELAY);
5030
5070
  case 4:
5031
- return _context.a(2);
5071
+ return _context2.a(2);
5032
5072
  }
5033
5073
  }, _loop);
5034
5074
  });
5035
5075
  i = 0;
5036
5076
  case 2:
5037
5077
  if (!(i < segments.length)) {
5038
- _context3.n = 4;
5078
+ _context4.n = 4;
5039
5079
  break;
5040
5080
  }
5041
- return _context3.d(_regeneratorValues(_loop(i)), 3);
5081
+ return _context4.d(_regeneratorValues(_loop(i)), 3);
5042
5082
  case 3:
5043
5083
  i++;
5044
- _context3.n = 2;
5084
+ _context4.n = 2;
5045
5085
  break;
5046
5086
  case 4:
5047
5087
  // Only call updatePaths ONCE after all segments are translated
@@ -5050,11 +5090,11 @@ var TransformControlsManager = /*#__PURE__*/function () {
5050
5090
  this.sceneViewer.updatePaths();
5051
5091
  console.log('✅ Paths regenerated successfully for all segments');
5052
5092
  }
5053
- _context3.n = 8;
5093
+ _context4.n = 8;
5054
5094
  break;
5055
5095
  case 5:
5056
5096
  if (!(segments.length > 0)) {
5057
- _context3.n = 8;
5097
+ _context4.n = 8;
5058
5098
  break;
5059
5099
  }
5060
5100
  // Fallback to individual API calls if manager not available
@@ -5071,18 +5111,18 @@ var TransformControlsManager = /*#__PURE__*/function () {
5071
5111
  };
5072
5112
  _loop2 = /*#__PURE__*/_regenerator().m(function _loop2(_i) {
5073
5113
  var segment, _segment$userData7, _segment$userData8, segmentId, newSegmentId, _segment$userData9, _segment$userData0, _segmentId3, _newSegmentId3, _segment$userData1, _segment$userData10, _segmentId4, _newSegmentId4, selectedIndex;
5074
- return _regenerator().w(function (_context2) {
5075
- while (1) switch (_context2.n) {
5114
+ return _regenerator().w(function (_context3) {
5115
+ while (1) switch (_context3.n) {
5076
5116
  case 0:
5077
5117
  segment = segments[_i];
5078
5118
  if (!(Math.abs(deltaX) > threshold)) {
5079
- _context2.n = 1;
5119
+ _context3.n = 1;
5080
5120
  break;
5081
5121
  }
5082
5122
  segmentId = segment.uuid || ((_segment$userData7 = segment.userData) === null || _segment$userData7 === void 0 ? void 0 : _segment$userData7.originalUuid);
5083
5123
  _this9.centralPlant.translateSegment(segmentId, 'x', deltaX);
5084
5124
  // Refresh segment reference by searching for the new UUID after manualization
5085
- newSegmentId = (_segment$userData8 = segment.userData) !== null && _segment$userData8 !== void 0 && _segment$userData8.segmentIndex ? "Segment-".concat(segment.userData.segmentIndex) : segmentId;
5125
+ newSegmentId = (_segment$userData8 = segment.userData) !== null && _segment$userData8 !== void 0 && _segment$userData8.segmentIndex ? "SEGMENT-".concat(segment.userData.segmentIndex) : segmentId;
5086
5126
  segment = _this9.sceneViewer.scene.getObjectByProperty('uuid', newSegmentId) || segment;
5087
5127
 
5088
5128
  // Update matrix to ensure geometry is current for next operation
@@ -5090,17 +5130,17 @@ var TransformControlsManager = /*#__PURE__*/function () {
5090
5130
  segment.updateMatrix();
5091
5131
  segment.updateMatrixWorld(true);
5092
5132
  }
5093
- _context2.n = 1;
5133
+ _context3.n = 1;
5094
5134
  return _throttleDelay2(_THROTTLE_DELAY);
5095
5135
  case 1:
5096
5136
  if (!(Math.abs(deltaY) > threshold)) {
5097
- _context2.n = 2;
5137
+ _context3.n = 2;
5098
5138
  break;
5099
5139
  }
5100
5140
  _segmentId3 = segment.uuid || ((_segment$userData9 = segment.userData) === null || _segment$userData9 === void 0 ? void 0 : _segment$userData9.originalUuid);
5101
5141
  _this9.centralPlant.translateSegment(_segmentId3, 'y', deltaY);
5102
5142
  // Refresh segment reference by searching for the new UUID after manualization
5103
- _newSegmentId3 = (_segment$userData0 = segment.userData) !== null && _segment$userData0 !== void 0 && _segment$userData0.segmentIndex ? "Segment-".concat(segment.userData.segmentIndex) : _segmentId3;
5143
+ _newSegmentId3 = (_segment$userData0 = segment.userData) !== null && _segment$userData0 !== void 0 && _segment$userData0.segmentIndex ? "SEGMENT-".concat(segment.userData.segmentIndex) : _segmentId3;
5104
5144
  segment = _this9.sceneViewer.scene.getObjectByProperty('uuid', _newSegmentId3) || segment;
5105
5145
 
5106
5146
  // Update matrix to ensure geometry is current for next operation
@@ -5108,17 +5148,17 @@ var TransformControlsManager = /*#__PURE__*/function () {
5108
5148
  segment.updateMatrix();
5109
5149
  segment.updateMatrixWorld(true);
5110
5150
  }
5111
- _context2.n = 2;
5151
+ _context3.n = 2;
5112
5152
  return _throttleDelay2(_THROTTLE_DELAY);
5113
5153
  case 2:
5114
5154
  if (!(Math.abs(deltaZ) > threshold)) {
5115
- _context2.n = 3;
5155
+ _context3.n = 3;
5116
5156
  break;
5117
5157
  }
5118
5158
  _segmentId4 = segment.uuid || ((_segment$userData1 = segment.userData) === null || _segment$userData1 === void 0 ? void 0 : _segment$userData1.originalUuid);
5119
5159
  _this9.centralPlant.translateSegment(_segmentId4, 'z', deltaZ);
5120
5160
  // Refresh segment reference by searching for the new UUID after manualization
5121
- _newSegmentId4 = (_segment$userData10 = segment.userData) !== null && _segment$userData10 !== void 0 && _segment$userData10.segmentIndex ? "Segment-".concat(segment.userData.segmentIndex) : _segmentId4;
5161
+ _newSegmentId4 = (_segment$userData10 = segment.userData) !== null && _segment$userData10 !== void 0 && _segment$userData10.segmentIndex ? "SEGMENT-".concat(segment.userData.segmentIndex) : _segmentId4;
5122
5162
  segment = _this9.sceneViewer.scene.getObjectByProperty('uuid', _newSegmentId4) || segment;
5123
5163
 
5124
5164
  // Update matrix to ensure geometry is current for next operation
@@ -5126,7 +5166,7 @@ var TransformControlsManager = /*#__PURE__*/function () {
5126
5166
  segment.updateMatrix();
5127
5167
  segment.updateMatrixWorld(true);
5128
5168
  }
5129
- _context2.n = 3;
5169
+ _context3.n = 3;
5130
5170
  return _throttleDelay2(_THROTTLE_DELAY);
5131
5171
  case 3:
5132
5172
  // Update the segment in the selectedObjects array with the refreshed reference
@@ -5145,34 +5185,38 @@ var TransformControlsManager = /*#__PURE__*/function () {
5145
5185
  _this9.selectedObjects[selectedIndex] = segment;
5146
5186
  console.log("\u2705 Updated selectedObjects[".concat(selectedIndex, "] with refreshed segment reference"));
5147
5187
  }
5148
- console.log("\uD83D\uDCE6 Segment ".concat(segment.name, " translated (").concat(_i + 1, "/").concat(segments.length, "):"), {
5149
- deltaX: deltaX,
5150
- deltaY: deltaY,
5151
- deltaZ: deltaZ
5152
- });
5188
+ if (segment) {
5189
+ console.log("\uD83D\uDCE6 Segment ".concat(segment.name, " translated (").concat(_i + 1, "/").concat(segments.length, "):"), {
5190
+ deltaX: deltaX,
5191
+ deltaY: deltaY,
5192
+ deltaZ: deltaZ
5193
+ });
5194
+ } else {
5195
+ console.warn("\u26A0\uFE0F Segment reference became null after translation (".concat(_i + 1, "/").concat(segments.length, ")"));
5196
+ }
5153
5197
 
5154
5198
  // Delay between segments
5155
5199
  if (!(_i < segments.length - 1)) {
5156
- _context2.n = 4;
5200
+ _context3.n = 4;
5157
5201
  break;
5158
5202
  }
5159
- _context2.n = 4;
5203
+ _context3.n = 4;
5160
5204
  return _throttleDelay2(_SEGMENT_DELAY);
5161
5205
  case 4:
5162
- return _context2.a(2);
5206
+ return _context3.a(2);
5163
5207
  }
5164
5208
  }, _loop2);
5165
5209
  });
5166
5210
  _i = 0;
5167
5211
  case 6:
5168
5212
  if (!(_i < segments.length)) {
5169
- _context3.n = 8;
5213
+ _context4.n = 8;
5170
5214
  break;
5171
5215
  }
5172
- return _context3.d(_regeneratorValues(_loop2(_i)), 7);
5216
+ return _context4.d(_regeneratorValues(_loop2(_i)), 7);
5173
5217
  case 7:
5174
5218
  _i++;
5175
- _context3.n = 6;
5219
+ _context4.n = 6;
5176
5220
  break;
5177
5221
  case 8:
5178
5222
  // Throttle delays for gateways and components
@@ -5188,33 +5232,33 @@ var TransformControlsManager = /*#__PURE__*/function () {
5188
5232
  _i2 = 0;
5189
5233
  case 9:
5190
5234
  if (!(_i2 < gateways.length)) {
5191
- _context3.n = 14;
5235
+ _context4.n = 14;
5192
5236
  break;
5193
5237
  }
5194
5238
  gateway = gateways[_i2];
5195
5239
  gatewayId = gateway.uuid || ((_gateway$userData = gateway.userData) === null || _gateway$userData === void 0 ? void 0 : _gateway$userData.originalUuid);
5196
5240
  if (!(Math.abs(deltaX) > threshold)) {
5197
- _context3.n = 10;
5241
+ _context4.n = 10;
5198
5242
  break;
5199
5243
  }
5200
5244
  this.centralPlant.translateGateway(gatewayId, 'x', deltaX);
5201
- _context3.n = 10;
5245
+ _context4.n = 10;
5202
5246
  return throttleDelay(GATEWAY_THROTTLE);
5203
5247
  case 10:
5204
5248
  if (!(Math.abs(deltaY) > threshold)) {
5205
- _context3.n = 11;
5249
+ _context4.n = 11;
5206
5250
  break;
5207
5251
  }
5208
5252
  this.centralPlant.translateGateway(gatewayId, 'y', deltaY);
5209
- _context3.n = 11;
5253
+ _context4.n = 11;
5210
5254
  return throttleDelay(GATEWAY_THROTTLE);
5211
5255
  case 11:
5212
5256
  if (!(Math.abs(deltaZ) > threshold)) {
5213
- _context3.n = 12;
5257
+ _context4.n = 12;
5214
5258
  break;
5215
5259
  }
5216
5260
  this.centralPlant.translateGateway(gatewayId, 'z', deltaZ);
5217
- _context3.n = 12;
5261
+ _context4.n = 12;
5218
5262
  return throttleDelay(GATEWAY_THROTTLE);
5219
5263
  case 12:
5220
5264
  console.log("\uD83D\uDEAA Gateway ".concat(gateway.name, " translated (").concat(_i2 + 1, "/").concat(gateways.length, "):"), {
@@ -5225,46 +5269,46 @@ var TransformControlsManager = /*#__PURE__*/function () {
5225
5269
 
5226
5270
  // Delay between gateways
5227
5271
  if (!(_i2 < gateways.length - 1)) {
5228
- _context3.n = 13;
5272
+ _context4.n = 13;
5229
5273
  break;
5230
5274
  }
5231
- _context3.n = 13;
5275
+ _context4.n = 13;
5232
5276
  return throttleDelay(GATEWAY_DELAY);
5233
5277
  case 13:
5234
5278
  _i2++;
5235
- _context3.n = 9;
5279
+ _context4.n = 9;
5236
5280
  break;
5237
5281
  case 14:
5238
5282
  _i3 = 0;
5239
5283
  case 15:
5240
5284
  if (!(_i3 < components.length)) {
5241
- _context3.n = 20;
5285
+ _context4.n = 20;
5242
5286
  break;
5243
5287
  }
5244
5288
  component = components[_i3];
5245
5289
  componentId = component.uuid || ((_component$userData = component.userData) === null || _component$userData === void 0 ? void 0 : _component$userData.originalUuid);
5246
5290
  if (!(Math.abs(deltaX) > threshold)) {
5247
- _context3.n = 16;
5291
+ _context4.n = 16;
5248
5292
  break;
5249
5293
  }
5250
5294
  this.centralPlant.translate(componentId, 'x', deltaX);
5251
- _context3.n = 16;
5295
+ _context4.n = 16;
5252
5296
  return throttleDelay(COMPONENT_THROTTLE);
5253
5297
  case 16:
5254
5298
  if (!(Math.abs(deltaY) > threshold)) {
5255
- _context3.n = 17;
5299
+ _context4.n = 17;
5256
5300
  break;
5257
5301
  }
5258
5302
  this.centralPlant.translate(componentId, 'y', deltaY);
5259
- _context3.n = 17;
5303
+ _context4.n = 17;
5260
5304
  return throttleDelay(COMPONENT_THROTTLE);
5261
5305
  case 17:
5262
5306
  if (!(Math.abs(deltaZ) > threshold)) {
5263
- _context3.n = 18;
5307
+ _context4.n = 18;
5264
5308
  break;
5265
5309
  }
5266
5310
  this.centralPlant.translate(componentId, 'z', deltaZ);
5267
- _context3.n = 18;
5311
+ _context4.n = 18;
5268
5312
  return throttleDelay(COMPONENT_THROTTLE);
5269
5313
  case 18:
5270
5314
  console.log("\uD83D\uDD27 Component ".concat(component.name, " translated (").concat(_i3 + 1, "/").concat(components.length, "):"), {
@@ -5275,14 +5319,14 @@ var TransformControlsManager = /*#__PURE__*/function () {
5275
5319
 
5276
5320
  // Delay between components
5277
5321
  if (!(_i3 < components.length - 1)) {
5278
- _context3.n = 19;
5322
+ _context4.n = 19;
5279
5323
  break;
5280
5324
  }
5281
- _context3.n = 19;
5325
+ _context4.n = 19;
5282
5326
  return throttleDelay(COMPONENT_DELAY);
5283
5327
  case 19:
5284
5328
  _i3++;
5285
- _context3.n = 15;
5329
+ _context4.n = 15;
5286
5330
  break;
5287
5331
  case 20:
5288
5332
  console.log("\u2705 All ".concat(this.selectedObjects.length, " objects translated with delta:"), {
@@ -5291,22 +5335,29 @@ var TransformControlsManager = /*#__PURE__*/function () {
5291
5335
  deltaZ: deltaZ
5292
5336
  });
5293
5337
  case 21:
5294
- // Reset the multi-selection group transform
5295
- this.multiSelectionGroup.position.set(0, 0, 0);
5296
- this.multiSelectionGroup.rotation.set(0, 0, 0);
5297
- this.multiSelectionGroup.scale.set(1, 1, 1);
5338
+ // Reset the multi-selection group transform (if it still exists)
5339
+ // Note: The group might have been cleared during async operations
5340
+ if (this.multiSelectionGroup) {
5341
+ this.multiSelectionGroup.position.set(0, 0, 0);
5342
+ this.multiSelectionGroup.rotation.set(0, 0, 0);
5343
+ this.multiSelectionGroup.scale.set(1, 1, 1);
5344
+ } else {
5345
+ console.warn('âš ī¸ Multi-selection group was cleared during transformation');
5346
+ }
5298
5347
 
5299
5348
  // CRITICAL: Clear bounding box cache after manualization
5300
5349
  // Manualization changes object references, making cached boxes invalid
5301
5350
  this.clearBoundingBoxCache();
5302
5351
 
5303
- // Update the multi-selection display with new positions
5304
- this.updateMultiSelection();
5352
+ // Update the multi-selection display with new positions (only if we still have selected objects)
5353
+ if (this.selectedObjects.length > 0) {
5354
+ this.updateMultiSelection();
5355
+ }
5305
5356
  console.log("\u2705 Multi-selection transform applied");
5306
5357
  case 22:
5307
- return _context3.a(2);
5358
+ return _context4.a(2);
5308
5359
  }
5309
- }, _callee, this);
5360
+ }, _callee2, this);
5310
5361
  }));
5311
5362
  function applyMultiSelectionTransform() {
5312
5363
  return _applyMultiSelectionTransform.apply(this, arguments);
@@ -19005,6 +19056,20 @@ var TransformOperationsManager = /*#__PURE__*/function () {
19005
19056
  this.fixUndergroundComponent(component);
19006
19057
  }
19007
19058
 
19059
+ // Auto-update paths if enabled (matches behavior of translateSegment and translateGateway)
19060
+ if (this.sceneViewer.shouldUpdatePaths) {
19061
+ try {
19062
+ if (this.sceneViewer && typeof this.sceneViewer.updatePaths === 'function') {
19063
+ this.sceneViewer.updatePaths();
19064
+ console.log('🔄 Paths auto-updated after component translation');
19065
+ } else {
19066
+ console.warn('âš ī¸ updatePaths method not available on sceneViewer');
19067
+ }
19068
+ } catch (error) {
19069
+ console.error('❌ Error auto-updating paths:', error);
19070
+ }
19071
+ }
19072
+
19008
19073
  // Emit transform event if available
19009
19074
  if (this.sceneViewer.emit && typeof this.sceneViewer.emit === 'function') {
19010
19075
  this.sceneViewer.emit('objectTransformed', {
@@ -19028,7 +19093,7 @@ var TransformOperationsManager = /*#__PURE__*/function () {
19028
19093
  }, {
19029
19094
  key: "translateSegment",
19030
19095
  value: function translateSegment(segmentId, axis, value) {
19031
- var _segment$userData, _segment$userData2, _this$sceneViewer3, _this$sceneViewer$man3, _this$sceneViewer$man4, _this$sceneViewer$man5;
19096
+ var _segment$userData, _segment$userData2, _segment$userData3, _this$sceneViewer2, _this$sceneViewer$man2, _this$sceneViewer$man3, _this$sceneViewer$man4;
19032
19097
  var skipPathUpdate = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
19033
19098
  // Validate parameters
19034
19099
  if (!segmentId || !axis || value === undefined || value === null) {
@@ -19069,6 +19134,12 @@ var TransformOperationsManager = /*#__PURE__*/function () {
19069
19134
  return false;
19070
19135
  }
19071
19136
 
19137
+ // Check if segment is immutable (computed from pathfinder)
19138
+ if (((_segment$userData3 = segment.userData) === null || _segment$userData3 === void 0 ? void 0 : _segment$userData3.immutable) === true) {
19139
+ console.warn("\u26A0\uFE0F translateSegment(): Segment '".concat(segmentId, "' is immutable (computed from pathfinder)"));
19140
+ return false;
19141
+ }
19142
+
19072
19143
  // Check segment orientation and cancel invalid translations
19073
19144
  // Get the segment's direction vector to determine which axis it runs along
19074
19145
  var direction = new THREE__namespace.Vector3(0, 1, 0);
@@ -19114,66 +19185,6 @@ var TransformOperationsManager = /*#__PURE__*/function () {
19114
19185
  parentType: (_c$parent2 = c.parent) === null || _c$parent2 === void 0 || (_c$parent2 = _c$parent2.userData) === null || _c$parent2 === void 0 ? void 0 : _c$parent2.objectType
19115
19186
  };
19116
19187
  }));
19117
-
19118
- // Filter out segment connectors - we only care about component connectors
19119
- var componentConnectorsAtEndpoints = connectorsAtEndpoints.filter(function (connector) {
19120
- var _connector$userData;
19121
- return ((_connector$userData = connector.userData) === null || _connector$userData === void 0 ? void 0 : _connector$userData.objectType) !== 'segment-connector';
19122
- });
19123
- console.log("\uD83D\uDD0D After filtering, ".concat(componentConnectorsAtEndpoints.length, " component connectors at endpoints"));
19124
- if (componentConnectorsAtEndpoints.length > 0) {
19125
- var _this$sceneViewer2, _this$sceneViewer$man2;
19126
- console.warn("\u26A0\uFE0F translateSegment(): Segment '".concat(segmentId, "' has component connectors at endpoints."));
19127
- console.log(" Found ".concat(componentConnectorsAtEndpoints.length, " component connector(s):"), componentConnectorsAtEndpoints.map(function (c) {
19128
- var _c$parent3;
19129
- return {
19130
- uuid: c.uuid,
19131
- parent: (_c$parent3 = c.parent) === null || _c$parent3 === void 0 ? void 0 : _c$parent3.uuid
19132
- };
19133
- }));
19134
-
19135
- // Check if segment splitting is enabled in settings
19136
- var splitSegmentsEnabled = (_this$sceneViewer2 = this.sceneViewer) === null || _this$sceneViewer2 === void 0 || (_this$sceneViewer2 = _this$sceneViewer2.managers) === null || _this$sceneViewer2 === void 0 || (_this$sceneViewer2 = _this$sceneViewer2.settingsManager) === null || _this$sceneViewer2 === void 0 ? void 0 : _this$sceneViewer2.getSetting('scene', 'splitSegmentsWithComponentConnectors');
19137
- if (splitSegmentsEnabled === false) {
19138
- console.warn('âš ī¸ Segment splitting is disabled. Cannot translate segments with component connectors at endpoints.');
19139
- return false;
19140
- }
19141
-
19142
- // Split the segment and translate the free half
19143
- console.log('âœ‚ī¸ Splitting segment to enable translation of the free half...');
19144
-
19145
- // Get sceneOperationsManager
19146
- var _sceneOperationsManager = (_this$sceneViewer$man2 = this.sceneViewer.managers) === null || _this$sceneViewer$man2 === void 0 ? void 0 : _this$sceneViewer$man2.sceneOperationsManager;
19147
- if (!_sceneOperationsManager) {
19148
- console.error('❌ translateSegment(): SceneOperationsManager not available for splitting');
19149
- return false;
19150
- }
19151
- try {
19152
- var splitResult = _sceneOperationsManager.splitSegment(segment, this.sceneViewer.currentSceneData);
19153
- if (splitResult) {
19154
- console.log("\u2705 Segment split and shortened: ".concat(splitResult.uuid, " (new length: ").concat(splitResult.geometry.parameters.height, ")"));
19155
-
19156
- // The splitResult is now a shortened manual segment
19157
- // Translate this shortened segment
19158
- console.log("\uD83C\uDFAF Translating shortened manual segment: ".concat(splitResult.uuid));
19159
-
19160
- // Now translate the shortened manual segment (recursive call with the new segment)
19161
- var translateSuccess = this.translateSegment(splitResult.uuid, axis, value);
19162
- if (!translateSuccess) {
19163
- console.error('❌ translateSegment(): Failed to translate shortened manual segment');
19164
- return false;
19165
- }
19166
- console.log('✅ Split, shorten, and translate operation completed successfully');
19167
- return true;
19168
- } else {
19169
- console.error('❌ translateSegment(): Split operation failed');
19170
- return false;
19171
- }
19172
- } catch (error) {
19173
- console.error('❌ translateSegment(): Error splitting segment:', error);
19174
- return false;
19175
- }
19176
- }
19177
19188
  console.log("\uD83D\uDD04 translateSegment(): Translating segment ".concat(segmentId, " on ").concat(axis, " axis by ").concat(value));
19178
19189
 
19179
19190
  // Temporarily apply the translation to check for collisions
@@ -19203,7 +19214,7 @@ var TransformOperationsManager = /*#__PURE__*/function () {
19203
19214
  segment.updateMatrixWorld(true);
19204
19215
 
19205
19216
  // Check if translationalOverrideForAutomaticSegments is enabled
19206
- var translationalOverride = (_this$sceneViewer3 = this.sceneViewer) === null || _this$sceneViewer3 === void 0 || (_this$sceneViewer3 = _this$sceneViewer3.managers) === null || _this$sceneViewer3 === void 0 || (_this$sceneViewer3 = _this$sceneViewer3.settingsManager) === null || _this$sceneViewer3 === void 0 ? void 0 : _this$sceneViewer3.getSetting('scene', 'translationalOverrideForAutomaticSegments');
19217
+ var translationalOverride = (_this$sceneViewer2 = this.sceneViewer) === null || _this$sceneViewer2 === void 0 || (_this$sceneViewer2 = _this$sceneViewer2.managers) === null || _this$sceneViewer2 === void 0 || (_this$sceneViewer2 = _this$sceneViewer2.settingsManager) === null || _this$sceneViewer2 === void 0 ? void 0 : _this$sceneViewer2.getSetting('scene', 'translationalOverrideForAutomaticSegments');
19207
19218
 
19208
19219
  // If override is disabled (false), check for intersections with computed segments
19209
19220
  if (translationalOverride === false) {
@@ -19237,8 +19248,8 @@ var TransformOperationsManager = /*#__PURE__*/function () {
19237
19248
  }
19238
19249
 
19239
19250
  // Validate PathfindingManager and SceneOperationsManager availability
19240
- var pathfindingManager = (_this$sceneViewer$man3 = this.sceneViewer.managers) === null || _this$sceneViewer$man3 === void 0 ? void 0 : _this$sceneViewer$man3.pathfindingManager;
19241
- var sceneOperationsManager = (_this$sceneViewer$man4 = this.sceneViewer.managers) === null || _this$sceneViewer$man4 === void 0 ? void 0 : _this$sceneViewer$man4.sceneOperationsManager;
19251
+ var pathfindingManager = (_this$sceneViewer$man2 = this.sceneViewer.managers) === null || _this$sceneViewer$man2 === void 0 ? void 0 : _this$sceneViewer$man2.pathfindingManager;
19252
+ var sceneOperationsManager = (_this$sceneViewer$man3 = this.sceneViewer.managers) === null || _this$sceneViewer$man3 === void 0 ? void 0 : _this$sceneViewer$man3.sceneOperationsManager;
19242
19253
  if (!pathfindingManager || !sceneOperationsManager) {
19243
19254
  console.error('❌ translateSegment(): PathfindingManager or SceneOperationsManager not available');
19244
19255
  return false;
@@ -19259,21 +19270,11 @@ var TransformOperationsManager = /*#__PURE__*/function () {
19259
19270
 
19260
19271
  // ALWAYS update connector positions after segment movement (first or subsequent moves)
19261
19272
  this.updateSegmentConnectorPositions(segment);
19262
-
19263
- // NEW: Update adjacent manual segments to follow this segment's new position
19264
- var maintainedConnections = this.snapSegmentConnectorsToNearbyEndpoints(segment);
19265
-
19266
- // NOTE: We do NOT remove connections from scene data
19267
- // The connections remain valid - the manual segments are maintaining those connections
19268
- // The pathfinding algorithm should detect that connectors are at the same position
19269
- // and skip creating computed segments for them
19270
- if (maintainedConnections.length > 0) {
19271
- console.log("\u2139\uFE0F ".concat(maintainedConnections.length, " connection(s) maintained by manual segments"));
19272
- }
19273
+ this.snapSegmentConnectorsToNearbyEndpoints(segment);
19273
19274
 
19274
19275
  // Store transform parameters using the OperationHistoryManager BEFORE updatePaths
19275
19276
  // This is critical so that intersection detection can undo the operation
19276
- if ((_this$sceneViewer$man5 = this.sceneViewer.managers) !== null && _this$sceneViewer$man5 !== void 0 && _this$sceneViewer$man5.operationHistory) {
19277
+ if ((_this$sceneViewer$man4 = this.sceneViewer.managers) !== null && _this$sceneViewer$man4 !== void 0 && _this$sceneViewer$man4.operationHistory) {
19277
19278
  this.sceneViewer.managers.operationHistory.addToOperationHistory('translateSegment', {
19278
19279
  segmentId: segmentId,
19279
19280
  axis: axis,
@@ -19286,9 +19287,6 @@ var TransformOperationsManager = /*#__PURE__*/function () {
19286
19287
  // UNLESS skipPathUpdate is true (for batch operations)
19287
19288
  if (!skipPathUpdate) {
19288
19289
  console.log('🔄 Regenerating paths to create connecting pipe segments...');
19289
- if (maintainedConnections.length > 0) {
19290
- console.log("\u2139\uFE0F Manual segments are maintaining connections - pathfinding should skip connectors at same position");
19291
- }
19292
19290
  try {
19293
19291
  if (this.sceneViewer && typeof this.sceneViewer.updatePaths === 'function') {
19294
19292
  this.sceneViewer.updatePaths();
@@ -19326,11 +19324,11 @@ var TransformOperationsManager = /*#__PURE__*/function () {
19326
19324
  }, {
19327
19325
  key: "translateGateway",
19328
19326
  value: function translateGateway(gatewayId, axis, value) {
19329
- var _this$sceneViewer$man6, _this$sceneViewer$man7;
19327
+ var _this$sceneViewer$man5, _this$sceneViewer$man6;
19330
19328
  console.log("[Pathfinder] translateGateway started");
19331
19329
 
19332
19330
  // Store transform parameters using the OperationHistoryManager
19333
- if ((_this$sceneViewer$man6 = this.sceneViewer.managers) !== null && _this$sceneViewer$man6 !== void 0 && _this$sceneViewer$man6.operationHistoryManager) {
19331
+ if ((_this$sceneViewer$man5 = this.sceneViewer.managers) !== null && _this$sceneViewer$man5 !== void 0 && _this$sceneViewer$man5.operationHistoryManager) {
19334
19332
  this.sceneViewer.managers.operationHistoryManager.addToOperationHistory('translateGateway', {
19335
19333
  gatewayId: gatewayId,
19336
19334
  axis: axis,
@@ -19381,7 +19379,7 @@ var TransformOperationsManager = /*#__PURE__*/function () {
19381
19379
 
19382
19380
  // Handle manual gateway transformation (convert to declared and process connections)
19383
19381
  console.log('🔧 Handling manual gateway transformation via SceneOperationsManager');
19384
- var sceneOperationsManager = (_this$sceneViewer$man7 = this.sceneViewer.managers) === null || _this$sceneViewer$man7 === void 0 ? void 0 : _this$sceneViewer$man7.sceneOperationsManager;
19382
+ var sceneOperationsManager = (_this$sceneViewer$man6 = this.sceneViewer.managers) === null || _this$sceneViewer$man6 === void 0 ? void 0 : _this$sceneViewer$man6.sceneOperationsManager;
19385
19383
  if (!sceneOperationsManager) {
19386
19384
  console.error('❌ translateGateway(): SceneOperationsManager not available');
19387
19385
  return false;
@@ -19483,6 +19481,20 @@ var TransformOperationsManager = /*#__PURE__*/function () {
19483
19481
  component.updateMatrix();
19484
19482
  component.updateMatrixWorld(true);
19485
19483
 
19484
+ // Auto-update paths if enabled (matches behavior of translateComponent)
19485
+ if (this.sceneViewer.shouldUpdatePaths) {
19486
+ try {
19487
+ if (this.sceneViewer && typeof this.sceneViewer.updatePaths === 'function') {
19488
+ this.sceneViewer.updatePaths();
19489
+ console.log('🔄 Paths auto-updated after component rotation');
19490
+ } else {
19491
+ console.warn('âš ī¸ updatePaths method not available on sceneViewer');
19492
+ }
19493
+ } catch (error) {
19494
+ console.error('❌ Error auto-updating paths:', error);
19495
+ }
19496
+ }
19497
+
19486
19498
  // Emit transform event if available
19487
19499
  if (this.sceneViewer.emit && typeof this.sceneViewer.emit === 'function') {
19488
19500
  this.sceneViewer.emit('objectTransformed', {
@@ -19665,9 +19677,9 @@ var TransformOperationsManager = /*#__PURE__*/function () {
19665
19677
  }, {
19666
19678
  key: "findConnectorsAtPositions",
19667
19679
  value: function findConnectorsAtPositions(positions) {
19668
- var _this$sceneViewer4;
19680
+ var _this$sceneViewer3;
19669
19681
  var tolerance = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0.15;
19670
- if (!((_this$sceneViewer4 = this.sceneViewer) !== null && _this$sceneViewer4 !== void 0 && _this$sceneViewer4.scene)) {
19682
+ if (!((_this$sceneViewer3 = this.sceneViewer) !== null && _this$sceneViewer3 !== void 0 && _this$sceneViewer3.scene)) {
19671
19683
  return [];
19672
19684
  }
19673
19685
  var foundConnectors = [];
@@ -19711,9 +19723,9 @@ var TransformOperationsManager = /*#__PURE__*/function () {
19711
19723
  }, {
19712
19724
  key: "updateSegmentConnectorPositions",
19713
19725
  value: function updateSegmentConnectorPositions(segment) {
19714
- var _this$sceneViewer5;
19726
+ var _this$sceneViewer4;
19715
19727
  console.log("updateSegmentConnectorPositions started:", segment);
19716
- if (!segment || !((_this$sceneViewer5 = this.sceneViewer) !== null && _this$sceneViewer5 !== void 0 && (_this$sceneViewer5 = _this$sceneViewer5.currentSceneData) !== null && _this$sceneViewer5 !== void 0 && _this$sceneViewer5.scene)) {
19728
+ if (!segment || !((_this$sceneViewer4 = this.sceneViewer) !== null && _this$sceneViewer4 !== void 0 && (_this$sceneViewer4 = _this$sceneViewer4.currentSceneData) !== null && _this$sceneViewer4 !== void 0 && _this$sceneViewer4.scene)) {
19717
19729
  console.warn('âš ī¸ updateSegmentConnectorPositions(): Missing segment or scene data');
19718
19730
  return;
19719
19731
  }
@@ -19739,8 +19751,8 @@ var TransformOperationsManager = /*#__PURE__*/function () {
19739
19751
 
19740
19752
  // First, find the segment in scene data
19741
19753
  var sceneDataSegment = this.sceneViewer.currentSceneData.scene.children.find(function (child) {
19742
- var _segment$userData3;
19743
- return child.uuid === segment.uuid || child.uuid === ((_segment$userData3 = segment.userData) === null || _segment$userData3 === void 0 ? void 0 : _segment$userData3.originalUuid);
19754
+ var _segment$userData4;
19755
+ return child.uuid === segment.uuid || child.uuid === ((_segment$userData4 = segment.userData) === null || _segment$userData4 === void 0 ? void 0 : _segment$userData4.originalUuid);
19744
19756
  });
19745
19757
  if (!sceneDataSegment) {
19746
19758
  console.warn("\u26A0\uFE0F Segment ".concat(segment.uuid, " not found in scene data"));
@@ -19760,8 +19772,8 @@ var TransformOperationsManager = /*#__PURE__*/function () {
19760
19772
 
19761
19773
  // Find the connector in the segment's children array (not root scene.children)
19762
19774
  var sceneDataConnector = sceneDataSegment.children.find(function (child) {
19763
- var _connector$userData2;
19764
- return child.uuid === connector.uuid || child.uuid === ((_connector$userData2 = connector.userData) === null || _connector$userData2 === void 0 ? void 0 : _connector$userData2.originalUuid);
19775
+ var _connector$userData;
19776
+ return child.uuid === connector.uuid || child.uuid === ((_connector$userData = connector.userData) === null || _connector$userData === void 0 ? void 0 : _connector$userData.originalUuid);
19765
19777
  });
19766
19778
  if (sceneDataConnector && sceneDataConnector.userData) {
19767
19779
  // Update position as array [x, y, z] for pathfinder compatibility
@@ -19783,9 +19795,9 @@ var TransformOperationsManager = /*#__PURE__*/function () {
19783
19795
  }, {
19784
19796
  key: "checkSegmentIntersection",
19785
19797
  value: function checkSegmentIntersection(segment) {
19786
- var _this$sceneViewer6,
19798
+ var _this$sceneViewer5,
19787
19799
  _this = this;
19788
- if (!((_this$sceneViewer6 = this.sceneViewer) !== null && _this$sceneViewer6 !== void 0 && _this$sceneViewer6.scene)) {
19800
+ if (!((_this$sceneViewer5 = this.sceneViewer) !== null && _this$sceneViewer5 !== void 0 && _this$sceneViewer5.scene)) {
19789
19801
  return false;
19790
19802
  }
19791
19803
 
@@ -19855,8 +19867,8 @@ var TransformOperationsManager = /*#__PURE__*/function () {
19855
19867
  }, {
19856
19868
  key: "checkSegmentPathConnectorCollision",
19857
19869
  value: function checkSegmentPathConnectorCollision(segment) {
19858
- var _this$sceneViewer7;
19859
- if (!((_this$sceneViewer7 = this.sceneViewer) !== null && _this$sceneViewer7 !== void 0 && _this$sceneViewer7.scene) || !segment) {
19870
+ var _this$sceneViewer6;
19871
+ if (!((_this$sceneViewer6 = this.sceneViewer) !== null && _this$sceneViewer6 !== void 0 && _this$sceneViewer6.scene) || !segment) {
19860
19872
  return null;
19861
19873
  }
19862
19874
  var collisionRadius = 0.5; // Radius around connector that triggers collision
@@ -19970,8 +19982,8 @@ var TransformOperationsManager = /*#__PURE__*/function () {
19970
19982
  }, {
19971
19983
  key: "checkComponentConnectorCollision",
19972
19984
  value: function checkComponentConnectorCollision(newPosition) {
19973
- var _this$sceneViewer8;
19974
- if (!((_this$sceneViewer8 = this.sceneViewer) !== null && _this$sceneViewer8 !== void 0 && _this$sceneViewer8.scene)) {
19985
+ var _this$sceneViewer7;
19986
+ if (!((_this$sceneViewer7 = this.sceneViewer) !== null && _this$sceneViewer7 !== void 0 && _this$sceneViewer7.scene)) {
19975
19987
  return null;
19976
19988
  }
19977
19989
  var tolerance = 0.01; // Small tolerance for floating-point comparison
@@ -20127,10 +20139,10 @@ var TransformOperationsManager = /*#__PURE__*/function () {
20127
20139
  }, {
20128
20140
  key: "snapSegmentConnectorsToNearbyEndpoints",
20129
20141
  value: function snapSegmentConnectorsToNearbyEndpoints(movedSegment) {
20130
- var _this$sceneViewer9,
20131
- _this$sceneViewer0,
20142
+ var _this$sceneViewer8,
20143
+ _this$sceneViewer9,
20132
20144
  _this2 = this;
20133
- if (!movedSegment || !((_this$sceneViewer9 = this.sceneViewer) !== null && _this$sceneViewer9 !== void 0 && _this$sceneViewer9.scene)) {
20145
+ if (!movedSegment || !((_this$sceneViewer8 = this.sceneViewer) !== null && _this$sceneViewer8 !== void 0 && _this$sceneViewer8.scene)) {
20134
20146
  return [];
20135
20147
  }
20136
20148
  console.log('🔗 Finding adjacent segments connected to moved segment...');
@@ -20152,7 +20164,7 @@ var TransformOperationsManager = /*#__PURE__*/function () {
20152
20164
  var newEndpoints = this.calculateSegmentEndpoints(movedSegment);
20153
20165
 
20154
20166
  // Check scene data for connections involving the moved segment's connectors
20155
- var connections = ((_this$sceneViewer0 = this.sceneViewer) === null || _this$sceneViewer0 === void 0 || (_this$sceneViewer0 = _this$sceneViewer0.currentSceneData) === null || _this$sceneViewer0 === void 0 ? void 0 : _this$sceneViewer0.connections) || [];
20167
+ var connections = ((_this$sceneViewer9 = this.sceneViewer) === null || _this$sceneViewer9 === void 0 || (_this$sceneViewer9 = _this$sceneViewer9.currentSceneData) === null || _this$sceneViewer9 === void 0 ? void 0 : _this$sceneViewer9.connections) || [];
20156
20168
  var movedConnectorIds = movedConnectors.map(function (c) {
20157
20169
  return c.uuid;
20158
20170
  });
@@ -20308,9 +20320,9 @@ var TransformOperationsManager = /*#__PURE__*/function () {
20308
20320
  }, {
20309
20321
  key: "updateConnectorPositionInSceneData",
20310
20322
  value: function updateConnectorPositionInSceneData(connector, worldPosition, parentSegment) {
20311
- var _this$sceneViewer1;
20323
+ var _this$sceneViewer0;
20312
20324
  // Update scene data if available
20313
- if (!((_this$sceneViewer1 = this.sceneViewer) !== null && _this$sceneViewer1 !== void 0 && _this$sceneViewer1.currentSceneData)) {
20325
+ if (!((_this$sceneViewer0 = this.sceneViewer) !== null && _this$sceneViewer0 !== void 0 && _this$sceneViewer0.currentSceneData)) {
20314
20326
  return;
20315
20327
  }
20316
20328
  var cleanPosition = function cleanPosition(value) {
@@ -20333,8 +20345,8 @@ var TransformOperationsManager = /*#__PURE__*/function () {
20333
20345
  }
20334
20346
 
20335
20347
  /**
20336
- * Recreate segment mesh with new length based on connector positions
20337
- * @param {THREE.Object3D} segment - The segment to recreate
20348
+ * Adjust segment geometry and transform to match new endpoint positions
20349
+ * @param {THREE.Object3D} segment - The segment to adjust
20338
20350
  * @param {Array<THREE.Object3D>} connectors - The segment's connectors
20339
20351
  * @param {THREE.Vector3} endPoint1 - Explicit world position for first endpoint (optional)
20340
20352
  * @param {THREE.Vector3} endPoint2 - Explicit world position for second endpoint (optional)
@@ -20348,7 +20360,7 @@ var TransformOperationsManager = /*#__PURE__*/function () {
20348
20360
  var endPoint2 = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
20349
20361
  var activeSegment = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;
20350
20362
  if (!segment || connectors.length !== 2) {
20351
- console.warn('âš ī¸ Cannot recreate segment: invalid segment or connectors');
20363
+ console.warn('âš ī¸ Cannot adjust segment: invalid segment or connectors');
20352
20364
  return;
20353
20365
  }
20354
20366
  var _connectors = _slicedToArray(connectors, 2),
@@ -20391,21 +20403,28 @@ var TransformOperationsManager = /*#__PURE__*/function () {
20391
20403
  this._removeZeroLengthSegment(segment, connectors, activeSegment);
20392
20404
  return;
20393
20405
  }
20394
- console.log("\uD83D\uDD27 Recreating segment with new length: ".concat(newLength.toFixed(3), " (was ").concat(segment.geometry.parameters.height.toFixed(3), ")"));
20406
+ var oldLength = segment.geometry.parameters.height;
20407
+ console.log("\uD83D\uDD27 Adjusting segment geometry: ".concat(oldLength.toFixed(3), " \u2192 ").concat(newLength.toFixed(3)));
20408
+
20409
+ // Only recreate geometry if length has changed significantly
20410
+ if (Math.abs(newLength - oldLength) > 1e-6) {
20411
+ var oldGeometry = segment.geometry;
20412
+ var pipeRadius = oldGeometry.parameters.radiusTop || 0.1;
20413
+
20414
+ // Create new cylinder geometry with updated length
20415
+ var newGeometry = new THREE__namespace.CylinderGeometry(pipeRadius, pipeRadius, newLength, 16, 1, false);
20395
20416
 
20396
- // Store old geometry and material references
20397
- var oldGeometry = segment.geometry;
20398
- segment.material;
20399
- var pipeRadius = oldGeometry.parameters.radiusTop || 0.1;
20417
+ // Replace geometry
20418
+ segment.geometry = newGeometry;
20400
20419
 
20401
- // Create new cylinder geometry with updated length
20402
- var newGeometry = new THREE__namespace.CylinderGeometry(pipeRadius, pipeRadius, newLength, 16, 1, false);
20420
+ // Dispose old geometry
20421
+ oldGeometry.dispose();
20422
+ }
20403
20423
 
20404
- // Update segment mesh
20405
- segment.geometry = newGeometry;
20424
+ // Update segment position to new center
20406
20425
  segment.position.copy(newCenter);
20407
20426
 
20408
- // Calculate and apply rotation
20427
+ // Calculate and apply rotation to align with new direction
20409
20428
  var quaternion = new THREE__namespace.Quaternion();
20410
20429
  var up = new THREE__namespace.Vector3(0, 1, 0);
20411
20430
  quaternion.setFromUnitVectors(up, direction.clone().normalize());
@@ -20414,12 +20433,7 @@ var TransformOperationsManager = /*#__PURE__*/function () {
20414
20433
  // Update matrices
20415
20434
  segment.updateMatrix();
20416
20435
  segment.updateMatrixWorld(true);
20417
-
20418
- // Dispose old geometry
20419
- if (oldGeometry && oldGeometry !== newGeometry) {
20420
- oldGeometry.dispose();
20421
- }
20422
- console.log("\u2705 Segment mesh recreated: new length = ".concat(newLength.toFixed(3), ", center = [").concat(newCenter.x.toFixed(2), ", ").concat(newCenter.y.toFixed(2), ", ").concat(newCenter.z.toFixed(2), "]"));
20436
+ console.log("\u2705 Segment adjusted: length = ".concat(newLength.toFixed(3), ", center = [").concat(newCenter.x.toFixed(2), ", ").concat(newCenter.y.toFixed(2), ", ").concat(newCenter.z.toFixed(2), "]"));
20423
20437
  }
20424
20438
 
20425
20439
  /**
@@ -20536,8 +20550,8 @@ var TransformOperationsManager = /*#__PURE__*/function () {
20536
20550
  // Remove segment from scene data
20537
20551
  if (currentSceneData.scene && currentSceneData.scene.children) {
20538
20552
  var segmentIndex = currentSceneData.scene.children.findIndex(function (child) {
20539
- var _segment$userData4;
20540
- return child.uuid === segment.uuid || child.uuid === ((_segment$userData4 = segment.userData) === null || _segment$userData4 === void 0 ? void 0 : _segment$userData4.originalUuid);
20553
+ var _segment$userData5;
20554
+ return child.uuid === segment.uuid || child.uuid === ((_segment$userData5 = segment.userData) === null || _segment$userData5 === void 0 ? void 0 : _segment$userData5.originalUuid);
20541
20555
  });
20542
20556
  if (segmentIndex !== -1) {
20543
20557
  currentSceneData.scene.children.splice(segmentIndex, 1);
@@ -24088,21 +24102,12 @@ var KeyboardControlsManager = /*#__PURE__*/function () {
24088
24102
  return _createClass(KeyboardControlsManager, [{
24089
24103
  key: "setupKeyboardControls",
24090
24104
  value: function setupKeyboardControls() {
24091
- var _this = this;
24092
24105
  this.handleKeyDown = function (event) {
24093
24106
  // Sample Ctrl+Z example
24094
24107
  if (event.ctrlKey && (event.key.toLowerCase() === 'z' || event.code === 'KeyZ')) {
24095
24108
  // method call here
24096
24109
  return;
24097
24110
  }
24098
-
24099
- // Shift+D to split selected segment
24100
- if (event.shiftKey && (event.key.toLowerCase() === 'd' || event.code === 'KeyD')) {
24101
- _this.handleSegmentSplit();
24102
- event.preventDefault();
24103
- event.stopPropagation();
24104
- return;
24105
- }
24106
24111
  switch (event.key.toLowerCase()) {
24107
24112
  }
24108
24113
  };
@@ -24116,53 +24121,6 @@ var KeyboardControlsManager = /*#__PURE__*/function () {
24116
24121
  console.log('Keyboard controls initialized with Ctrl+Z undo override and Shift+D segment split');
24117
24122
  }
24118
24123
 
24119
- /**
24120
- * Handle segment split operation (Shift+D)
24121
- * Splits the currently selected segment in half if it's a pipe segment
24122
- */
24123
- }, {
24124
- key: "handleSegmentSplit",
24125
- value: function handleSegmentSplit() {
24126
- var sceneViewer = this.sceneViewer;
24127
-
24128
- // Check if transform controls are active with a selected object
24129
- if (!sceneViewer.transformManager || !sceneViewer.transformManager.selectedObjects || sceneViewer.transformManager.selectedObjects.length === 0) {
24130
- console.log('â„šī¸ No object selected for segment split');
24131
- return;
24132
- }
24133
- var selectedObject = sceneViewer.transformManager.selectedObjects[0];
24134
-
24135
- // Verify it's a segment
24136
- if (!selectedObject.userData || selectedObject.userData.objectType !== 'segment') {
24137
- console.log('â„šī¸ Selected object is not a segment, cannot split');
24138
- return;
24139
- }
24140
- console.log('âœ‚ī¸ Shift+D pressed - splitting segment:', selectedObject.uuid);
24141
-
24142
- // Access CentralPlant through sceneViewer
24143
- var centralPlant = sceneViewer.centralPlant;
24144
- if (!centralPlant || typeof centralPlant.splitSegment !== 'function') {
24145
- console.error('❌ CentralPlant or splitSegment method not available');
24146
- return;
24147
- }
24148
-
24149
- // Call the public API to split the segment
24150
- var result = centralPlant.splitSegment(selectedObject.uuid);
24151
- if (result) {
24152
- console.log('✅ Segment split successful:', result);
24153
-
24154
- // Deselect the original segment (now removed) and optionally select one of the new segments
24155
- sceneViewer.transformManager.deselectObject();
24156
-
24157
- // Optionally select the first new segment
24158
- if (result.segment1) {
24159
- sceneViewer.transformManager.selectObject(result.segment1);
24160
- }
24161
- } else {
24162
- console.error('❌ Segment split failed');
24163
- }
24164
- }
24165
-
24166
24124
  /**
24167
24125
  * Toggle auto-rotation of the camera
24168
24126
  */
@@ -24929,10 +24887,23 @@ var SceneDataManager = /*#__PURE__*/function () {
24929
24887
  worldBoundingBox: worldBoundingBox
24930
24888
  })
24931
24889
  };
24890
+
24891
+ // For connectors and gateways, add world position
24932
24892
  if (obj.userData.objectType.includes('connector') || obj.userData.objectType === 'gateway') {
24933
24893
  var worldPosition = new THREE__namespace.Vector3();
24934
24894
  obj.getWorldPosition(worldPosition);
24935
24895
  results.userData.position = [worldPosition.x, worldPosition.y, worldPosition.z];
24896
+
24897
+ // Differentiate component connectors from segment connectors for pathfinder
24898
+ // Component connectors are children of components
24899
+ if (obj.userData.objectType === 'connector') {
24900
+ var _parent$userData;
24901
+ // Check if parent is a component (not a segment)
24902
+ var parent = obj.parent;
24903
+ if (parent && ((_parent$userData = parent.userData) === null || _parent$userData === void 0 ? void 0 : _parent$userData.objectType) === 'component') {
24904
+ results.userData.objectType = 'component-connector';
24905
+ }
24906
+ }
24936
24907
  }
24937
24908
  return results;
24938
24909
  });
@@ -25217,8 +25188,30 @@ var PathRenderingManager = /*#__PURE__*/function (_BaseDisposable) {
25217
25188
  value: function createPipePaths(paths, crosscubeTextureSet) {
25218
25189
  var _this3 = this;
25219
25190
  var sceneViewer = this.sceneViewer;
25220
- var globalSegmentIndex = 0; // Counter for globally unique segment indices
25221
25191
 
25192
+ // Find the highest segment index currently in use (both computed SEGMENT-X and manual Segment-X)
25193
+ var maxExistingIndex = -1;
25194
+ sceneViewer.scene.traverse(function (obj) {
25195
+ if (obj.uuid) {
25196
+ // Check for computed segments: SEGMENT-123
25197
+ var computedMatch = obj.uuid.match(/^SEGMENT-(\d+)$/);
25198
+ if (computedMatch) {
25199
+ var index = parseInt(computedMatch[1], 10);
25200
+ maxExistingIndex = Math.max(maxExistingIndex, index);
25201
+ }
25202
+
25203
+ // Check for manual segments: Segment-123
25204
+ var manualMatch = obj.uuid.match(/^Segment-(\d+)$/);
25205
+ if (manualMatch) {
25206
+ var _index = parseInt(manualMatch[1], 10);
25207
+ maxExistingIndex = Math.max(maxExistingIndex, _index);
25208
+ }
25209
+ }
25210
+ });
25211
+
25212
+ // Start counter after the highest existing index to prevent UUID conflicts
25213
+ var globalSegmentIndex = maxExistingIndex + 1;
25214
+ console.log("\uD83D\uDD22 Starting segment index at ".concat(globalSegmentIndex, " (max existing: ").concat(maxExistingIndex, ")"));
25222
25215
  var pipeRadius = 0.1;
25223
25216
  var pipeMaterial = this.createPipeMaterial(crosscubeTextureSet);
25224
25217
  paths.forEach(function (pathData, index) {
@@ -25237,6 +25230,10 @@ var PathRenderingManager = /*#__PURE__*/function (_BaseDisposable) {
25237
25230
  }
25238
25231
  });
25239
25232
 
25233
+ // Check if endpoints are component connectors (from pathfinder result)
25234
+ var fromIsComponentConnector = pathData.fromObjectType === 'component-connector';
25235
+ var toIsComponentConnector = pathData.toObjectType === 'component-connector';
25236
+
25240
25237
  // Create one cylinder per segment (after colinear optimization, this should be minimal segments)
25241
25238
  for (var j = 0; j < pathPoints.length - 1; j++) {
25242
25239
  var start = pathPoints[j];
@@ -25265,13 +25262,19 @@ var PathRenderingManager = /*#__PURE__*/function (_BaseDisposable) {
25265
25262
  // Make pipe segments selectable and add identifying data
25266
25263
  var segmentId = cylinder.uuid;
25267
25264
 
25265
+ // Determine if this segment should be immutable (first or last 0.5-unit segment connected to component)
25266
+ var isFirstSegment = j === 0;
25267
+ var isLastSegment = j === pathPoints.length - 2;
25268
+ var isImmutable = fromIsComponentConnector && isFirstSegment || toIsComponentConnector && isLastSegment;
25269
+
25268
25270
  // Add userData to make pipe segments selectable and for tooltip display
25269
25271
  cylinder.userData = {
25270
25272
  objectType: 'segment',
25271
25273
  segmentId: segmentId,
25272
25274
  segmentIndex: globalSegmentIndex,
25273
25275
  pathFrom: pathData.from,
25274
- pathTo: pathData.to
25276
+ pathTo: pathData.to,
25277
+ immutable: isImmutable // Mark segments connected to component connectors as immutable
25275
25278
  };
25276
25279
 
25277
25280
  // Increment global segment counter
@@ -25336,6 +25339,8 @@ var PathRenderingManager = /*#__PURE__*/function (_BaseDisposable) {
25336
25339
  pathFrom: pathData.from,
25337
25340
  pathTo: pathData.to,
25338
25341
  angle: (angle * 180 / Math.PI).toFixed(1),
25342
+ immutable: true,
25343
+ // Mark computed elbows as immutable
25339
25344
  // Add component data for tooltips
25340
25345
  component: {
25341
25346
  type: 'PipeElbow',
@@ -26564,13 +26569,6 @@ var PathfindingManager = /*#__PURE__*/function (_BaseDisposable) {
26564
26569
  connectionsCopy,
26565
26570
  simplifiedSceneData,
26566
26571
  pathfindingResult,
26567
- intersectionCheck,
26568
- _this$sceneViewer,
26569
- operationHistoryManager,
26570
- lastOp,
26571
- undoSuccess,
26572
- correctedResult,
26573
- _this$sceneViewer2,
26574
26572
  _args = arguments;
26575
26573
  return _regenerator().w(function (_context) {
26576
26574
  while (1) switch (_context.n) {
@@ -26605,93 +26603,79 @@ var PathfindingManager = /*#__PURE__*/function (_BaseDisposable) {
26605
26603
  console.log('Rewired connections:', JSON.parse(JSON.stringify(pathfindingResult.rewiredConnections)));
26606
26604
  console.log("intersectionCheck input:", pathfindingResult.paths);
26607
26605
 
26608
- // Check for path intersections (including manual segments)
26609
- intersectionCheck = this.checkPathIntersections(pathfindingResult.paths, 0.2, true);
26610
- pathfindingResult.intersections = intersectionCheck;
26611
- console.log("intersectionCheck:", intersectionCheck);
26612
- console.log("intersectionCheck.hasIntersections:", intersectionCheck.hasIntersections);
26613
-
26614
- // Handle intersection detection - undo last operation if intersections found
26615
- // Skip this if we're already in the middle of an undo operation
26616
- if (!(intersectionCheck.hasIntersections && !this.isUndoInProgress)) {
26617
- _context.n = 8;
26618
- break;
26619
- }
26620
- console.warn('âš ī¸ Path intersections detected! Attempting to undo last operation...');
26621
-
26622
- // Set flag to prevent recursive undo attempts
26623
- this.isUndoInProgress = true;
26624
-
26625
- // Access operationHistoryManager through sceneViewer.managers.operationHistory
26626
- operationHistoryManager = (_this$sceneViewer = this.sceneViewer) === null || _this$sceneViewer === void 0 || (_this$sceneViewer = _this$sceneViewer.managers) === null || _this$sceneViewer === void 0 ? void 0 : _this$sceneViewer.operationHistory;
26627
- if (!operationHistoryManager) {
26628
- _context.n = 6;
26629
- break;
26630
- }
26631
- lastOp = operationHistoryManager.getLastOperation();
26632
- if (!lastOp) {
26633
- _context.n = 4;
26634
- break;
26635
- }
26636
- console.warn("\u26A0\uFE0F Intersection caused by operation: ".concat(lastOp.operationName), lastOp.params);
26637
-
26638
- // Attempt to undo the operation FIRST (before removing computed objects)
26639
- // This is important because undo needs to find the segment that was moved
26640
- undoSuccess = operationHistoryManager.undoLastOperation();
26641
- if (!undoSuccess) {
26642
- _context.n = 2;
26643
- break;
26644
- }
26645
- console.log('✅ Successfully undid operation that caused intersection');
26646
-
26647
- // Now remove the buggy computed objects that were created with the invalid state
26648
- console.log('đŸ—‘ī¸ Removing buggy computed objects after undo...');
26649
- this.removeComputedObjects();
26650
-
26651
- // Re-run pathfinding after undo to restore valid state
26652
- console.log('🔄 Re-running pathfinding after undo to restore clean state...');
26606
+ // // Check for path intersections (including manual segments)
26607
+ // const intersectionCheck = this.checkPathIntersections(pathfindingResult.paths, 0.2, true);
26608
+ // pathfindingResult.intersections = intersectionCheck;
26609
+
26610
+ // console.log("intersectionCheck:", intersectionCheck);
26611
+ // console.log("intersectionCheck.hasIntersections:", intersectionCheck.hasIntersections);
26612
+
26613
+ // // Handle intersection detection - undo last operation if intersections found
26614
+ // // Skip this if we're already in the middle of an undo operation
26615
+ // if (intersectionCheck.hasIntersections && !this.isUndoInProgress) {
26616
+ // console.warn('âš ī¸ Path intersections detected! Attempting to undo last operation...');
26617
+
26618
+ // // Set flag to prevent recursive undo attempts
26619
+ // this.isUndoInProgress = true;
26620
+
26621
+ // // Access operationHistoryManager through sceneViewer.managers.operationHistory
26622
+ // const operationHistoryManager = this.sceneViewer?.managers?.operationHistory;
26623
+
26624
+ // if (operationHistoryManager) {
26625
+ // const lastOp = operationHistoryManager.getLastOperation();
26626
+
26627
+ // if (lastOp) {
26628
+ // console.warn(`âš ī¸ Intersection caused by operation: ${lastOp.operationName}`, lastOp.params);
26629
+
26630
+ // // Attempt to undo the operation FIRST (before removing computed objects)
26631
+ // // This is important because undo needs to find the segment that was moved
26632
+ // const undoSuccess = operationHistoryManager.undoLastOperation();
26633
+
26634
+ // if (undoSuccess) {
26635
+ // console.log('✅ Successfully undid operation that caused intersection');
26636
+
26637
+ // // Now remove the buggy computed objects that were created with the invalid state
26638
+ // console.log('đŸ—‘ī¸ Removing buggy computed objects after undo...');
26639
+ // this.removeComputedObjects();
26640
+
26641
+ // // Re-run pathfinding after undo to restore valid state
26642
+ // console.log('🔄 Re-running pathfinding after undo to restore clean state...');
26643
+
26644
+ // // Recursively call _executePathfinding with the corrected scene state
26645
+ // // This is safe because we've undone the operation, so we won't get into an infinite loop
26646
+ // const correctedResult = await this._executePathfinding(
26647
+ // sceneData,
26648
+ // connections,
26649
+ // { ...options, context: `${context} (After Undo)` }
26650
+ // );
26651
+
26652
+ // // Mark that we performed an undo and return the corrected result
26653
+ // correctedResult.undoPerformed = true;
26654
+ // correctedResult.undoneOperation = lastOp;
26655
+
26656
+ // // Clear the undo flag before returning
26657
+ // this.isUndoInProgress = false;
26658
+
26659
+ // return correctedResult;
26660
+ // } else {
26661
+ // console.error('❌ Failed to undo operation that caused intersection');
26662
+ // pathfindingResult.undoFailed = true;
26663
+ // // Clear the undo flag even on failure
26664
+ // this.isUndoInProgress = false;
26665
+ // }
26666
+ // } else {
26667
+ // console.warn('âš ī¸ No operation in history to undo');
26668
+ // this.isUndoInProgress = false;
26669
+ // }
26670
+ // } else {
26671
+ // console.error('❌ OperationHistoryManager not available for undo');
26672
+ // console.error(' Available managers:', Object.keys(this.sceneViewer?.managers || {}));
26673
+ // this.isUndoInProgress = false;
26674
+ // }
26675
+ // } else if (intersectionCheck.hasIntersections && this.isUndoInProgress) {
26676
+ // console.log('â­ī¸ Skipping intersection handling - undo already in progress');
26677
+ // }
26653
26678
 
26654
- // Recursively call _executePathfinding with the corrected scene state
26655
- // This is safe because we've undone the operation, so we won't get into an infinite loop
26656
- _context.n = 1;
26657
- return this._executePathfinding(sceneData, connections, _objectSpread2(_objectSpread2({}, options), {}, {
26658
- context: "".concat(context, " (After Undo)")
26659
- }));
26660
- case 1:
26661
- correctedResult = _context.v;
26662
- // Mark that we performed an undo and return the corrected result
26663
- correctedResult.undoPerformed = true;
26664
- correctedResult.undoneOperation = lastOp;
26665
-
26666
- // Clear the undo flag before returning
26667
- this.isUndoInProgress = false;
26668
- return _context.a(2, correctedResult);
26669
- case 2:
26670
- console.error('❌ Failed to undo operation that caused intersection');
26671
- pathfindingResult.undoFailed = true;
26672
- // Clear the undo flag even on failure
26673
- this.isUndoInProgress = false;
26674
- case 3:
26675
- _context.n = 5;
26676
- break;
26677
- case 4:
26678
- console.warn('âš ī¸ No operation in history to undo');
26679
- this.isUndoInProgress = false;
26680
- case 5:
26681
- _context.n = 7;
26682
- break;
26683
- case 6:
26684
- console.error('❌ OperationHistoryManager not available for undo');
26685
- console.error(' Available managers:', Object.keys(((_this$sceneViewer2 = this.sceneViewer) === null || _this$sceneViewer2 === void 0 ? void 0 : _this$sceneViewer2.managers) || {}));
26686
- this.isUndoInProgress = false;
26687
- case 7:
26688
- _context.n = 9;
26689
- break;
26690
- case 8:
26691
- if (intersectionCheck.hasIntersections && this.isUndoInProgress) {
26692
- console.log('â­ī¸ Skipping intersection handling - undo already in progress');
26693
- }
26694
- case 9:
26695
26679
  // Create gateways in the scene if requested
26696
26680
  if (options.createGateways && pathfindingResult.gateways) {
26697
26681
  this.renderingManager.createGateways(pathfindingResult);
@@ -29374,7 +29358,7 @@ var SceneOperationsManager = /*#__PURE__*/function () {
29374
29358
  }, {
29375
29359
  key: "manualizeSegment",
29376
29360
  value: function manualizeSegment(segment, currentSceneData) {
29377
- var _segment$userData, _this$sceneViewer$man;
29361
+ var _segment$userData, _segment$material$use, _this$sceneViewer$man;
29378
29362
  if (!segment || !((_segment$userData = segment.userData) !== null && _segment$userData !== void 0 && _segment$userData.objectType) === 'segment') {
29379
29363
  console.log('❌ Object is not a pipe segment:', {
29380
29364
  isObject: !!segment,
@@ -29391,6 +29375,16 @@ var SceneOperationsManager = /*#__PURE__*/function () {
29391
29375
  return;
29392
29376
  }
29393
29377
 
29378
+ // CRITICAL: Clone the material BEFORE changing its color
29379
+ // This prevents the color change from affecting other segments that share the same material instance
29380
+ if (segment.material && !((_segment$material$use = segment.material.userData) !== null && _segment$material$use !== void 0 && _segment$material$use.isCloned)) {
29381
+ var originalMaterial = segment.material;
29382
+ segment.material = originalMaterial.clone();
29383
+ segment.material.userData = segment.material.userData || {};
29384
+ segment.material.userData.isCloned = true;
29385
+ console.log('📋 Cloned segment material to prevent shared material mutation');
29386
+ }
29387
+
29394
29388
  // Override material color to blue in dev mode
29395
29389
  var isDev = false;
29396
29390
  if (typeof window !== 'undefined') {
@@ -29415,7 +29409,7 @@ var SceneOperationsManager = /*#__PURE__*/function () {
29415
29409
  // Change from "SEGMENT-X" to "Segment-X" (capital S to lowercase s)
29416
29410
  var segmentIndex = segment.userData.segmentIndex;
29417
29411
  var oldUuid = segment.uuid;
29418
- segment.uuid = "Segment-".concat(segmentIndex);
29412
+ segment.uuid = "SEGMENT-".concat(segmentIndex);
29419
29413
  console.log("\uD83D\uDD27 Renamed segment UUID from ".concat(oldUuid, " to: ").concat(segment.uuid));
29420
29414
 
29421
29415
  // Calculate segment endpoints in world coordinates
@@ -29672,147 +29666,6 @@ var SceneOperationsManager = /*#__PURE__*/function () {
29672
29666
  }
29673
29667
  console.log("\u2705 Gateway ".concat(gateway.uuid, " successfully converted to manual (declared)"));
29674
29668
  }
29675
-
29676
- /**
29677
- * Split a segment by manualizing it and shortening it by 0.5 units
29678
- * The segment gets converted to a declared (manual) segment with connectors,
29679
- * and is shortened from the end that has a component connector (or the end if no connectors)
29680
- * @param {string|THREE.Object3D} segmentIdOrObject - The UUID or Three.js object of the segment to split
29681
- * @param {Object} currentSceneData - Current scene data with connections
29682
- * @returns {THREE.Object3D|null} The shortened manual segment or null on failure
29683
- */
29684
- }, {
29685
- key: "splitSegment",
29686
- value: function splitSegment(segmentIdOrObject, currentSceneData) {
29687
- var _segment$userData3,
29688
- _this6 = this;
29689
- console.log('âœ‚ī¸ splitSegment started:', segmentIdOrObject);
29690
-
29691
- // Find the segment object
29692
- var segment = null;
29693
- if (typeof segmentIdOrObject === 'string') {
29694
- this.sceneViewer.scene.traverse(function (child) {
29695
- var _child$userData10;
29696
- if (child.uuid === segmentIdOrObject || ((_child$userData10 = child.userData) === null || _child$userData10 === void 0 ? void 0 : _child$userData10.originalUuid) === segmentIdOrObject) {
29697
- segment = child;
29698
- }
29699
- });
29700
- } else if (segmentIdOrObject && segmentIdOrObject.isObject3D) {
29701
- segment = segmentIdOrObject;
29702
- }
29703
-
29704
- // Validate segment
29705
- if (!segment || ((_segment$userData3 = segment.userData) === null || _segment$userData3 === void 0 ? void 0 : _segment$userData3.objectType) !== 'segment') {
29706
- console.error('❌ splitSegment(): Invalid segment or not found');
29707
- return null;
29708
- }
29709
- if (!currentSceneData) {
29710
- console.error('❌ splitSegment(): currentSceneData is required');
29711
- return null;
29712
- }
29713
- console.log('âœ‚ī¸ Splitting/shortening segment:', segment.uuid);
29714
-
29715
- // Get segment geometry to calculate endpoints
29716
- var geometry = segment.geometry;
29717
- if (!geometry || !geometry.parameters) {
29718
- console.error('❌ splitSegment(): Segment has invalid geometry');
29719
- return null;
29720
- }
29721
- var segmentLength = geometry.parameters.height || 1;
29722
- var segmentRadius = geometry.parameters.radiusTop || 0.1;
29723
- var shortenAmount = 0.5;
29724
- var newLength = segmentLength - shortenAmount;
29725
- if (newLength <= 0) {
29726
- console.error('❌ splitSegment(): Segment too short to shorten by 0.5');
29727
- return null;
29728
- }
29729
-
29730
- // Calculate segment direction vector
29731
- var direction = new THREE__namespace.Vector3(0, 1, 0);
29732
- direction.applyQuaternion(segment.quaternion);
29733
- direction.normalize();
29734
-
29735
- // Calculate original segment endpoints
29736
- var startPoint = new THREE__namespace.Vector3();
29737
- startPoint.copy(segment.position).sub(direction.clone().multiplyScalar(segmentLength / 2));
29738
- var endPoint = new THREE__namespace.Vector3();
29739
- endPoint.copy(segment.position).add(direction.clone().multiplyScalar(segmentLength / 2));
29740
-
29741
- // Check for component connectors at endpoints
29742
- var findConnectorsAtPosition = function findConnectorsAtPosition(position) {
29743
- var tolerance = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0.15;
29744
- var connectors = [];
29745
- _this6.sceneViewer.scene.traverse(function (child) {
29746
- var _child$userData11;
29747
- if (((_child$userData11 = child.userData) === null || _child$userData11 === void 0 ? void 0 : _child$userData11.objectType) === 'connector') {
29748
- var connectorWorldPos = new THREE__namespace.Vector3();
29749
- child.getWorldPosition(connectorWorldPos);
29750
- var distance = connectorWorldPos.distanceTo(position);
29751
- if (distance <= tolerance) {
29752
- connectors.push(child);
29753
- }
29754
- }
29755
- });
29756
- return connectors.filter(function (c) {
29757
- var _c$userData;
29758
- return ((_c$userData = c.userData) === null || _c$userData === void 0 ? void 0 : _c$userData.objectType) !== 'segment-connector';
29759
- });
29760
- };
29761
- var startConnectors = findConnectorsAtPosition(startPoint);
29762
- var endConnectors = findConnectorsAtPosition(endPoint);
29763
-
29764
- // Determine which end to shorten from
29765
- var newStartPoint, newEndPoint;
29766
- if (endConnectors.length > 0) {
29767
- // Component connector at end - shorten from end
29768
- newStartPoint = startPoint.clone();
29769
- newEndPoint = endPoint.clone().sub(direction.clone().multiplyScalar(shortenAmount));
29770
- console.log("\uD83D\uDCCD Component connector at END - shortening from end by ".concat(shortenAmount));
29771
- } else if (startConnectors.length > 0) {
29772
- // Component connector at start - shorten from start
29773
- newStartPoint = startPoint.clone().add(direction.clone().multiplyScalar(shortenAmount));
29774
- newEndPoint = endPoint.clone();
29775
- console.log("\uD83D\uDCCD Component connector at START - shortening from start by ".concat(shortenAmount));
29776
- } else {
29777
- // No component connectors - shorten from end (default)
29778
- newStartPoint = startPoint.clone();
29779
- newEndPoint = endPoint.clone().sub(direction.clone().multiplyScalar(shortenAmount));
29780
- console.log("\uD83D\uDCCD No component connectors - shortening from end by ".concat(shortenAmount));
29781
- }
29782
- console.log('📍 Segment shortening:', {
29783
- originalStart: startPoint.toArray(),
29784
- originalEnd: endPoint.toArray(),
29785
- newStart: newStartPoint.toArray(),
29786
- newEnd: newEndPoint.toArray(),
29787
- originalLength: segmentLength,
29788
- newLength: newLength,
29789
- shortenAmount: shortenAmount
29790
- });
29791
-
29792
- // Get material from existing segment
29793
- segment.material;
29794
-
29795
- // Dispose old geometry and create new shortened geometry
29796
- if (segment.geometry) {
29797
- segment.geometry.dispose();
29798
- }
29799
- var newGeometry = new THREE__namespace.CylinderGeometry(segmentRadius, segmentRadius, newLength, 16, 1, false);
29800
- segment.geometry = newGeometry;
29801
-
29802
- // Reposition the segment to the new center
29803
- var newPosition = new THREE__namespace.Vector3();
29804
- newPosition.lerpVectors(newStartPoint, newEndPoint, 0.5);
29805
- segment.position.copy(newPosition);
29806
- // Quaternion stays the same
29807
-
29808
- console.log('✅ Segment geometry updated and repositioned');
29809
-
29810
- // Now manualize the shortened segment
29811
- console.log('🔧 Manualizing the shortened segment...');
29812
- this.manualizeSegment(segment, currentSceneData);
29813
- console.log('✅ Segment split completed successfully - segment shortened and manualized');
29814
- return segment;
29815
- }
29816
29669
  }]);
29817
29670
  }();
29818
29671
 
@@ -33756,7 +33609,7 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
33756
33609
  * Initialize the CentralPlant manager
33757
33610
  *
33758
33611
  * @constructor
33759
- * @version 0.1.49
33612
+ * @version 0.1.51
33760
33613
  * @updated 2025-10-22
33761
33614
  *
33762
33615
  * @description Creates a new CentralPlant instance and initializes internal managers and utilities.
@@ -34061,51 +33914,6 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
34061
33914
  return this.internals.translateGateway(gatewayId, axis, value);
34062
33915
  }
34063
33916
 
34064
- /**
34065
- * Split a pipe segment by shortening it by 0.5 units and manualizing it
34066
- * @param {string} segmentId - The UUID of the segment to split
34067
- * @returns {THREE.Object3D|null} The shortened manual segment or null on failure
34068
- * @description Shortens a selected pipe segment by 0.5 units and converts it to
34069
- * manual/declared status with connectors. The segment is shortened from the end that
34070
- * has a component connector (or from the end if no connectors are present).
34071
- * The segment becomes transformable after this operation. Paths are regenerated
34072
- * to ensure proper connections.
34073
- * @example
34074
- * // Split/shorten a segment when selected via transform controls
34075
- * const result = centralPlant.splitSegment('SEGMENT-12345');
34076
- * if (result) {
34077
- * console.log('Segment shortened and manualized:', result.uuid);
34078
- * }
34079
- *
34080
- * @since 0.1.37
34081
- */
34082
- }, {
34083
- key: "splitSegment",
34084
- value: function splitSegment(segmentId) {
34085
- var _this$sceneViewer$man;
34086
- if (!this.sceneViewer || !((_this$sceneViewer$man = this.sceneViewer.managers) !== null && _this$sceneViewer$man !== void 0 && _this$sceneViewer$man.sceneOperationsManager)) {
34087
- console.warn('âš ī¸ splitSegment(): Scene viewer or scene operations manager not available');
34088
- return null;
34089
- }
34090
- if (!segmentId) {
34091
- console.error('❌ splitSegment(): No segment ID provided');
34092
- return null;
34093
- }
34094
- try {
34095
- var result = this.sceneViewer.managers.sceneOperationsManager.splitSegment(segmentId, this.sceneViewer.currentSceneData);
34096
- if (result) {
34097
- console.log('✅ splitSegment(): Segment split successfully');
34098
- return result;
34099
- } else {
34100
- console.warn('âš ī¸ splitSegment(): Split operation returned null');
34101
- return null;
34102
- }
34103
- } catch (error) {
34104
- console.error('❌ splitSegment(): Error splitting segment:', error);
34105
- return null;
34106
- }
34107
- }
34108
-
34109
33917
  /**
34110
33918
  * Rotate a component by componentId
34111
33919
  * @param {string} componentId - The UUID of the component to rotate
@@ -35387,8 +35195,8 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
35387
35195
  }, {
35388
35196
  key: "generatePath",
35389
35197
  value: function generatePath(fromConnectorId, toConnectorId) {
35390
- var _this$sceneViewer$man2;
35391
- if (!this.sceneViewer || !((_this$sceneViewer$man2 = this.sceneViewer.managers) !== null && _this$sceneViewer$man2 !== void 0 && _this$sceneViewer$man2.pathfinding)) {
35198
+ var _this$sceneViewer$man;
35199
+ if (!this.sceneViewer || !((_this$sceneViewer$man = this.sceneViewer.managers) !== null && _this$sceneViewer$man !== void 0 && _this$sceneViewer$man.pathfinding)) {
35392
35200
  return null;
35393
35201
  }
35394
35202
  try {