I used the function below to create custom geometry from 2D points.
/**
* Code from: https://stackoverflow.com/a/29969348
* @param points
* @param depth
* @returns {PlaneGeometry}
*/
extrudePath(points, depth) {
const geometry = new THREE.PlaneGeometry(0, 0, points.length - 1, 1);
const vertices = geometry.vertices;
for (let i = 0, l = points.length, p; i < l; i++) {
p = points[i];
vertices[i].x = vertices[i + l].x = p[0];
vertices[i].y = vertices[i + l].y = p[1];
vertices[i].z = p[2];
vertices[i + l].z = p[2] + depth;
}
geometry.computeFaceNormals();
return geometry;
}
Plain and simple, and much needed in the configurators I’m creating.
However this function doesn’t work anymore using a newer version of Three which only supports BufferGeometry.
How do I change the function to support BufferGeometry?
I am aware that I can extrude a shape defined by 2D points, but it seems that the shape always wants to close itself.