evanw / csg.js

Constructive solid geometry on meshes using BSP trees in JavaScript
http://evanw.github.com/csg.js/
MIT License
1.79k stars 264 forks source link

CSG.Polygon assumes no collinear edges #10

Open ericu opened 11 years ago

ericu commented 11 years ago

If you try to create a CSG.Polygon, passing in a series of vertices where the first 3 are collinear, the calculation of the plane normal will be wrong. The documentation for the function only requires that the polygon be planar and convex, not that it contain no degeneracies; either the code or the docs should change.

janhelleman commented 9 years ago

The problem is at the polygon constructor. There it constructs a plane from the first three points. If these are colinear they should not be used untill none colinear are found.

NateTG commented 9 years ago

That looks like a relatively easy fix, but I'm not sure that this repository is still being maintained.

razola commented 9 years ago

@NateTG I think I've seen issues in my app related to this. Would really appreciate a fix if you have the time and energy.

NateTG commented 9 years ago

I'm still a js neophyte, but the changes at:

https://github.com/NateTG/csg.js

Should support polygons with some non-colinear edges.