jscad / io

DEPRECATED : Input Output handling for JSCAD (see the link below)
https://github.com/jscad/OpenJSCAD.org/tree/V2/packages
34 stars 13 forks source link

Bad facet normals in .stl from csg.js based export (web & cli) #17

Closed z3dev closed 6 years ago

z3dev commented 7 years ago

From @Spiritdude on March 27, 2013 15:52

Right now csg.js, in more concrete fixTJunctions() in the export chain to create .stl creates (edit: in few cases) bad facet normals, e.g. 'NaN' in the ascii export (both web or cli). E.g. when csg.toSTLString() without fixTJunction() then the .stl looks fine.

It wouldn't be such a big problem as most slicers disregard the normals, but OpenJSCAD relies (at least for now) on proper set normals in order to determine the orientation of the triangles (cw vs ccw) and correct them (which means also, stl with bad normals cannot imported in general).

Copied from original issue: Spiritdude/OpenJSCAD.org#9

z3dev commented 7 years ago

From @kaosat-dev on March 28, 2013 20:28

FyI Rene, there are lots of issues with fixTJunctions(), I have not gotten round to actually check if there is indeed an improvement in most common cases when using it vs without, but stl's are valid either way.

z3dev commented 7 years ago

From @Spiritdude on March 29, 2013 10:27

Well, my tests have shown, as I wrote above (!!), that fixTJunctions() gives in few examples bad stl, the facet normals are giving 'NaN' - in binary and ascii, example000.jscad/example000.stl for example.

z3dev commented 7 years ago

From @kaosat-dev on March 29, 2013 10:53

what I meant is, stl's that do not use fixTJunctions() are still valid, although might need to be passed through an stl cleaner like netfab

z3dev commented 7 years ago

From @Spiritdude on March 29, 2013 17:17

I disabled fixTJunctions() temporarely in the stl exports (binary/ascii) on web and cli now, as valid stl is right now more important than sliceable stl - but this might change and focus back on fixTJunctions() will soon come again. I really like to have a robust stl import and export and be sliceable without to use netfab or other tools.

z3dev commented 7 years ago

40 and this issue are about the same thing. Although possible, I'm not sure if the effort is worth it. There's no such thing as a "perfect" set of normals in STL. So, it's better to state the goal properly. Something like...

STL (and other formats) should be immediately usable by slicers.

Or

STL (and other formats) should be "error" free, i.e. not violating format models.

z3dev commented 7 years ago

From @swsnider on July 16, 2015 2:34

Incorrect. This is not the same thing as #40. Please read the entire issue before proclaiming a dupe.

z3dev commented 7 years ago

From @sergerusso on December 8, 2015 21:10

CSG.polygon calculates plane by first 3 vertices, but fixTJunction can add some more. Like [[0,0,0],[0,0,50],[0,50,50]] -> [[0,0,0],[0,0,25],[0,0,50],[0,50,50]] and it fails as we need triangle

107

z3dev commented 7 years ago

Pull request #107 contains some changes to CSG.js and openjscad.js. I ran some tests and all issues with T-junctions were resolved after making those changes.

If you need this fixed then please make the changes manually.

kaosat-dev commented 6 years ago

closed by #34