# Clip mesh: cut a cylinder based on a circle/plane

**URL:** <https://forum.babylonjs.com/t/clip-mesh-cut-a-cylinder-based-on-a-circle-plane/22577>\
**Category:** Questions\
**Created:** [July 23, 2021, 2:30pm UTC](https://forum.babylonjs.com/t/clip-mesh-cut-a-cylinder-based-on-a-circle-plane/22577 "2021-07-23T14:30:28Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![maxime1992](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/maxime1992/32/4922_2.png) [@maxime1992](https://forum.babylonjs.com/u/maxime1992)\
**Post date:** [July 23, 2021, 2:30pm UTC](https://forum.babylonjs.com/t/clip-mesh-cut-a-cylinder-based-on-a-circle-plane/22577/1 "2021-07-23T14:30:28Z")

</div>

Hello 🙂

Here’s a schema of what I’m trying to achieve:

(can only upload 1 picture so I’ve put numbers to describe each steps)

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/9/c/9ce8e50f595a651a784df4cb61addbcb921accde.jpeg)

1: Draw 2 planes or preferably 2 circles (should be the same I assume). Then put a cylinder in between and cut that cylinder exactly where it intersects with the circles.

As you can see above, if you do a cylinder that’s exactly as long as it needs to be, unless it’s perpendicular… You’ll have either a tiny gap (if cylinder is too short):

See number 2 on pic.

Or it’ll go beyond (cylinder is slightly too long):

See number 3 on pic.

What I’d like would be a “nice” cut:

See number 4 on pic.

I’m not sure how to achieve this and my first thought would be to have a longer cylinder and a custom vertex + fragment shader to which I’d provide the min x and max x and anything below/above those values would receive a transparent color.

But it feels wrong 🤔.

I’m fairly new to all this, thanks for any idea and the patience to help me out 🙏.

Ps: I don’t have any code right now, just sharing my idea to see if I’m going into the right direction. I’m not expecting anyone to do this for me and provide code, just share idea/give some guidance 😊.

Thanks

---

<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:** [July 23, 2021, 2:50pm UTC](https://forum.babylonjs.com/t/clip-mesh-cut-a-cylinder-based-on-a-circle-plane/22577/2 "2021-07-23T14:50:12Z")

</div>

Why not creating the model in blender and exporting it ? or manually creating the vertices for it ? [Creating Parametric Meshes | Babylon.js Documentation](https://doc.babylonjs.com/divingDeeper/mesh/creation/param)

---

<div class="post-metadata">

**Author:** ![maxime1992](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/maxime1992/32/4922_2.png) [@maxime1992](https://forum.babylonjs.com/u/maxime1992)\
**Post date:** [July 23, 2021, 2:57pm UTC](https://forum.babylonjs.com/t/clip-mesh-cut-a-cylinder-based-on-a-circle-plane/22577/3 "2021-07-23T14:57:43Z")

</div>

It’ll be dynamic. It’ll represent cables in a box and the order in which they are (and their direction) will change based on some user config so I need to be able to do that dynamically

---

<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:** [July 23, 2021, 3:21pm UTC](https://forum.babylonjs.com/t/clip-mesh-cut-a-cylinder-based-on-a-circle-plane/22577/4 "2021-07-23T15:21:09Z")

</div>

You could use a ribbon, the start and end positions of each path would lie on the planes.

> **[Creating Ribbons | Babylon.js Documentation](https://doc.babylonjs.com/divingDeeper/mesh/creation/param/ribbon)**
>
> Learn how to create ribbons in Babylon.js.

---

<div class="post-metadata">

**Author:** ![maxime1992](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/maxime1992/32/4922_2.png) [@maxime1992](https://forum.babylonjs.com/u/maxime1992)\
**Post date:** [July 23, 2021, 3:51pm UTC](https://forum.babylonjs.com/t/clip-mesh-cut-a-cylinder-based-on-a-circle-plane/22577/5 "2021-07-23T15:51:05Z")

</div>

Oooh thanks, looks like that could work perfectly thanks I’ll try that
