TweenAnimation
Represents a type of animation for "from-to-by" behavior.
PICO Spatial SDK supports four combinations of TweenAnimation: FromTo, FromBy, To, and By. If any other combinations are constructed, they will not function as intended because the system cannot perform interpolation calculations with the given data.
Additionally, a corresponding BindTarget is required for applying an animation to an entity. For instance, to change an entity's position, use bindTarget = AnimationBindTarget.bindPosition() to indicate that the animation should modify the entity's position values. In this case, the type of input parameter for fromValue, toValue, and byValue should be Vector3. Refer to the documentation of the static functions in AnimationBindTarget for the types of input parameter required by different types of bindTarget.
Code sample:
// Create a position animation for an entity.
val animation = TweenAnimation.createTweenAnimation(
bindTarget = AnimationBindTarget.bindPosition(),
to = Vector3(-7F, 5.5F, -11F),
repeatMode = RepeatMode.RESTART,
repeatCount = 100,
duration = 2F
)
val animationResource = AnimationResource.generateWithTweenAnimation(animation)
val entity = Entity()
entity.playAnimation(animationResource)
// Create a base color animation for an entity.
val colorAnimation = TweenAnimation.createTweenAnimation(
bindTarget = AnimationBindTarget.bindMaterial(0, MaterialTarget.BASE_COLOR_TINT),
from = Color4.fromLinearHex("5CCF6BFF"), // Starting color
to = Color4.BLUE, // Ending color
repeatMode = RepeatMode.RESTART,
repeatCount = 100,
duration = 2F
)
val colorAnimationResource = AnimationResource.generateWithTweenAnimation(colorAnimation)
entity.playAnimation(colorAnimationResource)Types
The companion of TweenAnimation.
Properties
Functions
Sets if this animation is additive.
Sets the AnimationBindTarget of the animation.
Sets the delay before the animation starts, in seconds.
Sets the duration of the animation.
Sets the ease type of the animation.
Sets the name of the animation.
Sets the offset time of animation.
Sets how many times the animation should repeat.
Sets the repeat mode of animation.
Sets the speed of the animation.
Sets the duration of the animation to trim, in seconds.
Sets the end time (in seconds) at which to trim the animation.
Sets the start time (in seconds) from which to begin trimming the animation.