Three.js |动态生成贝塞尔曲线

Three.js | Generate dynamically a BezierCurve

我找不到从数组动态生成 BezierCurve 的正确语法,我尝试进行推送,但没有成功。

var x = [0,10,100,220,100, etc,...];
var y = [10,0,100,200,200, etc,...];
var z = [100,220,10,0,100, etc,...];

var points = [];

for(i=0; i < x.length; i++){ 
   points.push( new THREE.Vector3( x[i], y[i], z[i] ) );
   } 

var curve = new THREE.CubicBezierCurve3( points );

var geometry = new THREE.Geometry();
var curveObject = new THREE.Line( geometry, material );
scene.add(curveObject);

一个想法?

你可以使用

var curve = new (Function.bind.apply(THREE.CubicBezierCurve3, [null].concat(points)));

或者如果您仅针对 ES6 兼容浏览器传播运算符

var curve = new THREE.CubicBezierCurve3(...points);