build method
dynamic
build()
Implementation
build() {
var positionAttribute = this.positionAttribute;
var weightAttribute = this.weightAttribute;
var 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.fromBufferAttribute(positionAttribute, i);
}
if (i + 1 < positionAttribute.count) {
_face.b.fromBufferAttribute(positionAttribute, i + 1);
}
if (i + 2 < positionAttribute.count) {
_face.c.fromBufferAttribute(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 (var i = 0; i < faceWeights.length; i++) {
cumulativeTotal += faceWeights[i];
distribution![i] = cumulativeTotal.toDouble();
}
return this;
}