Tube from 3d points

In this topic there is code for drawing a tube from a set of 2d points, but I need to draw from a set of 3d points, where the tube can’t be represented as a line in a 2d plane.

I’m working in a open source project and we need to create tubes like Wolfram does.

Linked GitHub issue:

If you need round “joints” between line segments, then create a capsule geometry and use it for segments :thinking:

1 Like

Maybe you can use some of it?

How would I do that?

I’ll try it out. But I guess yes, that seems to create the curve from a set of 3d points.

Get points from a THREE.Path() of two .absarc(), and use THREE.LatheGeometry :thinking:
For example: Selective Bloom (parts of a single geometry)

function CapsuleGeom(R, L){

  let path = new THREE.Path();
  path.absarc(0, 0, R, Math.PI * 1.5, 0);
  path.absarc(0, L, R, 0, Math.PI * 0.5);
  let pts = path.getPoints(5);
  let g = new THREE.LatheBufferGeometry(pts);
  return g;
1 Like

@hofk I couldn’t use your code :cry:.

@prisoner849 I don’t understand, doesn’t Path can only be 2D? I mean, it can be shifted and rotated, but it will always be a line in a 2D plane. Isn’t it?

An [probably bad] idea I had with your other comment is betwen each two coordinates have a tube geometry, but that would be very slow.

Another idea is use LineGeometry? Can it looks more 3Dish?

When you create a lathe geometry, you can translate, rotate and scale it at your will in 3D.

What I want to say is that even if it be rotated, translated and scalled it still is a line in a 2d plane.

2d plane over 3d

There is a plane which pass through any 3 points, but this is not true for every 4 points, what leads to even if we rotate and translate a set of 2d points, its plane won’t contain every possibility of a set of 4+ coordinates. But of course this is a start, as I guess the tubes are going to be <4 points a good part of the time.

I saw a solution for the path here.

I made the end caps with half spheres.


If anyone is interested in the code, it is in this PR and is going to be merged soon was merged.