jscad / OpenJSCAD.org

JSCAD is an open source set of modular, browser and command line tools for creating parametric 2D and 3D designs with JavaScript code. It provides a quick, precise and reproducible method for generating 3D models, and is especially useful for 3D printing applications.
https://openjscad.xyz/
MIT License
2.63k stars 512 forks source link

Can we export STL files with arbitrary resolution? #87

Closed jgrizou closed 7 years ago

jgrizou commented 9 years ago

In OpenScad, we can change the global $fn variable to generate more or less detailled STL files.

Spiritdude commented 9 years ago

Might be a good to have globally in the overall settings - will consider it (in openscad.js, but not sure if it can make it into csg.js as well).

z3dev commented 9 years ago

I have a quick reference started at http://www.z3d.jp/wiki/doku.php?id=en:resources:openjscad Let me know if you want to add to this.

My preference is to make the "resolution" into a parameter for the design. That allows people to render both low and high resolution output. And some browsers (Safari / Chrome) are not capable of high resolution rendering.

jgrizou commented 9 years ago

Yes users should have the choice to output arbitray resolution, ideally in the parameter definition box. To give an example, I like that in this project: http://builder.mobilityshield.com/ users can select between low, medium, and high quality for the parts. The respective resolution being ["8","16","32"]. But to do so the guy had to add the resolution paramter in all of its primitives, see https://github.com/mobilityshield/OpenJsCAD-Parts/blob/master/plates-strips.jscad. Which I found annoying.

@z3dev: why would Safari and Chrome not capable of high resolution? For me resolution is a continum (see $fn variable in OpenScad), what would be the limit for $fn each browsers?

z3dev commented 9 years ago

Thanks for the information. I like the idea of low, medium, and high quality as that is easy for normal people to understand. But CSG.js only understands numbers.

The "resolution" applies to the number of slices in cylinders, and number of steps in creating arcs (and 3D spheres). So, a low resolution (lets say 12) creates far fewer vertices and faces. As the resolution is increases, the number of vertices and faces increase rapidly.

Safari and Chrome have limitations in the JavaScript stack size. Scripts can easily over run this. If you hit these limits then I suggest moving to Firefox.

As for passing parameters, I suggesting using "attributes" on a single parameter. That's how the parameters are passed into the scripts. Typically, I just add attributes to that same variable, and pass that through to other routines.

z3dev commented 7 years ago

This issue was moved to jscad/scad-api#15