sweptSurface = {
const { nsweep, nsection, closed, frenet } = conf;
const start = curve(views.start).getPoints(nsection);
const finish = curve(views.finish).getPoints(nsection);
const sweepCurve = curve(views.sweep).getPoints(nsweep);
const twist = curve(views.sweep).computeFrenetFrames(nsweep, closed);
const curvesArray = [];
for (const sweepPoint of Array(nsweep + 1).keys()) {
const angle = THREE.MathUtils.degToRad(conf.twist) * (sweepPoint / nsweep);
twist.binormals[sweepPoint].applyAxisAngle(twist.tangents[sweepPoint], angle);
twist.normals[sweepPoint].applyAxisAngle(twist.tangents[sweepPoint], angle);
}
for (const sweepPoint of Array(nsweep + 1).keys()) {
const curve = [];
const matrix = new THREE.Matrix4();
matrix.makeBasis(twist.binormals[sweepPoint], twist.normals[sweepPoint], twist.tangents[sweepPoint]);
for (const section of Array(nsection).keys()) {
const coord = new THREE.Vector3();
coord.lerpVectors(start[section], finish[section], sweepPoint / nsweep);
coord.applyMatrix4(matrix);
coord.add(sweepCurve[sweepPoint]);
curve.push(coord);
}
curvesArray.push(curve);
}
frenetFrames.children = [];
if (frenet) {
for (const sweepPoint of Array(nsweep + 1).keys()) {
const vectors = [
new THREE.ArrowHelper(twist.tangents[sweepPoint], sweepCurve[sweepPoint], 1, 0xff0000),
new THREE.ArrowHelper(twist.normals[sweepPoint], sweepCurve[sweepPoint], 1, 0x00ff00),
new THREE.ArrowHelper(twist.binormals[sweepPoint], sweepCurve[sweepPoint], 1, 0x0000ff)
];
for (const vector of vectors) {
frenetFrames.add(vector);
}
}
}
return curvesArray;
}