gpt4 book ai didi

aframe - 在 A 形框架中添加多边形

转载 作者:行者123 更新时间:2023-12-02 20:44:24 25 4
gpt4 key购买 nike

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

<a-entity geometry="primitive:polygon;positions:x y z, ..., x y z;">
</a-entity>

谢谢。

最佳答案

曾经有一个多边形组件,但它不适用于 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 );

工作 fiddle here ,它是“foo”组件。

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

var extrudedGeometry = new THREE.ExtrudeGeometry(shape, {amount: 5, 
bevelEnabled: false});

您可以找到有关挤出参数的更多信息 hereamount 是对象的“厚度”。
工作 fiddle here .

关于aframe - 在 A 形框架中添加多边形,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44968918/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com