How to create a pipeline geometry as shown below from two vectors?

data: new Vector3(0, 0, 0) , new Vector3(10, 10, 0);

There’s lots of ways… here’s one…


  let geo = new THREE.CylinderGeometry(1,1,.01);
  let a = geo.attributes.position.array;
  for(let i=0;i<a.length;i+=3)
  if(a[i+1]>0){
      a[i+0]+=10;
      a[i+1]+=10;
  }
  scene.add(new THREE.Mesh(geo,new THREE.MeshStandardMaterial()))

https://charmed-spotless-guide.glitch.me

Is any vector data OK?

My example was just a very simple hack.

If you want to extrude along a path… check out this example:

https://threejs.org/examples/?q=extr#webgl_geometry_extrude_shapes

I’ve tried this, but it doesn’t work as I expected. Because my vector data consists of many groups of data, and the connection points are relatively sharp.

post an example of your data, and maybe we can help you decide how to best build the structure?

Are you trying to make the windows pipes screensaver?

1 Like

https://jsfiddle.net/seadd/2Lqat0j9/18/
Here is the example, using TubeGeometry, but the shape is not what I expected.

Can anyone please help me?

Create a cylinder that starts from vector 1. Its height should be as much as the vertical difference between vector 2 and vector 1. This is the dashed cylinder in the image. Then modify only the top vertices of the cylinder geometry by shifting them as much as is the horizontal distance between the vectors. @manthrax already showed you how individual verticed can be moved.

2 Likes

@a627247084
This is a bit tricky, than it seems, if you care about tube’s profile to be a circle.
The more you shift the top cut, the more flat ellipse as tube’s profile you get.
Cosine has to be taken in count, to make cuts into ellipses to keep tube’s profile in the form of a circle :thinking:

My suggestion is based on the original post. It is rather vague and it does not specify a lot of details. Thus I have the liberty to set the unknown things the easiest way. I’d assume that the caps should be circular, because I have the impression that several pipes will be glued together, so the point of stitching should be consistent.

@PavelBoytchev Yeah, true, no questions to your solution at all. :handshake:
In my head I addressed my post to the author or the topic :slight_smile: I edited my previous post.

1 Like

Hm. If several pipes need to be glued together, they have to have angled cuts :thinking:
изображение
Otherwise, result will look weird.
But we really don’t know what’s the goal :slight_smile:

1 Like

Isnt this how 3D geometry works ??? If you want smoother pipes, then increase the horizontal segment amount. Anyway, to get the result of your first picture, you may want to try intersecting the tube with 2 planes or cubes and attempt to boolean intersect the model. I think there are some tools in buffergeometry (utils) or try three csg. three.js examples

I used the vertex translation method above, and the outline will indeed become an ellipse.

Any relevance to the topic?

How to update tubeGeometry geometry based in lineCurve modifications? - #14 by hofk
DynamicTubeGeometryCaps