# How to loop gltf animation let's say from 5 seconds to 15 if whole animation is 20 seconds

**URL:** <https://discourse.threejs.org/t/how-to-loop-gltf-animation-lets-say-from-5-seconds-to-15-if-whole-animation-is-20-seconds/35221>\
**Category:** Questions\
**Tags:** animation\
**Created:** [February 23, 2022, 9:19am UTC](https://discourse.threejs.org/t/how-to-loop-gltf-animation-lets-say-from-5-seconds-to-15-if-whole-animation-is-20-seconds/35221 "2022-02-23T09:19:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dzmitry\_Haiduk](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/dzmitry_haiduk/32/8998_2.png) [@Dzmitry\_Haiduk](https://discourse.threejs.org/u/Dzmitry_Haiduk)\
**Post date:** [February 23, 2022, 9:19am UTC](https://discourse.threejs.org/t/how-to-loop-gltf-animation-lets-say-from-5-seconds-to-15-if-whole-animation-is-20-seconds/35221/1 "2022-02-23T09:19:22Z")

</div>

How to loop gltf animation let’s say from 5 seconds to 15 if whole animation is 20 seconds

---

<div class="post-metadata">

**Author:** ![seanwasere](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/seanwasere/32/20864_2.png) [@seanwasere](https://discourse.threejs.org/u/seanwasere)\
**Post date:** [February 24, 2022, 11:26am UTC](https://discourse.threejs.org/t/how-to-loop-gltf-animation-lets-say-from-5-seconds-to-15-if-whole-animation-is-20-seconds/35221/2 "2022-02-24T11:26:33Z")

</div>

there is a function [AnimationUtils#subclip – three.js docs (threejs.org)](https://threejs.org/docs/#api/en/animation/AnimationUtils.subclip)

In my example link below, I use the walk animation which is 1 second long. If my demo is running at 60FPS then I can loop from .3 to .6 seconds by using frame numbers 20 → 40

Example : [subclip](https://jsfiddle.net/seanwasere/z43Ldem7/)

see lines 43-45

```javascript
const walkAction = gltf.animations[6] // walk
const trimmedAction = THREE.AnimationUtils.subclip(walkAction, 'trimmedWalk', 20, 40);
mixer.clipAction(trimmedAction).play()

```

---

<div class="post-metadata">

**Author:** ![Dzmitry\_Haiduk](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/dzmitry_haiduk/32/8998_2.png) [@Dzmitry\_Haiduk](https://discourse.threejs.org/u/Dzmitry_Haiduk)\
**Post date:** [February 25, 2022, 5:03am UTC](https://discourse.threejs.org/t/how-to-loop-gltf-animation-lets-say-from-5-seconds-to-15-if-whole-animation-is-20-seconds/35221/3 "2022-02-25T05:03:24Z")

</div>

Thank you, it works.

---

<div class="post-metadata">

**Author:** ![the\_greck](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/the_greck/32/30001_2.png) [@the\_greck](https://discourse.threejs.org/u/the_greck)\
**Post date:** [October 4, 2022, 1:55pm UTC](https://discourse.threejs.org/t/how-to-loop-gltf-animation-lets-say-from-5-seconds-to-15-if-whole-animation-is-20-seconds/35221/4 "2022-10-04T13:55:55Z")

</div>

I hate to jump into an old thread like this, but I’ve been searching and this is one of the few examples of the .subclip method that I’ve been able to find. Unfortunately, I’m trying to use it in 8th Wall’s AR platform, in which we have to load the .glb files via A-frame, then access them through javascript. The problem is I can’t figure out what I’m supposed to use in place of the “walkAction” part, since it looks like that’s instantiated with the loading of the glb/gtlf file. All I can call is the ID of the glb file, but that doesn’t work if I use that in the subclip function.
