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.68k stars 516 forks source link

Tessellating object. #143

Open mtippett opened 8 years ago

mtippett commented 8 years ago

Hi, I'm attempting to take an object and transform it to be wrapped around a cylinder. I believe I have the maths, however my concern is that for primitives there is insufficient points to to make it appear like it is wrapped.

Ideally I would like to tessellate a simple object (say for a stretched 10x1x1 cube). Right now a cube is returned with the minimal number of polygons. I'd like to be able to increase the number of polygons by quite an order to allow the transform to be successful.

z3dev commented 8 years ago

Sounds cool.

See the solidFromSlices() function. The documentation is not good, so please see this example.

http://www.z3d.jp/lab/view.php?design=lab-000000016

You should be able to create as many polygons (layers) as needed.

FYI, I'm also working on a "bend" function. It should be very similar to the function that you're writing. I'll share the code once I have a working version.

z3dev commented 3 years ago

@mtippett If you want to split polygons into smaller pieces that that should be possible. The new triangulate() function does this, and splits polygons based on how many vertices are available. The algorithm is based on some information that I found on Splitting facets by Paul Bourke.

P.S. Be aware that the boolean operations will assemble small polygons into larger ones.

hrgdavor commented 3 years ago

Would it be ok for boolean to have retesselate optional (ofcourse default that is as it is currently). I was looking few times for performance gains, and as script dev I would like to control when to do retesselate or not. and maybe do retessselate later.