Creating a mesh from Vertices

I’m trying to create a Mesh from vertices using this code:

getMeshFromVertices = function(vertices, holes) {
        var triangles, mesh;
        var geometry = new THREE.Geometry();
        var material = new THREE.MeshBasicMaterial();

        geometry.vertices = vertices;
        triangles = THREE.Shape.Utils.triangulateShape(vertices, holes);

        for( var i = 0; i < triangles.length; i++ ){
            geometry.faces.push(new THREE.Face3(triangles[i][0], triangles[i][1], triangles[i][2]));

        return new THREE.Mesh(geometry, material);

But when I do this I get this error:

Uncaught TypeError: contour.concat is not a function
THREE.Shape.Utils.triangulateShape @ three.js:29200

When I go to that line in the Three.js source I discover this is what its trying to do:

var allpoints = contour.concat();

Which isn’t ever going to work. There is a similar problem on line 29254.

return triangles.concat();

All of this is taken from revision 71.

Author: Fantashit

1 thought on “Creating a mesh from Vertices

Comments are closed.