Created
March 4, 2019 14:45
-
-
Save giln/85f0eaae5ad9d34d276c448ddaf30446 to your computer and use it in GitHub Desktop.
BallNode
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 BallNode: SCNNode { | |
// MARK: - Lifecycle | |
public convenience init(radius: CGFloat) { | |
self.init() | |
let sphere = SCNSphere(radius: radius) | |
// We create a Physically Based Rendering material | |
let reflectiveMaterial = SCNMaterial() | |
reflectiveMaterial.lightingModel = .physicallyBased | |
// We want our ball to look metallic | |
reflectiveMaterial.metalness.contents = 1.0 | |
// And shiny | |
reflectiveMaterial.roughness.contents = 0.0 | |
sphere.firstMaterial = reflectiveMaterial | |
self.geometry = sphere | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment