curve = {
const curve = new THREE.CatmullRomCurve3(positions);
curve.curveType = 'catmullrom';
curve.closed = false;
const curvePoints = curve.getPoints(500);
const tubeRadius = 0.1;
const tubularSegments = 250;
const radialSegments = 36;
const tubeGeometry = new THREE.TubeGeometry(curve, tubularSegments, tubeRadius, radialSegments, false);
const colors = [];
const color1 = new THREE.Color(0x7ae7c7);
const color2 = new THREE.Color(0xEEB868);
const color3 = new THREE.Color(0xEF767A)
for (let i = 0; i < tubeGeometry.attributes.position.count; i++) {
const t = i / tubeGeometry.attributes.position.count;
const color = t <= .25 ? color1 : t <= .5 ? color2 : color3
colors.push(color.r, color.g, color.b);
}
tubeGeometry.setAttribute('color', new THREE.Float32BufferAttribute(colors, 3));
const tubeMaterial = new THREE.MeshStandardMaterial({
vertexColors: true,
side: THREE.DoubleSide,
transparent: true,
opacity: .5
});
return new THREE.Mesh(tubeGeometry, tubeMaterial);
}