Animate color property of SphereVisual3D's material.brush

Jul 3, 2013 at 7:52 PM
Edited Jul 3, 2013 at 7:53 PM

I'm trying to animate the Brush.ColorProperty of the DiffuseMaterial assigned to a SphereVisual3D object in code, but am not having any success. I'd appreciate any suggestions anyone can offer.

In the class constructor:
            targetModel = new SphereVisual3D();

            targetModel.Center = new Point3D(0,0,0);
            targetModel.Radius = 3;
            targetModel.Material = FindResource("TargetMaterial") as Material;
Later, as a response to a button press:
                ColorAnimation myColorAnimation = new ColorAnimation();
                myColorAnimation.To = Colors.Red;
                myColorAnimation.BeginTime = TimeSpan.FromSeconds(0);
                myColorAnimation.Duration = TimeSpan.FromSeconds(.5);
                myColorAnimation.FillBehavior = FillBehavior.HoldEnd;

                DiffuseMaterial material = targetModel.Model.Material as DiffuseMaterial;
                Storyboard.SetTarget(myColorAnimation, material.Brush);
                Storyboard.SetTargetProperty(myColorAnimation, new PropertyPath(SolidColorBrush.ColorProperty));

                Storyboard myStoryboard = new Storyboard();
                myStoryboard.Duration = TimeSpan.FromSeconds(3);
                myStoryboard.RepeatBehavior = RepeatBehavior.Forever;
BTW - I was able to successfully animate the SphereVisual3D's radius property, but I have not been successful at it's material brush color property.
Jul 3, 2013 at 8:21 PM
Forgot to mention... Great toolkit! Thanks for your hard work!