getAt method

Vector3 getAt(
  1. Vector3 normal,
  2. Vector3 target
)

Implementation

Vector3 getAt(Vector3 normal, Vector3 target) {
  // normal is assumed to be unit length

  var x = normal.x, y = normal.y, z = normal.z;

  var coeff = coefficients;

  // band 0
  target.copy(coeff[0]).multiplyScalar(0.282095);

  // band 1
  target.addScaledVector(coeff[1], 0.488603 * y);
  target.addScaledVector(coeff[2], 0.488603 * z);
  target.addScaledVector(coeff[3], 0.488603 * x);

  // band 2
  target.addScaledVector(coeff[4], 1.092548 * (x * y));
  target.addScaledVector(coeff[5], 1.092548 * (y * z));
  target.addScaledVector(coeff[6], 0.315392 * (3.0 * z * z - 1.0));
  target.addScaledVector(coeff[7], 1.092548 * (x * z));
  target.addScaledVector(coeff[8], 0.546274 * (x * x - y * y));

  return target;
}