2017-07-07 1 views

Répondre

2

Il y avait un polygone-composant, mais cela ne fonctionne pas avec 0.5.0 ou 0.6.0, donc vous devez faire votre propre dans three.js, en créant un composant qui ajoute un maillage à Votre entité:

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); 

violon travail here, son composant 'foo'.

UPDATE
vous faire une forme d'un objet 3D par excruding le long de l'axe z, en utilisant:

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

suite sur le params d'extrusion here. Le montant est le «épaisseur»
Fiddle travail here.

+0

Merci! Peut-on en faire une certaine hauteur/épaisseur? –

+0

@YohannesKristiawan mis à jour –

+0

Cool! Merci beaucoup! ACCEPTÉ! :-) –