mapbox / earcut

The fastest and smallest JavaScript polygon triangulation library for your WebGL apps
ISC License
2.21k stars 207 forks source link

Result from earcut triangulate is wrong in this condition #130

Closed ShadowVolume closed 5 years ago

ShadowVolume commented 5 years ago

var datas = [
    298117.47879999917, 2034526.4696999996, 0,
    298119.32010000205, 2034526.3901000004, 0,
    298126.96960000019, 2034526.1855999995, 0,
    298130.08169999666, 2034526.0928000007, 0,
    298189.35729999817, 2034524.3201000001, 0,
    298193.12520000362, 2034524.0200999996, 0,
    298225.15659999871, 2034521.4898000003, 0,
    298260.28959999955, 2034519.5592, 0,
    298277.49880000175, 2034519.3772999996, 0,
    298277.75509999646, 2034519.3606999998, 0,
    298324.68670000148, 2034516.2570999991, 0,
    298340.9241999989, 2034515.1832999997, 0,
    298342.50339999737, 2034515.012700001, 0,
    298366.81909999938, 2034510.5452999992, 0,
    298395.35279999551, 2034508.3451, 0,
    298434.66810000001, 2034502.4641999993, 0,
    298472.80359999888, 2034497.0133999998, 0,
    298499.95130000205, 2034494.1929999997, 0,
    298528.18810000271, 2034489.5522000007, 0,
    298557.5718000012, 2034483.5611999999, 0,
    298590.46150000382, 2034475.479800001, 0,
    298615.15129999828, 2034470.4189999993, 0,
    298643.0416999982, 2034463.8578999992, 0,
    298675.8651999986, 2034455.1263999993, 0,
    298712.12020000082, 2034444.9746000001, 0,
    298750.66019999981, 2034435.703, 0,
    298791.43569999869, 2034424.5711000005, 0,
    298814.51690000354, 2034416.4495999999, 0,
    298833.9519999997, 2034407.9481000006, 0,
    298859.87080000411, 2034397.6361999994, 0,
    298900.73719999939, 2034380.8731999996, 0,
    298941.50439999945, 2034365.5905000011, 0,
    298960.37020000041, 2034356.0784000012, 0,
    299029.47349999822, 2034326.1504999995, 0,
    299065.45629999839, 2034309.6171000004, 0,
    299096.96809999645, 2034292.8340000007, 0,
    299152.15529999853, 2034267.4293000007, 0,
    299176.92809999711, 2034251.9464999994, 0,
    299187.2726999966, 2034245.1451999992, 0,
    299221.39209999831, 2034221.1506999992, 0,
    299258.68720000249, 2034201.237, 0,
    299283.26200000162, 2034185.5440999994, 0,
    299302.08659999789, 2034171.9614999997, 0,
    299316.33290000306, 2034160.4793999998, 0,
    299406.17469999916, 2034096.8574000003, 0,
    299451.84279999911, 2034061.0007000011, 0,
    299494.59970000316, 2034025.1834999991, 0,
    299533.81729999965, 2033988.845100001, 0,
    299573.12449999928, 2033953.4072999991, 0,
    299624.03859999764, 2033902.9675999989, 0,
    299665.17729999823, 2033862.0799, 0,
    299718.90420000412, 2033809.0598000009, 0,
    299742.1675999983, 2033787.4257999994, 0,
    299759.2933999974, 2033772.3828999994, 0,
    299772.19560000341, 2033756.7498999997, 0,
    299782.81270000362, 2033743.4572999999, 0,
    299813.32729999593, 2033711.3211999999, 0,
    299826.86429999711, 2033697.0484999998, 0,
    299853.14620000205, 2033673.7741, 0,
    299870.75819999783, 2033654.6404000001, 0,
    299891.07590000378, 2033633.6364999993, 0,
    299914.81710000371, 2033609.1213000005, 0,
    299933.41900000011, 2033588.3962999992, 0,
    299961.38379999937, 2033559.3496000008, 0,
    299989.16709999717, 2033530.2837000003, 0,
    300014.60050000198, 2033505.5289999989, 0,
    300028.17100000393, 2033490.6061999998, 0,
    300058.98269999737, 2033457.4398999999, 0,
    300171.17190000461, 2033340.7476999999, 0,
    300192.13310000347, 2033320.5737999994, 0,
    300216.97139999957, 2033296.6392999999, 0,
    300237.75930000062, 2033277.3655999992, 0,
    300256.47680000192, 2033259.1721999994, 0,
    300298.52340000123, 2033210.7208999994, 0,
    300373.09860000055, 2033128.9943000004, 0,
    300433.40839999937, 2033065.9122000001, 0,
    300491.52390000282, 2033003.5303000004, 0,
    300536.73769999994, 2032959.682, 0,
    300570.2047000007, 2032926.2248999998, 0,
    300684.47429999762, 2032808.3401999995, 0,
    300743.49000000174, 2032753.1996999998, 0,
    300760.64010000223, 2032736.6965999994, 0,
    300785.85779999907, 2032712.4419999996, 0,
    300830.21369999618, 2032676.7252999991, 0,
    300879.3293000015, 2032637.1776000001, 0,
    300964.45250000095, 2032574.1729000008, 0,
    301036.46769999841, 2032525.1137000003, 0,
    301040.04800000042, 2032523.1733999997, 0,
    301064.01999999559, 2032510.1409000012, 0,
    301103.74799999606, 2032485.1062999999, 0,
    301141.43840000057, 2032463.7622999996, 0,
    301185.66220000345, 2032440.3579999986, 0,
    301244.7510000022, 2032409.6115000006, 0,
    301320.38059999741, 2032375.8730999993, 0,
    301327.12860000023, 2032372.9124999996, 0,
    301417.61500000226, 2032347.9881999998, 0,
    301455.8250999978, 2032334.4757000005, 0,
    301503.34849999822, 2032319.0930000001, 0,
    301539.61169999803, 2032311.0817000009, 0,
    301580.42019999755, 2032298.489499999, 0,
    301664.14919999981, 2032275.0140000002, 0,
    301742.35109999718, 2032250.6281000003, 0,
    301877.24939999799, 2032223.3935000002, 0,
    301903.89419999777, 2032219.3828999996, 0,
    301925.82869999832, 2032215.7122000009, 0,
    301931.5288000037, 2032214.7422000004, 0,
    302008.1057000017, 2032201.6899999992, 0,
    302104.9671999967, 2032186.3644999992, 0,
    302256.25649999885, 2032157.3897999988, 0,
    302319.65950000344, 2032145.2278000005, 0,
    302343.07880000083, 2032140.7569999993, 0,
    302389.62049999903, 2032131.8255000003, 0,
    302448.55240000144, 2032121.8038999999, 0,
    302502.1305999977, 2032112.6906000003, 0,
    302541.16560000135, 2032105.1182000004, 0,
    302643.46329999669, 2032085.3048999999, 0,
    302697.04150000273, 2032074.9231000002, 0,
    302763.7028999991, 2032063.3113000002, 0,
    302819.26070000231, 2032053.6294, 0,
    303035.58359999908, 2032015.9005999994, 0,
    303103.69669999991, 2032003.9685999993, 0,
    303191.35220000101, 2031988.6161999996, 0,
    303236.85450000293, 2031980.6148000003, 0,
    303471.35300000012, 2031939.3150999993, 0,
    303628.76209999417, 2031912.730900001, 0,
    303781.25400000066, 2031881.6241999997, 0,
    303815.85090000211, 2031872.821900001, 0,
    303862.81340000062, 2031860.8790000004, 0,
    303943.80349999719, 2031833.5441999992, 0,
    304030.48579999746, 2031793.9869999995, 0,
    304046.48070000054, 2031786.6955999988, 0,
    304071.90439999837, 2031771.0427000001, 0,
    304123.80849999946, 2031739.0767000001, 0,
    304238.20690000046, 2031656.5004999994, 0,
    304309.50469999755, 2031586.7448999994, 0,
    304368.77629999811, 2031522.2826000007, 0,
    304408.71040000021, 2031478.8344000003, 0,
    304508.2207000028, 2031362.0320999995, 0,
    304550.38239999837, 2031312.8527000009, 0,
    304638.36829999741, 2031210.2232000008, 0,
    304673.82339999767, 2031171.0756000003, 0,
    304696.78949999844, 2031145.7007999998, 0,
    304716.86800000095, 2031123.5365999993, 0,
    304770.4136999998, 2031064.3937000001, 0,
    304780.51929999865, 2031053.2411000005, 0,
    304847.99970000191, 2030971.8345999997, 0,
    304880.98000000475, 2030932.0669999998, 0,
    304935.77130000212, 2030865.9642999994, 0,
    305023.88090000313, 2030759.7139999999, 0,
    305068.34419999953, 2030706.4838999989, 0,
    305103.50329999626, 2030664.4253999998, 0,
    305129.88430000155, 2030632.8584000005, 0,
    305184.63449999708, 2030571.7250999997, 0,
    305248.4764000029, 2030500.4414000008, 0,
    305309.89999999886, 2030426.9374000004, 0,
    305440.76529999869, 2030270.3673000003, 0,
    305573.63729999925, 2030119.5256999994, 0,
    305646.50310000079, 2030033.0591999998, 0,
    305680.38260000199, 2029992.8615000003, 0,
    305697.0293999986, 2029973.1076999996, 0,
    305823.74539999699, 2029821.9458000006, 0,
    305891.38059999805, 2029741.270400001, 0,
    305921.63859999902, 2029705.1635, 0,
    305952.70509999932, 2029668.1163999997, 0,
    306083.39710000099, 2029514.6543000003, 0,
    306120.18020000245, 2029472.0459, 0,
    306126.04550000239, 2029465.2446000001, 0,
    306132.47980000038, 2029457.7831999995, 0,
    306188.68989999569, 2029392.6508000011, 0,
    306212.56300000066, 2029364.975400001, 0,
    306231.97450000083, 2029342.2493999992, 0,
    306300.38140000438, 2029262.1567999998, 0,
    306351.65029999637, 2029202.1431000012, 0,
    306367.04330000258, 2029185.1692999993, 0,
    306426.20650000055, 2029119.9563999996, 0,
    306478.39090000151, 2029062.4353999996, 0,
    306538.12200000195, 2028993.0522000005, 0,
    306588.40749999939, 2028933.6098999996, 0,
    306607.17440000153, 2028912.5448000005, 0,
    306664.26699999662, 2028847.6414000003, 0,
    306683.45380000066, 2028822.4857999999, 0,
    306715.40999999666, 2028784.6472999989, 0,
    306753.44619999814, 2028742.7584000009, 0,
    306829.52009999682, 2028666.4137999988, 0,
    306879.60099999671, 2028612.7226, 0,
    306908.30809999973, 2028582.8754999992, 0,
    306932.08200000378, 2028555.079600001, 0,
    306958.88260000164, 2028525.2739000006, 0,
    307004.51579999994, 2028486.2164999992, 0,
    307049.06929999631, 2028449.8096999994, 0,
    307076.19269999838, 2028425.7051000001, 0,
    307111.63939999847, 2028394.1591, 0,
    307123.76569999941, 2028383.1569999997, 0,
    307134.50609999913, 2028373.2449999987, 0,
    307169.85390000034, 2028342.2081000004, 0,
    307206.10899999726, 2028313.1811999995, 0,
    307225.79969999922, 2028297.948000001, 0,
    307252.0152000041, 2028273.2732000002, 0,
    307276.49000000174, 2028256.5801000001, 0,
    307293.82930000138, 2028243.0075000003, 0,
    307320.22609999613, 2028224.7140999995, 0,
    307343.51299999619, 2028209.6313000005, 0,
    307363.2528999967, 2028195.2285999989, 0,
    307387.36519999814, 2028178.5954999996, 0,
    307414.1832000023, 2028162.4524000012, 0,
    307433.32949999743, 2028160.3021000007, 0,
    307450.33919999737, 2028160.1920999996, 0,
    307460.30420000176, 2028157.5315000005, 0,
    307483.42660000164, 2028140.4276000003, 0,
    307497.4667000029, 2028132.1956999989, 0,
    307512.29039999854, 2028120.7928000002, 0,
    307546.00479999965, 2028099.3377999996, 0,
    307574.07609999867, 2028081.8746000007, 0,
    307599.23560000269, 2028066.731799999, 0,
    307619.23950000107, 2028056.0798000004, 0,
    307633.33699999732, 2028044.7676999997, 0,
    307653.72850000125, 2028028.7846000008, 0,
    307666.9209000027, 2028021.3764999991, 0,
    307634.22950000304, 2027977.7643999995, 0,
    307634.2186999995, 2027977.7498999999, 0,
    307634.17440000153, 2027977.6907000002, 0,
    307616.89570000034, 2027987.4663999991, 0,
    307547.94150000106, 2028031.0044, 0,
    307466.54050000018, 2028088.1969000008, 0,
    307452.13780000061, 2028099.0797000008, 0,
    307425.22910000524, 2028119.3139999995, 0,
    307369.25839999999, 2028159.5317000002, 0,
    307330.71829999983, 2028186.3266000003, 0,
    307247.60119999934, 2028246.3578999992, 0,
    307176.1398999989, 2028299.1882000009, 0,
    307126.83460000122, 2028339.2478000002, 0,
    307068.66139999789, 2028387.0574999992, 0,
    307040.5728999984, 2028409.8518000003, 0,
    307007.26280000038, 2028440.0975000004, 0,
    306951.25949999737, 2028492.8874999995, 0,
    306905.40349999972, 2028530.0447000007, 0,
    306849.55780000298, 2028588.5879999998, 0,
    306804.78109999734, 2028642.5590000006, 0,
    306772.54330000223, 2028667.3937000001, 0,
    306737.64100000303, 2028707.7114000006, 0,
    306703.86879999883, 2028749.6693999991, 0,
    306684.59099999862, 2028774.8948999995, 0,
    306654.12770000292, 2028804.9214999997, 0,
    306631.87210000248, 2028828.607000001, 0,
    306611.23330000043, 2028848.1712, 0,
    306538.97869999718, 2028930.7197999989, 0,
    306488.09090000426, 2028989.0811000001, 0,
    306456.34090000379, 2029025.4980999995, 0,
    306401.90469999553, 2029087.9199999999, 0,
    306350.54519999761, 2029149.5319999999, 0,
    306204.57819999702, 2029320.9167999995, 0,
    306194.8936000031, 2029332.3890000002, 0,
    306102.90669999982, 2029441.1697000002, 0,
    306100.580399998, 2029444.0203000009, 0,
    306097.23129999626, 2029448.1110999996, 0,
    306039.19820000243, 2029518.9652999993, 0,
    306036.9296000005, 2029521.5459000003, 0,
    305967.52099999797, 2029600.4932000004, 0,
    305873.01820000308, 2029707.9936999995, 0,
    305825.34610000084, 2029761.2639000006, 0,
    305813.4342999974, 2029774.8265000004, 0,
    305728.97070000373, 2029871.0865000002, 0,
    305661.04690000368, 2029951.7533000002, 0,
    305629.66690000182, 2029989.0205000003, 0,
    305618.37380000076, 2030002.3929999992, 0,
    305531.39300000109, 2030105.4627000003, 0,
    305381.92409999605, 2030279.7390999999, 0,
    305244.96270000207, 2030448.3512999993, 0,
    305109.30369999999, 2030607.3134999999, 0,
    305038.03750000184, 2030691.7007999998, 0,
    304916.53450000222, 2030829.9371000004, 0,
    304901.10019999614, 2030847.9506000001, 0,
    304805.47559999785, 2030959.4319000002, 0,
    304645.78549999779, 2031149.5513000004, 0,
    304634.65690000297, 2031162.5538000001, 0,
    304502.28989999805, 2031317.1331999991, 0,
    304456.48200000048, 2031371.6137000003, 0,
    304408.88419999892, 2031428.8946000002, 0,
    304337.49570000195, 2031506.7995, 0,
    304251.29919999896, 2031598.4085000011, 0,
    304220.2248999998, 2031626.4148999993, 0,
    304165.23579999816, 2031666.9428000001, 0,
    304090.07800000149, 2031722.1831999996, 0,
    304023.27619999653, 2031764.0711000003, 0,
    303992.28409999656, 2031779.9739999995, 0,
    303956.3096000026, 2031792.186100001, 0,
    303894.14389999898, 2031816.2104000004, 0,
    303818.77130000287, 2031839.5547000002, 0,
    303747.49870000069, 2031857.2191000001, 0,
    303694.16789999569, 2031870.6029000005, 0,
    303651.76839999855, 2031878.8044000005, 0,
    303579.71400000132, 2031891.0863000005, 0,
    303479.14859999751, 2031907.7990000008, 0,
    303395.28779999772, 2031921.1810999997, 0,
    303312.441600002, 2031935.0440999998, 0,
    303264.06040000101, 2031943.1871000007, 0,
    303244.41089999559, 2031946.4981999993, 0,
    303193.44770000083, 2031955.0695999991, 0,
    303092.6348000018, 2031972.7325000004, 0,
    302958.03490000247, 2031997.5164999999, 0,
    302823.42689999961, 2032022.3128999993, 0,
    302721.40139999974, 2032040.6064999998, 0,
    302592.17029999924, 2032064.2403999995, 0,
    302432.21930000221, 2032090.9970999996, 0,
    302304.48120000225, 2032114.6016000006, 0,
    302179.02820000082, 2032136.7151999993, 0,
    302101.74189999676, 2032150.2173999995, 0,
    302061.93980000168, 2032157.1799000001, 0,
    301980.60320000199, 2032172.0240000002, 0,
    301925.46590000391, 2032180.8753999989, 0,
    301915.81440000259, 2032183.5259000009, 0,
    301893.55820000195, 2032190.3369999991, 0,
    301864.29020000197, 2032194.3776999994, 0,
    301706.86349999846, 2032228.0834999999, 0,
    301638.15630000096, 2032243.3373000005, 0,
    301589.29659999837, 2032254.9606999992, 0,
    301510.85539999546, 2032277.5448999996, 0,
    301467.04420000338, 2032289.6171000004, 0,
    301429.33730000281, 2032304.8797999995, 0,
    301382.34179999738, 2032319.6823999994, 0,
    301356.50530000194, 2032330.5645000001, 0,
    301313.66650000197, 2032348.5577000007, 0,
    301279.18399999978, 2032365.0713, 0,
    301234.16759999911, 2032384.8862999992, 0,
    301188.90429999708, 2032406.8513999989, 0,
    301142.46150000568, 2032433.0363999996, 0,
    301092.38910000067, 2032461.6216000002, 0,
    301055.57310000033, 2032483.1855999997, 0,
    301024.68810000276, 2032502.8392999992, 0,
    300974.64859999658, 2032536.7356, 0,
    300942.69139999931, 2032555.0294000008, 0,
    300916.97869999724, 2032572.543400001, 0,
    300880.21220000088, 2032600.0802999996, 0,
    300839.56019999855, 2032634.6171000001, 0,
    300775.01039999689, 2032688.3271999997, 0,
    300772.27990000008, 2032690.5975999997, 0,
    300746.35270000109, 2032710.1113000009, 0,
    300736.98990000028, 2032719.5931000004, 0,
    300709.02520000166, 2032746.1481000001, 0,
    300669.92310000141, 2032783.2552000002, 0,
    300643.12850000022, 2032811.3205999993, 0,
    300580.56589999812, 2032873.2133000009, 0,
    300540.16139999789, 2032916.6132999992, 0,
    300499.41040000378, 2032956.9013000003, 0,
    300448.17469999986, 2033008.081, 0,
    300395.00859999715, 2033066.9321999997, 0,
    300366.99440000154, 2033096.1677999999, 0,
    300329.10539999581, 2033132.3045999999, 0,
    300291.70189999876, 2033169.7819999997, 0,
    300248.64029999857, 2033217.5930000001, 0,
    300215.77560000063, 2033255.4112, 0,
    300197.60260000115, 2033274.6449, 0,
    300165.8348999974, 2033306.6510000008, 0,
    300142.19280000008, 2033331.3856000006, 0,
    300099.35469999874, 2033371.9133000004, 0,
    300054.95759999868, 2033417.301999999, 0,
    300029.31069999991, 2033444.6171000001, 0,
    300001.41910000169, 2033476.6632999999, 0,
    299986.00069999672, 2033489.6757, 0,
    299968.26439999801, 2033504.5384999996, 0,
    299943.01319999958, 2033530.7634999994, 0,
    299924.16370000009, 2033559.0297999997, 0,
    299894.97810000216, 2033588.2065999995, 0,
    299876.87110000162, 2033604.5102999993, 0,
    299853.71570000041, 2033628.4152000004, 0,
    299822.18729999615, 2033659.0610000007, 0,
    299799.40299999679, 2033681.4453, 0,
    299790.2382000013, 2033692.5373999998, 0,
    299784.9751999958, 2033698.8986000009, 0,
    299756.07779999857, 2033730.4547000008, 0,
    299735.23120000178, 2033754.5192000009, 0,
    299725.6204999981, 2033765.7914000002, 0,
    299719.74679999804, 2033771.2623999994, 0,
    299700.14610000001, 2033788.8257999998, 0,
    299672.42019999784, 2033813.270400001, 0,
    299653.25749999902, 2033831.0538000001, 0,
    299635.33200000261, 2033848.2971000003, 0,
    299616.6146000023, 2033867.1405999993, 0,
    299605.39559999917, 2033878.7327999996, 0,
    299587.63510000019, 2033898.0264999997, 0,
    299562.82980000164, 2033919.2104999998, 0,
    299548.74030000024, 2033933.3637000008, 0,
    299518.42450000381, 2033958.9596999998, 0,
    299478.57270000188, 2033992.1572999991, 0,
    299452.48740000138, 2034019.7026000004, 0,
    299428.7370999977, 2034042.3869000003, 0,
    299393.30619999731, 2034069.902100001, 0,
    299353.36370000237, 2034095.2968000008, 0,
    299295.81750000257, 2034140.3652999997, 0,
    299253.37539999955, 2034173.7816000003, 0,
    299231.07789999997, 2034187.1041000001, 0,
    299187.12550000061, 2034211.6986999991, 0,
    299158.72320000071, 2034227.1614999995, 0,
    299131.06310000236, 2034246.7051999997, 0,
    299079.44720000192, 2034273.1900999991, 0,
    299035.29760000051, 2034291.5735999998, 0,
    299017.76810000231, 2034299.7656999996, 0,
    298986.98219999601, 2034316.0997000004, 0,
    298956.15510000312, 2034330.5934999997, 0,
    298924.09889999765, 2034343.9060999989, 0,
    298890.89599999739, 2034354.4480000008, 0,
    298854.19560000277, 2034369.7206999997, 0,
    298835.79999999714, 2034374.9015999998, 0,
    298824.43259999854, 2034377.8121000007, 0,
    298804.48610000382, 2034387.9039999989, 0,
    298790.973999999, 2034391.9346999992, 0,
    298768.79200000362, 2034398.2758000009, 0,
    298743.89609999896, 2034404.6568999998, 0,
    298730.93670000171, 2034409.7578, 0,
    298707.12969999807, 2034415.2487999999, 0,
    298672.41709999728, 2034423.4401999991, 0,
    298637.88619999762, 2034433.4518999991, 0,
    298623.40070000308, 2034437.5626999997, 0,
    298609.40190000134, 2034441.1832999995, 0,
    298595.00710000086, 2034443.5436000004, 0,
    298588.58929999889, 2034443.9436000008, 0,
    298556.20309999667, 2034450.7848000007, 0,
    298529.18720000284, 2034459.4663999996, 0,
    298516.58249999612, 2034460.1564000007, 0,
    298491.92580000346, 2034464.9271000009, 0,
    298481.54840000038, 2034465.7573000006, 0,
    298461.30489999772, 2034466.0973000005, 0,
    298446.2668000015, 2034469.4377999997, 0,
    298432.5979000029, 2034472.7383999994, 0,
    298416.13260000187, 2034473.0183000003, 0,
    298396.96980000334, 2034475.7288000013, 0,
    298371.30669999879, 2034480.2695000004, 0,
    298352.65539999917, 2034483.6099999994, 0,
    298332.62650000345, 2034485.0203000009, 0,
    298307.95340000052, 2034486.8013999998, 0,
    298293.50909999781, 2034488.9022000004, 0,
    298286.72829999792, 2034489.8926000001, 0,
    298253.81419999897, 2034490.7737000005, 0,
    298221.87349999737, 2034493.1842, 0,
    298199.51839999878, 2034493.5540999987, 0,
    298190.64239999675, 2034493.0940000007, 0,
    298180.51240000105, 2034492.0337000003, 0,
    298169.49149999622, 2034491.9136999999, 0,
    298145.37099999865, 2034495.9843000004, 0,
    298092.3456000021, 2034497.4442999996, 0,
    298073.19110000134, 2034497.3640999999, 0,
    298058.74679999799, 2034499.544500001, 0,
    298052.5682000001, 2034500.9546000005, 0,
    298023.21779999789, 2034503.6150999998, 0,
    297998.75900000276, 2034504.0149000005, 0,
    297961.88539999665, 2034499.6039000002, 0,
    297944.57050000119, 2034499.8837999997, 0,
    297916.2017000023, 2034502.0841000006, 0,
    297890.94280000043, 2034503.8943000007, 0,
    297873.2484000026, 2034502.4539000003, 0,
    297861.08099999966, 2034500.5734999999, 0,
    297846.52949999872, 2034496.1325000003, 0,
    297837.24099999666, 2034494.6820999996, 0,
    297814.38260000199, 2034494.4120000002, 0,
    297759.51749999984, 2034494.3015999999, 0,
    297712.64599999768, 2034494.0715999997, 0,
    297665.98860000225, 2034493.2727000006, 0,
    297627.14320000249, 2034491.5734000001, 0,
    297571.89710000122, 2034488.1424000005, 0,
    297567.15380000253, 2034487.9122999997, 0,
    297547.10769999726, 2034488.1522000001, 0,
    297510.02769999951, 2034488.7621000002, 0,
    297478.18609999912, 2034487.8917999992, 0,
    297407.34250000096, 2034485.9710000011, 0,
    297377.05169999582, 2034486.1608000004, 0,
    297346.15029999602, 2034486.3607000001, 0,
    297332.7290000025, 2034486.5906000007, 0,
    297311.80920000351, 2034485.9404000009, 0,
    297271.95759999729, 2034485.4901000001, 0,
    297244.06729999871, 2034483.7194999997, 0,
    297216.49870000023, 2034483.8193999995, 0,
    297182.18219999957, 2034483.6491000003, 0,
    297158.14419999748, 2034484.8893000002, 0,
    297153.34319999628, 2034485.509400001, 0,
    297137.13369999797, 2034485.1092000005, 0,
    297118.26789999817, 2034484.3189999999, 0,
    297100.07029999787, 2034484.6190000006, 0,
    297084.99090000143, 2034485.7596000005, 0,
    297076.57670000149, 2034485.3498999996, 0,
    297066.31489999586, 2034484.1097999997, 0,
    297052.4315999964, 2034483.1500000001, 0,
    297040.75079999852, 2034483.3405000006, 0,
    297028.08839999826, 2034484.1509000007, 0,
    297021.15909999615, 2034484.2711999994, 0,
    297014.20499999775, 2034483.1910999999, 0,
    297004.35530000174, 2034478.6602, 0,
    296995.14890000201, 2034477.9199999999, 0,
    296976.05979999958, 2034478.2400000005, 0,
    296951.14649999887, 2034479.0098999999, 0,
    296906.56750000245, 2034479.2197999989, 0,
    296885.54860000254, 2034479.5595999991, 0,
    296870.90360000043, 2034479.9674999993, 0,
    296872.33789999806, 2034508.2645999994, 0,
    296895.46390000032, 2034507.0650999995, 0,
    296942.34420000046, 2034507.4655000009, 0,
    296986.52809999883, 2034509.8562, 0,
    297004.90770000214, 2034510.7265000008, 0,
    297030.6950000003, 2034511.4663999996, 0,
    297055.10410000343, 2034513.0763000008, 0,
    297066.6694000006, 2034512.6458999999, 0,
    297108.85549999948, 2034512.9954000004, 0,
    297143.36990000249, 2034512.7652000003, 0,
    297172.6626000033, 2034513.3352000006, 0,
    297205.76609999652, 2034515.0725999996, 0,
    297212.90720000106, 2034515.1929000001, 0,
    297221.93490000028, 2034515.3450000004, 0,
    297239.61259999877, 2034515.2556999999, 0,
    297249.99080000038, 2034515.7452000009, 0,
    297250.17229999637, 2034515.7467999998, 0,
    297250.74469999969, 2034515.7523000001, 0,
    297416.54450000089, 2034517.2323000005, 0,
    297441.19969999779, 2034517.8311000001, 0,
    297441.80879999732, 2034517.8454999996, 0,
    297456.17719999608, 2034517.8175000008, 0,
    297475.43180000002, 2034518.6615999991, 0,
    297475.83129999833, 2034518.6712999993, 0,
    297476.93020000344, 2034518.6985999995, 0,
    297539.68230000196, 2034520.2216999996, 0,
    297539.93519999774, 2034520.227399999, 0,
    297563.28440000111, 2034519.7585000002, 0,
    297568.4483999986, 2034520.3487, 0,
    297594.21859999804, 2034521.5449999997, 0,
    297635.83330000192, 2034522.5549999999, 0,
    297653.73759999918, 2034522.4488999993, 0,
    297667.49140000477, 2034523.3233999996, 0,
    297672.38229999738, 2034523.4420999996, 0,
    297672.4026999998, 2034523.4425000008, 0,
    297672.40649999672, 2034523.4427000005, 0,
    297673.26190000027, 2034523.4635000008, 0,
    297699.94179999852, 2034523.5677000005, 0,
    297725.71239999693, 2034524.3972999991, 0,
    297749.28849999432, 2034524.327400001, 0,
    297790.55889999808, 2034524.3476999998, 0,
    297816.07350000029, 2034523.9277999997, 0,
    297836.65510000318, 2034524.3479999993, 0,
    297857.75320000178, 2034527.1294999996, 0,
    297858.21130000078, 2034527.1366000006, 0,
    297858.21509999747, 2034527.1368000004, 0,
    297858.21909999877, 2034527.1367000004, 0,
    298004.59880000365, 2034529.4165000005, 0,
    298100.69020000135, 2034526.9715999998, 0,
    298116.23420000111, 2034526.5070999991, 0,
    298117.11550000275, 2034526.4806999993, 0,
    298117.47879999917, 2034526.4696999996, 0,
]

var result = earcut(datas, [], 3);
mourner commented 5 years ago

Looks like you forgot to specify that the input data has 3 dimensions, so it treats it as 2D.

ShadowVolume commented 4 years ago

Looks like you forgot to specify that the input data has 3 dimensions, so it treats it as 2D.

I invoke the function earcut with size argument but forget it in question. Triangulate return a result and shown in the canvas successful. But the face is cross intricately. It's look at some bug in the algorithm.