Reputation: 221
I have a line (of points) and I want to extrude it.
What would be a simple way to achieve this?
Upvotes: 7
Views: 2428
Reputation: 221
I've found a solution. Not sure if this is the best way because three.js throws an info to use PlaneBufferGeometry instead.
function extrudePath( points, depth ) {
var geometry = new THREE.PlaneGeometry(0, 0, points.length - 1, 1);
var vertices = geometry.vertices;
for (var 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;
}
Upvotes: 3