2017-07-07 66 views

回答

2

曾經有一個多邊形組件,但它不能與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,它的 '富' 的組成部分。

UPDATE
您一個由excruding它沿着z軸,採用使形狀的3D對象:

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

更上擠出PARAMS here。金額是'厚度'
工作小提琴here

+0

謝謝!我們可以讓它具有一定的高度/厚度嗎? –

+0

@YohannesKristiawan更新 –

+0

酷!非常感謝!公認! :-) –