Sfoglia il codice sorgente

Earcut: Updated to latest version. (#31956)

* merge latest earcut changes

fix hashed earcut not taking the first point into account

* updated version headers
Anton Bartsits 3 mesi fa
parent
commit
6ba3cbef70
1 ha cambiato i file con 7 aggiunte e 7 eliminazioni
  1. 7 7
      src/extras/lib/earcut.js

+ 7 - 7
src/extras/lib/earcut.js

@@ -1,6 +1,6 @@
 /* eslint-disable */
 /* eslint-disable */
-// copy of mapbox/earcut version 3.0.1
-// https://github.com/mapbox/earcut/tree/v3.0.1
+// copy of mapbox/earcut version 3.0.2
+// https://github.com/mapbox/earcut/tree/v3.0.2
 
 
 export default function earcut(data, holeIndices, dim = 2) {
 export default function earcut(data, holeIndices, dim = 2) {
 
 
@@ -17,10 +17,10 @@ export default function earcut(data, holeIndices, dim = 2) {
 
 
     // if the shape is not too simple, we'll use z-order curve hash later; calculate polygon bbox
     // if the shape is not too simple, we'll use z-order curve hash later; calculate polygon bbox
     if (data.length > 80 * dim) {
     if (data.length > 80 * dim) {
-        minX = Infinity;
-        minY = Infinity;
-        let maxX = -Infinity;
-        let maxY = -Infinity;
+        minX = data[0];
+        minY = data[1];
+        let maxX = minX;
+        let maxY = minY;
 
 
         for (let i = dim; i < outerLen; i += dim) {
         for (let i = dim; i < outerLen; i += dim) {
             const x = data[i];
             const x = data[i];
@@ -296,7 +296,7 @@ function compareXYSlope(a, b) {
     return result;
     return result;
 }
 }
 
 
-// find a bridge between vertices that connects hole with an outer ring and and link it
+// find a bridge between vertices that connects hole with an outer ring and link it
 function eliminateHole(hole, outerNode) {
 function eliminateHole(hole, outerNode) {
     const bridge = findHoleBridge(hole, outerNode);
     const bridge = findHoleBridge(hole, outerNode);
     if (!bridge) {
     if (!bridge) {

粤ICP备19079148号