Straight tube geometry

Is it possible to use the tube geometry with a straight path or can it only be used with curve path? I know that exists the cylinder geometry but for what I’m doing it doesn’t work .

CylinderGeomety is the first option I would recommend. And what are you doing that it doesn’t work?

The main problem is that i’m trying to make it appear in runtime but the fact that the cylinder geometry create itself from the center and grow from both side instead of only one make it look very bad on my project, i tried to post a video here but it says that the format is not supported. Can you give me an hand?

I even don’t know what visual you’re trying to achieve. And you provided no code
Looks like you’re trying to put a tube from one point to another.

let a = _some_v3_;
let b = _some_v3_;
let lookAt = new THREE.Vector3();

let dist = a.distanceTo(b);
let g = new THREE.CylinderGeometry(r, r, dist) //create geometry
    .translate(0, dist * 0.5, 0) // rise at a half of height, setting bottm to 0, 0, 0
    .rotateX(Math.PI * 0.5); // align with Z-axis
let m = _some_material_;
let o = new THREE.Mesh(g, m);
o.position.copy(a); // set position
o.lookAt(b); // orient

Something like this. Needs testing :slight_smile:

1 Like