diff --git a/package.json b/package.json index 9092b96..8260d6b 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,7 @@ ], "dependencies": { "bit-twiddle": "^1.0.2", - "earcut": "^2.0.7", + "earcut": "^2.1.3", "eventemitter3": "^2.0.0", "ismobilejs": "^0.4.0", "object-assign": "^4.0.1", diff --git a/package.json b/package.json index 9092b96..8260d6b 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,7 @@ ], "dependencies": { "bit-twiddle": "^1.0.2", - "earcut": "^2.0.7", + "earcut": "^2.1.3", "eventemitter3": "^2.0.0", "ismobilejs": "^0.4.0", "object-assign": "^4.0.1", diff --git a/src/core/utils/index.js b/src/core/utils/index.js index a0f560d..2d70db2 100644 --- a/src/core/utils/index.js +++ b/src/core/utils/index.js @@ -6,6 +6,7 @@ import * as isMobile from 'ismobilejs'; import removeItems from 'remove-array-items'; import mapPremultipliedBlendModes from './mapPremultipliedBlendModes'; +import earcut from 'earcut'; let nextUid = 0; let saidHello = false; @@ -61,6 +62,17 @@ */ pluginTarget, mixins, + /** + * @see {@link https://github.com/mapbox/earcut} + * + * @memberof PIXI.utils + * @function earcut + * @param {number[]} vertices - A flat array of vertice coordinates + * @param {number[]} [holes] - An array of hole indices + * @param {number} [dimensions=2] The number of coordinates per vertice in the input array + * @return {number[]} Triangulated polygon + */ + earcut, }; /** diff --git a/package.json b/package.json index 9092b96..8260d6b 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,7 @@ ], "dependencies": { "bit-twiddle": "^1.0.2", - "earcut": "^2.0.7", + "earcut": "^2.1.3", "eventemitter3": "^2.0.0", "ismobilejs": "^0.4.0", "object-assign": "^4.0.1", diff --git a/src/core/utils/index.js b/src/core/utils/index.js index a0f560d..2d70db2 100644 --- a/src/core/utils/index.js +++ b/src/core/utils/index.js @@ -6,6 +6,7 @@ import * as isMobile from 'ismobilejs'; import removeItems from 'remove-array-items'; import mapPremultipliedBlendModes from './mapPremultipliedBlendModes'; +import earcut from 'earcut'; let nextUid = 0; let saidHello = false; @@ -61,6 +62,17 @@ */ pluginTarget, mixins, + /** + * @see {@link https://github.com/mapbox/earcut} + * + * @memberof PIXI.utils + * @function earcut + * @param {number[]} vertices - A flat array of vertice coordinates + * @param {number[]} [holes] - An array of hole indices + * @param {number} [dimensions=2] The number of coordinates per vertice in the input array + * @return {number[]} Triangulated polygon + */ + earcut, }; /** diff --git a/test/core/util.js b/test/core/util.js index 68c7e6d..9813d9a 100755 --- a/test/core/util.js +++ b/test/core/util.js @@ -306,4 +306,12 @@ expect(PIXI.utils.isMobile.any).to.be.a('boolean'); }); }); + + describe('earcut', function () + { + it('should exist', function () + { + expect(PIXI.utils.earcut).to.be.a('function'); + }); + }); });