Extruding a line in three.js

筅森魡賤 提交于 2020-08-07 04:04:38

问题


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

extrude result

What would be a simple way to achieve this?


回答1:


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;
}


来源:https://stackoverflow.com/questions/29964283/extruding-a-line-in-three-js

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!