Skip to content

Instantly share code, notes, and snippets.

@eugenebokhan
Created March 2, 2018 11:59
Show Gist options
  • Save eugenebokhan/9967c96818a5d2f2d382e76222b87158 to your computer and use it in GitHub Desktop.
Save eugenebokhan/9967c96818a5d2f2d382e76222b87158 to your computer and use it in GitHub Desktop.
SCNMaterial extensions
extension SCNMaterial {
static func material(withDiffuse diffuse: Any?, respondsToLighting: Bool = true) -> SCNMaterial {
let material = SCNMaterial()
material.diffuse.contents = diffuse
material.isDoubleSided = true
if respondsToLighting {
material.locksAmbientWithDiffuse = true
} else {
material.ambient.contents = UIColor.black
material.lightingModel = .constant
material.emission.contents = diffuse
}
return material
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment