karl-/pb_Stl

The Mesh direction is probably reversed.

rich-wan opened this issue · 3 comments

The Mesh direction is probably reversed.

karl- commented

What app are you importing from?

@karl- OpenSCAD
this is my test file
Untitled.zip

@hsc0der is correct. The triangles in the example file have counter-clockwise winding order as required by the STL "standard". Here's the first facet:

solid OpenSCAD_Model
  facet normal 0 0 -1
    outer loop
      vertex 10 0 0
      vertex 15 0 0
      vertex 14.6722 -3.11868 0
    endloop
  endfacet
  ...

Looking back from the normal (sitting on the negative z axis) we can see a vertex that travels left (positive x), then down-right (negative x, negative y), which is in a counter-clockwise direction.

The binary importer is fine because you reverse the counter-clockwise points to be clockwise in order to match the Unity convention, but in the ASCII importer it looks like you reverse the direction, but actually you only reverse the lines of code (it's a classic error).

Happy make a pull request if it would make it clearer, but you may be looking at this area anyway for other reasons.