本文介绍了在three.js中挤出一条线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一条线(点),我想挤出它.
I have a line (of points) and I want to extrude it.
实现这一目标的简单方法是什么?
What would be a simple way to achieve this?
推荐答案
我找到了解决方案.不确定这是否是最好的方法,因为three.js 会抛出一个信息来改用PlaneBufferGeometry.
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;
}
这篇关于在three.js中挤出一条线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!