Skip to content

Commit

Permalink
feat: use @wowserhq/[email protected] with updated Matrix4 and Vector3 (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
timkurvers authored May 24, 2020
1 parent c7a0a11 commit 8290732
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 27 deletions.
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"wow"
],
"dependencies": {
"@wowserhq/math": "0.1.0",
"@wowserhq/math": "0.2.0",
"fengari": "0.1.4"
},
"devDependencies": {
Expand Down
12 changes: 1 addition & 11 deletions src/math/Matrix4.mjs
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
import math from '@wowserhq/math';

class Matrix4 extends math.Matrix4 {
// TODO: Remove this once new package is published
translate(move) {
this[12] = this[8] * move[2] + this[4] * move[1] + this[0] * move[0] + this[12];
this[13] = this[9] * move[2] + this[5] * move[1] + this[1] * move[0] + this[13];
this[14] = this[10] * move[2] + this[6] * move[1] + this[2] * move[0] + this[14];
return this;
}
}

export default Matrix4;
export default math.Matrix4;
8 changes: 0 additions & 8 deletions src/math/Vector3.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,6 @@ class Vector3 extends math.Vector3 {
this.set(other);
return this;
}

// TODO: Remove this once new package is published
setElements(x, y, z) {
this[0] = x;
this[1] = y;
this[2] = z;
return this;
}
}

export default Vector3;
8 changes: 4 additions & 4 deletions src/ui/rendering/Renderer.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,10 @@ class Renderer {
]);
const offsetX = (root.rect.minX + root.rect.maxX) * 0.5;
const offsetY = (root.rect.minY + root.rect.maxY) * 0.5;
const viewMatrix = new Matrix4();
viewMatrix.translate([-offsetX, -offsetY, 0]);
projMatrix.multiply(viewMatrix).transpose();
gl.uniformMatrix4fv(viewProjMatrixPtr, false, projMatrix);
const viewProjMatrix = new Matrix4();
viewProjMatrix.translate([-offsetX, -offsetY, 0.0]);
viewProjMatrix.multiply(projMatrix).transpose();
gl.uniformMatrix4fv(viewProjMatrixPtr, false, viewProjMatrix);

gl.useProgram(this.program);
gl.bindVertexArray(vao);
Expand Down

0 comments on commit 8290732

Please sign in to comment.