How to update imported GLB mesh position (Bug?)

So 2 days ago I was losing my mind on how to import a mesh that has multiple Mixamo animations from Blender to Babylon. After 5 hours of pulling my hair, I finally got it.

I exported the mesh from Blender as GLB, tested it on the Babylon sandbox and it worked perfectly fine (it still does!).
But now I’ve encountered a new problem that has been demotivating and heavy on me and I have no clue how to fix it.

Basically these are the steps I need to do:

  1. Import the mesh via SceneLoader.ImportMesh
  2. Save the imported mesh to an object Player via constructor
  3. Use update(pos) function in the object to update its position

Simple yet something is not working correctly at step 3.

If you take a look at the playground examples I’ve created you’ll see that it compiles fine and if you open the console you’ll also see that Players mesh.position is actually getting updated but the mesh that is on the screen does not move and it always remains on the same place. Even if Players mesh.position shows values changing.

Babylon.js Playground (JAVASCRIPT)
Babylon.js Playground (TYPESCRIPT)

Thank you in advance.

For some reason, you must update the node named “skeletal.3” and not the mesh to make it move:

https://playground.babylonjs.com/#YP9U1X#1

People more knowledgeable than me on skeleton animations should be able to explain why.

1 Like

This is because gltf handles bone animation is a “Weird” way. Instead of animating the bones, gltf animates meshes that are linked to bones.

Thank you! This worked perfectly fine.
Basically you just have to move skeletal or armature of the mesh instead of mesh itself. Works perfectly fine.

Thank you for your response. I see.

Will switching to .babylon instead of .glb file make things better/easier? It probably will hence suffix “.babylon”.

But is there anyway to export glb to .babylon apart from Blender and Bablyon Sandbox? Trying to export via Blender throws me a long stack of errors and using the sandbox to export gives me a model without animations, just a T-pose of my model with textures.

well we have a fantastic babylon exporter for Blender done by @JCPalmer

change parent

   const newParent = new BABYLON.Node('parent')
    this.lamp?.loadedMeshes?.forEach((e) => {
      e.parent = newParent
      e.position = new BABYLON.Vector3(-20, 0, 80)
    })

I do not think you answered to the right post ?

Only changing parent for gltf might cause issues as you would bypass the rootnode. It is not safe to do in the default scene handedness