I create a model (cube) and add that to my viewport and it works properly without any problem.
this.mainViewport.Children.Add(model);
whenever I use the following code, the cube become black instead of it's original color.
this.mainViewport.Children.Clear(); this.mainViewport.Children.Add(model);
I need to clear the viewport as I am adding the cube in another position in next second. any suggestion to solve that problem would be highly appreciated.
I would do something like this instead : Create the Cube first time in it start location :
ModelVisual3D model = new ModelVisual3D();
model.Content = cube;
Then in the timer I would change the Transform wit the new location:
model.Transform = new TranslateTransform3D(X, Y, Z); // model need to be a field in your class
The other available transorms are :
ScaleTransform3D
RotateTransform3D
MatrixTransform3D
Transform3DGroup