@RequiresApi(Build.VERSION_CODES.O)
public class SpatialGltfModelAnimation internal constructor(private val animation: GltfAnimation) :
AutoCloseable
An animation that is attached to a glTF model.
This may be used to inspect or control the state of this animation.
Properties
animationState
public val animationState: AnimationState
The current playing state of this animation.
This is backed by a snapshot State object that is updated whenever the animation state changes and may trigger recomposition.
name
public val name: String?
The name of this animation or null if the animation does not have a name.
The name is not guaranteed to be unique across all animations.
duration
public val duration: Duration
The duration of this animation.
speed
public var speed: Float
The playback rate for this animation.
Negative multipliers will play the animation in reverse.
Functions
start
public fun start()
Starts playing this animation. The animation will play once and stop once it reaches its duration.
This transitions the animation state to AnimationState.Playing.
If the animation is already looping, calling this will start the animation again but it won't loop when the animation is over.
loop
public fun loop()
Starts playing this animation. The animation will play and repeat from the beginning when it reaches its duration.
This transitions the animation state to AnimationState.Playing.
If the animation is already playing, calling this will start the animation again but it will now loop instead of ending when the animation is over.
stop
public fun stop()
Stops this animation.
This resets the playback time to 0 and transitions the animation state to AnimationState.Stopped. If this animation is not currently playing or pausing, this method has no effect.
pause
public fun pause()
Pauses this animation.
This freezes the animation at the current frame and transitions the animation state to AnimationState.Paused. Use start to continue playback.
Note: Calling start or loop while in the AnimationState.Paused state will resume the animation from the current frame. To reset the animation, call stop() or seekTo(0.seconds).
seekTo
public fun seekTo(time: Duration)
Seeks the animation to a specific time offset from the start of the animation.
If the animationState of the animation is AnimationState.Stopped, this will set the start time of the animation that will take effect when the animation is played next. The state of glTF will not update until the next time start or loop is called.
Parameters
| time | The offset from the beginning of the animation. It must be greater than or equal to zero. If time is larger than the duration of the animation, the duration of the animation will be used instead. |