ShapePath.splineThru() 是 three.js 中 ShapePath 类的方法之一。 它接受一组 Vector2 对象作为参数,并使用样条函数将这些点连接起来形成平滑的曲线。
splineThru(points: Vector2[])
points:一组 Vector2 对象,用于形成曲线。该方法没有返回值。它通过修改 ShapePath 实例上的 curves 属性来创建曲线。
const shape = new THREE.Shape();
const points = [
  new THREE.Vector2(0, 0),
  new THREE.Vector2(10, 10),
  new THREE.Vector2(20, 5),
  new THREE.Vector2(30, 15),
  new THREE.Vector2(40, 0)
];
shape.moveTo(points[0].x, points[0].y);
const path = new THREE.ShapePath();
path.splineThru(points);
shape.curves = path.curves;
ShapePath.splineThru() 之前,必须首先调用 Shape.moveTo(),指定形状中的起始点。points 数组中指定的点要多。这是因为样条函数需要一些额外的点来使曲线平滑连接。ShapePath.splineThru() 创建曲线,请确保使用 Vector2,不要使用 Vector3 或其他类型的向量。否则,可能会得到意外的结果。