Skip to content

Instantly share code, notes, and snippets.

@giln
Created March 4, 2019 14:45
Show Gist options
  • Save giln/85f0eaae5ad9d34d276c448ddaf30446 to your computer and use it in GitHub Desktop.
Save giln/85f0eaae5ad9d34d276c448ddaf30446 to your computer and use it in GitHub Desktop.
BallNode
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