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

Link copied to clipboard
object Companion

The companion of TweenAnimation.

Properties

Link copied to clipboard

The EaseType of the animation. This defines the rate of change of the animation over time, allowing for effects such as acceleration, deceleration, or linear motion. It affects the smoothness, style, and realism of the animation.

Functions

Link copied to clipboard
fun additive(additive: Boolean): TweenAnimation

Sets if this animation is additive.

Link copied to clipboard
fun bindTarget(animationBindTarget: AnimationBindTarget): TweenAnimation

Sets the AnimationBindTarget of the animation.

Link copied to clipboard
fun delay(delay: Float): TweenAnimation

Sets the delay before the animation starts, in seconds.

Link copied to clipboard
fun duration(duration: Float): TweenAnimation

Sets the duration of the animation.

Link copied to clipboard

Sets the ease type of the animation.

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard
fun name(name: String): TweenAnimation

Sets the name of the animation.

Link copied to clipboard
fun offset(offset: Float): TweenAnimation

Sets the offset time of animation.

Link copied to clipboard
fun repeatCount(repeatCount: Int): TweenAnimation

Sets how many times the animation should repeat.

Link copied to clipboard

Sets the repeat mode of animation.

Link copied to clipboard
fun speed(speed: Float): TweenAnimation

Sets the speed of the animation.

Link copied to clipboard
open override fun toString(): String
Link copied to clipboard
fun trimDuration(trimDuration: Float): TweenAnimation

Sets the duration of the animation to trim, in seconds.

Link copied to clipboard
fun trimEnd(trimEnd: Float): TweenAnimation

Sets the end time (in seconds) at which to trim the animation.

Link copied to clipboard
fun trimStart(trimStart: Float): TweenAnimation

Sets the start time (in seconds) from which to begin trimming the animation.