# Mesh scaling problems

**URL:** <https://forum.babylonjs.com/t/mesh-scaling-problems/26363>\
**Category:** Questions\
**Created:** [December 30, 2021, 5:53am UTC](https://forum.babylonjs.com/t/mesh-scaling-problems/26363 "2021-12-30T05:53:44Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![wangjia5693](https://avatars.discourse-cdn.com/v4/letter/w/a183cd/32.png) [@wangjia5693](https://forum.babylonjs.com/u/wangjia5693)\
**Post date:** [December 30, 2021, 5:53am UTC](https://forum.babylonjs.com/t/mesh-scaling-problems/26363/1 "2021-12-30T05:53:45Z")

</div>

i have a scene with 3 meshes to combine one ,the meshes are from diff glb;i want scaling one of mesh in one direction(etc:z),but the positon will change

i looks like this [https://www.babylonjs-playground.com/#1BZJVJ#117;but](https://www.babylonjs-playground.com/#1BZJVJ#117;but) my meshes are from 3 glb

---

<div class="post-metadata">

**Author:** ![labris](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/labris/32/12576_2.png) [@labris](https://forum.babylonjs.com/u/labris)\
**Post date:** [December 30, 2021, 6:02am UTC](https://forum.babylonjs.com/t/mesh-scaling-problems/26363/2 "2021-12-30T06:02:03Z")

</div>

You can do it with 2 ways:

1. Open 3 GLBs in some 3D editor like Blender and scale and move them as you want to, then save as one GLB.
2. Scale needed mesh and then reposition it in Babylon scene.

Basically, because after scaling the position is changed you just need to reposition you mesh.  
`mesh.position = new BABYLON.Vector3(0, 5, -10)` , for example.

---

<div class="post-metadata">

**Author:** ![wangjia5693](https://avatars.discourse-cdn.com/v4/letter/w/a183cd/32.png) [@wangjia5693](https://forum.babylonjs.com/u/wangjia5693)\
**Post date:** [December 30, 2021, 6:06am UTC](https://forum.babylonjs.com/t/mesh-scaling-problems/26363/3 "2021-12-30T06:06:41Z")

</div>

in my condition, i prefer 2, but this is the problem, how to calculate the new position

---

<div class="post-metadata">

**Author:** ![labris](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/labris/32/12576_2.png) [@labris](https://forum.babylonjs.com/u/labris)\
**Post date:** [December 30, 2021, 6:21am UTC](https://forum.babylonjs.com/t/mesh-scaling-problems/26363/4 "2021-12-30T06:21:45Z")

</div>

The same way like in 3D editor - move it manually and check visually.  
You can do it with Inspector in Playground - press Gizmo sign and move with gizmo, then write this new position in the code

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/7/4/74ec83c6caeed8ebfd29dee7532cdd563d90e316.png)

---

<div class="post-metadata">

**Author:** ![wangjia5693](https://avatars.discourse-cdn.com/v4/letter/w/a183cd/32.png) [@wangjia5693](https://forum.babylonjs.com/u/wangjia5693)\
**Post date:** [December 31, 2021, 12:53am UTC](https://forum.babylonjs.com/t/mesh-scaling-problems/26363/5 "2021-12-31T00:53:21Z")

</div>

::,this is one solution,but my issue is the scaling is programatically

---

<div class="post-metadata">

**Author:** ![Blake](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/blake/32/21509_2.png) [@Blake](https://forum.babylonjs.com/u/Blake)\
**Post date:** [December 31, 2021, 1:23am UTC](https://forum.babylonjs.com/t/mesh-scaling-problems/26363/6 "2021-12-31T01:23:40Z")

</div>

I think we might need the PG with wrong positions to help fix it programmatically - in the PG the positioning look fine but it’s scaling bones not meshes…

---

<div class="post-metadata">

**Author:** ![wangjia5693](https://avatars.discourse-cdn.com/v4/letter/w/a183cd/32.png) [@wangjia5693](https://forum.babylonjs.com/u/wangjia5693)\
**Post date:** [December 31, 2021, 2:00am UTC](https://forum.babylonjs.com/t/mesh-scaling-problems/26363/7 "2021-12-31T02:00:58Z")

</div>

i add a pg ,[Babylon.js Playground](https://www.babylonjs-playground.com/#RIM2HV)

---

<div class="post-metadata">

**Author:** ![Blake](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/blake/32/21509_2.png) [@Blake](https://forum.babylonjs.com/u/Blake)\
**Post date:** [December 31, 2021, 2:33am UTC](https://forum.babylonjs.com/t/mesh-scaling-problems/26363/8 "2021-12-31T02:33:00Z")

</div>

What I would do is simply multiple position by same factor as scaling, like below. 🙂

> **[Babylon.js Playground](https://www.babylonjs-playground.com/#RIM2HV%232)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

---

<div class="post-metadata">

**Author:** ![wangjia5693](https://avatars.discourse-cdn.com/v4/letter/w/a183cd/32.png) [@wangjia5693](https://forum.babylonjs.com/u/wangjia5693)\
**Post date:** [December 31, 2021, 2:58am UTC](https://forum.babylonjs.com/t/mesh-scaling-problems/26363/9 "2021-12-31T02:58:56Z")

</div>

::::,you see the result is not right

---

<div class="post-metadata">

**Author:** ![Blake](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/blake/32/21509_2.png) [@Blake](https://forum.babylonjs.com/u/Blake)\
**Post date:** [December 31, 2021, 3:21am UTC](https://forum.babylonjs.com/t/mesh-scaling-problems/26363/10 "2021-12-31T03:21:08Z")

</div>

> [@wangjia5693](#):
>
> the result is not right

It looks right to me - the handle is now right next to the brush as it should be… What’s the issue I wonder? 🤔

---

<div class="post-metadata">

**Author:** ![wangjia5693](https://avatars.discourse-cdn.com/v4/letter/w/a183cd/32.png) [@wangjia5693](https://forum.babylonjs.com/u/wangjia5693)\
**Post date:** [December 31, 2021, 3:25am UTC](https://forum.babylonjs.com/t/mesh-scaling-problems/26363/11 "2021-12-31T03:25:56Z")

</div>

![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/3/5/35a70901bfc7e0012c5b5d18250752613f87aa52.png)

it has gap,you can comment scaling code to see the origin effect

---

<div class="post-metadata">

**Author:** ![Blake](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/blake/32/21509_2.png) [@Blake](https://forum.babylonjs.com/u/Blake)\
**Post date:** [December 31, 2021, 3:46am UTC](https://forum.babylonjs.com/t/mesh-scaling-problems/26363/13 "2021-12-31T03:46:59Z")

</div>

Welp, I didn’t zoom in enough to notice that. The other way, scaling the parent, produces the same result with the small gap between them. I’m not sure why thou. 🤔 But I’l take another look tomorrow if still isn’t solved thou. 🙂

> **[Babylon.js Playground](https://www.babylonjs-playground.com/#RIM2HV%234)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

---

<div class="post-metadata">

**Author:** ![Blake](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/blake/32/21509_2.png) [@Blake](https://forum.babylonjs.com/u/Blake)\
**Post date:** [December 31, 2021, 7:31pm UTC](https://forum.babylonjs.com/t/mesh-scaling-problems/26363/14 "2021-12-31T19:31:08Z")

</div>

I double checked and it works with the model I made in Blender with multiple meshes right next to each other, without creating a gap when I multiply my weapon mesh’s scale and position by the same factor. IDK why it isn’t working in this case thou, with your models. When I did it all the meshes were exported in the same GLB file, but IDK why that would affect the gap. 🤔

---

<div class="post-metadata">

**Author:** ![wangjia5693](https://avatars.discourse-cdn.com/v4/letter/w/a183cd/32.png) [@wangjia5693](https://forum.babylonjs.com/u/wangjia5693)\
**Post date:** [January 1, 2022, 12:56am UTC](https://forum.babylonjs.com/t/mesh-scaling-problems/26363/15 "2022-01-01T00:56:49Z")

</div>

thanks a lot ,i think i should check it or change another way

---

<div class="post-metadata">

**Author:** ![wangjia5693](https://avatars.discourse-cdn.com/v4/letter/w/a183cd/32.png) [@wangjia5693](https://forum.babylonjs.com/u/wangjia5693)\
**Post date:** [January 1, 2022, 1:40am UTC](https://forum.babylonjs.com/t/mesh-scaling-problems/26363/16 "2022-01-01T01:40:31Z")

</div>

i think pivotPoint maybe work,like this [https://www.babylonjs-playground.com/#RIM2HV#7,now](https://www.babylonjs-playground.com/#RIM2HV#7,now) i just should caculate the pivotPoint Programmatic

---

<div class="post-metadata">

**Author:** ![Blake](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/blake/32/21509_2.png) [@Blake](https://forum.babylonjs.com/u/Blake)\
**Post date:** [January 1, 2022, 9:11pm UTC](https://forum.babylonjs.com/t/mesh-scaling-problems/26363/17 "2022-01-01T21:11:39Z")

</div>

Heya I took another shot and got it working using the root node bounding vectors to correct the alignment programmatically. 🙂 I think you’re pivot point solution could work too but IDK how to calculate the right value programmatically to correct the alignment that way. 🍻

> **[Babylon.js Playground](https://www.babylonjs-playground.com/#RIM2HV%2310)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes
