Three.js text mesh missing every other face/triangle

719 views Asked by At

So I performed a simple operation where i generated a text mesh (of the word TEST), put it's vertices, normals and faces into a json object then had my server save it to an STL. The problem is that it seems to be missing every other face/triangle. It renders in the browser correctly but it looks like this whenever I export it to an STL. I'm not sure why.

My code for getting all the relevant info is simple so I don't see why it seems to be missing half the faces/triangles

// Pass in textMesh.geometry
function getTextMesh(geometry)
{
    var mfaces = geometry.faces;
    var mvertices = geometry.vertices;

    var i;

    var faces=[],
        vertices=[],
        normals=[];

    for(i=0; i<mfaces.length; i++) {
        var face = mfaces[i];
        var normal = face.normal;

        faces.push([face.a, face.b, face.c]);
        normals.push([normal.x, normal.y, normal.z]);
    }

    for(i=0; i<mvertices.length; i++) {
        var vertex = mvertices[i];
        vertices.push([vertex.x, vertex.y, vertex.z]);
    }

    return {'faces':faces, 'vertices':vertices, 'normals':normals};
}
1

There are 1 answers

0
Jared Joke On BEST ANSWER

Bah, turns out the issue was that TextGeometry also used Face4 for faces. I had assumed it only used triangles (Face3). This was easily solved by calling

THREE.GeometryUtils.triangulateQuads(textGeo);

after creating the geometry for the text