<!--
{
  "availability" : [
    "iOS: 15.0.0 -",
    "iPadOS: 15.0.0 -",
    "macCatalyst: 15.0.0 -",
    "macOS: 12.0.0 -",
    "tvOS: 26.0.0 -",
    "visionOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "RealityKit",
  "identifier" : "/documentation/RealityKit/OrbitAnimation",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "RealityKit"
    ],
    "preciseIdentifier" : "s:17RealityFoundation14OrbitAnimationV"
  },
  "title" : "OrbitAnimation"
}
-->

# OrbitAnimation

An animation that revolves an entity around its origin.

```
struct OrbitAnimation
```

## Overview

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`](/documentation/RealityKit/OrbitAnimation/startTransform) and rotates it around the point `(0,` `0,`
`0)`. The [`axis`](/documentation/RealityKit/OrbitAnimation/axis) specifies which cartesian axis around
which to rotate. The full orbit completes after [`duration`](/documentation/RealityKit/OrbitAnimation/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.

```swift
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.

```swift
// Create an animation clip that skips the first two seconds.
let trimmed = orbit.trimmed(start: 2)
```

Use [`generate(with:)`](/documentation/RealityKit/AnimationResource/generate(with:)) to convert `OrbitAnimation`
to an [`AnimationResource`](/documentation/RealityKit/AnimationResource) that can be applied to your entity with [`playAnimation(_:transitionDuration:blendLayerOffset:separateAnimatedValue:startsPaused:clock:)`](/documentation/RealityKit/Entity/playAnimation(_:transitionDuration:blendLayerOffset:separateAnimatedValue:startsPaused:clock:)).

![A screen recording of a red cube in a living room scene. The cube is slightly offset from the center, and rotates around the y-axis twice at a rate of 1 rotation every 2 seconds.](videos/com.apple.RealityKit/orbitanimation-red-box~dark.mp4)

## Topics

### Creating an animation

[`init(name: String, duration: TimeInterval, axis: SIMD3<Float>, startTransform: Transform, spinClockwise: Bool, orientToPath: Bool, rotationCount: Float, bindTarget: BindTarget?, blendLayer: Int32, repeatMode: AnimationRepeatMode, fillMode: AnimationFillMode, isAdditive: Bool, trimStart: TimeInterval?, trimEnd: TimeInterval?, trimDuration: TimeInterval?, offset: TimeInterval, delay: TimeInterval, speed: Float)`](/documentation/RealityKit/OrbitAnimation/init(name:duration:axis:startTransform:spinClockwise:orientToPath:rotationCount:bindTarget:blendLayer:repeatMode:fillMode:isAdditive:trimStart:trimEnd:trimDuration:offset:delay:speed:))

Creates an animation that revolves an entity around its origin.

### Configuring the animation

[`var startTransform: Transform`](/documentation/RealityKit/OrbitAnimation/startTransform)

The pose of the orbiting object at the start of the animation.

[`var axis: SIMD3<Float>`](/documentation/RealityKit/OrbitAnimation/axis)

A 3D vector that points in the direction of the axis around which to
rotate.

[`var name: String`](/documentation/RealityKit/OrbitAnimation/name)

A textual name for the animation.

[`var bindTarget: BindTarget`](/documentation/RealityKit/OrbitAnimation/bindTarget)

A textual name that identifies the particular property that animates.

[`var blendLayer: Int32`](/documentation/RealityKit/OrbitAnimation/blendLayer)

The order in which the framework composites the animation.

[`var rotationCount: Float`](/documentation/RealityKit/OrbitAnimation/rotationCount)

The number of times to rotate the target entity before stopping.

[`var spinClockwise: Bool`](/documentation/RealityKit/OrbitAnimation/spinClockwise)

A Boolean value that indicates whether the object orbits the center
point in the clockwise direction.

[`var orientToPath: Bool`](/documentation/RealityKit/OrbitAnimation/orientToPath)

A Boolean value that indicates whether the orbiting object updates its
orientation during the animation to orient itself along the rotation
path.

[`var additive: Bool`](/documentation/RealityKit/OrbitAnimation/additive)

A Boolean value that indicates whether the animation builds on the
current state of the target entity or resets the state before running.

### Timing the animation

[`var speed: Float`](/documentation/RealityKit/OrbitAnimation/speed)

A factor that changes the animation’s rate of playback.

[`var delay: TimeInterval`](/documentation/RealityKit/OrbitAnimation/delay)

An amount of time that lapses before the animation plays.

[`var duration: TimeInterval`](/documentation/RealityKit/OrbitAnimation/duration)

The elapsed time for one complete rotation.

[`var offset: TimeInterval`](/documentation/RealityKit/OrbitAnimation/offset)

The time, in seconds, at which the animation begins within the duration.

[`var trimDuration: TimeInterval?`](/documentation/RealityKit/OrbitAnimation/trimDuration)

An optional duration that overrides the calculated duration.

[`var trimStart: TimeInterval?`](/documentation/RealityKit/OrbitAnimation/trimStart)

The optional time, in seconds, at which the animation plays.

[`var trimEnd: TimeInterval?`](/documentation/RealityKit/OrbitAnimation/trimEnd)

The optional time, in seconds, at which the animation stops.

### Repeating animation playback

[`var repeatMode: AnimationRepeatMode`](/documentation/RealityKit/OrbitAnimation/repeatMode)

An option that determines how the animation repeats.

[`var fillMode: AnimationFillMode`](/documentation/RealityKit/OrbitAnimation/fillMode)

An option that determines which data displays outside of the normal
duration.

## Relationships

### Conforms To

[`AnimationDefinition`](/documentation/RealityKit/AnimationDefinition)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)