build method
Implementation
MeshSurfaceSampler build() {
final positionAttribute = this.positionAttribute;
final weightAttribute = this.weightAttribute;
final faceWeights = Float32List( positionAttribute.count ~/ 3 ); // Accumulate weights for each mesh face.
for ( int i = 0; i < positionAttribute.count; i += 3 ) {
num faceWeight = 1.0;
if ( weightAttribute != null ) {
faceWeight = weightAttribute.getX( i )! + weightAttribute.getX( i + 1 )! + weightAttribute.getX( i + 2 )!;
}
if(i < positionAttribute.count) {
_face.a.fromBuffer( positionAttribute, i );
}
if(i + 1 < positionAttribute.count) {
_face.b.fromBuffer( positionAttribute, i + 1 );
}
if(i + 2 < positionAttribute.count) {
_face.c.fromBuffer( positionAttribute, i + 2 );
}
faceWeight *= _face.getArea();
faceWeights[ i ~/ 3 ] = faceWeight.toDouble();
} // Store cumulative total face weights in an array, where weight index
// corresponds to face index.
distribution = Float32List( positionAttribute.count ~/ 3 );
num cumulativeTotal = 0;
for(int i = 0; i < faceWeights.length; i ++) {
cumulativeTotal += faceWeights[ i ];
distribution![ i ] = cumulativeTotal.toDouble();
}
return this;
}