Modify Mesh faces and UV mapping at runtime

Hello everyone!

Is it possible to change a Mesh and it’s UV mapping at runtime? For example what I would like to do is create a simple box, but then make sure that each side is comprised of nine regular square faces instead of a single face and then adapt the UV mapping such that those faces shows a part of a texture map containing for example different walls and windows.

I know how to create such a model and texture in Blender and import the resulting .glb file, but I was hoping there is a way to do something like this programatically.

I am new with Babylon.js and would appreciate any hints and tipps on this issue!

Thanks in advance and happy hollidays!
Patrick

Hello @Yrucoo , welcome to the Babylon forum!

Yes, Babylon allows you to programatically create a mesh. You can use the “VertexData” class to store position, normals, UVs and indexes of a mesh and manipulate those values as you choose.

See documentation here: Create Custom Meshes From Scratch | Babylon.js Documentation

1 Like

Hello @srzerbetto!

Thanks for the hint, yes that looks very promising!

Thanks again and best regards,
Patrick

1 Like