src/m4.js
function transformDirection(m, v, dst) {
  dst = dst || v3.create();

  const v0 = v[0];
  const v1 = v[1];
  const v2 = v[2];

  dst[0] = v0 * m[0 * 4 + 0] + v1 * m[1 * 4 + 0] + v2 * m[2 * 4 + 0];
  dst[1] = v0 * m[0 * 4 + 1] + v1 * m[1 * 4 + 1] + v2 * m[2 * 4 + 1];
  dst[2] = v0 * m[0 * 4 + 2] + v1 * m[1 * 4 + 2] + v2 * m[2 * 4 + 2];

  return dst;
}
function transformDirection(m, v, dst) {
  dst = dst || v3.create();

  const v0 = v[0];
  const v1 = v[1];
  const v2 = v[2];

  dst[0] = v0 * m[0 * 4 + 0] + v1 * m[1 * 4 + 0] + v2 * m[2 * 4 + 0];
  dst[1] = v0 * m[0 * 4 + 1] + v1 * m[1 * 4 + 1] + v2 * m[2 * 4 + 1];
  dst[2] = v0 * m[0 * 4 + 2] + v1 * m[1 * 4 + 2] + v2 * m[2 * 4 + 2];

  return dst;
}
function transformDirection ( m , v , dst ) { dst = dst || v3 . create ( ) ; const v0 = v [ 0 ] ; const v1 = v [ 1 ] ; const v2 = v [ 2 ] ; dst [ 0 ] = v0 * m [ 0 * 4 + 0 ] + v1 * m [ 1 * 4 + 0 ] + v2 * m [ 2 * 4 + 0 ] ; dst [ 1 ] = v0 * m [ 0 * 4 + 1 ] + v1 * m [ 1 * 4 + 1 ] + v2 * m [ 2 * 4 + 1 ] ; dst [ 2 ] = v0 * m [ 0 * 4 + 2 ] + v1 * m [ 1 * 4 + 2 ] + v2 * m [ 2 * 4 + 2 ] ; return dst ; }
Takes a 4-by-4 matrix and a vector with 3 entries, interprets the vector as a
direction, transforms that direction by the matrix, and returns the result;
assumes the transformation of 3-dimensional space represented by the matrix
is parallel-preserving, i.e. any combination of rotation, scaling and
translation, but not a perspective distortion. Returns a vector with 3
entries.
@param {module:twgl/m4.Mat4} m The matrix.
@param {module:twgl/v3.Vec3} v The direction.
@param {module:twgl/v3.Vec3} dst optional Vec3 to store result
@return {module:twgl/v3.Vec3} dst or new Vec3 if not provided
@memberOf module:twgl/m4
Takes a 4 - by - 4 matrix and a vector with 3 entries interprets the vector as a direction transforms that direction by the matrix and returns the result ; assumes the transformation of 3 - dimensional space represented by the matrix is parallel - preserving i . e . any combination of rotation scaling and translation but not a perspective distortion . Returns a vector with 3 entries .