How to clone a GLB model and play seperate animation on each clone?

Heya,

I’ve managed to make a .glb file which contains 5 animations plus the player avatar. I can import the .glb ok, and have worked out how to clone the avatar mesh, but I can’t work out how to play a seperate animation on each clone of the avatar.

Here is the playground - each of the avatars should be playing a seperate animation on loop.

https://playground.babylonjs.com/#AJA5J6#2

Been scratching my head at this for a few days, thanks for your help. :slight_smile: :slight_smile: :slight_smile:

Ben
www.cryptovoxels.com

Things that confused me:

  • The skeleton doesn’t have an animations property - which it does have in the docs.
  • I can’t work out how to add an instance of the avatar to an animationGroup
  • Using babylon 3.3, when I import the avatar I get multiple meshes, but the 4.0 importer seems to bring in only one mesh
  • Using babylon 3.3, cloning the root mesh doesn’t clone the quaternion, and when I try and apply a skeleton to it, the avatar gets hideously deformed

Pinging @bghgary

Ok, got a bit closer! I’m cloning the animation group which is working, but all the meshes are horribly deformed now. Poor art mannequin man.

https://playground.babylonjs.com/#AJA5J6#4

55%20PM

Hmm weird - it seems like all the animations are playing properly to the skeleton - but the maybe the bone weights on the model got messed up by the clone? :confused:

Are the bone indexes somehow messed up?

53%20PM

Unrelated but hey! Your the Cryptovoxels guys! I just want to say that the concept is cool, and I would love to have my own square, but I have no ethereum.

1 Like

Hey man, thanks! I’m really enjoying working on it, and babylon has been amazing to work with (this problem notwithstanding). If someone is able to fix the playground for me so that it clones and plays the animations, I’d be happy to give a parcel in the west end as a bounty!

Bounty: 1 Parcel in the West end. :squid:

1 Like

I am not the guy to ask to help fix the issue, but free sounds nice.

There isn’t an easy way to clone with skeletons and animations. The easiest thing you can do is to reload the asset.

https://playground.babylonjs.com/#AJA5J6#5

See Make it easier to clone a mesh and start the associated animations/animationGroup · Issue #5423 · BabylonJS/Babylon.js · GitHub for more info.

2 Likes

Ok thanks Gary! It’s not ideal but it’ll do for no I guess. As long as I have my caching rules set ok it hopefully won’t hit the network multiple times. :slight_smile:

2 Likes

Hi guys, I am looking for a way to do this exact thing. I understand there is no easy way to do that except than reloading the asset for now.
But I wonder if it might have changed with the V4 update?

The best way is probably to reload the model instead of cloning it

Any update on this, I am also facing similar issue with cloning of GLB
https://www.babylonjs-playground.com/#5NIBE1#7

for .babylon it seems to work fine

https://www.babylonjs-playground.com/#QY1WYT#0

The best option for now is to reload the glb and let the browser cache does the work for you

2 Likes