# Problem with the position of the texture on my custom mesh

**URL:** <https://forum.babylonjs.com/t/problem-with-the-position-of-the-texture-on-my-custom-mesh/23107>\
**Category:** Questions\
**Tags:** material\
**Created:** [August 16, 2021, 2:09pm UTC](https://forum.babylonjs.com/t/problem-with-the-position-of-the-texture-on-my-custom-mesh/23107 "2021-08-16T14:09:38Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Arash\_Bagheri](https://avatars.discourse-cdn.com/v4/letter/a/dfb087/32.png) [@Arash\_Bagheri](https://forum.babylonjs.com/u/Arash_Bagheri)\
**Post date:** [August 16, 2021, 2:09pm UTC](https://forum.babylonjs.com/t/problem-with-the-position-of-the-texture-on-my-custom-mesh/23107/1 "2021-08-16T14:09:38Z")

</div>

Hello everyone

I have a GIS application, and I should texture an image on the plane shape custom mesh , the problem is I must select one of the edge of the custom mesh, and put the texture on it from that point. I want to know how can I get the one edge of the custom mesh ( as a start point of texture) and put the texture on the custom mesh from that point.

here is a test PG : [https://playground.babylonjs.com/#2TCZZ9#10](https://playground.babylonjs.com/#2TCZZ9#10)

and here is my actual custom mesh in my project:

 ![Screenshot 2021-08-16 at 15.01.42](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/e/4/e43aba5565da66c05e0926f1301e550d5a5b7568.jpeg)

---

<div class="post-metadata">

**Author:** ![JohnK](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/johnk/32/26764_2.png) [@JohnK](https://forum.babylonjs.com/u/JohnK)\
**Post date:** [August 16, 2021, 3:31pm UTC](https://forum.babylonjs.com/t/problem-with-the-position-of-the-texture-on-my-custom-mesh/23107/2 "2021-08-16T15:31:16Z")

</div>

> [@Arash\_Bagheri](#):
>
> I want to know how can I get the one edge of the custom mesh ( as a start point of texture) and put the texture on the custom mesh from that point.

There are 4 edges to your image texture, left, right, top, bottom. Imagine picking up your texture image and laying it over your mesh in the correct position. You then need to assign uv values to each vertex of your mesh with the v axis along the mesh side under the texture image left edge and the u axis along the mesh side under the texture image bottom edge.

Only on mobile so cannot do drawings or a playground

---

<div class="post-metadata">

**Author:** ![Arash\_Bagheri](https://avatars.discourse-cdn.com/v4/letter/a/dfb087/32.png) [@Arash\_Bagheri](https://forum.babylonjs.com/u/Arash_Bagheri)\
**Post date:** [August 16, 2021, 3:38pm UTC](https://forum.babylonjs.com/t/problem-with-the-position-of-the-texture-on-my-custom-mesh/23107/3 "2021-08-16T15:38:40Z")

</div>

@JohnK thank you for your help.

how can I assign uv value to each vertex? I mean I didn’t understand how can I do this.

I have 4 uv points :

```auto
   let uvs = [
        0, 0,
        1, 0,
        0, 1,
        1, 1,
    ]

```

and then ` vertexData.uvs = uvs;`  
why this not working?

---

<div class="post-metadata">

**Author:** ![JohnK](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/johnk/32/26764_2.png) [@JohnK](https://forum.babylonjs.com/u/JohnK)\
**Post date:** [August 16, 2021, 5:16pm UTC](https://forum.babylonjs.com/t/problem-with-the-position-of-the-texture-on-my-custom-mesh/23107/4 "2021-08-16T17:16:40Z")

</div>

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](https://forum.babylonjs.com/t/trying-to-fit-a-simple-image-as-a-planar-xz-uv-map-on-a-createlathe-object/21998/7)

---

<div class="post-metadata">

**Author:** ![Arash\_Bagheri](https://avatars.discourse-cdn.com/v4/letter/a/dfb087/32.png) [@Arash\_Bagheri](https://forum.babylonjs.com/u/Arash_Bagheri)\
**Post date:** [August 16, 2021, 5:20pm UTC](https://forum.babylonjs.com/t/problem-with-the-position-of-the-texture-on-my-custom-mesh/23107/5 "2021-08-16T17:20:49Z")

</div>

I have a GIS application, and in my app the plane is lying on XZ axis and Y is the attitude,  
so it should be Z instead of Y in the formula?

---

<div class="post-metadata">

**Author:** ![JohnK](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/johnk/32/26764_2.png) [@JohnK](https://forum.babylonjs.com/u/JohnK)\
**Post date:** [August 16, 2021, 5:24pm UTC](https://forum.babylonjs.com/t/problem-with-the-position-of-the-texture-on-my-custom-mesh/23107/6 "2021-08-16T17:24:17Z")

</div>

> [@Arash\_Bagheri](#):
>
> I have a GIS application, and in my app the plane is lying on XZ axis and Y is the attitude,  
> so it should be Z instead of Y in the formula?

Possibly

> [@Arash\_Bagheri](#):
>
> I must select one of the edge of the custom mesh, and put the texture on it from that point.

- depends on the selected edge

Best thing to do is try it out and set up a playground and ask if you have problems .

---

<div class="post-metadata">

**Author:** ![Arash\_Bagheri](https://avatars.discourse-cdn.com/v4/letter/a/dfb087/32.png) [@Arash\_Bagheri](https://forum.babylonjs.com/u/Arash_Bagheri)\
**Post date:** [August 16, 2021, 5:25pm UTC](https://forum.babylonjs.com/t/problem-with-the-position-of-the-texture-on-my-custom-mesh/23107/7 "2021-08-16T17:25:16Z")

</div>

Thank you so much 🙏 🙏
