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

Hello :slight_smile:

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)

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 :thinking:.

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

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 :blush:.


Why not creating the model in blender and exporting it ? or manually creating the vertices for it ? Creating Parametric Meshes | Babylon.js Documentation

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

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

1 Like

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