I’m developing a configurator with loaded .gltf objects. It’ll be necessary to have some meshes set as parent of others (because they have to move together). But it’s important that the scaling of the parent doesn’t affect the scaling of the child, since it’ll be a fixed object in dimensions.
In Blender there’s the constraint “Child of” feature, in which you can relate two objects and set which transformation won’t have an impact on the child (for example X ax of scaling property).
I tried to export it but it seems that babylon doesn’t keep the relationship.
I searched in the mesh documentation but i couldn’t find any properties / methods related to this goal.
When looking up online I found this trick of setting the child’s scaling to be the inverse of the parent → babylonjs - Babylon Js children that follow parent withouth the scaling - Stack Overflow
I wondered if there’s a feature in babylon api to achieve this, or if someone has suggestions on how to proceed.
Otherwise I thought about creating for each parent mesh an empty object on the edge of the mesh, to which the child will always snap to for every transformation. So they would be fake parent - child, only related to that pos x, y, z of the empty object.
But idk, i wanted to see before starting this new procedure, if there was something easier.
The red mesh will actually be my “empty objects” that will be used just as snapping points.
They are child of the variable part, so that when the parent scales, also their position changes.
While the fixed part, after the scaling of the variable, will be repositioned according to the empty object.
The only obstacle is that, when i scale the variable mesh, even though the red cubes move as expected, their x, y, z value remains equal to the starting one.
So I need to understand if there’s a way to have an updated location of those mesh.
(The behaviour is the same also in blender, i have to do some research)
Thank you very much for your example.
Unfortunately I think this could not work though, cause in my situation there is more interaction between the parts: https://playground.babylonjs.com/#AL6DK7#1
(When i scale the yellow part, the blue / fixed ones have to be repositioned in the extremes of the yellow )
Hello again and sry for late reply (I had to attend to a weekend of flight sim in the Swiss alps;)
Just need to get my feets back on the ground. This must work (may be not just this way), but using parented empty meshes for defining inner and outer exclusion zones you can snap to (or collide with) is something I have used for creating customer environments and dealer dev tools for scene building in unity and this approach in 3D with meshes works. Did you have a chance to investigate it a little further during the WE or are you still stuck?
Hei @mawa, i’m late too with this reply, i don’t know how i missed it. I hope everything was great in the Swiss alps!
The configurator i’m building had to do a jump back on the flow analysis and bureaucracy stuff, but in the meanwhile i’ve used another approach: https://playground.babylonjs.com/#AL6DK7#3
I’m scaling the variable pieces and at the same time, multiplying the original position of the fixed mesh * the scaling factor.
I don’t think it’s the most performing solution but it’s the only one that i found that suits my situation.
When the configurator will be (finally) done, i’ll share it with you guys