# Clone skinned mesh with SkeletonUtils undefined error

**URL:** https://discourse.threejs.org/t/clone-skinned-mesh-with-skeletonutils-undefined-error/48592
**Category:** Questions
**Tags:** skinned-mesh
**Created:** [March 1, 2023, 8:45pm UTC](https://discourse.threejs.org/t/clone-skinned-mesh-with-skeletonutils-undefined-error/48592 "2023-03-01T20:45:02Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Luck](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/luck/32/34042_2.png) [@Luck](https://discourse.threejs.org/u/Luck)
#### Post date: [March 1, 2023, 8:45pm UTC](https://discourse.threejs.org/t/clone-skinned-mesh-with-skeletonutils-undefined-error/48592/1 "2023-03-01T20:45:02Z")

</div>

I am loading fbx model like this:

> function loadModel(url) {  
> return new Promise(res =\> { fbxLoader.load(url, res); })  
> }
> 
> ```
> //Function that is called after model is loaded where basic setup for model is done ( material, size etc.) and it's stored in the array
> function storeLoadedModel(object, size, position, _mat) {            
>     
> object.children[0].material = mat; 
> 
> object.scale.set(1, 1, 1);
> object.position.set(0,0,0);
> 
> models.push(object);
> }
> 
> ```

After this I want to instantiate bunch of same models with animation

> for(let i = 0; i \< amount; i++) {
> 
> ```
> console.log(models[0]);
> const animatedModel = SkeletonUtils.clone(models[0]);
> 
> ```

but the skeleton utils throw this error:

> Uncaught (in promise) TypeError: Cannot read properties of undefined (reading ‘clone’)  
> at Object.subclip (chunk-JKTWCPHD.js?v=e962c5f6:22666:27)

I cant figure out why it’s undefined, when I don’t use the clone(), it’s working fine and model loads fine. When i log the model I am getting the model, it’s a group with animations, material, children etc. All looks fine, but for whatever it’s undefined. It probably has something to do with the subclip?

---

<div class="post-metadata">

### Author: ![makc3d](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/makc3d/32/10452_2.png) [@makc3d](https://discourse.threejs.org/u/makc3d)
#### Post date: [March 1, 2023, 9:47pm UTC](https://discourse.threejs.org/t/clone-skinned-mesh-with-skeletonutils-undefined-error/48592/2 "2023-03-01T21:47:48Z")

</div>

> [@Luck](#):
>
> I cant figure out why it’s undefined

well, where did you define it? (normally that would be an import statement)

edit: just to make sure, the error says SkeletonUtils is undefined, not models[0]

---

<div class="post-metadata">

### Author: ![Luck](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/luck/32/34042_2.png) [@Luck](https://discourse.threejs.org/u/Luck)
#### Post date: [March 2, 2023, 10:45pm UTC](https://discourse.threejs.org/t/clone-skinned-mesh-with-skeletonutils-undefined-error/48592/3 "2023-03-02T22:45:14Z")

</div>

This is how I define it:

> import \* as SkeletonUtils from ‘three/examples/jsm/utils/SkeletonUtils.js’;

Are you sure that SkeletonUtils is not defined? Reading the error, it complains about subclip, which I am using. It also specifies the error line to be on the subclip line

> const animatedModel = SkeletonUtils.clone(models[0]);
> 
> const mixer = new THREE.AnimationMixer(animatedModel);  
> const idleAnim = animatedModel.animations[0];  
> const idleAnimTrim = THREE.AnimationUtils.subclip(idleAnim, ‘idle’, 10, 100);

Ani idea if SkeletonUtils copy has issue with subclips?

---

<div class="post-metadata">

### Author: ![makc3d](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/makc3d/32/10452_2.png) [@makc3d](https://discourse.threejs.org/u/makc3d)
#### Post date: [March 3, 2023, 12:08am UTC](https://discourse.threejs.org/t/clone-skinned-mesh-with-skeletonutils-undefined-error/48592/4 "2023-03-03T00:08:39Z")

</div>

ah then Ig animatedModel.animations[0] is undefined, since it does

```javascript
function subclip( sourceClip, name, startFrame, endFrame, fps = 30 ) {

	const clip = sourceClip.clone();

```

^^ this. try using models[0].animations[0] instead?

---

<div class="post-metadata">

### Author: ![Luck](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/luck/32/34042_2.png) [@Luck](https://discourse.threejs.org/u/Luck)
#### Post date: [March 7, 2023, 8:07pm UTC](https://discourse.threejs.org/t/clone-skinned-mesh-with-skeletonutils-undefined-error/48592/5 "2023-03-07T20:07:10Z")

</div>

I am using fbx with defined subclips in 3ds max. The only way I was able to get it working in threejs from 3ds max was using fbx, so I have to use subclips.  
So the SkeletonUtils probably is not able to clone it along with subclips it seems.

The only solution I was able to figure out so far was to load the same model multiple times instead of cloning it. That is of course bad, but is only solution for me right now.
