This time I have a tricky one for you. My problem is simply explained: I want to put an imported model into a box. But as models always have their own very specific parameters, I just can’t get it working.
Here is my approach:
I check the boundingBox of every meshes from the model in order to determine the size and the center of this group of meshes. Then I scale it and move it so that it goes in the boundmesh. It seems pretty simple but I really can’t find the right formulas to make it work whatever the model!
I made a playground with two models, one which works (a pretty simple sphere icon) and one which don’t (two separated shoes, you can see one shoes goes outside the boundmesh): https://www.babylonjs-playground.com/#0108NG#8
Check the “meshgroup” class which I use with my comments!
Thanks for your help!