How to create a segmented Tube?

I’ve seen examples of creating infinite tubes using a list of points, converting them to a list of vertices, generating a CatmullRomCurve3 and then using that for a TubeGeometry. But I want to create a “tunnel” that has 4 parts like so (excuse the horrendous sketch):

Through the gaps you can see outside the “tunnel”. The bottom of this tube is a flat plane, to mimic a road. I could give the cylinders a certain theta end like Math.PI / 2 to make it 25% of a circle and position them a certain way, but I’m not sure how to have all of the 4 pieces follow the same curve to make it “feel” like a single tube.

Thanks for the challenging question.

  • Easy way: use a texture with transparent areas that correspond to the gaps
  • Hard way: make a parametric geometry that builds a part of a circular tube

I tried the hard way and here is what I came up with. I hope it can provide you with enough hints or ideas.

https://codepen.io/boytchev/full/poxpGZN

image

I went another way, with a curve.

Demo: https://codepen.io/prisoner849/full/rNqpZGN

In @PavelBoytchev’s solution, the flat part on which you move always stays down. In @prisoner849’s solution, you rotate in the tube and the flat part is in different positions.

I have not yet found a solution for the rotation in my problem Inaccurate adjustment when cylinder is deformed. Must see if I can learn something from these solutions. :thinking:

I updated the codepen, found a very interesting solution from @ycw to keep camera stable, so the flat part of the tunnel is always oriented horizontally. Comments are in the code.

Wow some terrific solutions. I’m going to try and wrap my head around the codepens, thanks so much for the help!