在WPF 3D中旋转360度

syn*_*pis 5 c# 3d wpf animation rotation

我有一个立方体的ModelVisual3D,我想动画它围绕其轴旋转360度.我制作了一个RoationTransform3D,我告诉它旋转360但它根本不旋转,如果你说270度它只旋转90度但反方向旋转.我猜他计算机计算旋转的"最短路径".我想出的最好的解决方案是让一个动画转180,然后在它完成后再调用180以完成完整的旋转.有没有办法在一个动画中做到这一点?

RotateTransform3D rotateTransform = new RotateTransform3D();
myCube.Model.Transform = rotateTransform;

AxisAngleRotation3D rotateAxis =
      new AxisAngleRotation3D(new Vector3D(0, 1, 0), 180/*or 360*/);
Rotation3DAnimation rotateAnimation =
      new Rotation3DAnimation(rotateAxis, TimeSpan.FromSeconds(2));

rotateTransform.BeginAnimation(RotateTransform3D.RotationProperty,
      rotateAnimation);
Run Code Online (Sandbox Code Playgroud)

Jas*_*dez 3

我的理解是,Rotation3DAnimation 使用球面线性插值,因此它总是会找到最短路径。

一种解决方法是使用 Rotation3DAnimationUsingKeyFrames:将关键帧设置为 120、240 和 360,应该就可以了。

抱歉,现在没有代码,我这台机器上没有 WPF...

-杰森