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
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:
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.
::::,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?
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.
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.
thanks a lot ,i think i should check it or change another way
i think pivotPoint maybe work,like this https://www.babylonjs-playground.com/#RIM2HV#7,now i just should caculate the pivotPoint Programmatic
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.