One Logo Pool Ball
RealityFoundation · IOS API REFERENCE

OrbitAnimation

struct · iOS 15.0+ · SDK 27.1

struct OrbitAnimation

An animation that revolves an entity around its origin. This class moves an entity in a circular path by gradually adjusting its local transform. The animation sets the entity's initial position with ``OrbitAnimation/startTransform`` and rotates it around the point `(0,` `0,` `0)`. The ``OrbitAnimation/axis`` specifies which cartesian axis around which to rotate. The full orbit completes after ``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 ``AnimationResource/generate(with:)`` to convert `OrbitAnimation` to an ``AnimationResource`` that can be applied to your entity with ``Entity/playAnimation(_:transitionDuration:blendLayerOffset:separateAnimatedValue:startsPaused:clock:)``. @Video( source: orbitanimation-red-box, alt: "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.", poster: orbitanimation-red-box-poster )

Members (37)

get · iOS 15.0+

bindTarget

TypeScript
get bindTarget(): BindTarget
Swift declaration
var bindTarget: BindTarget { get set }

A textual name that identifies the particular property that animates.

set · iOS 15.0+

bindTarget

TypeScript
set bindTarget(value: BindTarget)
Swift declaration
var bindTarget: BindTarget { get set }

A textual name that identifies the particular property that animates.

get · iOS 15.0+

blendLayer

TypeScript
get blendLayer(): number
Swift declaration
var blendLayer: Int32 { get set }

The order in which the framework composites the animation. The framework applies multiple animations on the same target in ascending order of this property’s value. Animations in a lower layer run before animations in a higher layer. Animations that share the same value apply in the order that they execute.

set · iOS 15.0+

blendLayer

TypeScript
set blendLayer(value: number)
Swift declaration
var blendLayer: Int32 { get set }

The order in which the framework composites the animation. The framework applies multiple animations on the same target in ascending order of this property’s value. Animations in a lower layer run before animations in a higher layer. Animations that share the same value apply in the order that they execute.

get · iOS 15.0+

repeatMode

TypeScript
get repeatMode(): AnimationRepeatMode
Swift declaration
var repeatMode: AnimationRepeatMode { get set }

An option that determines how the animation repeats. If you call ``OrbitAnimation/trimmed(start:end:duration:)`` with a `start` or `end` that lies outside of the timeline defined by ``OrbitAnimation/duration``, the animation fills the additional playback by applying this property.

set · iOS 15.0+

repeatMode

TypeScript
set repeatMode(value: AnimationRepeatMode)
Swift declaration
var repeatMode: AnimationRepeatMode { get set }

An option that determines how the animation repeats. If you call ``OrbitAnimation/trimmed(start:end:duration:)`` with a `start` or `end` that lies outside of the timeline defined by ``OrbitAnimation/duration``, the animation fills the additional playback by applying this property.

get · iOS 15.0+

orientToPath

TypeScript
get orientToPath(): boolean
Swift declaration
var orientToPath: Bool { get set }

A Boolean value that indicates whether the orbiting object updates its orientation during the animation to orient itself along the rotation path. The default value of this property is `false`.

set · iOS 15.0+

orientToPath

TypeScript
set orientToPath(value: boolean)
Swift declaration
var orientToPath: Bool { get set }

A Boolean value that indicates whether the orbiting object updates its orientation during the animation to orient itself along the rotation path. The default value of this property is `false`.

get · iOS 15.0+

trimDuration

TypeScript
get trimDuration(): (number) | null
Swift declaration
var trimDuration: TimeInterval? { get set }

An optional duration that overrides the calculated duration. The framework calculates ``OrbitAnimation/duration``, but you can set this property to override it. This property is `nil` by default, which indicates that the animation stops after one play that spans ``OrbitAnimation/duration``. If you set a non-zero value for this property and both ``OrbitAnimation/trimStart`` and ``OrbitAnimation/trimEnd`` are `nil`, the animation observes this property as an edited duration. When you set ``OrbitAnimation/repeatMode`` to make the animation repeat: - If this property is `nil`, the animation repeats forever. - If set to a value greater than ``OrbitAnimation/duration``, the animation repeats for the specified duration.

set · iOS 15.0+

trimDuration

TypeScript
set trimDuration(value: (number) | null)
Swift declaration
var trimDuration: TimeInterval? { get set }

An optional duration that overrides the calculated duration. The framework calculates ``OrbitAnimation/duration``, but you can set this property to override it. This property is `nil` by default, which indicates that the animation stops after one play that spans ``OrbitAnimation/duration``. If you set a non-zero value for this property and both ``OrbitAnimation/trimStart`` and ``OrbitAnimation/trimEnd`` are `nil`, the animation observes this property as an edited duration. When you set ``OrbitAnimation/repeatMode`` to make the animation repeat: - If this property is `nil`, the animation repeats forever. - If set to a value greater than ``OrbitAnimation/duration``, the animation repeats for the specified duration.

get · iOS 15.0+

rotationCount

TypeScript
get rotationCount(): number
Swift declaration
var rotationCount: Float { get set }

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

set · iOS 15.0+

rotationCount

TypeScript
set rotationCount(value: number)
Swift declaration
var rotationCount: Float { get set }

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

get · iOS 15.0+

spinClockwise

TypeScript
get spinClockwise(): boolean
Swift declaration
var spinClockwise: Bool { get set }

A Boolean value that indicates whether the object orbits the center point in the clockwise direction. The default value is `true`, which indicates that the rotation occurs in the clockwise direction. Set the value to `false` to cause the object to orbit the center point counterclockwise.

set · iOS 15.0+

spinClockwise

TypeScript
set spinClockwise(value: boolean)
Swift declaration
var spinClockwise: Bool { get set }

A Boolean value that indicates whether the object orbits the center point in the clockwise direction. The default value is `true`, which indicates that the rotation occurs in the clockwise direction. Set the value to `false` to cause the object to orbit the center point counterclockwise.

get · iOS 15.0+

startTransform

TypeScript
get startTransform(): Transform
Swift declaration
var startTransform: Transform { get set }

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

set · iOS 15.0+

startTransform

TypeScript
set startTransform(value: Transform)
Swift declaration
var startTransform: Transform { get set }

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

get · iOS 15.0+

axis

TypeScript
get axis(): SDKHandle
Swift declaration
var axis: SIMD3<Float> { get set }

A 3D vector that points in the direction of the axis around which to rotate. You can rotate an object around any axis. For example, if you set a `1` in the vector's x-coordinate, rotation occurs around the x-axis, as in the following code. ```swift orbitAnimation.axis = SIMD3<Float>(x: 1.0, y: 0.0, z: 0.0) ```

set · iOS 15.0+

axis

TypeScript
set axis(value: SDKHandle)
Swift declaration
var axis: SIMD3<Float> { get set }

A 3D vector that points in the direction of the axis around which to rotate. You can rotate an object around any axis. For example, if you set a `1` in the vector's x-coordinate, rotation occurs around the x-axis, as in the following code. ```swift orbitAnimation.axis = SIMD3<Float>(x: 1.0, y: 0.0, z: 0.0) ```

init · iOS 15.0+

init

TypeScript
static init(name?: string, duration?: number, axis?: SDKHandle, startTransform?: Transform, spinClockwise?: boolean, orientToPath?: boolean, rotationCount?: number, bindTarget?: (BindTarget) | null, blendLayer?: number, repeatMode?: AnimationRepeatMode, fillMode?: AnimationFillMode, isAdditive?: boolean, trimStart?: (number) | null, trimEnd?: (number) | null, trimDuration?: (number) | null, offset?: number, delay?: number, speed?: number): OrbitAnimation
Swift declaration
init(name: String = "", duration: TimeInterval = 1.0, axis: SIMD3<Float> = .init(x: 0.0, y: 1.0, z: 0.0), startTransform: Transform = .identity, spinClockwise: Bool = true, orientToPath: Bool = false, rotationCount: Float = 1.0, bindTarget: BindTarget? = nil, blendLayer: Int32 = 0, repeatMode: AnimationRepeatMode = .none, fillMode: AnimationFillMode = [], isAdditive: Bool = false, trimStart: TimeInterval? = nil, trimEnd: TimeInterval? = nil, trimDuration: TimeInterval? = nil, offset: TimeInterval = 0, delay: TimeInterval = 0, speed: Float = 1)

Creates an animation that revolves an entity around its origin. - Parameters: - name: A textual name for the animation. - duration: The elapsed time for one complete rotation. - axis: A 3D vector that points in the direction of the axis around which to rotate. - startTransform: The orbiting entity's beginning position. - spinClockwise: A Boolean value that indicates whether the object orbits the center point in the clockwise direction. - orientToPath: A Boolean value that indicates whether the orbiting object updates its orientation during the animation to orient itself along the rotation path. - rotationCount: The number of times to rotate the target entity before stopping. - bindTarget: A textual name that identifies the particular property that animates. - blendLayer: The order in which the framework composites the animation into the view. - repeatMode: An option that determines how the animation repeats. - fillMode: The playback behavior outside of the normal duration. - isAdditive: A Boolean value that indicates whether the animation builds on the current state of the target entity or resets the state before running. - trimStart: The optional time, in seconds, at which the animation plays. - trimEnd: The optional time, in seconds, at which the animation stops. - trimDuration: An optional duration that overrides the calculated duration. - offset: The time, in seconds, at which the animation begins within the duration. - delay: An amount of time that lapses before the animation plays. - speed: A factor that changes the animation’s rate of playback.

get · iOS 15.0+

name

TypeScript
get name(): string
Swift declaration
var name: String { get set }

A textual name for the animation.

set · iOS 15.0+

name

TypeScript
set name(value: string)
Swift declaration
var name: String { get set }

A textual name for the animation.

get · iOS 15.0+

delay

TypeScript
get delay(): number
Swift declaration
var delay: TimeInterval { get set }

An amount of time that lapses before the animation plays. The default value is `0`, which indicates that the animation plays with no delay. If you set a value for this property, the animation plays from its start time after the specified delay lapses. During the delayed time, the animation doesn't update. However, to fill the delayed time with some portion of animation, set a negative ``OrbitAnimation/trimStart`` instead and choose a ``OrbitAnimation/fillMode`` that displays the desired portion of animation.

set · iOS 15.0+

delay

TypeScript
set delay(value: number)
Swift declaration
var delay: TimeInterval { get set }

An amount of time that lapses before the animation plays. The default value is `0`, which indicates that the animation plays with no delay. If you set a value for this property, the animation plays from its start time after the specified delay lapses. During the delayed time, the animation doesn't update. However, to fill the delayed time with some portion of animation, set a negative ``OrbitAnimation/trimStart`` instead and choose a ``OrbitAnimation/fillMode`` that displays the desired portion of animation.

get · iOS 15.0+

speed

TypeScript
get speed(): number
Swift declaration
var speed: Float { get set }

A factor that changes the animation’s rate of playback. The default value is `1.0`, which doesn’t alter the animation’s duration. A value of `2.0` indicates that the duration is half the normal rate. A value of `0.5` indicates that the duration is twice the normal rate. Negative values play the animation in reverse. This property doesn’t affect the animation’s ``FromToByAnimation/delay``.

set · iOS 15.0+

speed

TypeScript
set speed(value: number)
Swift declaration
var speed: Float { get set }

A factor that changes the animation’s rate of playback. The default value is `1.0`, which doesn’t alter the animation’s duration. A value of `2.0` indicates that the duration is half the normal rate. A value of `0.5` indicates that the duration is twice the normal rate. Negative values play the animation in reverse. This property doesn’t affect the animation’s ``FromToByAnimation/delay``.

get · iOS 15.0+

offset

TypeScript
get offset(): number
Swift declaration
var offset: TimeInterval { get set }

The time, in seconds, at which the animation begins within the duration. The default value is `0`, which indicates that the animation plays with no offset. Setting a value for this property moves the animation data along the timeline and doesn't change timing. If you set a ``OrbitAnimation/fillMode`` other than ``AnimationFillMode/none``, the animation fills the vacant area created by the offset according to the characteristics of the specified fill mode.

set · iOS 15.0+

offset

TypeScript
set offset(value: number)
Swift declaration
var offset: TimeInterval { get set }

The time, in seconds, at which the animation begins within the duration. The default value is `0`, which indicates that the animation plays with no offset. Setting a value for this property moves the animation data along the timeline and doesn't change timing. If you set a ``OrbitAnimation/fillMode`` other than ``AnimationFillMode/none``, the animation fills the vacant area created by the offset according to the characteristics of the specified fill mode.

get · iOS 15.0+

trimEnd

TypeScript
get trimEnd(): (number) | null
Swift declaration
var trimEnd: TimeInterval? { get set }

The optional time, in seconds, at which the animation stops. This property is `nil` by default, which plays the animation until `time` = ``AnimationGroup/duration``. If you set a value, the animation edits the duration according to the specified ending time.

set · iOS 15.0+

trimEnd

TypeScript
set trimEnd(value: (number) | null)
Swift declaration
var trimEnd: TimeInterval? { get set }

The optional time, in seconds, at which the animation stops. This property is `nil` by default, which plays the animation until `time` = ``AnimationGroup/duration``. If you set a value, the animation edits the duration according to the specified ending time.

get · iOS 15.0+

additive

TypeScript
get additive(): boolean
Swift declaration
var additive: Bool { get set }

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

set · iOS 15.0+

additive

TypeScript
set additive(value: boolean)
Swift declaration
var additive: Bool { get set }

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

get · iOS 15.0+

duration

TypeScript
get duration(): number
Swift declaration
var duration: TimeInterval { get set }

The elapsed time for one complete rotation. The framework sets a value for this property depending on the underlying animation data and the specified ``OrbitAnimation/speed``. You can override the default duration by defining ``OrbitAnimation/trimStart``, ``OrbitAnimation/trimEnd``, or ``OrbitAnimation/trimDuration``.

set · iOS 15.0+

duration

TypeScript
set duration(value: number)
Swift declaration
var duration: TimeInterval { get set }

The elapsed time for one complete rotation. The framework sets a value for this property depending on the underlying animation data and the specified ``OrbitAnimation/speed``. You can override the default duration by defining ``OrbitAnimation/trimStart``, ``OrbitAnimation/trimEnd``, or ``OrbitAnimation/trimDuration``.

get · iOS 15.0+

fillMode

TypeScript
get fillMode(): AnimationFillMode
Swift declaration
var fillMode: AnimationFillMode { get set }

An option that determines which data displays outside of the normal duration. This property determines what to display when the framework samples the animation outside of the range defined by its underlying duration. The animation applies this property when: - Playback progresses toward, but hasn't yet reached, a nonzero ``AnimationDefinition/offset``. - A range determined by ``AnimationDefinition/trimStart``, ``AnimationDefinition/trimEnd``, or ``AnimationDefinition/trimDuration`` exceeds the animation's underlying duration.

set · iOS 15.0+

fillMode

TypeScript
set fillMode(value: AnimationFillMode)
Swift declaration
var fillMode: AnimationFillMode { get set }

An option that determines which data displays outside of the normal duration. This property determines what to display when the framework samples the animation outside of the range defined by its underlying duration. The animation applies this property when: - Playback progresses toward, but hasn't yet reached, a nonzero ``AnimationDefinition/offset``. - A range determined by ``AnimationDefinition/trimStart``, ``AnimationDefinition/trimEnd``, or ``AnimationDefinition/trimDuration`` exceeds the animation's underlying duration.

get · iOS 15.0+

trimStart

TypeScript
get trimStart(): (number) | null
Swift declaration
var trimStart: TimeInterval? { get set }

The optional time, in seconds, at which the animation plays. This property is `nil` by default, which plays the animation with `time` = `0`. If you set a value, the animation edits the duration according to the specified beginning time. If you set a negative value for this property, the duration increases and the additional animation data fills in based on the ``AnimationView/fillMode`` you choose.

set · iOS 15.0+

trimStart

TypeScript
set trimStart(value: (number) | null)
Swift declaration
var trimStart: TimeInterval? { get set }

The optional time, in seconds, at which the animation plays. This property is `nil` by default, which plays the animation with `time` = `0`. If you set a value, the animation edits the duration according to the specified beginning time. If you set a negative value for this property, the duration increases and the additional animation data fills in based on the ``AnimationView/fillMode`` you choose.

Skipped declarations

No declarations were skipped in this snapshot.

All RealityFoundation types →