Created
March 4, 2019 14:48
-
-
Save giln/10fe27bf38f1880ca8c5ea150a8cd65a to your computer and use it in GitHub Desktop.
SpotlightNode
This file contains hidden or 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
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