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

fix triangle() orientation in webgl mode #6263

Merged
merged 2 commits into from
Jul 10, 2023
Merged

fix triangle() orientation in webgl mode #6263

merged 2 commits into from
Jul 10, 2023

Conversation

inaridarkfox4231
Copy link
Contributor

Since the direction of triangle() is the front direction regardless of the order of specifying vertices, we make sure that the order of specifying vertices is properly reflected.

Resolves #6262

Changes:

When calculating the matrix, by inserting the sign of the direction into the (3,3) component, to make sure that the order of specifying the vertices will be reflected.

Screenshots of the change:

triangle()_debug

function setup() {
  createCanvas(400, 400, WEBGL);

  noStroke();
  pointLight(color("lime"), 0, 0, 50);

  // clockwise orientation. normal: (0, 0, 1)
  quad(-200, -200, 0, -200, 0, 0, -200, 0);
  // counter-clockwise orientation. normal: (0, 0, -1)
  quad(200, -200, 0, -200, 0, 0, 200, 0);

  // clockwise orientation. normal: (0, 0, 1)
  triangle(0, 0, 0, 200, -200, 200);
  // counter-clockwise orientation. normal: (0, 0, 1), the same.
  triangle(0, 0, 0, 200, 200, 200);
}

before

triquad

after

true

PR Checklist

Since the direction of triangle() is the front direction regardless of the order of specifying vertices, we make sure that the order of specifying vertices is properly reflected.
add explanation comments
@davepagurek davepagurek merged commit b4edf1a into processing:main Jul 10, 2023
@inaridarkfox4231 inaridarkfox4231 deleted the triangle_orientation_fix branch July 10, 2023 16:04
@inaridarkfox4231
Copy link
Contributor Author

Thanks for merge!

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.

Small bug with triangle() orientation in webgl
2 participants