sample method

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

Implementation

sample(targetPosition, targetNormal, targetColor) {
  var cumulativeTotal = this.distribution![this.distribution!.length - 1];

  var faceIndex = this.binarySearch(this.randomFunction() * cumulativeTotal);

  return this
      .sampleFace(faceIndex, targetPosition, targetNormal, targetColor);
}