With a solution give by @rickster in this post : SceneKit - Crossfade material property textures, I try to implement an animation on fadeFactor. I try many things but nothing works as expected.
Here is some of my code :
For shader :
"uniform float fadeFactor;"In swift :
let anim = CABasicAnimation(keyPath: "fadeFactor") anim.fromValue = NSNumber(value: 0.0) anim.toValue = NSNumber(value: 1.0) anim.duration = duration anim.repeatCount = .infinity node.geometry?.firstMaterial?.addAnimation(anim, forKey: "fadeFactor")
When I execute my code, no animation on fadeFactor property.
What I'm doing wrong ?
In CABasicAnimation, I try different values for keyPath : geometry.firstMaterial.diffuse.contents, fadeFactor, etc.
I can't find which value I must give for parameters 'keyPath' and 'forKey' !
When I change value for fadeFactor with setValue function, it's OK :
node.geometry?.firstMaterial?.setValue(NSNumber(value: 0.5), forKey: "fadeFactor")
If somenone have a solution or can give me an example, it will be great.
Thanks in advance.