setFromPoints method

Sphere setFromPoints(
  1. List<Vector3> points, [
  2. Vector3? optionalCenter
])

Implementation

Sphere setFromPoints(List<Vector3> points, [Vector3? optionalCenter]) {
  var center = this.center;

  if (optionalCenter != null) {
    center.copy(optionalCenter);
  } else {
    _box.setFromPoints(points).getCenter(center);
  }

  num maxRadiusSq = 0.0;

  for (var i = 0, il = points.length; i < il; i++) {
    maxRadiusSq = Math.max(maxRadiusSq, center.distanceToSquared(points[i]));
  }

  radius = Math.sqrt(maxRadiusSq);

  return this;
}