Is there a way I can create a Path or Curve to use for TubeGeomety(path,…) from an existing geometry’s points/vertices array?

I’m very new to both three.js & to js in general.
1st I select a polyHedron geometry with a dat.gui checkbox
which renders say a tetrahedron. these selections work.
I also have a dat.gui checkbox to either phongfill or wireframe render.
I initially wanted just a wireframe type mesh but not with all of the internal triangles. I found the edgesgeometry() function which draws pretty much what I want(hard edges only). there is however a known issue with linewidth not working in windows anymore. all lines drawn as strokeweight/width 1.

I’d like to use tubeGeometry() to draw tubes of whatever radius as opposed to 1weight lines. I know I’ll have to draw something such as a sphere at/over the connection vertices for it to not look ridiculous.

geo = new THREE.TetrahedronBufferGeometry(controls0.Radius,controls0.Detail);
egeo = new THREE.EdgesGeometry( geo );
lmat = new THREE.LineBasicMaterial({ color: 0x0099ff, linewidth: 4 });
ph = new THREE.LineSegments( egeo, lmat );

playing around in the console I found some geometry/bufferGeomery arrays that are likely the vertices/indices of my selected X-hedron as their sizes change with type(tetra/icosa etc) selection & detail increase/decrease:

//p = dome.geometry.attributes.uv.array;
p = egeo.attributes.position.array
//p = geo.attributes.uv.array
var path = new THREE.Curve();
path.getPoint = function (t) {
// trace the arc as t ranges from 0 to 1
var segment = (0 - Math.PI*2) *t;
return new THREE.Vector3( Math.cos(segment), Math.sin(segment), 0);

 var geomet = new THREE.TubeBufferGeometry( path, 10, 0.2, 12, false );
 var mesh = new THREE.Mesh( geomet, mat );
 scene.add( mesh );

from above the tubeGeometry() draws fine separately as well but with the “path” made by that curve example. How can I use the vertices from my tetrahedron for example to create that “path” to pass to tubegeometry() ?

maybe a function that creates “segment vectors” from the vertices ?
I think it needs other properties of curve/path as well ?
I’m quite stuck at this point.

ANY Help, suggestions or examples would be greatly appreciated !

Leave a Reply

Your email address will not be published.