# Get the scaling vector

**URL:** <https://forum.babylonjs.com/t/get-the-scaling-vector/24285>\
**Category:** Questions\
**Created:** [October 4, 2021, 10:18am UTC](https://forum.babylonjs.com/t/get-the-scaling-vector/24285 "2021-10-04T10:18:10Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![kArThIk\_TS](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/karthik_ts/32/14377_2.png) [@kArThIk\_TS](https://forum.babylonjs.com/u/kArThIk_TS)\
**Post date:** [October 4, 2021, 10:18am UTC](https://forum.babylonjs.com/t/get-the-scaling-vector/24285/1 "2021-10-04T10:18:10Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [October 4, 2021, 10:26am UTC](https://forum.babylonjs.com/t/get-the-scaling-vector/24285/2 "2021-10-04T10:26:54Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![kArThIk\_TS](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/karthik_ts/32/14377_2.png) [@kArThIk\_TS](https://forum.babylonjs.com/u/kArThIk_TS)\
**Post date:** [October 4, 2021, 11:31am UTC](https://forum.babylonjs.com/t/get-the-scaling-vector/24285/3 "2021-10-04T11:31:54Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [October 4, 2021, 11:40am UTC](https://forum.babylonjs.com/t/get-the-scaling-vector/24285/4 "2021-10-04T11:40:47Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![kArThIk\_TS](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/karthik_ts/32/14377_2.png) [@kArThIk\_TS](https://forum.babylonjs.com/u/kArThIk_TS)\
**Post date:** [October 4, 2021, 11:56am UTC](https://forum.babylonjs.com/t/get-the-scaling-vector/24285/5 "2021-10-04T11:56:15Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [October 4, 2021, 2:14pm UTC](https://forum.babylonjs.com/t/get-the-scaling-vector/24285/6 "2021-10-04T14:14:57Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![kArThIk\_TS](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/karthik_ts/32/14377_2.png) [@kArThIk\_TS](https://forum.babylonjs.com/u/kArThIk_TS)\
**Post date:** [October 5, 2021, 1:15pm UTC](https://forum.babylonjs.com/t/get-the-scaling-vector/24285/7 "2021-10-05T13:15:27Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![msDestiny14](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/msdestiny14/32/9572_2.png) [@msDestiny14](https://forum.babylonjs.com/u/msDestiny14)\
**Post date:** [October 5, 2021, 7:47pm UTC](https://forum.babylonjs.com/t/get-the-scaling-vector/24285/8 "2021-10-05T19:47:36Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ynnek](https://avatars.discourse-cdn.com/v4/letter/y/c68b51/32.png) [@ynnek](https://forum.babylonjs.com/u/ynnek)\
**Post date:** [October 6, 2021, 5:59am UTC](https://forum.babylonjs.com/t/get-the-scaling-vector/24285/9 "2021-10-06T05:59:01Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![kArThIk\_TS](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/karthik_ts/32/14377_2.png) [@kArThIk\_TS](https://forum.babylonjs.com/u/kArThIk_TS)\
**Post date:** [October 6, 2021, 7:54am UTC](https://forum.babylonjs.com/t/get-the-scaling-vector/24285/10 "2021-10-06T07:54:52Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![kArThIk\_TS](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/karthik_ts/32/14377_2.png) [@kArThIk\_TS](https://forum.babylonjs.com/u/kArThIk_TS)\
**Post date:** [October 6, 2021, 8:16am UTC](https://forum.babylonjs.com/t/get-the-scaling-vector/24285/11 "2021-10-06T08:16:49Z")

</div>

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

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

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [October 6, 2021, 2:27pm UTC](https://forum.babylonjs.com/t/get-the-scaling-vector/24285/12 "2021-10-06T14:27:33Z")

</div>

I am sorry I am completely lost cause looking in your playground I do not see any actual skeletons or bones 🙂 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)

---

<div class="post-metadata">

**Author:** ![bghgary](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/bghgary/32/48532_2.png) [@bghgary](https://forum.babylonjs.com/u/bghgary)\
**Post date:** [October 7, 2021, 10:02pm UTC](https://forum.babylonjs.com/t/get-the-scaling-vector/24285/13 "2021-10-07T22:02:51Z")

</div>

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`](https://doc.babylonjs.com/typedoc/classes/babylon.abstractmesh#refreshboundinginfo) on a mesh. Getting the vertices is not as easy right now. There is [`applySkeleton`](https://doc.babylonjs.com/typedoc/classes/babylon.mesh#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. 🙂
