One Logo Pool Ball
RealityFoundation · IOS API REFERENCE

FromToByAction

struct · iOS 18.0+ · SDK 27.1

struct FromToByAction<Value> where Value : AnimatableData

An action that starts, stops, or increments by a specific value. This action animates a bound parameters value over time. Specifying a ``FromToByAction/from`` value represents the animated properties' initial value at the start of the animation. Specifying a ``FromToByAction/to`` determines the value of the property at the end of the animation. Specifying a``FromToByAction/by`` adds a value to the properties initial state, which calculates the value at the end of the animation. This action exposes ``FromToByAction/TransformMode`` which is used when animating a ``Transform`` property. Use this mode to determine the reference space the property is relative to. For example, ``TransformMode/local`` means the provided transforms are relative to the transform of the bound entity. The only exception is when ``FromToByAction/by`` is specified, this is relative to the space of the starting transform. - Note: `FromToByAction` doesn't support ``JointTransforms`` or ``BlendShapeWeights`` types. Use ``FromToByAnimation`` to animate these types. ### Creating a from, to, by action to animate an entity's opacity The example below creates an animation which gradually animates the bound entity's opacity property for five seconds with a linear transition. In this example, the entity starts with opacity at `1.0`. ```swift // Create an action that gradually animates a float value // towards `0.0`, with a linear transition. // // This action does not have a `from` value supplied, // meaning this starts from the default source value. let opacityAction = FromToByAction<Float>(to: 0.0, timing: .linear, isAdditive: false) // A five second animation that plays an animation causing the entity to // gradually animate the `.opacity` property towards `0.0`. // // This makes the entity fade-out. let opacityAnimation = try AnimationResource .makeActionAnimation(for: opacityAction, duration: 5.0, bindTarget: .opacity) // Play the five second animation on the entity that will fade-out. entity.playAnimation(opacityAnimation) ``` ### Create a from, to, by action to animate an entity's transform property The example below creates an animation which gradually animates the bound entities transform property for five seconds with a linear transition. ```swift // Create a transform to start animating from. let startTransform = Transform(translation: [0.0, 2.0, 0.0]) // Create a transform to animate towards. let endTransform = Transform(translation: [0.0, -2.0, 0.0]) // Create an action that gradually animates a transform value. // // This starts `from` a specified value, and animates towards // a specified `to` value. // // The bound entity will move in the space relative to its parent. let transformAction = FromToByAction<Transform>(from: startTransform, to: endTransform, mode: .parent, timing: .linear, isAdditive: false) // A five second animation that plays an animation causing // the entity to gradually move from a specific start, and end transform let transformAnimation = try AnimationResource .makeActionAnimation(for: transformAction, duration: 5.0, bindTarget: .transform) // Play the five second animation on the entity that will cause it to move. entity.playAnimation(transformAnimation) ``` - Note: The default source value is the base value of the of animated property. If multiple animations target the property, then the framework observes the output of the previous animation as the subsequent animation's default source value. - Important: This action animates various bound properties, for example ``BindTarget/transform`` on the bound entity. Ensure a correct bind target is supplied when creating the animation. - Note: For more information on the combination of inputs this action supports see ``FromToByAnimation``. - Important: If you do not provide values for any of the `from`, `to`, and `by` parameters, the animation stays at the default source value.

Members (0)

This type has no directly callable members in this snapshot. See the framework’s skipped declarations for unsupported APIs.

Skipped declarations

1 declarations were excluded from these bindings. Each reason comes from the generator or the iOS SDK compiler.

FromToByAction.animatedValueType

Passing a Swift type itself is not supported.

All RealityFoundation types →