src/v3.js
function normalize(a, dst) {
  dst = dst || new VecType(3);

  const lenSq = a[0] * a[0] + a[1] * a[1] + a[2] * a[2];
  const len = Math.sqrt(lenSq);
  if (len > 0.00001) {
    dst[0] = a[0] / len;
    dst[1] = a[1] / len;
    dst[2] = a[2] / len;
  } else {
    dst[0] = 0;
    dst[1] = 0;
    dst[2] = 0;
  }

  return dst;
}
function normalize(a, dst) {
  dst = dst || new VecType(3);

  const lenSq = a[0] * a[0] + a[1] * a[1] + a[2] * a[2];
  const len = Math.sqrt(lenSq);
  if (len > 0.00001) {
    dst[0] = a[0] / len;
    dst[1] = a[1] / len;
    dst[2] = a[2] / len;
  } else {
    dst[0] = 0;
    dst[1] = 0;
    dst[2] = 0;
  }

  return dst;
}
function normalize ( a , dst ) { dst = dst || new VecType ( 3 ) ; const lenSq = a [ 0 ] * a [ 0 ] + a [ 1 ] * a [ 1 ] + a [ 2 ] * a [ 2 ] ; const len = Math . sqrt ( lenSq ) ; if ( len > 0.00001 ) { dst [ 0 ] = a [ 0 ] / len ; dst [ 1 ] = a [ 1 ] / len ; dst [ 2 ] = a [ 2 ] / len ; } else { dst [ 0 ] = 0 ; dst [ 1 ] = 0 ; dst [ 2 ] = 0 ; } return dst ; }
Divides a vector by its Euclidean length and returns the quotient.
@param {module:twgl/v3.Vec3} a The vector.
@param {module:twgl/v3.Vec3} [dst] vector to hold result. If not new one is created..
@return {module:twgl/v3.Vec3} The normalized vector.
@memberOf module:twgl/v3
Divides a vector by its Euclidean length and returns the quotient .