computeNormal static method

Vec3 computeNormal(
  1. Vec3 va,
  2. Vec3 vb,
  3. Vec3 vc,
  4. Vec3 target,
)

Get face normal given 3 vertices

Implementation

static Vec3 computeNormal(final Vec3 va, final Vec3 vb, final Vec3 vc, final Vec3 target) {
  final cb = Vec3();
  final ab = Vec3();
  vb.vsub(va, ab);
  vc.vsub(vb, cb);
  cb.cross(ab, target);
  if (!target.isZero()) {
    target.normalize();
  }

  return target;
}