C#で3Dオブジェクトを操作していますが、立方体をアニメーション化して独自の軸を中心に回転させようとして立ち往生しています。さらに、回転の方向を制御し、アニメーションを一時停止できる必要があります。
私の現在のアプローチは、ストーリーボードを作成し、XAMLで定義されている「キューブ」オブジェクトにアクセスしようとすることですが、役に立ちません。誰かが私が間違っていることを指摘できますか?
this.RegisterName("cube", cube);
myStoryboard = new Storyboard();
RotateTransform3D myRotateTransform = new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(0, 1, 0), 0));
Rotation3DAnimation myRotationAnimation = new Rotation3DAnimation(Rotation,AnimationSpeed);
myRotationAnimation.RepeatBehavior = RepeatBehavior.Forever;
myRotateTransform.Rotation.BeginAnimation(AxisAngleRotation3D.AxisProperty, myVectorAnimation);
myStoryboard.Children.Add(myRotationAnimation);
Storyboard.SetTargetName(myRotationAnimation, "cube");
Storyboard.SetTarget(myRotationAnimation,cube.Transform);
myStoryboard.Begin();
このコードがもたらすエラーは次のとおりです。
Cannot animate '(0)' on an immutable object instance.