setFromBufferAttribute method

Box3 setFromBufferAttribute(
  1. BufferAttribute<NativeArray<num>> attribute
)

Implementation

Box3 setFromBufferAttribute(BufferAttribute attribute) {
  double minX = infinity;
  double minY = infinity;
  double minZ = infinity;

  double maxX = -infinity;
  double maxY = -infinity;
  double maxZ = -infinity;

  for (var i = 0, l = attribute.count; i < l; i++) {
    double x = attribute.getX(i)!.toDouble();
    double y = attribute.getY(i)!.toDouble();
    double z = attribute.getZ(i)!.toDouble();

    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.set(minX, minY, minZ);
  max.set(maxX, maxY, maxZ);

  return this;
}