---
title: "SpatialGltfModelAnimation"
description: "An animation that is attached to a glTF model."
type: "class"
lastmod: "2026-05-08T01:17:01.389584Z"
---
## API Reference

> Source set: Android

```kotlin
@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

> Source set: Android

```kotlin
public val animationState: AnimationState
```

The current playing state of this animation.

This is backed by a snapshot [State](/jetpack-compose/androidx.compose.runtime/runtime/interfaces/State) object that is updated whenever the animation state
changes and may trigger recomposition.

### name

> Source set: Android

```kotlin
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

> Source set: Android

```kotlin
public val duration: Duration
```

The duration of this animation.

### speed

> Source set: Android

```kotlin
public var speed: Float
```

The playback rate for this animation.

Negative multipliers will play the animation in reverse.

## Functions

### start

```kotlin
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

```kotlin
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

```kotlin
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

```kotlin
public fun pause()
```

Pauses this animation.

This freezes the animation at the current frame and transitions the animation state to
`AnimationState.Paused`. Use [start](#start) to continue playback.

Note: Calling [start](#start) or [loop](#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

```kotlin
public fun seekTo(time: Duration)
```

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

If the [animationState](/jetpack-compose/androidx.xr.compose/compose/classes/SpatialGltfModelAnimation.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](#start) or [loop](#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. |
