Created
August 31, 2017 19:34
-
-
Save mattrobmattrob/e934d664ef0fc8d45b7837d9eb797255 to your computer and use it in GitHub Desktop.
Swift transposed version of a different color approach on all sides of a `SCNBox` (https://stackoverflow.com/a/27509866/856336)
This file contains 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
/// 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