diff --git a/src/UI/WPF/ViewModels/AnimationControlViewModel.cs b/src/UI/WPF/ViewModels/AnimationControlViewModel.cs index 1979276..4e8473a 100644 --- a/src/UI/WPF/ViewModels/AnimationControlViewModel.cs +++ b/src/UI/WPF/ViewModels/AnimationControlViewModel.cs @@ -2299,6 +2299,34 @@ namespace NavisworksTransport.UI.WPF.ViewModels else if (d < -0.9999f) overrideQ = Quaternion.CreateFromAxisAngle(Vector3.UnitX, (float)Math.PI); else overrideQ = Quaternion.CreateFromAxisAngle(Vector3.Normalize(Vector3.Cross(cadWorldN, t)), (float)Math.Acos(d)); + // 路径 yaw 补偿 + var routePoints = CurrentPathRoute?.Points; + if ((CurrentPathRoute?.PathType == PathType.Ground || CurrentPathRoute?.PathType == PathType.Hoisting) + && routePoints != null && routePoints.Count >= 2) + { + // 照抄 TryResolveStartPathDirection 的取点方式 + var start = routePoints[0]; + var startVector = new Vector3((float)start.X, (float)start.Y, (float)start.Z); + Vector3 hostForward = Vector3.Zero; + for (int i = 1; i < routePoints.Count; i++) + { + var point = routePoints[i]; + var candidate = new Vector3((float)point.X, (float)point.Y, (float)point.Z) - startVector; + if (candidate.LengthSquared() > 1e-8f) + { + hostForward = candidate; + break; + } + } + if (hostForward.LengthSquared() > 1e-8f + && PathTargetFrameResolver.TryResolvePlanarHostYaw( + hostForward, CoordinateSystemManager.Instance.ResolvedType, out double yawRadians)) + { + overrideQ = Quaternion.Normalize( + Quaternion.CreateFromAxisAngle(adapter.HostUpVector3, (float)yawRadians) * overrideQ); + } + } + var center = item.BoundingBox().Center; var tp = new Vector3((float)center.X, (float)center.Y, (float)center.Z); var rtp = Vector3.Transform(tp, overrideQ);