AnimationView
An animation that represents a variation of another animation.
Declaration
struct AnimationViewOverview
This structure creates a variation of an existing animation by overriding its configuration. The term view in the name signifies that the variation represents a new visual perspective of the existing animation.
Create a clip of an animation
By supplying a new beginning time (trimStart) and ending time (trimEnd), the following code creates a shorter clip of an existing animation. With trimStart set to 1.0 and trimEnd at 2.0, the clip spans a one-second duration.
// Create or access an existing animation.
let anim1 = FromToByAnimation<Float>(name: "Anim1",
from: 100.0, to: 200.0, duration: 10.0)
// Use a view to create a clip of the original animation.
let view = AnimationView(source: anim1,
name: "clip",
bindTarget: nil,
blendLayer: 0,
repeatMode: .autoReverse,
fillMode: [],
trimStart: 1.0,
trimEnd: 2.0,
trimDuration: nil,
offset: 0,
delay: 0,
speed: 1.0)
// Create an animation resource from the clip.
clipResource = try? AnimationResource.generate(with: view)
// Play the clip.
myModelEntity.playAnimation(clipResource)Define a view in relation to the animation source
The source animation’s timing properties define a timeline on which the trimDuration, delay, and speed properties operate to derive the view. The trimDuration property specifies which animation data the view displays. If trimDuration exceeds the length of the source animation’s timeline, the animation plays according to the characteristics of repeatMode. The delay property defines a waiting period before the animation begins, and the speed determines how fast the view plays in relation to the original pace.