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;
}