我認爲你需要指定你要多少點樣條插值與曲線,雖然您指定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
之間的價值,開始和結束點花鍵。
順便說一下,請參閱最近爲我解答的Question,其中包括上述示例。
另外,考慮您的項目,您可以使用球體中的頂點作爲樣條的控制點! – Neil