Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support beginShape(TESS) for faces that don't face the camera #5914

Merged
merged 2 commits into from
Dec 23, 2022

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