A set of animatable transform values for joints that collectively represent
a single skeletal pose.
This structure provides a template that informs an animation on how to animate a
character. The resulting movement bases on
the _from_ (``FromToByAnimation/fromValue-6msd``)
, _to_ (``FromToByAnimation/toValue-813jk``)
, or _by_ values (``FromToByAnimation/byValue-3bp3q``) you
supply for a ``FromToByAnimation``. The animation determines which joints take
on the movement through its ``FromToByAnimation/jointNames`` property.
## Animate an Entity's Skeleton
The following code moves the joints of a 3D asset by specifying the joint,
`joint1`, beginning, and ending values.
```swift
// Define the joint's pose at the start of the animation.
let fromTransforms: [Transform] = [Transform(scale: SIMD3<Float>(1, 2, 3), rotation: simd_quatf(ix: 5.0, iy: 6.0, iz: 7.0, r: 8.0), translation: SIMD3<Float>(10, 20, 30))]
let fromPose = JointTransforms(fromTransforms)
// Define the joint's pose at the end of the animation.
let toTransforms: [Transform] = [Transform(scale: SIMD3<Float>(10, 20, 30), rotation:
simd_quatf(ix: 50.0, iy: 60.0, iz: 70.0, r: 80.0), translation:
SIMD3<Float>(100, 200, 300)) ]
let toPose = JointTransforms(toTransforms)
// Indicate that the animation applies to the joint named 'joint1'.
let jointNames = ["joint1"]
// Configure the animation specifics.
var fromToBy = FromToByAnimation<JointTransforms>()
fromToBy.name = "anim"
fromToBy.blendLayer = 100
fromToBy.duration = 10.0
fromToBy.fillMode = .forwards
fromToBy.jointNames = jointNames
fromToBy.fromValue = fromPose
fromToBy.toValue = toPose
fromToBy.bindTarget = .transform
// Generate a resource from the animation.
let animationResource = fromToBy.create()
```
To run the animation on an entity and animate the joints, call
`playAnimation(_:transitionDuration:startsPaused:)`. Optionally, you can
control the animation's playback by storing the returned controller object.
```swift
// Play the animation on an entity.
let entity = AnchorEntity(...)
let controller = entity.playAnimation(animationResource)
// Optionally control playback using the returned controller.
controller.pause()
```
Members (7)
get · iOS 15.0+
startIndex
TypeScript
get startIndex(): number
Swift declaration
var startIndex: JointTransforms.Index { get }
An index to the first joint transform in the collection.
For more on the sequence's beginning index, see
<doc://com.apple.documentation/documentation/swift/array/1541237-startindex>.
Returns the position in the sequence of the joint that follows the given
position.
For more on calculating indices, see
<doc://com.apple.documentation/documentation/swift/array/1787306-index>.
Returns the position in the sequence of the joint that preceeds the
given position.
For more on calculating indices, see
<doc://com.apple.documentation/documentation/swift/array/1782301-index>.
get · iOS 15.0+
endIndex
TypeScript
get endIndex(): number
Swift declaration
var endIndex: JointTransforms.Index { get }
An index to the last joint transform in the collection.
For more more on the sequence's final index, see
<doc://com.apple.documentation/documentation/swift/array/1539310-endindex>.
init · iOS 15.0+
init
TypeScript
static init(): JointTransforms
Swift declaration
init()
Initializes a collection of animatable transforms for a single skeletal
pose.
subscript · iOS 15.0+
subscript
TypeScript
subscript(index: number): Transform
Swift declaration
subscript(index: JointTransforms.Index) -> Transform { get set }
Accesses a single joint transform in the collection at the given index.
For more on accessing elements by index, see
<doc://com.apple.documentation/documentation/swift/array/1540606-subscript>.
init<S>(_ transforms: S) where S : Sequence, S.Element == Transform
Initializes a collection of transforms of a specific type for a single
skeletal pose.
- Parameters:
- transforms: An array of position, rotation, and scale data for the joints.
Skipped declarations
1 declarations were excluded from these bindings. Each reason comes from the generator or the iOS SDK compiler.
JointTransforms.init(arrayLiteral:)
A variable number of Swift arguments is not supported.