Get the scaling vector

How to compare two bones of different skeletons and get the scaling vector?

You can get the bone by name or id on the scene and then simply rely on bone.scaling

Sorry for missing details.
Let me explain in detail:

  1. Load a glb having skeleton ->bone rib → bone leg
  2. Load a glb having skeleton → bone rib → bone leg
    How do I compare the “bone leg” of 1 and 2 to get scale along x axis, y axis and z axis?

you can get the skeleton from the loading results and then iterate through its bones to find the one you want.

Keep both bones in cache so that you can compare afterwards.

I am able to iterate. But the scale is showing 1 for both the imported glb though it visually has difference.
Can I get it by some other means say from position of the bone, distance to camera?

I tried them, but could not get the scaling offset.

This is really hard to say without a repro. Could you repro in the playground ?

1 Like

I will try to trim down the problem and share the playground. Thank you for the suggestion.

Just as a hunch without seeing the code. Isn’t the scaling being 1 part of the model being loaded. This seems to be at the source level so wouldn’t you have to compare the vertices to each other?

I can probably take a look more into the glb documentation this is my gut memory from doing my photogrammetry demos. I remember having to set different scaling’s on each cause of how the mesh was exported.

1 Like

Maybe you can get the result scaling factor by multiplying bone’s scaling recursively…
By the way, in my experiences, models loaded from local files are scaled down in the Armature bone…

Let me explain the requirement:
mesh1 is thin mesh. (scaling is 1 by default after importing glb )
mesh2 is fat mesh. (scaling is 1 by default after importing glb)

As per your suggestion, I tried the following in registerBeforeRender:

  1. pos1 = mesh1.getVerticesData() //vertices of thin mesh
  2. mesh2.updateMeshPositions(pos1) //replace vertices of fat mesh with thin mesh positions

Please let me know if fat mesh can be made thin mesh by following the above steps.

Here we go. Please have a look at this minified playground.
https://playground.babylonjs.com/#1UZIZC#120

It works for the cube.
Will it work for any complex meshes?

I am sorry I am completely lost cause looking in your playground I do not see any actual skeletons or bones :slight_smile: So I am still trying to figure out what you are trying to achieve. I thought you wanted to compute some scaling ?

Nevertheless your playground code would only work with fully compatible veticesData (same length at the very least and indexed in the same way)

I think maybe you are asking about getting the vertices/bounding boxes of the mesh after the skeleton has been applied so that you can get the size? If so, this happens on the GPU. There is a way you can get the bounding info with skeleton applied using CPU by passing true for applySkeleton when calling refreshBoundingInfo on a mesh. Getting the vertices is not as easy right now. There is applySkeleton but that will actually change the vertices of the mesh. There is a private function _getPositionData on a mesh that you can use to get the positions after applying the skeleton. Not sure if any of this helps. :slight_smile: