2d imposter texture positioning

Hi, im trying to use 2d imposters in my scene, i already have a texture with a variety of angles for my mesh, but how can i apply them to a plane? So where can i set the uv coordinates for the applied texture on the mesh?

Could you not rely on sprites for this ? Sprites - Babylon.js Documentation

Welcome aboard!

You can use decals (Use decals - Babylon.js Documentation) for that, but maybe it’s a bit heavyweight if your target meshes are only planes…

1 Like

thanks for the quick response, yeah i probably could use sprites, but would prefer the solution with planes. Decals would help (i think), but the scene is already quite big and i think this would kill my performance, is there no possibility to just say: “use this part of the texture” and then exchange them on camera rotation, i only need to track the rotation on the y-axis

A texture needs texture coordinate to be applied correctly, so you have to provide them in a way or another (normally through the uv attribute).

yeah, but how can i set the uv coordinates on the mesh?

Normally you do it in an external program (for eg in Blender) at modeling time.

For a plane, as there’s a very little number of vertices, you can do it programmatically by building the uvs yourself and setting them by calling mesh.setVerticesData("uv", uvarray).

I think you can also use faceuv at plane creation time (see Product Customizer - UI and applying/projecting elements (text, image) to the specific part of the UV space for a use case with a cube).