* Creates identity matrix * This method updates the current matrix with the result of the multiplication. * * @private
(dimension)
| 1617 | * @private |
| 1618 | */ |
| 1619 | #createIdentityMatrix(dimension) { |
| 1620 | // This it to prevent loops in the most common 3x3 and 4x4 cases |
| 1621 | // TODO: check performance if it actually helps |
| 1622 | if (dimension === 3) |
| 1623 | return new GLMAT_ARRAY_TYPE([1, 0, 0, 0, 1, 0, 0, 0, 1]); |
| 1624 | if (dimension === 4) |
| 1625 | return new GLMAT_ARRAY_TYPE([ |
| 1626 | 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 |
| 1627 | ]); |
| 1628 | const identityMatrix = new GLMAT_ARRAY_TYPE(dimension * dimension).fill(0); |
| 1629 | for (let i = 0; i < dimension; i++) { |
| 1630 | identityMatrix[i * dimension + i] = 1; |
| 1631 | } |
| 1632 | return identityMatrix; |
| 1633 | } |
| 1634 | |
| 1635 | /** |
| 1636 | * Multiplies the current 4x4 matrix with another 4x4 matrix. |
no test coverage detected