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

#1

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

#2

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
#3

Pinging @bghgary

#4

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

#5

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

#6

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
#7

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
#8

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

AnimationGroup questions
#9

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.

1 Like
#10

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
#11

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?

#12

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