How do i unwrap a 3D mesh in Babylonjs programatically?

Hi, I’m trying to apply different textures on different faces of a mesh. In this playground, a cube

when you click on a surface of the cube, you can see an image appears there, the problem is it appears on other faces as well. Right now 'im using a dynamic texture to achieve this. This kind of behaviour is because each face uses the entire image as it’s texture. What i would like is that no UV’s to overlap. Also I know this can be done using external softwares like blender but i need to do this programatically.

This is not built in Babylon, but you can implement any UV mapping algorithm you want, such as spherical mapping: Spherical Texture Mapping (mvps.org)

1 Like

I will be importing a mesh that is going to be cube/cuboid, sphere or a cylinder mostly, any ideas what would be the best algorithm? I’m still new to UV mapping so i could use some help.

Spherical mapping is a pretty simple one, there’s also this C++ library that has more complex algorithms: jpcy/xatlas: Mesh parameterization / UV unwrapping library (github.com)

Thank you @carolhmj.