2
我有一个SceneKit SCNSceneRendererDelegate实现下面的方法:不可预知的SceneKit行为?
- (void) renderer:(id<SCNSceneRenderer>)renderer
didRenderScene:(SCNScene*)scene
atTime:(NSTimeInterval)time
{
static NSUInteger counter = 0 ;
counter++ ;
// Rotate via animation
if (counter==1)
{
SCNNode *man = [scene.rootNode childNodeWithName:@"Man" recursively:YES] ;
SCNNode *headBone = [man childNodeWithName:@"mixamorig_Head" recursively:YES] ;
CABasicAnimation *animation1 = [CABasicAnimation animationWithKeyPath:@"rotation"] ;
animation1.fromValue = [NSValue valueWithSCNVector4:headBone.rotation] ;
animation1.toValue = [NSValue valueWithSCNVector4:SCNVector4Make(0,1,0,M_PI_4)] ;
animation1.duration = 1.2 ;
animation1.fillMode = kCAFillModeForwards ;
animation1.removedOnCompletion = NO ;
[headBone addAnimation:animation1 forKey:@"rotationAnimation"] ;
}
}
显然,这只是旋转了45度,名为“mixamorig_Head”骨。
当我运行该程序时,我实际上可以看到头部旋转... 只有一次出来了2。
我唯一要做的就是点击XCode的运行按钮。节目开始并显示场景,头部旋转或不旋转。在运行之间没有代码更新,只需点击运行按钮即可。
我试图记录每个变量,并且一切都看起来正确。
任何想法为什么SceneKit行为可能会因一次跑到另一次而有所不同?
编辑 上传演示项目here。
在头不旋转的情况下,做头似乎有*已经旋转,还是看起来没有旋转过? –
它根本不动,仍然处于起始位置。 –
我不知道这个场景是否有时候没有完全初始化......你说你已经记录了几乎所有的东西---你是否证实在没有发生旋转的情况下man和headBone不是零? –