在SceneKit中自定义可设置动画的属性

Nat*_*din 11 macos core-animation objective-c osx-mountain-lion scenekit

我知道可以在Core Animation中创建自定义的可动画属性,但在OS X 10.8的SceneKit框架中呢? SCNAnimatable似乎没有公开与CALayer使动画属性动画相同的API .

在我的应用程序中,我有一个SCNNode名为的子类Starfield,我通过使用一个从旧的OpenGL应用程序移植SCNNodeRendererDelegate.Starfields公开了一个GLfloat名为warpFactor:

@interface Starfield : SCNNode<SCNNodeRendererDelegate> {
    // other stuff that's not really important for this question
    GLfloat warpFactor;
}

@property(nonatomic) GLfloat warpFactor;
@end
Run Code Online (Sandbox Code Playgroud)

但是当我尝试添加动画时,就像这样:

CABasicAnimation *warp = [CABasicAnimation animationWithKeyPath:@"warpFactor"];
warp.toValue = @1.0;
warp.duration = 5.0;
[starfield addAnimation:warp forKey:@"warp"];
Run Code Online (Sandbox Code Playgroud)

我在控制台中得到以下内容:

[SCNKit ERROR] warpFactor is not an animatable path (from <unnamed SCNNode 0x1016473c0, no children>)
Run Code Online (Sandbox Code Playgroud)

我知道SceneKit是全新的,但有没有人碰巧知道如何使这项工作?

小智 -1

SceneKit 不支持自定义动画键路径