Mesh scaling problems

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 my meshes are from 3 glb

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.

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

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

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

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…

i add a pg ,Babylon.js Playground

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

::::,you see 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? :thinking:

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

1 Like

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. :thinking: But I’l take another look tomorrow if still isn’t solved thou. :slight_smile:

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. :thinking:

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

1 Like

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

1 Like

Heya I took another shot and got it working using the root node bounding vectors to correct the alignment programmatically. :slight_smile: 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. :beers:

2 Likes