UV mapping over extruded Mesh

Hi there,
i’ve an extruded mesh builded from a bizier curve. I want to remapping the UV becouse i need to apply textures only at one face. Working with a cube texture is pretty simple, but with a custom mesh i didn’t understand how to do it.
This is my PG: https://playground.babylonjs.com/#RG2S1J#3

I’ve tried using also getIndices() but i didn’t figured out how to manege the results.
Any idea? Thanks in advance.

If there are no rotations or scaling along the extrusion then an extruded polygon method might suffice Irregular Polygon Extrusion | Babylon.js Documentation

1 Like

Thank you, it works!

In this way a can easily place the texture on my extruded shape but i can’t map the texture only on one face. In this PG https://playground.babylonjs.com/#RG2S1J#12 i want the texture to be mapped only on the flat face of the mesh, but it seems that faceUV[1] = new BABYLON.Vector4(0, 0, -1, 1); (line 57) takes also all the the others faces (except the bottom e top which are correctly mapped on face 0 and 2).
Is there a way to manage that?

I think I understand. By the flat face you mean one of the extruded sides rather than the top and bottom faces. You would need to have your texture extended with blank areas on its left and/or right sides and set the wrap option to true. The alternative is to create a plane of the correct size and parent it to the flat side and apply the texture to the plane.

1 Like

Ok understood. But the idea was to map another portion of texture on the other extruded side (the curved one), so i suppose i must refactor the texture and then try to fit all the mesh faces i need. Is it right?

EDIT: where do i set the wrap option, on the texture object?

Yes and fit the size of each image to match the ratios of the flat side and curved side heights and widths.

One of the options for extrudePolygon.

1 Like