Note that there are some explanatory texts on larger screens.

plurals
  1. POPausing a SceneKit animation
    primarykey
    data
    text
    <p>I'm trying to create a test app in which the user can pause an animation by clicking in the SceneView. The SceneView loads the animation from a .dae file created in a 3d app (Cinema 4D). The app successfully plays and loops the animation upon launch.</p> <p>To pause the animation, I used <a href="https://developer.apple.com/library/ios/#qa/qa2009/qa1673.html" rel="nofollow">Technical Q&amp;A QA1673</a> as a reference. In the case of this .dae file, the animation actually comes in as a hierarchy of animations, so I have tried reaching down to each underlying CAKeyframeAnimation and setting its speed to zero. My code currently looks like this:</p> <pre><code>- (void)mouseDown:(NSEvent *)event { SCNNode *cubeNode = [self.scene.rootNode childNodeWithName:@"C4D_Cube" recursively:YES]; CAAnimation *cubeAnimation = [cubeNode animationForKey:@"Cube_Anim_01-02-1"]; CAAnimationGroup *cubeAnimationGroup = (CAAnimationGroup *)cubeAnimation; // cubeAnimationGroup contains 3 CAAnimationGroups, each of which contains a CAKeyframeAnimation. // So I directly access each CAKeyframeAnimation and set its speed to zero. for (CAAnimationGroup *subGroup in [cubeAnimationGroup animations]) { CFTimeInterval pausedTime = CACurrentMediaTime(); [[subGroup animations] setValue:@0.0 forKey:@"speed"]; [[subGroup animations] setValue:[NSNumber numberWithFloat:pausedTime] forKey:@"timeOffset"]; } } </code></pre> <p>When I set a breakpoint, I can see that the speed of the keyframe animations does change from 1 to 0, but the animation continues to play at its normal speed in the scene view. I originally tried just setting the speed on the top level CAAnimationGroup to zero, but this also had no effect. What's the correct way to pause an animation in progress?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload