Skip to content

Instantly share code, notes, and snippets.

@benbotto
Created March 25, 2020 14:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benbotto/12871c8f901aa86ec96e9a45300e4bfd to your computer and use it in GitHub Desktop.
Save benbotto/12871c8f901aa86ec96e9a45300e4bfd to your computer and use it in GitHub Desktop.
Rectangle rotating at the origin.
class Rectangle {
constructor(gl, color, width, height) {
this.gl = gl;
this.color = color;
this.width = width;
this.height = height;
this.rotation = gl.mat2d.create();
}
/**
* Update the Rectangle's transformation matrix before a render.
*/
update(elapsedMs) {
// Rotate PI per second.
this.gl.mat2d.rotate(this.rotation, this.rotation,
Math.PI * elapsedMs / 1000);
}
/**
* Get the Rectangle's transformation matrix.
*/
getTransformation() {
return this.rotation;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment