我认为你需要指定你希望样条曲线用多少点来插值曲线,虽然你指定control
了点,但曲线不知道你想要它有多平滑。
尝试这样的事情:
// smooth my curve over this many points
var numPoints = 100;
spline = new THREE.SplineCurve3([
new THREE.Vector3(0, 0, 0),
new THREE.Vector3(0, 200, 0),
new THREE.Vector3(150, 150, 0),
new THREE.Vector3(150, 50, 0),
new THREE.Vector3(250, 100, 0),
new THREE.Vector3(250, 300, 0)
]);
var material = new THREE.LineBasicMaterial({
color: 0xff00f0,
});
var geometry = new THREE.Geometry();
var splinePoints = spline.getPoints(numPoints);
for(var i = 0; i < splinePoints.length; i++){
geometry.vertices.push(splinePoints[i]);
}
var line = new THREE.Line(geometry, material);
scene.add(line);
然后,正如@juan Mellado 回答中所指出的那样,您可以使用spline.getPoint(t)
其中 t 是0-1
样条曲线的起点和终点之间的值来获得在线上的位置。
顺便说一句,请参阅最近为我回答的问题,其中包括上面的示例。