joostn / OpenJsCad

3D solid CAD using only Javascript
315 stars 128 forks source link

feature request: polyhedron #4

Closed alx closed 10 years ago

alx commented 12 years ago

Hi Joostn,

do you think you could include polyhedron primitive inside OpenJsCAD?

I'm trying to convert Thread_Library.scad - https://github.com/syvwlch/Thingiverse-Projects/blob/master/Threaded%20Library/Thread_Library.scad - into js and I'm having an issue converting Polyhedron primitive from OpenSCAD: https://github.com/openscad/openscad/blob/master/src/primitives.cc#L449

Thanks :)

Alex

joostn commented 12 years ago

Hi Alex,

You can make a polyhedron as follows:

var polygons=[];

var polygon = new CSG.Polygon([
  new CSG.Vertex(point1),
  new CSG.Vertex(point2),
  new CSG.Vertex(point3)]);
polygons.push(polygon);

// ...and add more polygons...

var polyhedron = CSG.fromPolygons(polygons);

It should be easy to write a wrapper compatible with openscad's polyhedron but I don't have time at the moment.

joostn commented 10 years ago

This is implemented by bebbi in 3ffaf11ba43af4a2a943e2ed35a305d740b2a4d5