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

Incorrect matrix component order #33

Open
max-ch9i opened this issue Feb 17, 2018 · 2 comments
Open

Incorrect matrix component order #33

max-ch9i opened this issue Feb 17, 2018 · 2 comments

Comments

@max-ch9i
Copy link
Contributor

On the page https://github.com/greggman/webgl2-fundamentals/blob/master/webgl/lessons/webgl-2d-matrices.md the rotation matrix generator is incorrectly defined as:

  rotation: function(angleInRadians) {
    var c = Math.cos(angleInRadians);
    var s = Math.sin(angleInRadians);
    return [
      c,-s, 0,
      s, c, 0,
      0, 0, 1,
    ];
  },

This results in rotation in the reverse direction. Matrix components in GLSL are defined in column-major order, so the correct definition should be:

  rotation: function(angleInRadians) {
    var c = Math.cos(angleInRadians);
    var s = Math.sin(angleInRadians);
    return [
      c, s, 0,
      -s, c, 0,
      0, 0, 1,
    ];
  },
@greggman
Copy link
Member

Sorry everyone. You are right.

Unfortunately it's not as simple as making that one change. I have to go fix all the samples using these libraries on both webgl2 and webgl1. I also have to rename the libraries to like 2d-math-v2.js so as not to break anyone using the old versions (since people link directly). The short of that is I've just been too lazy to fix since it will talk a while.

It's on my todo list but no ETA ATM

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

No branches or pull requests

3 participants