I want to set a different image for each face of SCNNode
, how can I do it?
I've tried this but it didn't work and the first material was on all of the faces. I'm using Swift 4.2.
I've tried this:
self.addChildNode(playerNode!)
let head = playerNode?.childNode(withName: "head",
recursively: true)!
let greenMaterial = SCNMaterial()
greenMaterial.diffuse.contents = UIColor.green
greenMaterial.locksAmbientWithDiffuse = true;
let redMaterial = SCNMaterial()
redMaterial.diffuse.contents = UIColor.red
redMaterial.locksAmbientWithDiffuse = true;
let blueMaterial = SCNMaterial()
blueMaterial.diffuse.contents = UIColor.blue
blueMaterial.locksAmbientWithDiffuse = true;
let yellowMaterial = SCNMaterial()
yellowMaterial.diffuse.contents = UIColor.yellow
yellowMaterial.locksAmbientWithDiffuse = true;
let purpleMaterial = SCNMaterial()
purpleMaterial.diffuse.contents = UIColor.purple
purpleMaterial.locksAmbientWithDiffuse = true
let WhiteMaterial = SCNMaterial()
WhiteMaterial.diffuse.contents = UIColor.white
WhiteMaterial.locksAmbientWithDiffuse = true
head?.geometry?.materials = [redMaterial,
greenMaterial,
blueMaterial,
WhiteMaterial,
yellowMaterial,
purpleMaterial]