Logic of vertex ordering of box builder

I am trying to understand the MeshBuilder and its strategies because I want to decide if I may be better off just using vertex data.

First I want to understand the reason why vertices are ordered the way they are for the box builder:


The order is +z, -z, +x, -x, +y, -y as explained in Map Materials to Individual Mesh Faces | Babylon.js Documentation

Is there a reason why z is first ? Perhaps because it is the forward direction.

shows the construction.

The next question is why are sides rotated (with default uvs, and no wrap) with respect to each other ? Is that ordering systematic ? Probably, but what is the principle ?

I think I understand the purpose of the wrap option (reorient faces upright on the sides) but the implementation is hard to follow. Is is possible to explain that procedure ?

Finally, I could not find examples for the top/bottomBaseAt options. I think they are linked to wrap, and may define how wrap reorients sides.

useRightHandedSystem seems to result in mirroring of textures, perhaps because there is no attempt at taking the option into account (which may be the most transparent option).

Haha! I wrote it this way because it was the clearer in my mind at that time. There is no big strategy unfortunately

I found that representation easy to write and maintain

1 Like

I did not write the topAt/bottomAt though. I think @JohnK did if my memory serves

Thanks. Mostly, I needed to figure out how to adjust faceUVs for RHS and wrap, and could accomplished that more or less by experimenting.