Find target object for animation clip loaded via GLB/GLTF file

Hello,

I’m loading a gltf file using the GLTFLoader. The loaded file contains my array of animation but I can’t find any information about the target object that animation was originally assigned to.

Loading the gltf in babylon or modelviewer works and I can switch between the animation clips and it animates the correct objects so it looks like there is a way to resolve those connections.

Would appreciate any help!

The animation isn’t necessarily assigned to a single object – it could animate many objects, and you don’t need to manually resolve them to play the animation. See the webgl / animation / keyframes demo for an example of this.

If you do need to identify the objects affected, that’s part of the name of each keyframe track. The example below would target the object with the name ‘LeftArm’. The first part could also be a UUID.

for (const track of clip.tracks) {
  console.log(track.name); // Example: 'LeftArm.rotation'
}

Yes but what if multiple objects share the same name? For example in case of multiple characters sharing one rig but should be assigned different animations.
In my case the name is the name and not the UUID unfortunately

THREE.GLTFLoader makes names unique within each model for this reason. When loading multiple glTF models into the same scene you could have name collisions though.

THREE.AnimationMixer finds objects underneath whatever root object you give it. So for multiple characters whose armatures have the same bone names, you could use a separate mixer for each character — each with a different root object — and that’d be fine.