OrbitAnimation
An animation that revolves an entity around its origin.
Declaration
struct OrbitAnimationOverview
This class moves an entity in a circular path by gradually adjusting its local transform. The animation sets the entity’s initial position with startTransform and rotates it around the point (0, 0, 0). The axis specifies which cartesian axis around which to rotate. The full orbit completes after duration lapses.
If the target entity contains child entities, the target entity orbits the children.
Revolve an entity around its origin
The following code creates an animation that orbits an entity around the y-axis 3 times over 6 seconds.
let yAxis: SIMD3<Float> = [0, 1, 0]
let startingPosition: SIMD3<Float> = [0.25, 0, 0]
let orbit = OrbitAnimation(
name: "orbit",
duration: 6,
axis: yAxis,
startTransform: Transform(translation: startingPosition),
spinClockwise: false,
orientToPath: true,
rotationCount: 3,
bindTarget: .transform
)The newly created animation can be trimmed after creation, to last only 4 seconds.
// Create an animation clip that skips the first two seconds.
let trimmed = orbit.trimmed(start: 2)Use generate(with:) to convert OrbitAnimation to an AnimationResource that can be applied to your entity with playAnimation(_:transitionDuration:blendLayerOffset:separateAnimatedValue:startsPaused:clock:).