I have a mesh that I build up of multiple boxes where I change the position of each box so that all boxes together form my desired shape. I then merge all those boxes together using let mergedBoxes = BABYLON.Mesh.MergeMeshes(boxes)
where boxes is an array holding all my boxes.
I noticed that the position of mergedBoxes is not in the center of all boxes and also not in the center of any box that was merged.
Here’s a simple PG that reproduces this: https://playground.babylonjs.com/#E0XKDU#1
I have one box at (10, 0, 0) and one box at (10, 0, 10), and after merging their position seems to be (0, 0, 0).
I’m pretty sure this is expected behaviour, but I need the position that is at the center of those boxes because I have an arrow that points to that merged mesh, and it doesn’t point at the right position now.
I thought about taking the positions of all boxes that I merge and averaging out their x,y and z positions so that I have a position for the arrow to point to, but I’d prefer an approach that changes the mergedMesh’s position to what I want