Apply a matrix 4 to a point (vec3) Useful to convert a point position from plane local world to webgl space using projection view matrix for example Source code from: http://glmatrix.net/docs/vec3.js.html params : @matrix (array): 4x4 matrix used returns : @this (Vec3
(matrix)
| 334 | @this (Vec3): this vector after matrix application |
| 335 | ***/ |
| 336 | applyMat4(matrix) { |
| 337 | const x = this._x, y = this._y, z = this._z; |
| 338 | const mArray = matrix.elements; |
| 339 | |
| 340 | let w = mArray[3] * x + mArray[7] * y + mArray[11] * z + mArray[15]; |
| 341 | w = w || 1; |
| 342 | |
| 343 | this._x = (mArray[0] * x + mArray[4] * y + mArray[8] * z + mArray[12]) / w; |
| 344 | this._y = (mArray[1] * x + mArray[5] * y + mArray[9] * z + mArray[13]) / w; |
| 345 | this._z = (mArray[2] * x + mArray[6] * y + mArray[10] * z + mArray[14]) / w; |
| 346 | |
| 347 | return this; |
| 348 | } |
| 349 | |
| 350 | |
| 351 | /*** |
no outgoing calls
no test coverage detected