# Stretch tube UVs of cylinder mesh

**URL:** <https://forum.babylonjs.com/t/stretch-tube-uvs-of-cylinder-mesh/45604>\
**Category:** Questions\
**Tags:** uv\
**Created:** [November 10, 2023, 11:56am UTC](https://forum.babylonjs.com/t/stretch-tube-uvs-of-cylinder-mesh/45604 "2023-11-10T11:56:49Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![DukeVen](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/dukeven/32/34217_2.png) [@DukeVen](https://forum.babylonjs.com/u/DukeVen)\
**Post date:** [November 10, 2023, 11:56am UTC](https://forum.babylonjs.com/t/stretch-tube-uvs-of-cylinder-mesh/45604/1 "2023-11-10T11:56:49Z")

</div>

How would I be able to stretch the uvs of the tube of the cylinder after it’s creation, using it’s verticesData?

Not sure of a way to only get the uvs of the tube of the cylinder in order to do this basically:

![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/8/7/8751d8b3af8eadcb1fb37a8b67dd5373e8f22982.png)

PG: [https://playground.babylonjs.com/#41JD5Z](https://playground.babylonjs.com/#41JD5Z)

---

<div class="post-metadata">

**Author:** ![Cedric](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/cedric/32/2742_2.png) [@Cedric](https://forum.babylonjs.com/u/Cedric)\
**Post date:** [November 10, 2023, 4:30pm UTC](https://forum.babylonjs.com/t/stretch-tube-uvs-of-cylinder-mesh/45604/2 "2023-11-10T16:30:02Z")

</div>

don’t forget to set mesh as updatable, and then do something like this :

> **[Babylon.js Playground](https://playground.babylonjs.com/#41JD5Z%231)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

also, don’t hesitate to read the documentation : [Updating Vertices | Babylon.js Documentation](https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/custom/updatingVertices)

---

<div class="post-metadata">

**Author:** ![DukeVen](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/dukeven/32/34217_2.png) [@DukeVen](https://forum.babylonjs.com/u/DukeVen)\
**Post date:** [November 10, 2023, 10:32pm UTC](https://forum.babylonjs.com/t/stretch-tube-uvs-of-cylinder-mesh/45604/3 "2023-11-10T22:32:39Z")

</div>

That’s not what I wanted to achieve exactly. I am familiar with a way to stretch all uvs of a mesh, but I’m only looking to stretch the uvs of the tube part of the cylinder, and not the top and bottom part, as seen marked on the image I posted.  
Since the cylinder has 300+ uv values, I’m not sure where to start…

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [November 10, 2023, 11:54pm UTC](https://forum.babylonjs.com/t/stretch-tube-uvs-of-cylinder-mesh/45604/4 "2023-11-10T23:54:23Z")

</div>

You could try checking if the corresponding normals are lying within a vertical or horizontal plan.

```auto
Dot(normal, up) = 0 -> tube else cap

```

---

<div class="post-metadata">

**Author:** ![DukeVen](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/dukeven/32/34217_2.png) [@DukeVen](https://forum.babylonjs.com/u/DukeVen)\
**Post date:** [November 11, 2023, 10:52am UTC](https://forum.babylonjs.com/t/stretch-tube-uvs-of-cylinder-mesh/45604/5 "2023-11-11T10:52:56Z")

</div>

So I get the normals of the mesh and then see which are lying within a vertical/horizontal plane.

But how do I actually get the UV data from that info afterwards?

---

<div class="post-metadata">

**Author:** ![Cedric](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/cedric/32/2742_2.png) [@Cedric](https://forum.babylonjs.com/u/Cedric)\
**Post date:** [November 13, 2023, 9:40am UTC](https://forum.babylonjs.com/t/stretch-tube-uvs-of-cylinder-mesh/45604/6 "2023-11-13T09:40:02Z")

</div>

You get the normals same way you get the UV. UV size array should be N \* 2 floats and Normal array size should be N \* 3. Where N is the number of vertices. So, it’s easy to get the corresponding normal for a particular UV index.
