Getting Bone from glTF model with raycasting

I’d like to get the name of the specific Bone object from my glTF model when hovering the mouse over it, eg when hovering over left upper arm of the model I’d like to return the Bone object called left-upper-arm.

I’ve used this example of Raycaster from the documentation but I’ve only managed to change the color of the entire model when my mouse hovers over the model - but I do get the root of the glTF model so I guess now I’d have to make the raycasting to be a little bit more specific.

I think a common way to do this is to attach a simple mesh (like a cylinder) to each bone as colliders. The bones themselves do not get hit by the Raycaster.

Alternatively if you use the vertex or triangle index returned by the Raycaster, you can use that to look up the bone(s) it is weighted to. In the geometry’s skinIndex attribute, it stores up to four bone indexes, and those indexes point into the skeleton’s bone list.

I think it’s a great idea to attach an invisible cylinder to each bone! This way I can simplify the process and attach any information I want to it! This could work!

I’m not sure how the alternative could be implemented. When hovering over the glTF model I get a reference to the entire object; I could definitely get the details out of it but I’d like the details to be returned on mouse hover over the specific body part.

Can you offer some more info on the alternative way please?

But regardless, I think I will try your first method - seems like it should work!

If you’re using THREE.Raycaster it returns a bunch of information, not just the reference to the object but also the index of the triangle that was selected or hovered. You can backtrack from the triangle to the Bone(s) affecting that triangle, but there may be more than one Bone weighted to the triangle so this is not a simple 1:1 mapping.