JointTransforms
A set of animatable transform values for joints that collectively represent a single skeletal pose.
Declaration
struct JointTransformsOverview
This structure provides a template that informs an animation on how to animate a character. The resulting movement bases on the from (fromValue) , to (toValue) , or by values (byValue) you supply for a FromToByAnimation. The animation determines which joints take on the movement through its 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.
// 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.
// Play the animation on an entity.
let entity = AnchorEntity(...)
let controller = entity.playAnimation(animationResource)
// Optionally control playback using the returned controller.
controller.pause()