Last active
August 29, 2015 14:03
-
-
Save mikebluestein/f6a56e758fe307c25068 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace FSHelloSceneKit | |
open System | |
open MonoTouch.UIKit | |
open MonoTouch.Foundation | |
open MonoTouch.SceneKit | |
type FSHelloSceneKitViewController () = | |
inherit UIViewController() | |
let CreateDiffuseLightNode (color: UIColor, position: SCNVector3, lightType: NSString): SCNNode = | |
new SCNLight ( Color = color, LightType = lightType ) | |
|> fun lightNode -> new SCNNode ( Light = lightNode, Position = position ) | |
override this.ViewDidLoad () = | |
let scene = new SCNScene () | |
let view = new SCNView (this.View.Frame, Scene = scene, AutoresizingMask = UIViewAutoresizing.All, AllowsCameraControl = true) | |
new SCNCamera (XFov = 40.0, YFov = 40.0) | |
|> fun c -> new SCNNode (Camera = c, Position = new SCNVector3(0.0F, 0.0F, 40.0F)) | |
|> scene.RootNode.AddChildNode | |
let material = new SCNMaterial () | |
material.Diffuse.Contents <- UIImage.FromFile ("monkey.png") | |
material.Specular.Contents <- UIColor.White | |
new SCNNode( Geometry = SCNSphere.Create(10.0F), Position = new SCNVector3(0.0F, 0.0F, 0.0F) ) | |
|> fun node -> node.Geometry.FirstMaterial <- material; node | |
|> scene.RootNode.AddChildNode | |
new SCNLight ( LightType = SCNLightType.Ambient, Color = UIColor.Purple) | |
|> fun lightNode -> new SCNNode ( Light = lightNode ) | |
|> scene.RootNode.AddChildNode | |
[| | |
( UIColor.Blue, new SCNVector3 (-40.0F, 40.0F, 60.0F) ); | |
( UIColor.Yellow, new SCNVector3 (20.0F, 20.0F, -70.0F) ); | |
( UIColor.Red, new SCNVector3 (20.0F, -20.0F, 40.0F) ); | |
( UIColor.Green, new SCNVector3 (20.0F, -40.0F, 70.0F) ) | |
|] | |
|> Seq.map (fun (color, pos) -> CreateDiffuseLightNode(color, pos, SCNLightType.Omni)) | |
|> Seq.iter scene.RootNode.AddChildNode | |
this.View.Add(view) |
I dont like the lambda piping either, the functions are so short they can be inline as @duncanmak said.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Why use
|>
inCreateDiffuseLightNode
, couldn't it be a lot more straight-forward to write it like this?