Skip to content

Instantly share code, notes, and snippets.

@giln
Created March 4, 2019 14:48
Show Gist options
  • Save giln/10fe27bf38f1880ca8c5ea150a8cd65a to your computer and use it in GitHub Desktop.
Save giln/10fe27bf38f1880ca8c5ea150a8cd65a to your computer and use it in GitHub Desktop.
SpotlightNode
import SceneKit
public class SpotlightNode: SCNNode {
// MARK: - Lifecycle
public override init() {
super.init()
commonInit()
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
commonInit()
}
private func commonInit() {
let spotLight = SCNLight()
// used to cast shadows
spotLight.type = .directional
spotLight.shadowMode = .deferred
spotLight.castsShadow = true
spotLight.shadowRadius = 100.0
spotLight.shadowColor = UIColor(red: 0.0, green: 0.0, blue: 0.0, alpha: 0.2)
light = spotLight
// Light is pointing toward the ground
eulerAngles = SCNVector3(-Float.pi / 2, 0, 0)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment