在 A 形框架中添加多边形

Yoh*_*wan 2 aframe

有没有办法在A形框架中添加多边形?有点像:

<a-entity geometry="primitive:polygon;positions:x y z, ..., x y z;">
</a-entity>
Run Code Online (Sandbox Code Playgroud)

谢谢。

Pio*_*ski 5

曾经有一个多边形组件,但它不适用于 0.5.0 或 0.6.0。因此,您必须在 Three.js 中创建自己的组件,方法是创建一个向实体添加网格的组件:

let points = []; //vertices of Your shape
points.push( new THREE.Vector2( 0, 0 ) );
points.push( new THREE.Vector2( 3, 0 ) );
points.push( new THREE.Vector2( 5, 2 ) );
points.push( new THREE.Vector2( 5, 5 ) );
points.push( new THREE.Vector2( 5, 5 ) );
points.push( new THREE.Vector2( 2, 7 ) );
// scaling, not necessary:
for( var i = 0; i < points.length; i ++ ) {
    points[ i ].multiplyScalar( 0.25 );
}
// Create new shape out of the points:
var heartShape = new THREE.Shape(points);
// Create geometry out of the shape
var geometry = new THREE.ShapeGeometry( heartShape );
// Give it a basic material
var material = new THREE.MeshBasicMaterial( { color: 0x00ff00 } );
// Create a mesh using our geometry and material
var mesh = new THREE.Mesh( geometry, material ) ;
// add it to the entity:
this.el.object3D.add( mesh );
Run Code Online (Sandbox Code Playgroud)

在这里工作,它是“foo”组件。

更新
您可以通过沿 z 轴拉伸形状将其变成 3D 对象,使用:

var extrudedGeometry = new THREE.ExtrudeGeometry(shape, {amount: 5, 
bevelEnabled: false});
Run Code Online (Sandbox Code Playgroud)

您可以在此处找到有关挤出参数的更多信息。这amount是物体的“厚度”。在这里
拉小提琴。