STL parsing: face interpretation

Hey everyone!
Does anyone have an idea, how to extract the faces array from a stl file? Is there any information within the file format possibly? I manage to upload the mesh object, but the face interpretation is not quite as expected. :wink: So far, I am using the same earcut method as tom, but it seems that it is not working for stl…

Hey Simon,

Not sure. I’ve never done it before. I only grokked this from wikipedia:

UINT8[80] – Header
UINT32 – Number of triangles


foreach triangle
REAL32[3] – Normal vector
REAL32[3] – Vertex 1
REAL32[3] – Vertex 2
REAL32[3] – Vertex 3
UINT16 – Attribute byte count
end

Which looks straight forward enough… If you share the code, and maybe a screenshot of what’s happening, that could help.

Hey dimitrie, thank you for that! I managed to put upload them as stl files have a fixed vertex order and are triangulated, so I am uploading every single triangle as a mesh object. Would that be the way to go? Or does it make more sense to upload all of them in one single mesh object?

Oh, for sure one single mesh object! it’s 100x more efficient!