setFromArray method
array
- An array attribute of position data that the resulting box will envelop.
Sets the upper and lower bounds of this box to include all of the data in
array
.
Implementation
BoundingBox setFromArray(List<double> array) {
double minX = double.infinity;
double minY = double.infinity;
double minZ = double.infinity;
double maxX = -double.infinity;
double maxY = -double.infinity;
double maxZ = -double.infinity;
for (int i = 0, l = array.length; i < l; i += 3) {
final x = array[i];
final y = array[i + 1];
final z = array[i + 2];
if (x < minX) minX = x;
if (y < minY) minY = y;
if (z < minZ) minZ = z;
if (x > maxX) maxX = x;
if (y > maxY) maxY = y;
if (z > maxZ) maxZ = z;
}
min.setValues(minX, minY, minZ);
max.setValues(maxX, maxY, maxZ);
return this;
}