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