Protocol

SCNAnimatable

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

Declaration

@protocol SCNAnimatable

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

- addAnimation:forKey:

Adds an animation object for the specified key.

Required.

- animationForKey:

Returns the animation with the specified key.

Required.

Deprecated
animationKeys

An array containing the keys of all animations currently attached to the object.

Required.

- removeAllAnimations

Removes all the animations currently attached to the object.

Required.

- removeAnimationForKey:

Removes the animation attached to the object with the specified key.

Required.

- removeAnimationForKey:fadeOutDuration:

Removes the animation attached to the object with the specified key, smoothly transitioning out of the animation’s effect.

Required.

Deprecated

Pausing and Resuming Animations

- pauseAnimationForKey:

Pauses the animation attached to the object with the specified key.

Required.

Deprecated
- resumeAnimationForKey:

Resumes a previously paused animation attached to the object with the specified key.

Required.

Deprecated
- isAnimationForKeyPaused:

Returns a Boolean value indicating whether the animation attached to the object with the specified key is paused.

Required.

Deprecated

See Also

Explicit Animation

SCNAnimationEvent

A container for a block to be executed at a specific time during playback of an animation.