Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Swift transposed version of a different color approach on all sides of a `SCNBox` (https://stackoverflow.com/a/27509866/856336)
/// Generate `SCNMaterial` that is the specified color
func material(withColor color : UIColor) -> SCNMaterial {
let material = SCNMaterial();
material.diffuse.contents = color
material.locksAmbientWithDiffuse = true
return material
}
let greenMaterial = material(withColor: UIColor.green)
let redMaterial = material(withColor: UIColor.red)
let blueMaterial = material(withColor: UIColor.blue)
let yellowMaterial = material(withColor: UIColor.yellow)
let purpleMaterial = material(withColor: UIColor.purple)
let magentaMaterial = material(withColor: UIColor.magenta)
cube.materials = [greenMaterial, redMaterial, blueMaterial, yellowMaterial, purpleMaterial, magentaMaterial];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.