WorldWideTelescope / wwt-web-client

The WorldWide Telescope web client lets you explore the universe in your browser.
https://worldwidetelescope.org/webclient/
MIT License
105 stars 35 forks source link

Polygon fill does not work for polygons in certain directions #181

Closed astrofrog closed 5 years ago

astrofrog commented 6 years ago

Using the staged WebGL SDK, there is an issue with the filling of polygons when the vertices are in one direction versus the other:

poly1 = wwt.createPolygon()
poly1.addPoint(0,0)
poly1.addPoint(0,1)
poly1.addPoint(1,0)
poly1.set_fill(true)
wwt.addAnnotation(poly1)

poly2 = wwt.createPolygon()
poly2.addPoint(2,0)
poly2.addPoint(3,0)
poly2.addPoint(2,1)
poly2.set_fill(true)
wwt.addAnnotation(poly2)

The result is:

screen shot 2018-08-15 at 17 31 02

With poly2 on the left, and poly1 on the right.

astrojonathan commented 5 years ago

Polygons have a specific counter-clockwise winding direction. The fill faces the normal of the triangles generated by tessellation. This behaviour is by design.