diff --git a/src/Core/Animation/PathAnimationManager.cs b/src/Core/Animation/PathAnimationManager.cs
index c002ea8..f1ca830 100644
--- a/src/Core/Animation/PathAnimationManager.cs
+++ b/src/Core/Animation/PathAnimationManager.cs
@@ -461,6 +461,32 @@ namespace NavisworksTransport.Core.Animation
doc.Models.OverridePermanentTransform(modelItems, comp.Combine(), false);
}
+ ///
+ /// 直接用四元数绕物体包围盒中心旋转(增量模式)。
+ /// 用于贴地面等不需要走 Euler 角度链的场景。
+ ///
+ public void ApplyQuaternionRotationInPlace(Quaternion rotation)
+ {
+ var item = CurrentControlledObject;
+ if (item == null) return;
+
+ var modelItems = new ModelItemCollection { item };
+ var doc = NavisApplication.ActiveDocument;
+
+ var center = GetLiveBoundingBoxCenter(item);
+ var tp = new Vector3((float)center.X, (float)center.Y, (float)center.Z);
+ var rotatedTp = Vector3.Transform(tp, rotation);
+
+ var identity = Transform3D.CreateTranslation(new Vector3D(0, 0, 0));
+ var comp = identity.Factor();
+ comp.Rotation = new Rotation3D(rotation.X, rotation.Y, rotation.Z, rotation.W);
+ comp.Translation = new Vector3D(
+ center.X - rotatedTp.X,
+ center.Y - rotatedTp.Y,
+ center.Z - rotatedTp.Z);
+ doc.Models.OverridePermanentTransform(modelItems, comp.Combine(), false);
+ }
+
///
/// 将当前显示姿态同步为跟踪状态(yaw=0 对应对齐 X 轴)。
/// 用于自动调整确认前,替代 RestoreObjectToCADPosition 的复位→设置链路。
diff --git a/src/UI/WPF/ViewModels/AnimationControlViewModel.cs b/src/UI/WPF/ViewModels/AnimationControlViewModel.cs
index 83a0b73..4a6efb1 100644
--- a/src/UI/WPF/ViewModels/AnimationControlViewModel.cs
+++ b/src/UI/WPF/ViewModels/AnimationControlViewModel.cs
@@ -2316,20 +2316,8 @@ namespace NavisworksTransport.UI.WPF.ViewModels
rotation = Quaternion.CreateFromAxisAngle(axis, angle);
}
- // 绕物体中心增量旋转
- var modelItem = _pathAnimationManager.AnimatedObject;
- var modelItems = new ModelItemCollection { modelItem };
- var center = modelItem.BoundingBox().Center;
- var toOrigin = Autodesk.Navisworks.Api.Transform3D.CreateTranslation(
- new Vector3D(-center.X, -center.Y, -center.Z));
- var rotate = new Autodesk.Navisworks.Api.Transform3D(
- new Rotation3D(rotation.X, rotation.Y, rotation.Z, rotation.W));
- var fromOrigin = Autodesk.Navisworks.Api.Transform3D.CreateTranslation(
- new Vector3D(center.X, center.Y, center.Z));
- var combined = Autodesk.Navisworks.Api.Transform3D.Multiply(
- Autodesk.Navisworks.Api.Transform3D.Multiply(fromOrigin, rotate), toOrigin);
- doc.Models.OverridePermanentTransform(modelItems, combined, false);
-
+ // 使用项目中已有的四元数旋转方法
+ _pathAnimationManager.ApplyQuaternionRotationInPlace(rotation);
_pathAnimationManager.SyncTrackedStateToCurrentDisplayPose();
UpdatePassageSpaceVisualization();