function getExtents(polygons) {
  const extentsList = [];
  const polygonIndicesList = [];

  const length = polygons.length;
  for (let polygonIndex = 0; polygonIndex < length; ++polygonIndex) {
    const polygon = polygons[polygonIndex];
    const extents = polygon.computeSphericalExtents();

    let height = Math.max(extents.height * 2.5, 0.001);
    let width = Math.max(extents.width * 2.5, 0.001);

    // Pad extents to avoid floating point error when fragment culling at edges.
    let paddedExtents = Rectangle.clone(extents);
    paddedExtents.south -= height;
    paddedExtents.west -= width;
    paddedExtents.north += height;
    paddedExtents.east += width;

    paddedExtents.south = Math.max(paddedExtents.south, -Math.PI);
    paddedExtents.west = Math.max(paddedExtents.west, -Math.PI);
    paddedExtents.north = Math.min(paddedExtents.north, Math.PI);
    paddedExtents.east = Math.min(paddedExtents.east, Math.PI);

    const polygonIndices = [polygonIndex];
    for (let i = 0; i < extentsList.length; ++i) {
      const e = extentsList[i];
      if (
        defined(e) &&
        defined(Rectangle.simpleIntersection(e, paddedExtents)) &&
        !Rectangle.equals(e, paddedExtents)
      ) {
        const intersectingPolygons = polygonIndicesList[i];
        polygonIndices.push(...intersectingPolygons);
        intersectingPolygons.reduce(
          (extents, p) =>
            Rectangle.union(
              polygons[p].computeSphericalExtents(scratchRectangle),
              extents,
              extents,
            ),
          extents,
        );

        extentsList[i] = undefined;
        polygonIndicesList[i] = undefined;

        height = Math.max(extents.height * 2.5, 0.001);
        width = Math.max(extents.width * 2.5, 0.001);

        paddedExtents = Rectangle.clone(extents, paddedExtents);
        paddedExtents.south -= height;
        paddedExtents.west -= width;
        paddedExtents.north += height;
        paddedExtents.east += width;

        paddedExtents.south = Math.max(paddedExtents.south, -Math.PI);
        paddedExtents.west = Math.max(paddedExtents.west, -Math.PI);
        paddedExtents.north = Math.min(paddedExtents.north, Math.PI);
        paddedExtents.east = Math.min(paddedExtents.east, Math.PI);

        // Reiterate through the extents list until there are no more intersections
        i = -1;
      }
    }

    extentsList.push(paddedExtents);
    polygonIndicesList.push(polygonIndices);
  }

  const extentsIndexByPolygon = new Map();
  polygonIndicesList
    .filter(defined)
    .forEach((polygonIndices, e) =>
      polygonIndices.forEach((p) => extentsIndexByPolygon.set(p, e)),
    );

  return {
    extentsList: extentsList.filter(defined),
    extentsIndexByPolygon: extentsIndexByPolygon,
  };
}
Removes the first occurrence of the given ClippingPolygon from the collection.

@param {ClippingPolygon} polygon
@returns {boolean} <code>true</code> if the polygon was removed; <code>false</code> if the polygon was not found in the collection.

@see ClippingPolygonCollection#add
@see ClippingPolygonCollection#contains
@see ClippingPolygonCollection#removeAll