How to align other stuff to an imported (gltf) scene's mesh

Hey there,

I have looked through a few forum posts already but couldn’t wrap my head around this problem:

  • when importing a GLTF scene with a skinned mesh,
  • I might want to draw something ‘in line’ with that mesh’s visual transform

I’ve tried using parenting to the mesh, but because the mesh is already placed in the scene, setting the mesh or top level TransformNode as parent just affects changes to the mesh transform after the parenting (if I don’t understand this wrong?)

PG example – how do I get this skeleton debug viewer to align with the character?:

I also need to understand this better to use attachToBone:

(@CodingCrusader maybe you have an idea? I’ve copied the attach function you used with Dude mesh here)

Many thanks! :slight_smile:

I’ve made progress by first resetting all the transforms on the root mesh and its ancestors:

skeleton debug viewer example (working):

attach to bone example (working):

For my purposes, this hack is good enough to keep going as I can re-apply any transforms to the mesh and the attached / child stuff will be updated correctly.

Is there a better way to avoid this though, so that the parenting applies before the transforms to the loaded mesh (so the child also gets the initial transform)?

1 Like

Solution from DeepSeek: use the “skinnedMesh”

[question] how to align anything with the transform of an imported mesh | Babylon.js Playground

2 Likes

Thanks, looks like it works perfectly. So the solution is to make sure the target of the parent or attachment is the skinned mesh rather than getting a specific mesh by number from the array. Makes sense :slight_smile:

you are welcome.

Buy me a beer or publish your hair project on https://forum.babylonjs.com/t/babylon-js-8-0-release-call-for-community-creations

I prefere the last one :slight_smile:

1 Like

Haha, gonna have to buy you a beer then, unfortunately I don’t have time to polish things if I’m ever gonna release a game :frowning_face: but I try to always share the working playgrounds after a problem is solved; it’s the best I can do. I’ll for sure have more improvements to make the wgsl hair system more general purpose soon as it’s in my roadmap. I just can’t write good documented TypeScript and port compute shaders to webgl2 tx feedbacks etc.

Appreciate the support still!

Edit: i guess you mean share a polished video demo of the hair sim for the release video. Maybe!

1 Like

Yes, a cool video presentation! :blush: