meta data for this page
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
|
en:design_guide_polyhedron [2020/11/28 02:18] JSCAD Editor created |
en:design_guide_polyhedron [2022/04/13 06:57] (current) rozek included "require" statement |
||
|---|---|---|---|
| Line 7: | Line 7: | ||
| // | // | ||
| - | Create a polyhedron | + | Create a polyhedron |
| + | |||
| + | //Note: The order of the points must be consistent, defining ' | ||
| <code javascript> | <code javascript> | ||
| - | polyhedron({ | + | const { polyhedron |
| - | points: [ [10, | + | |
| - | | + | const points |
| - | | + | const faces = [ [0, 1, 4], [1, 2, 4], [2, 3, 4], [3, 0, 4], [1, 0, 3], [2, 1, 3] ] |
| - | [1, | + | const myshape = polyhedron({points, |
| - | }); | + | |
| </ | </ | ||
| - | Additionally you can also define `polygons: [ [0,1,4,5], [..] ]` too, not just `triangles: | ||
| - | |||
| - | You can also create a polyhedron at a more low-level. | ||
| - | |||
| - | <code javascript> | ||
| - | var polygons = []; | ||
| - | polygons.push(new CSG.Polygon([ | ||
| - | new CSG.Vertex(new CSG.Vector3D(-5, | ||
| - | new CSG.Vertex(new CSG.Vector3D(2, | ||
| - | new CSG.Vertex(new CSG.Vector3D(3, | ||
| - | ]) | ||
| - | ); | ||
| - | // add more polygons and finally: | ||
| - | solid = CSG.fromPolygons(polygons); | ||
| - | </ | ||