0

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.

1 Answer 1

2

OK, finally that's work after make a clean of the project !!!
Project -> Clean Build Folder

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.