Problem with the position of the texture on my custom mesh

This is mathematics rather than Babylon.js. You could search the web for
calculate uv coordinates.

For a fairly simple plane.

Take the plane to be lying in the XY axis with Z axis making the bumps and the u axis of the texture along the X axis and v along the Y axis.

For a vertex at (x, y, z)

u = (x - minimum x) / (maximum x - minimum x)

v = (y - minimum y) / (maximum y - minimum y)

For the plane or texture lying in different directions these will change.

This may be useful for you Trying to fit a simple image as a planar XZ UV map on a CreateLathe object - #7 by JohnK

1 Like