Skip to content

Instantly share code, notes, and snippets.

@chamons
Created October 19, 2016 17:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chamons/0e2e0e8e04e0725cf802b17cf21643c4 to your computer and use it in GitHub Desktop.
Save chamons/0e2e0e8e04e0725cf802b17cf21643c4 to your computer and use it in GitHub Desktop.
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