Skip to content

Instantly share code, notes, and snippets.

@PaulWall43
Created April 22, 2018 22:48
Show Gist options
  • Save PaulWall43/71a75083cfa55d01799ef889e59d60a8 to your computer and use it in GitHub Desktop.
Save PaulWall43/71a75083cfa55d01799ef889e59d60a8 to your computer and use it in GitHub Desktop.
//After running the session we add a light node to help the scene look a little better
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
//Create light object
let light = SCNLight()
//Set type to be ambient
light.type = .ambient
//Create corresponding node for light so we can add this into the scene graph
let ambientLightNode = SCNNode()
//Set position (won't change over course of session run). Note that position doens't matter for ambient light.
ambientLightNode.position = SCNVector3(0,5,0)
//Add our light object to the node
ambientLightNode.light = light
//Add node to scene graph and tada we have ambient light.
sceneView.scene.rootNode.addChildNode(ambientLightNode)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment