Skip to content

Commit

Permalink
perf: improve mat4.scale
Browse files Browse the repository at this point in the history
- scale matrix components to avoid useless multiplication
  • Loading branch information
dmnsgn committed Feb 8, 2022
1 parent 87e33bb commit b10e687
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion mat4.js
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,19 @@ export function identity(a) {
}

export function _scale3(a, x, y, z) {
return _mult16(a, x, 0, 0, 0, 0, y, 0, 0, 0, 0, z, 0, 0, 0, 0, 1);
a[0] *= x;
a[1] *= x;
a[2] *= x;
a[3] *= x;
a[4] *= y;
a[5] *= y;
a[6] *= y;
a[7] *= y;
a[8] *= z;
a[9] *= z;
a[10] *= z;
a[11] *= z;
return a;
}

export function scale(a, v) {
Expand Down

0 comments on commit b10e687

Please sign in to comment.