SpatialGltfModelAnimation

@RequiresApi(value = 26)
class SpatialGltfModelAnimation : AutoCloseable


An animation that is attached to a glTF model.

This may be used to inspect or control the state of this animation.

Summary

Nested types

The current animation state of the SpatialGltfModelAnimation.

Public functions

open Unit
Unit

Starts playing this animation.

Unit

Pauses this animation.

Unit

Seeks the animation to a specific time offset from the start of the animation.

Unit

Starts playing this animation.

Unit

Stops this animation.

Public properties

SpatialGltfModelAnimation.AnimationState

The current playing state of this animation.

Duration

The duration of this animation.

String?

The name of this animation or null if the animation does not have a name.

Float

The playback rate for this animation.

Public functions

close

Added in 1.0.0-alpha13
open fun close(): Unit

loop

Added in 1.0.0-alpha13
fun loop(): Unit

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.

pause

Added in 1.0.0-alpha13
fun pause(): Unit

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

Added in 1.0.0-alpha13
fun seekTo(time: Duration): Unit

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: Duration

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.

Throws
IllegalArgumentException

if time is negative.

start

Added in 1.0.0-alpha13
fun start(): Unit

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.

stop

Added in 1.0.0-alpha13
fun stop(): Unit

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.

Public properties

animationState

val animationStateSpatialGltfModelAnimation.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.

duration

val durationDuration

The duration of this animation.

name

Added in 1.0.0-alpha13
val nameString?

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.

speed

Added in 1.0.0-alpha13
var speedFloat

The playback rate for this animation.

Negative multipliers will play the animation in reverse.