# Three.js geometry help

**URL:** <https://discourse.threejs.org/t/three-js-geometry-help/52210>\
**Category:** Questions\
**Tags:** geometry\
**Created:** [May 30, 2023, 3:25pm UTC](https://discourse.threejs.org/t/three-js-geometry-help/52210 "2023-05-30T15:25:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![cory](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/cory/32/33264_2.png) [@cory](https://discourse.threejs.org/u/cory)\
**Post date:** [May 30, 2023, 3:25pm UTC](https://discourse.threejs.org/t/three-js-geometry-help/52210/1 "2023-05-30T15:25:13Z")

</div>

> **[Screenshot\_2.png](https://drive.google.com/file/d/1VEKf84T-qQZ80i6VEhiGvl3gjfhjOR_l/view?usp=sharing)**
>
> Google Drive file.

I would like to build such geometry in three.js

How can I do it.  
Please help me 🥺

---

<div class="post-metadata">

**Author:** ![PavelBoytchev](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/pavelboytchev/32/38639_2.png) [@PavelBoytchev](https://discourse.threejs.org/u/PavelBoytchev)\
**Post date:** [May 30, 2023, 4:21pm UTC](https://discourse.threejs.org/t/three-js-geometry-help/52210/2 "2023-05-30T16:21:36Z")

</div>

Here is an idea:

Start with a cylinder with three layers of vertices. Keep the upper two layers unchanged. Modify only the bottom layer of vertices – reposition them into the vertices of a square. That’s all. Here is how it looks like in wireframe and in solid mode:

 ![image](https://canada1.discourse-cdn.com/flex035/uploads/threejs/original/3X/d/8/d85764a99625b0deee511a998aa21119587e276b.jpeg)

I will leave the actual coding to you.

---

<div class="post-metadata">

**Author:** ![cory](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/cory/32/33264_2.png) [@cory](https://discourse.threejs.org/u/cory)\
**Post date:** [May 30, 2023, 6:48pm UTC](https://discourse.threejs.org/t/three-js-geometry-help/52210/3 "2023-05-30T18:48:53Z")

</div>

Thank you, great idea.

Could you please explain how I can change the position of vertices of the cylinder geometry?

If you have any sample code, please share me.

Thank you again, Pavel

---

<div class="post-metadata">

**Author:** ![prisoner849](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/prisoner849/32/535_2.png) [@prisoner849](https://discourse.threejs.org/u/prisoner849)\
**Post date:** [May 30, 2023, 6:58pm UTC](https://discourse.threejs.org/t/three-js-geometry-help/52210/4 "2023-05-30T18:58:23Z")

</div>

@PavelBoytchev Very cool approach. Actually, this was my first thought too, to deform a cylinder.  
But I went the way of merging of geometries (custom one and an open-ended cylinder)

 ![изображение](https://canada1.discourse-cdn.com/flex035/uploads/threejs/original/3X/5/b/5b6ea027034ef3798faae5261eedf8e8e35ba1f6.png)

@cory  
To change vertices of a geometry, you can use [`.setXYZ()`](https://threejs.org/docs/index.html#api/en/core/BufferAttribute.setXYZ) method of `BufferAttribute`.
