【发布时间】:2017-12-11 15:24:50
【问题描述】:
有没有办法在 A 帧中添加多边形?有点像:
<a-entity geometry="primitive:polygon;positions:x y z, ..., x y z;">
</a-entity>
?
谢谢。
【问题讨论】:
标签: aframe
有没有办法在 A 帧中添加多边形?有点像:
<a-entity geometry="primitive:polygon;positions:x y z, ..., x y z;">
</a-entity>
?
谢谢。
【问题讨论】:
标签: aframe
曾经有一个多边形组件,但它不适用于 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 );
工作小提琴here,它是“foo”组件。
更新
您可以通过沿 z 轴将形状拉伸为 3D 对象,使用:
var extrudedGeometry = new THREE.ExtrudeGeometry(shape, {amount: 5,
bevelEnabled: false});
【讨论】: