CircleGeometry 到 Shape

CircleGeometry to Shape

我想将 THREE.CircleGeometry 转换为 THREE.Shape,但我还没有找到方法。我想挤出这个圆,但 ExtrudeGeometry() 仅适用于形状。

我知道我可以使用曲线绘制圆,但我想保留 CircleGeometry() 提供的拓扑结构。

如果这不可能,是否有解决方法来绘制一个由许多围绕中心点定向的三角形线段组成的圆形?

这将像圆形几何一样生成一个形状。 这是fiddlehttp://jsfiddle.net/tcLr7eg3/

var circleTri = new THREE.Shape();
radius = 30;
segments = 32;
var theta_next, x_next, y_next, j;
for (var i = 0; i < segments; i++) {
    theta = ((i + 1) / segments) * Math.PI * 2.0;
    x = radius * Math.cos(theta);
    y = radius * Math.sin(theta);
    j = i + 2;
    if( (j - 1) === segments ) j = 1;
    theta_next = (j / segments) * Math.PI * 2.0;
    x_next = radius * Math.cos(theta_next);
    y_next = radius * Math.sin(theta_next);
    circleTri.moveTo(0, 0);
    circleTri.lineTo(x, y);
    circleTri.lineTo(x_next, y_next);
    circleTri.lineTo(0, 0);
}

对于 three.js 新手想要这样做的人,您应该尝试 SphereGeometry shape. You can create a perfectly round sphere this way without the hassle of creating your own shape or trying to extrude a CircleGeometry 形状。文档上的代码示例应该为您提供一个很好的起点。

const geometry = new THREE.SphereGeometry( 5, 32, 32 );
const material = new THREE.MeshBasicMaterial( {color: 0xffff00} );
const sphere = new THREE.Mesh( geometry, material );
scene.add( sphere );