7

I have a line (of points) and I want to extrude it.

extrude result

What would be a simple way to achieve this?

2

1 Answer 1

3

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;
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.