evanw/csg.js — Issue #7: Combining coplanar polygons
Author: joostn
Created: 2012-01-08 20:19:24+00:00
State: open

Please forgive my enthusiasm for csg.js!

Take the following union of a cube and a larger, fully containing cube:

```javascript
var cube1=CSG.cube({center: [0,0,0], radius: [1,1,1]});
var cube2=CSG.cube({center: [0,0,0], radius: [1.1, 1.1, 1.1]});
var result=cube1.union(cube2);
alert(result.polygons.length);
return result;
```

The resulting union contains 24 polygons while it can be represented with only 6 polygons (it's just a cube). Maybe not a big issue in this case but I'm running into problems when combining spheres and cylinders where the number of polygons quickly grows extremely large. I think the library should combine all overlapping coplanar polygons into one after each operation, do you have an idea where and how to implement this?