|
@@ -108,11 +108,15 @@ class MeshSurfaceSampler {
|
|
|
|
|
|
sample( targetPosition, targetNormal, targetColor ) {
|
|
|
|
|
|
- const cumulativeTotal = this.distribution[ this.distribution.length - 1 ];
|
|
|
+ const faceIndex = this.sampleFaceIndex();
|
|
|
+ return this.sampleFace( faceIndex, targetPosition, targetNormal, targetColor );
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
- const faceIndex = this.binarySearch( this.randomFunction() * cumulativeTotal );
|
|
|
+ sampleFaceIndex() {
|
|
|
|
|
|
- return this.sampleFace( faceIndex, targetPosition, targetNormal, targetColor );
|
|
|
+ const cumulativeTotal = this.distribution[ this.distribution.length - 1 ];
|
|
|
+ return this.binarySearch( this.randomFunction() * cumulativeTotal );
|
|
|
|
|
|
}
|
|
|
|