有人可以帮我找出为什么这不起作用:
var story = new Storyboard {Duration = TimeSpan.FromSeconds(10)};
var meshBuilder = new MeshBuilder();
meshBuilder.AddCone(new Point3D(0, 0, 0), new Vector3D(0, 0, 1), 15, 10, 50, false, false, 20);
var mesh = meshBuilder.ToMesh();
var geometryModel = new GeometryModel3D
{
Geometry = mesh,
Material = new DiffuseMaterial(new SolidColorBrush(Colors.DeepSkyBlue)),
BackMaterial = new DiffuseMaterial(new SolidColorBrush(Colors.LightBlue)),
};
var modelVisual = new ModelVisual3D { Content = geometryModel };
helixViewport.Children.Add(modelVisual);
var scaleAnimation = new DoubleAnimation
{
BeginTime = TimeSpan.FromSeconds(1),
From = 1,
To = 2,
Duration = new Duration(TimeSpan.FromSeconds(10))
};
var scaleTransform3D = new ScaleTransform3D(1, 1, 2);
var transform3DGroup = new Transform3DGroup();
transform3DGroup.Children.Add(scaleTransform3D);
modelVisual.Transform = transform3DGroup;
story.Children.Add(scaleAnimation);
Storyboard.SetTargetProperty(scaleAnimation, new PropertyPath(ScaleTransform3D.ScaleZProperty));
Storyboard.SetTarget(scaleAnimation, modelVisual);
story.Begin();
首先,我只是使用 HelixToolkit 创建一个圆锥体,然后我想对其进行缩放。动画将持续 10 秒,从第 1 秒开始,持续 10 秒。但是动画没有执行,视口只显示了缩放后的最终结果。 注意:这是整个代码的简化部分,实际代码将多个动画应用于多个模型,每个动画将在不同的时间开始。这就是为什么我想在这里使用故事板和 BeginTime。请帮我找出我做错了什么。