Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
SCNView view = new SCNView (View.Frame);
view.Scene = new SCNScene ();
var sphere = SCNSphere.Create (10);
var node = new SCNNode () { Geometry = sphere };
view.Scene.RootNode.Add (node);
view.AutoenablesDefaultLighting = true;
view.AllowsCameraControl = true;
sphere.FirstMaterial.Diffuse.ContentColor = NSColor.Blue;
Task.Factory.StartNew (() =>
{
for (int i = 0; i < 1000; ++i)
{
BeginInvokeOnMainThread (() =>
{
int x = (int)Math.Floor (i * 2.4);
if (i % 4 == 0)
sphere.FirstMaterial.Diffuse.ContentColor = NSColor.FromRgba (x, 0, 0, 192);
else if (i % 4 == 1)
sphere.FirstMaterial.Diffuse.ContentColor = NSColor.FromRgba (0, x, 0, 192);
else if (i % 4 == 2)
sphere.FirstMaterial.Diffuse.ContentColor = NSColor.FromRgba (0, 0, x, 192);
else
sphere.FirstMaterial.Diffuse.ContentColor = NSColor.FromRgba (x, x, x, 192);
});
System.Threading.Thread.Sleep (25);
}
GC.Collect (2);
});
View.AddSubview (view);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment