0

In my React Three Fiber app I created a CatmullRomLine:

import { CatmullRomLine } from '@react-three/drei';
import * as THREE from 'three';

const Path = ({ pathRef }) => {
  const points = [];
  const numPoints = 50;
  const radiusX = 70;
  const radiusZ = 30;

  for (let i = 0; i <= numPoints; i++) {
    const angle = (i / numPoints) * Math.PI * 2;
    const x = Math.cos(angle) * radiusX;
    const y = 0;
    const z = Math.sin(angle) * radiusZ;

    points.push(new THREE.Vector3(x, y, z));
  }
  return (
    <CatmullRomLine
      points={points}
      color='white' // Line color
      lineWidth={2} // Line width
      position={[0, 10, 0]}
      ref={pathRef}
    />
  );
};

export default Path;

Now i want to attach a camera to it so that I can move the camera along the line, but I have no idea how.

Anybody got an idea?

Lucas
  • 37
  • 1
  • 5

0 Answers0