Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/108.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/asp.net-mvc-3/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 设置着色器值的动画_Ios_Swift_Animation_Glsl_Scenekit - Fatal编程技术网

Ios 设置着色器值的动画

Ios 设置着色器值的动画,ios,swift,animation,glsl,scenekit,Ios,Swift,Animation,Glsl,Scenekit,使用@rickster在本文中给出的解决方案:,我尝试在fadeFactor上实现一个动画。我尝试了很多事情,但没有一件像预期的那样有效 以下是我的一些代码: 对于着色器: “统一浮点fadeFactor;” 迅速: let anim = CABasicAnimation(keyPath: "fadeFactor") anim.fromValue = NSNumber(value: 0.0) anim.toValue = NSNumber(value: 1.0) anim.duration =

使用@rickster在本文中给出的解决方案:,我尝试在fadeFactor上实现一个动画。我尝试了很多事情,但没有一件像预期的那样有效

以下是我的一些代码:

  • 对于着色器:

    “统一浮点fadeFactor;”

  • 迅速:

    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")
    
执行代码时,fadeFactor属性上没有动画。 我做错了什么?
在CABasicAnimation中,我尝试了不同的键路径值:geometry.firstMaterial.diffuse.contents、fadeFactor等 我找不到必须为参数'keyPath''forKey'指定的值

当我使用setValue函数更改fadeFactor的值时,可以:

node.geometry?.firstMaterial?.setValue(NSNumber(value: 0.5), forKey: "fadeFactor")
如果没有人有解决方案或能给我举个例子,那就太好了


提前感谢。

好的,最后是清理项目后的工作

Project->Clean Build Folder

好的,最后是清理项目后的工作
项目->清理生成文件夹