Skip to content

Conversation

@davepagurek
Copy link
Contributor

@davepagurek davepagurek commented Dec 20, 2022

Resolves #5913

Previously, all vertices sent to libtess were assumed to be on the XY plane. Libtess can fit a plane to the vertices and use its normal for tesselation, if we tell it the plane's normal is (0,0,0). Presumably this is a little bit slower than not having to do that step, so rather than doing that all the time, I first check if all the vertices have the same z value (likely the most common use case) and tell libtess to use (0,0,1) as the normal if so. Otherwise, it calculates its own normal to use.

Screenshots of the change:

Before: (faces perpendicular to the initial camera turn into holes)
image

After:
image

Live: https://editor.p5js.org/davepagurek/sketches/X8o0LFCGd

PR Checklist

  • npm run lint passes
  • [Inline documentation] is included / updated
  • [Unit tests] are included / updated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

beginShape(TESS) only works on faces facing the camera

2 participants