sample method

dynamic sample(
  1. dynamic targetPosition,
  2. dynamic targetNormal,
  3. dynamic targetColor
)

Implementation

sample(targetPosition, targetNormal, targetColor) {
  var cumulativeTotal = distribution![distribution!.length - 1];
  var faceIndex = binarySearch(randomFunction() * cumulativeTotal);
  return sampleFace(faceIndex, targetPosition, targetNormal, targetColor);
}