I have a ModelVisual3D. I would like to animate its position in a Viewport3D. I have gotten the code to work with a BoxVisual3D (from HelixToolkit), but the code doesn't work for my ModelVisual3D. The ModelVisual3D should translate along the X axis, but instead it just sits still.
I have essentially copied the working code for my BoxVisual3D to my ModelVisual3D. For now, I am just doing the OffsetX property, but later on I will need to have multiple properties on multiple ModelVisual3Ds animated at once, hence the storyboard.
this is the code that doesn't work:
Transform3DGroup modelTransformGroup = (Transform3DGroup)_myModel.Transform;
TranslateTransform3D curTransform = (TranslateTransform3D)modelTransformGroup.Children[1];
var moveX = new DoubleAnimation(0, 1000, TimeSpan.FromSeconds(5));
Storyboard.SetTarget(moveX, curTransform);
Storyboard.SetTargetProperty(moveX, new PropertyPath(TranslateTransform3D.OffsetXProperty));
var sb = new Storyboard();
sb.Children.Add(moveX);
sb.Begin();
Here is some code that works, but won't be sufficient since I need to synchronize many animations at once with the storyboard:
Transform3DGroup modelTransformGroup = (Transform3DGroup)_myModel.Transform;
TranslateTransform3D curTransform = (TranslateTransform3D)modelTransformGroup.Children[1];
var moveX = new DoubleAnimation(0, 1000, TimeSpan.FromSeconds(5));
curTransform.BeginAnimation(TranslateTransform3D.OffsetXProperty, moveX);
Thanks for your help!
Edit: I wanted to add that _myModel.Transform is set as a Transform3DGroup earlier in the code and that the first child is a RotationTransform3D and the second child is a TranslateTransform3D.