Contents

SCNAnimatable

The common interface for attaching animations to nodes, geometries, materials, and other SceneKit objects.

Declaration

protocol SCNAnimatable : NSObjectProtocol

Mentioned in

Overview

SceneKit uses the same architecture as the Core Animation framework, allowing you to animate property changes implicitly or explicitly. For implicit animation, use the SCNTransaction class to quickly create simple animations with very little code. For more complex animations, explicitly create CAAnimation objects, and use the methods in the SCNAnimatable protocol to attach them to the SceneKit objects you want to animate. You also use the methods in this protocol to control any animations already attached to a SceneKit object.

For example, making a node spin continuously for as long as it appears in the scene graph requires explicitly creating an animation that repeats. The following code creates such an animation and attaches it to a node:

CABasicAnimation *rotationAnimation = [CABasicAnimation animationWithKeyPath:@"rotation"];
// Animate one complete revolution around the node's Y axis.
rotationAnimation.toValue = [NSValue valueWithSCNVector4:SCNVector4Make(0, 1, 0, M_PI * 2)];
rotationAnimation.duration = 10.0; // One revolution in ten seconds.
rotationAnimation.repeatCount = FLT_MAX; // Repeat the animation forever.
[node addAnimation:rotationAnimation forKey:nil]; // Attach the animation to the node to start it.

Topics

Managing Animations

Pausing and Resuming Animations

Instance Methods

See Also

Explicit Animation