Tubegeometry and linemateria How to apply different opacity

I am drawing a trajectory using tubegeometry and linematerial
I’m planning to use red as the trajectory color.
I want to give a lot of transparency at the beginning of the trajectory and make the color darker as it goes further away so that the lines behind it can be clearly seen.
What should I do

function setupLine(trajectory) {
  const lineMaterial = new THREE.LineBasicMaterial({ color: 'red', opacity: 0.7, transparent: true });
  let linePoints = [];
  for (let i = 0; i < trajectory.length; i++) {
    linePoints.push( new THREE.Vector3(trajectory[i].x, trajectory[i].z, -trajectory[i].y).multiplyScalar(1));

  let tubeGeometry = new THREE.TubeGeometry(
    new THREE.CatmullRomCurve3(linePoints),
    40,// path segments
    0.2,// THICKNESS
    22, //Roundness of Tube
    false //closed

  let line = new THREE.Mesh(tubeGeometry, lineMaterial);
  line.position.z = 95
  line.position.y = -12

You will need a different Shader material that can handle gradients and stops