I have a few shapes made created using blender, how can I change their color dynamically. I've tried this from another question but it didn't work:
newNode.geometry?.firstMaterial?.diffuse.contents = UIColor(red: 0.3, green: 0.5, blue: 0.4, alpha: 1 )
in this case newNode is a child node:
newNode=newNodeScene.rootNode.childNode(withName:"test3 reference", recursively:true)
how can I change it? Maybe it needs an override and if so how? Thanks for your time
i just tried just the "basic scenario" -> created a box in Blender with a color, exported as .dae, imported in scnassets and converted it to a scene and started it with this code. It just works. But this is just a simple test...maybe you added a texture or something else so it would be a good idea if you give us more details.
let scene2 = SCNScene(named: "art.scnassets/coloredbox.scn")!
scnView.scene = scene2
if let box = scene2.rootNode.childNode(withName: "Cube", recursively: true) {
box.geometry?.firstMaterial?.diffuse.contents = UIColor.yellow
}
}