mrdoob/three.js — Issue #1115: Custom Mesh: How do I define Faces?
Author: ahoi
Created: 2012-01-15 21:00:44+00:00
State: open

I want to create a custom mesh with lots of vertices.
When I create the faces I always get the error: "Uncaught TypeError: Cannot read property 'position' of undefined"
Because I could find an example I was wondering how do I define the faces. For now I have (short version):

First get all vertices:
geometry.vertices.push(new THREE.Vertex(new THREE.Vector3(x, y, z)));

Then split the vertices in half and save each in array
array[k] = new THREE.Vector(geometry.vertices[k].position.x, geometry.vertices[k].position.y, geometry.vertices[k].position.z);}

geometry.faces.push( new THREE.Face4( array[0], array[1], array[1], array[0] ) );