diff --git a/bundles/pixi.js/package.json b/bundles/pixi.js/package.json index 49c7276..177e059 100644 --- a/bundles/pixi.js/package.json +++ b/bundles/pixi.js/package.json @@ -49,6 +49,7 @@ "@pixi/loaders": "^5.0.0-alpha.2", "@pixi/math": "^5.0.0-alpha.2", "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/mesh-extras": "^5.0.0-alpha.2", "@pixi/mixin-cache-as-bitmap": "^5.0.0-alpha.2", "@pixi/mixin-get-child-by-name": "^5.0.0-alpha.2", "@pixi/mixin-get-global-position": "^5.0.0-alpha.2", diff --git a/bundles/pixi.js/package.json b/bundles/pixi.js/package.json index 49c7276..177e059 100644 --- a/bundles/pixi.js/package.json +++ b/bundles/pixi.js/package.json @@ -49,6 +49,7 @@ "@pixi/loaders": "^5.0.0-alpha.2", "@pixi/math": "^5.0.0-alpha.2", "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/mesh-extras": "^5.0.0-alpha.2", "@pixi/mixin-cache-as-bitmap": "^5.0.0-alpha.2", "@pixi/mixin-get-child-by-name": "^5.0.0-alpha.2", "@pixi/mixin-get-global-position": "^5.0.0-alpha.2", diff --git a/bundles/pixi.js/src/deprecated.js b/bundles/pixi.js/src/deprecated.js index 147617c..dbebeb0 100644 --- a/bundles/pixi.js/src/deprecated.js +++ b/bundles/pixi.js/src/deprecated.js @@ -263,15 +263,15 @@ Object.defineProperties(PIXI.mesh, { /** * @class PIXI.mesh.Mesh - * @see PIXI.Mesh + * @see PIXI.Mesh2d * @deprecated since 5.0.0 */ Mesh: { get() { - warn('PIXI.mesh.Mesh has moved to PIXI.Mesh'); + warn('PIXI.mesh.Mesh has moved to PIXI.Mesh2d'); - return PIXI.Mesh; + return PIXI.Mesh2d; }, }, /** @@ -315,15 +315,15 @@ }, /** * @class PIXI.mesh.RawMesh - * @see PIXI.RawMesh + * @see PIXI.Mesh * @deprecated since 5.0.0 */ RawMesh: { get() { - warn('PIXI.mesh.RawMesh has moved to PIXI.RawMesh'); + warn('PIXI.mesh.RawMesh has moved to PIXI.Mesh'); - return PIXI.RawMesh; + return PIXI.Mesh; }, }, /** diff --git a/bundles/pixi.js/package.json b/bundles/pixi.js/package.json index 49c7276..177e059 100644 --- a/bundles/pixi.js/package.json +++ b/bundles/pixi.js/package.json @@ -49,6 +49,7 @@ "@pixi/loaders": "^5.0.0-alpha.2", "@pixi/math": "^5.0.0-alpha.2", "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/mesh-extras": "^5.0.0-alpha.2", "@pixi/mixin-cache-as-bitmap": "^5.0.0-alpha.2", "@pixi/mixin-get-child-by-name": "^5.0.0-alpha.2", "@pixi/mixin-get-global-position": "^5.0.0-alpha.2", diff --git a/bundles/pixi.js/src/deprecated.js b/bundles/pixi.js/src/deprecated.js index 147617c..dbebeb0 100644 --- a/bundles/pixi.js/src/deprecated.js +++ b/bundles/pixi.js/src/deprecated.js @@ -263,15 +263,15 @@ Object.defineProperties(PIXI.mesh, { /** * @class PIXI.mesh.Mesh - * @see PIXI.Mesh + * @see PIXI.Mesh2d * @deprecated since 5.0.0 */ Mesh: { get() { - warn('PIXI.mesh.Mesh has moved to PIXI.Mesh'); + warn('PIXI.mesh.Mesh has moved to PIXI.Mesh2d'); - return PIXI.Mesh; + return PIXI.Mesh2d; }, }, /** @@ -315,15 +315,15 @@ }, /** * @class PIXI.mesh.RawMesh - * @see PIXI.RawMesh + * @see PIXI.Mesh * @deprecated since 5.0.0 */ RawMesh: { get() { - warn('PIXI.mesh.RawMesh has moved to PIXI.RawMesh'); + warn('PIXI.mesh.RawMesh has moved to PIXI.Mesh'); - return PIXI.RawMesh; + return PIXI.Mesh; }, }, /** diff --git a/bundles/pixi.js/src/index.js b/bundles/pixi.js/src/index.js index a3a0d1b..6fdabf0 100644 --- a/bundles/pixi.js/src/index.js +++ b/bundles/pixi.js/src/index.js @@ -9,6 +9,7 @@ import * as loaders from '@pixi/loaders'; import * as math from '@pixi/math'; import * as mesh from '@pixi/mesh'; +import * as meshExtras from '@pixi/mesh-extras'; import * as particles from '@pixi/particles'; import * as prepare from '@pixi/prepare'; import * as sprite from '@pixi/sprite'; @@ -128,6 +129,7 @@ loaders, math, mesh, + meshExtras, particles, sprite, spriteAnimated, @@ -152,6 +154,7 @@ export * from '@pixi/loaders'; export * from '@pixi/math'; export * from '@pixi/mesh'; +export * from '@pixi/mesh-extras'; export * from '@pixi/particles'; export * from '@pixi/sprite'; export * from '@pixi/spritesheet'; diff --git a/bundles/pixi.js/package.json b/bundles/pixi.js/package.json index 49c7276..177e059 100644 --- a/bundles/pixi.js/package.json +++ b/bundles/pixi.js/package.json @@ -49,6 +49,7 @@ "@pixi/loaders": "^5.0.0-alpha.2", "@pixi/math": "^5.0.0-alpha.2", "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/mesh-extras": "^5.0.0-alpha.2", "@pixi/mixin-cache-as-bitmap": "^5.0.0-alpha.2", "@pixi/mixin-get-child-by-name": "^5.0.0-alpha.2", "@pixi/mixin-get-global-position": "^5.0.0-alpha.2", diff --git a/bundles/pixi.js/src/deprecated.js b/bundles/pixi.js/src/deprecated.js index 147617c..dbebeb0 100644 --- a/bundles/pixi.js/src/deprecated.js +++ b/bundles/pixi.js/src/deprecated.js @@ -263,15 +263,15 @@ Object.defineProperties(PIXI.mesh, { /** * @class PIXI.mesh.Mesh - * @see PIXI.Mesh + * @see PIXI.Mesh2d * @deprecated since 5.0.0 */ Mesh: { get() { - warn('PIXI.mesh.Mesh has moved to PIXI.Mesh'); + warn('PIXI.mesh.Mesh has moved to PIXI.Mesh2d'); - return PIXI.Mesh; + return PIXI.Mesh2d; }, }, /** @@ -315,15 +315,15 @@ }, /** * @class PIXI.mesh.RawMesh - * @see PIXI.RawMesh + * @see PIXI.Mesh * @deprecated since 5.0.0 */ RawMesh: { get() { - warn('PIXI.mesh.RawMesh has moved to PIXI.RawMesh'); + warn('PIXI.mesh.RawMesh has moved to PIXI.Mesh'); - return PIXI.RawMesh; + return PIXI.Mesh; }, }, /** diff --git a/bundles/pixi.js/src/index.js b/bundles/pixi.js/src/index.js index a3a0d1b..6fdabf0 100644 --- a/bundles/pixi.js/src/index.js +++ b/bundles/pixi.js/src/index.js @@ -9,6 +9,7 @@ import * as loaders from '@pixi/loaders'; import * as math from '@pixi/math'; import * as mesh from '@pixi/mesh'; +import * as meshExtras from '@pixi/mesh-extras'; import * as particles from '@pixi/particles'; import * as prepare from '@pixi/prepare'; import * as sprite from '@pixi/sprite'; @@ -128,6 +129,7 @@ loaders, math, mesh, + meshExtras, particles, sprite, spriteAnimated, @@ -152,6 +154,7 @@ export * from '@pixi/loaders'; export * from '@pixi/math'; export * from '@pixi/mesh'; +export * from '@pixi/mesh-extras'; export * from '@pixi/particles'; export * from '@pixi/sprite'; export * from '@pixi/spritesheet'; diff --git a/package-lock.json b/package-lock.json index 7fe6db7..0814729 100644 --- a/package-lock.json +++ b/package-lock.json @@ -209,7 +209,7 @@ "argparse": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", - "integrity": "sha1-vNZ5HqWuCXJeF+WtmIE0zUCz2RE=", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", "dev": true, "requires": { "sprintf-js": "1.0.3" @@ -228,7 +228,7 @@ "arr-flatten": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz", - "integrity": "sha1-NgSLv/TntH4TZkQxbJlmnqWukfE=", + "integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==", "dev": true }, "arr-union": { @@ -297,7 +297,7 @@ "assertion-error": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", - "integrity": "sha1-5gtrDo8wG9l+U3UhW9pAbIURjAs=", + "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", "dev": true }, "async": { @@ -396,7 +396,7 @@ "brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha1-PH/L9SnYcibz0vUrlm/1Jx60Qd0=", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, "requires": { "balanced-match": "1.0.0", @@ -568,7 +568,7 @@ "circular-json": { "version": "0.3.3", "resolved": "https://registry.npmjs.org/circular-json/-/circular-json-0.3.3.tgz", - "integrity": "sha1-gVyZ6oT2gJUp0vRXkb34JxE1LWY=", + "integrity": "sha512-UZK3NBx2Mca+b5LsG7bY183pHWt5Y1xts4P3Pz7ENTwGVnJOUWbRb3ocjvX7hx9tq/yTAdclXm9sZ38gNuem4A==", "dev": true }, "cli-cursor": { @@ -638,7 +638,7 @@ "color-convert": { "version": "1.9.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.1.tgz", - "integrity": "sha1-wSYRB66y8pTr/+ye2eytUppgl+0=", + "integrity": "sha512-mjGanIiwQJskCC18rPR6OmrZ6fm2Lc7PeGFYwCmy5J34wC6F1PzdGL6xeMfmgicfYcNLGuVFA3WzXtIDCQSZxQ==", "dev": true, "requires": { "color-name": "1.1.3" @@ -1427,7 +1427,7 @@ "boom": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/boom/-/boom-5.2.0.tgz", - "integrity": "sha1-XdnabuOl8wIHdDYpDLcX0/SlTgI=", + "integrity": "sha512-Z5BTk6ZRe4tXXQlkqftmsAUANpXmuwlsF5Oov8ThoMbQRzdGTA1ngYRW160GexgOgjsFOKJz0LYhoNi+2AMBUw==", "dev": true, "requires": { "hoek": "4.2.1" @@ -1471,7 +1471,7 @@ "debug": { "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha1-XRKFFd8TT/Mn6QpMk/Tgd6U2NB8=", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", "dev": true, "requires": { "ms": "2.0.0" @@ -1585,7 +1585,7 @@ "doctrine": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", - "integrity": "sha1-XNAfwQFiG0LEzX9dGmYkNxbT850=", + "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", "dev": true, "requires": { "esutils": "2.0.2" @@ -1662,7 +1662,7 @@ "es6-promise": { "version": "4.2.4", "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.4.tgz", - "integrity": "sha1-3EIhwrFlGHYL2MOaUtjzVvwA7Sk=", + "integrity": "sha512-/NdNZVJg+uZgtm9eS3O6lrOLYmQag2DjdEXuPaHlZ6RuVqgqaVZfgYCepEIKsLqwdQArOPtC3XzRLqGGfT8KQQ==", "dev": true }, "escape-string-regexp": { @@ -1788,7 +1788,7 @@ "espree": { "version": "3.5.4", "resolved": "https://registry.npmjs.org/espree/-/espree-3.5.4.tgz", - "integrity": "sha1-sPRHGHyKi+2US4FaZgvd9d610ac=", + "integrity": "sha512-yAcIQxtmMiB/jL32dzEp2enBeidsB7xWPLNiw3IIkpVds1P+h7qF9YwJq1yUNzp2OKXgAprs4F61ih66UsoD1A==", "dev": true, "requires": { "acorn": "5.5.0", @@ -1798,7 +1798,7 @@ "esprima": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.0.tgz", - "integrity": "sha1-RJnt3NERDgshi6zy+n9/WfVcqAQ=", + "integrity": "sha512-oftTcaMu/EGrEIu904mWteKIv8vMuOgGYo7EhVJJN00R/EED9DCua/xxHRdYnKtcECzVg7xOWhflvJMnqcFZjw==", "dev": true }, "esquery": { @@ -1813,7 +1813,7 @@ "esrecurse": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.2.1.tgz", - "integrity": "sha1-AHo7n9vCs7uH5IeeoZyS/b05Qs8=", + "integrity": "sha512-64RBB++fIOAXPw3P9cy89qfMlvZEXZkqqJkjqqXIvzP5ezRZjW+lPWjw35UX/3EhUPFYbg5ER4JYgDw4007/DQ==", "dev": true, "requires": { "estraverse": "4.2.0" @@ -2024,7 +2024,7 @@ "find-root": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/find-root/-/find-root-1.1.0.tgz", - "integrity": "sha1-q8/Iunb3CMQql7PWhbfpRQv7nOQ=", + "integrity": "sha512-NKfW6bec6GfKc0SGx1e07QZY9PE99u0Bft/0rzSD5k3sO/vwkVUpDUKVm5Gpp5Ue3YfShPFTX2070tDs5kB9Ng==", "dev": true }, "find-up": { @@ -2103,7 +2103,7 @@ "supports-color": { "version": "5.3.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.3.0.tgz", - "integrity": "sha1-WySsFduA+pJ89SJ6SjP9PEx2dsA=", + "integrity": "sha512-0aP01LLIskjKs3lq52EC0aGBAJhLq7B2Rd8HC/DR/PtNNpcLilNmHC12O+hu0usQpo7wtHNRqtrhBwtDb0+dNg==", "dev": true, "requires": { "has-flag": "3.0.0" @@ -2567,7 +2567,7 @@ "glob": { "version": "7.1.2", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", - "integrity": "sha1-wZyd+aAocC1nhhI4SmVSQExjbRU=", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", "dev": true, "requires": { "fs.realpath": "1.0.0", @@ -2672,7 +2672,7 @@ "growl": { "version": "1.10.3", "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.3.tgz", - "integrity": "sha1-GSa6kM8+3+KttJJ/WIC8IsZseQ8=", + "integrity": "sha512-hKlsbA5Vu3xsh1Cg3J7jSmX/WaW6A5oBeqzM88oNbCRQFz+zUaXm6yxS4RVytp1scBoJzSYl4YAEOQIt6O8V1Q==", "dev": true }, "handlebars": { @@ -2738,7 +2738,7 @@ "hawk": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/hawk/-/hawk-6.0.2.tgz", - "integrity": "sha1-r02RTrBl+bXOTZ0RwcshJu7MMDg=", + "integrity": "sha512-miowhl2+U7Qle4vdLqDdPt9m09K6yZhkLDTWGoUiUzrQCn+mHHSmfJgAyGaLRZbPmTqfFFjRV1QWCW0VWUJBbQ==", "dev": true, "requires": { "boom": "4.3.1", @@ -2756,7 +2756,7 @@ "hoek": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/hoek/-/hoek-4.2.1.tgz", - "integrity": "sha1-ljRQKqEsRF3Vp8VzS1cruHOKrLs=", + "integrity": "sha512-QLg82fGkfnJ/4iy1xZ81/9SIJiq1NGFUMGs6ParyjBZr6jW2Ufj/snDqTHixNlHdPNwN2RLVD0Pi3igeK9+JfA==", "dev": true }, "home-path": { @@ -2791,7 +2791,7 @@ "ignore": { "version": "3.3.7", "resolved": "https://registry.npmjs.org/ignore/-/ignore-3.3.7.tgz", - "integrity": "sha1-YSKJv7PCIOGGpYEYYY1b6MG6sCE=", + "integrity": "sha512-YGG3ejvBNHRqu0559EOxxNFihD0AjpvHlC/pdGKd3X3ofe+CoJkYazwNJYTNebqpPKN+VVQbh4ZFn1DivMNuHA==", "dev": true }, "imurmurhash": { @@ -2828,7 +2828,7 @@ "ini": { "version": "1.3.5", "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", - "integrity": "sha1-7uJfVtscnsYIXgwid4CD9Zar+Sc=", + "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==", "dev": true }, "inquirer": { @@ -2901,7 +2901,7 @@ "is-buffer": { "version": "1.1.6", "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", - "integrity": "sha1-76ouqdqg16suoTqXsritUf776L4=", + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", "dev": true }, "is-builtin-module": { @@ -3054,7 +3054,7 @@ "is-resolvable": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/is-resolvable/-/is-resolvable-1.1.0.tgz", - "integrity": "sha1-+xj4fOH+uSUWnJpAfBkxijIG7Yg=", + "integrity": "sha512-qgDYXFSR5WvEfuS5dMj6oTMEbrrSaM0CrFk2Yiq/gXnBvD9pMa2jGXxyhGLfvhZpuMZe18CJpFxAt3CRs42NMg==", "dev": true }, "is-retry-allowed": { @@ -3204,7 +3204,7 @@ "js-yaml": { "version": "3.11.0", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.11.0.tgz", - "integrity": "sha1-WXwai9VxUvJtYizkEXhRpR9euu8=", + "integrity": "sha512-saJstZWv7oNeOyBh3+Dx1qWzhW0+e6/8eDzo7p5rDFqxntSztloLtuKu+Ejhtq82jsilwOIZYsCz+lIjthg1Hw==", "dev": true, "requires": { "argparse": "1.0.10", @@ -3324,7 +3324,7 @@ "just-extend": { "version": "1.1.27", "resolved": "https://registry.npmjs.org/just-extend/-/just-extend-1.1.27.tgz", - "integrity": "sha1-7G55QQ/5FORyZSq/oOYDwD1g6QU=", + "integrity": "sha512-mJVp13Ix6gFo3SBAy9U/kL+oeZqzlYYYLQBwXVBlVzIsZwBqGREnOro24oC/8s8aox+rJhtZ2DiQof++IrkA+g==", "dev": true }, "kind-of": { @@ -3703,7 +3703,7 @@ "lodash": { "version": "4.17.5", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.5.tgz", - "integrity": "sha1-maktZcAnLevoyWtgV7yPv6O+1RE=", + "integrity": "sha512-svL3uiZf1RwhH+cWrfZn3A4+U58wbP0tGVTLQPbjplZxZ8ROD9VLuNgsRniTlLe7OlSqR79RUehXgpBW/s0IQw==", "dev": true }, "lodash._reinterpolate": { @@ -3740,7 +3740,7 @@ "lolex": { "version": "2.3.2", "resolved": "https://registry.npmjs.org/lolex/-/lolex-2.3.2.tgz", - "integrity": "sha1-hflFBCUQO/nnpgZo6iXcQydMqAc=", + "integrity": "sha512-A5pN2tkFj7H0dGIAM6MFvHKMJcPnjZsOMvR7ujCjfgW5TbV6H9vb1PgxLtHvjqNZTHsUolz+6/WEO0N1xNx2ng==", "dev": true }, "longest": { @@ -3816,7 +3816,7 @@ "marked": { "version": "0.3.17", "resolved": "https://registry.npmjs.org/marked/-/marked-0.3.17.tgz", - "integrity": "sha1-YH8GZos8axJGso8T2nYRasGqLSs=", + "integrity": "sha512-+AKbNsjZl6jFfLPwHhWmGTqE009wTKn3RTmn9K8oUKHrX/abPJjtcRtXpYB/FFrwPJRUA86LX/de3T0knkPCmQ==", "dev": true }, "mem": { @@ -3896,13 +3896,13 @@ "mime-db": { "version": "1.33.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.33.0.tgz", - "integrity": "sha1-o0kgUKXLm2NFBUHjnZeI0icng9s=", + "integrity": "sha512-BHJ/EKruNIqJf/QahvxwQZXKygOQ256myeN/Ew+THcAa5q+PjyTTMMeNQC4DZw5AwfvelsUrA6B67NKMqXDbzQ==", "dev": true }, "mime-types": { "version": "2.1.18", "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.18.tgz", - "integrity": "sha1-bzI/YKg9ERRvgx/xH9ZuL+VQO7g=", + "integrity": "sha512-lc/aahn+t4/SWV/qcmumYjymLsWfN3ELhpmVuUFjgsORruuZPVSwAQryq+HHGvO/SI2KVX26bx+En+zhM8g8hQ==", "dev": true, "requires": { "mime-db": "1.33.0" @@ -3917,7 +3917,7 @@ "minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha1-UWbihkV/AzBgZL5Ul+jbsMPTIIM=", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "dev": true, "requires": { "brace-expansion": "1.1.11" @@ -4071,7 +4071,7 @@ "normalize-package-data": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.4.0.tgz", - "integrity": "sha1-EvlaMH1YNSB1oEkHuErIvpisAS8=", + "integrity": "sha512-9jjUFbTPfEy3R/ad/2oNbKtW9Hgovl5O1FvFWKkKblNXoN/Oou6+9+KKohPK13Yc3/TyunyWhJp6gvRNR/PPAw==", "dev": true, "requires": { "hosted-git-info": "2.5.0", @@ -4511,7 +4511,7 @@ "process-nextick-args": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", - "integrity": "sha1-o31zL0JxtKsa0HDTVQjoKQeI/6o=", + "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==", "dev": true }, "progress": { @@ -4584,7 +4584,7 @@ "qs": { "version": "6.5.1", "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.1.tgz", - "integrity": "sha1-NJzfbu+J7EXBLX1es/wMhwNDptg=", + "integrity": "sha512-eRzhrN1WSINYCDCbrz796z37LOe3m5tmW7RQf6oBntukAG1nmovJvhnwHHRMAfeoItc1m2Hk02WER2aQ/iqs+A==", "dev": true }, "quick-lru": { @@ -4596,7 +4596,7 @@ "randomatic": { "version": "1.1.7", "resolved": "https://registry.npmjs.org/randomatic/-/randomatic-1.1.7.tgz", - "integrity": "sha1-x6vpzIuHwLqodrGf3oP9RkeX44w=", + "integrity": "sha512-D5JUjPyJbaJDkuAazpVnSfVkLlpeO3wDlPROTMLGKG1zMFNFRgrciKo1ltz/AzNTkqE0HzDx655QOL51N06how==", "dev": true, "requires": { "is-number": "3.0.0", @@ -4701,7 +4701,7 @@ "regex-cache": { "version": "0.4.4", "resolved": "https://registry.npmjs.org/regex-cache/-/regex-cache-0.4.4.tgz", - "integrity": "sha1-db3FiioUls7EihKDW8VMjVYjNt0=", + "integrity": "sha512-nVIZwtCjkC9YgvWkpM55B5rBhBYRZhAaJbgcFYXXsHnbZ9UZI9nnVWYZpBlCqv9ho2eZryPnWrZGsOdPwVWXWQ==", "dev": true, "requires": { "is-equal-shallow": "0.1.3" @@ -4729,7 +4729,7 @@ "remap-istanbul": { "version": "0.10.1", "resolved": "https://registry.npmjs.org/remap-istanbul/-/remap-istanbul-0.10.1.tgz", - "integrity": "sha1-OqWN1QIdSZ8zbTulvzu7kcG4jjc=", + "integrity": "sha512-gsNQXs5kJLhErICSyYhzVZ++C8LBW8dgwr874Y2QvzAUS75zBlD/juZgXs39nbYJ09fZDlX2AVLVJAY2jbFJoQ==", "dev": true, "requires": { "amdefine": "1.0.1", @@ -4769,7 +4769,7 @@ "source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha1-dHIq8y6WFOnCh6jQu95IteLxomM=", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", "dev": true }, "through2": { @@ -4883,7 +4883,7 @@ "resolve": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.5.0.tgz", - "integrity": "sha1-HwmsznlsmnYlefMbLBzEw83fnzY=", + "integrity": "sha512-hgoSGrc3pjzAPHNBg+KnFcK2HwlHTs/YrAGUr6qgTVUZmXv1UEXXl0bZNBKMA9fud6lRYFdPGz0xXxycPzmmiw==", "dev": true, "requires": { "path-parse": "1.0.5" @@ -4924,7 +4924,7 @@ "rimraf": { "version": "2.6.2", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", - "integrity": "sha1-LtgVDSShbqhlHm1u8PR8QVjOejY=", + "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", "dev": true, "requires": { "glob": "7.1.2" @@ -5063,19 +5063,19 @@ "safe-buffer": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", - "integrity": "sha1-iTMSr2myEj3vcfV4iQAWce6yyFM=", + "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", "dev": true }, "samsam": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/samsam/-/samsam-1.3.0.tgz", - "integrity": "sha1-jR2TUOJWItow3j5EumkrUiGrfFA=", + "integrity": "sha512-1HwIYD/8UlOtFS3QO3w7ey+SdSDFE4HRNLZoZRYVQefrOY3l17epswImeB1ijgJFQJodIaHcwkp3r/myBjFVbg==", "dev": true }, "semver": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz", - "integrity": "sha1-3Eu8emyp2Rbe5dQ1FvAJK1j3uKs=", + "integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==", "dev": true }, "set-blocking": { @@ -5117,7 +5117,7 @@ "sinon-chai": { "version": "2.14.0", "resolved": "https://registry.npmjs.org/sinon-chai/-/sinon-chai-2.14.0.tgz", - "integrity": "sha1-2n3UzIPNaiYLZ8yg96n9riahIF0=", + "integrity": "sha512-9stIF1utB0ywNHNT7RgiXbdmen8QDCRsrTjw+G9TgKt1Yexjiv8TOWZ6WHsTPz57Yky3DIswZvEqX8fpuHNDtQ==", "dev": true }, "slash": { @@ -5146,7 +5146,7 @@ "sntp": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/sntp/-/sntp-2.1.0.tgz", - "integrity": "sha1-LGzsFP7cIiJznK+bXD2F0cxaLMg=", + "integrity": "sha512-FL1b58BDrqS3A11lJ0zEdnJ3UOKqVxawAkF3k7F0CVN7VQ34aZrV+G8BZ1WC9ZL7NyrwsW0oviwsWDgRuVYtJg==", "dev": true, "requires": { "hoek": "4.2.1" @@ -5203,7 +5203,7 @@ "spdx-correct": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.0.0.tgz", - "integrity": "sha1-BaW01xU6GVvJLDxCW2nzsqlSTII=", + "integrity": "sha512-N19o9z5cEyc8yQQPukRCZ9EUmb4HUpnrmaL/fxS2pBo2jbfcFRVuFZ/oFC+vZz0MNNk0h80iMn5/S6qGZOL5+g==", "dev": true, "requires": { "spdx-expression-parse": "3.0.0", @@ -5213,13 +5213,13 @@ "spdx-exceptions": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.1.0.tgz", - "integrity": "sha1-LHrmEFbHFKW5ubKyr30xHvXHj+k=", + "integrity": "sha512-4K1NsmrlCU1JJgUrtgEeTVyfx8VaYea9J9LvARxhbHtVtohPs/gFGG5yy49beySjlIMhhXZ4QqujIZEfS4l6Cg==", "dev": true }, "spdx-expression-parse": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.0.tgz", - "integrity": "sha1-meEZt6XaAOBUkcn6M4t5BII7QdA=", + "integrity": "sha512-Yg6D3XpRD4kkOmTpdgbUiEJFKghJH03fiC1OPll5h/0sO6neh2jqRDVHOQ4o/LMea0tgCkbMgea5ip/e+MkWyg==", "dev": true, "requires": { "spdx-exceptions": "2.1.0", @@ -5229,7 +5229,7 @@ "spdx-license-ids": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.0.tgz", - "integrity": "sha1-enzShHDMbToc/m1miG9rxDDTrIc=", + "integrity": "sha512-2+EPwgbnmOIl8HjGBXXMd9NAu02vLjOO1nWw4kmeRDFyHn+M/ETfHxQUK0oXg8ctgVnl9t3rosNVsZ1jG61nDA==", "dev": true }, "speedometer": { @@ -5566,7 +5566,7 @@ "tough-cookie": { "version": "2.3.4", "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.4.tgz", - "integrity": "sha1-7GDO44rGdQY//JelwYlwV47oNlU=", + "integrity": "sha512-TZ6TTfI5NtZnuyy/Kecv+CnoROnyXn2DN97LontgQpCwsX2XyLYCC0ENhYkehSOwAp8rTQKc/NUIF7BkQ5rKLA==", "dev": true, "requires": { "punycode": "1.4.1" @@ -5708,13 +5708,13 @@ "uuid": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.2.1.tgz", - "integrity": "sha1-EsUou51Y0LkmXZovbw/ovhf/HxQ=", + "integrity": "sha512-jZnMwlb9Iku/O3smGWvZhauCf6cvvpKi4BKRiliS3cxnI+Gz9j5MEpTz2UFuXiKPJocb7gnsLHwiS05ige5BEA==", "dev": true }, "validate-npm-package-license": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.3.tgz", - "integrity": "sha1-gWQ7y+8b3+zUYjeT3EZIlIupgzg=", + "integrity": "sha512-63ZOUnL4SIXj4L0NixR3L1lcjO38crAbgrTpl28t8jjrfuiOBL5Iygm+60qPs/KsZGzPNg6Smnc/oY16QTjF0g==", "dev": true, "requires": { "spdx-correct": "3.0.0", @@ -5750,7 +5750,7 @@ "which": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/which/-/which-1.3.0.tgz", - "integrity": "sha1-/wS9/AEO5UfXgL7DjhrBwnd9JTo=", + "integrity": "sha512-xcJpopdamTuY5duC/KnTTNBraPK54YwpenP4lzxU8H91GudWpFv38u0CKjclE1Wi2EH2EDz5LRcHcKbCIzqGyg==", "dev": true, "requires": { "isexe": "2.0.0" diff --git a/bundles/pixi.js/package.json b/bundles/pixi.js/package.json index 49c7276..177e059 100644 --- a/bundles/pixi.js/package.json +++ b/bundles/pixi.js/package.json @@ -49,6 +49,7 @@ "@pixi/loaders": "^5.0.0-alpha.2", "@pixi/math": "^5.0.0-alpha.2", "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/mesh-extras": "^5.0.0-alpha.2", "@pixi/mixin-cache-as-bitmap": "^5.0.0-alpha.2", "@pixi/mixin-get-child-by-name": "^5.0.0-alpha.2", "@pixi/mixin-get-global-position": "^5.0.0-alpha.2", diff --git a/bundles/pixi.js/src/deprecated.js b/bundles/pixi.js/src/deprecated.js index 147617c..dbebeb0 100644 --- a/bundles/pixi.js/src/deprecated.js +++ b/bundles/pixi.js/src/deprecated.js @@ -263,15 +263,15 @@ Object.defineProperties(PIXI.mesh, { /** * @class PIXI.mesh.Mesh - * @see PIXI.Mesh + * @see PIXI.Mesh2d * @deprecated since 5.0.0 */ Mesh: { get() { - warn('PIXI.mesh.Mesh has moved to PIXI.Mesh'); + warn('PIXI.mesh.Mesh has moved to PIXI.Mesh2d'); - return PIXI.Mesh; + return PIXI.Mesh2d; }, }, /** @@ -315,15 +315,15 @@ }, /** * @class PIXI.mesh.RawMesh - * @see PIXI.RawMesh + * @see PIXI.Mesh * @deprecated since 5.0.0 */ RawMesh: { get() { - warn('PIXI.mesh.RawMesh has moved to PIXI.RawMesh'); + warn('PIXI.mesh.RawMesh has moved to PIXI.Mesh'); - return PIXI.RawMesh; + return PIXI.Mesh; }, }, /** diff --git a/bundles/pixi.js/src/index.js b/bundles/pixi.js/src/index.js index a3a0d1b..6fdabf0 100644 --- a/bundles/pixi.js/src/index.js +++ b/bundles/pixi.js/src/index.js @@ -9,6 +9,7 @@ import * as loaders from '@pixi/loaders'; import * as math from '@pixi/math'; import * as mesh from '@pixi/mesh'; +import * as meshExtras from '@pixi/mesh-extras'; import * as particles from '@pixi/particles'; import * as prepare from '@pixi/prepare'; import * as sprite from '@pixi/sprite'; @@ -128,6 +129,7 @@ loaders, math, mesh, + meshExtras, particles, sprite, spriteAnimated, @@ -152,6 +154,7 @@ export * from '@pixi/loaders'; export * from '@pixi/math'; export * from '@pixi/mesh'; +export * from '@pixi/mesh-extras'; export * from '@pixi/particles'; export * from '@pixi/sprite'; export * from '@pixi/spritesheet'; diff --git a/package-lock.json b/package-lock.json index 7fe6db7..0814729 100644 --- a/package-lock.json +++ b/package-lock.json @@ -209,7 +209,7 @@ "argparse": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", - "integrity": "sha1-vNZ5HqWuCXJeF+WtmIE0zUCz2RE=", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", "dev": true, "requires": { "sprintf-js": "1.0.3" @@ -228,7 +228,7 @@ "arr-flatten": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz", - "integrity": "sha1-NgSLv/TntH4TZkQxbJlmnqWukfE=", + "integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==", "dev": true }, "arr-union": { @@ -297,7 +297,7 @@ "assertion-error": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", - "integrity": "sha1-5gtrDo8wG9l+U3UhW9pAbIURjAs=", + "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", "dev": true }, "async": { @@ -396,7 +396,7 @@ "brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha1-PH/L9SnYcibz0vUrlm/1Jx60Qd0=", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, "requires": { "balanced-match": "1.0.0", @@ -568,7 +568,7 @@ "circular-json": { "version": "0.3.3", "resolved": "https://registry.npmjs.org/circular-json/-/circular-json-0.3.3.tgz", - "integrity": "sha1-gVyZ6oT2gJUp0vRXkb34JxE1LWY=", + "integrity": "sha512-UZK3NBx2Mca+b5LsG7bY183pHWt5Y1xts4P3Pz7ENTwGVnJOUWbRb3ocjvX7hx9tq/yTAdclXm9sZ38gNuem4A==", "dev": true }, "cli-cursor": { @@ -638,7 +638,7 @@ "color-convert": { "version": "1.9.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.1.tgz", - "integrity": "sha1-wSYRB66y8pTr/+ye2eytUppgl+0=", + "integrity": "sha512-mjGanIiwQJskCC18rPR6OmrZ6fm2Lc7PeGFYwCmy5J34wC6F1PzdGL6xeMfmgicfYcNLGuVFA3WzXtIDCQSZxQ==", "dev": true, "requires": { "color-name": "1.1.3" @@ -1427,7 +1427,7 @@ "boom": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/boom/-/boom-5.2.0.tgz", - "integrity": "sha1-XdnabuOl8wIHdDYpDLcX0/SlTgI=", + "integrity": "sha512-Z5BTk6ZRe4tXXQlkqftmsAUANpXmuwlsF5Oov8ThoMbQRzdGTA1ngYRW160GexgOgjsFOKJz0LYhoNi+2AMBUw==", "dev": true, "requires": { "hoek": "4.2.1" @@ -1471,7 +1471,7 @@ "debug": { "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha1-XRKFFd8TT/Mn6QpMk/Tgd6U2NB8=", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", "dev": true, "requires": { "ms": "2.0.0" @@ -1585,7 +1585,7 @@ "doctrine": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", - "integrity": "sha1-XNAfwQFiG0LEzX9dGmYkNxbT850=", + "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", "dev": true, "requires": { "esutils": "2.0.2" @@ -1662,7 +1662,7 @@ "es6-promise": { "version": "4.2.4", "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.4.tgz", - "integrity": "sha1-3EIhwrFlGHYL2MOaUtjzVvwA7Sk=", + "integrity": "sha512-/NdNZVJg+uZgtm9eS3O6lrOLYmQag2DjdEXuPaHlZ6RuVqgqaVZfgYCepEIKsLqwdQArOPtC3XzRLqGGfT8KQQ==", "dev": true }, "escape-string-regexp": { @@ -1788,7 +1788,7 @@ "espree": { "version": "3.5.4", "resolved": "https://registry.npmjs.org/espree/-/espree-3.5.4.tgz", - "integrity": "sha1-sPRHGHyKi+2US4FaZgvd9d610ac=", + "integrity": "sha512-yAcIQxtmMiB/jL32dzEp2enBeidsB7xWPLNiw3IIkpVds1P+h7qF9YwJq1yUNzp2OKXgAprs4F61ih66UsoD1A==", "dev": true, "requires": { "acorn": "5.5.0", @@ -1798,7 +1798,7 @@ "esprima": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.0.tgz", - "integrity": "sha1-RJnt3NERDgshi6zy+n9/WfVcqAQ=", + "integrity": "sha512-oftTcaMu/EGrEIu904mWteKIv8vMuOgGYo7EhVJJN00R/EED9DCua/xxHRdYnKtcECzVg7xOWhflvJMnqcFZjw==", "dev": true }, "esquery": { @@ -1813,7 +1813,7 @@ "esrecurse": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.2.1.tgz", - "integrity": "sha1-AHo7n9vCs7uH5IeeoZyS/b05Qs8=", + "integrity": "sha512-64RBB++fIOAXPw3P9cy89qfMlvZEXZkqqJkjqqXIvzP5ezRZjW+lPWjw35UX/3EhUPFYbg5ER4JYgDw4007/DQ==", "dev": true, "requires": { "estraverse": "4.2.0" @@ -2024,7 +2024,7 @@ "find-root": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/find-root/-/find-root-1.1.0.tgz", - "integrity": "sha1-q8/Iunb3CMQql7PWhbfpRQv7nOQ=", + "integrity": "sha512-NKfW6bec6GfKc0SGx1e07QZY9PE99u0Bft/0rzSD5k3sO/vwkVUpDUKVm5Gpp5Ue3YfShPFTX2070tDs5kB9Ng==", "dev": true }, "find-up": { @@ -2103,7 +2103,7 @@ "supports-color": { "version": "5.3.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.3.0.tgz", - "integrity": "sha1-WySsFduA+pJ89SJ6SjP9PEx2dsA=", + "integrity": "sha512-0aP01LLIskjKs3lq52EC0aGBAJhLq7B2Rd8HC/DR/PtNNpcLilNmHC12O+hu0usQpo7wtHNRqtrhBwtDb0+dNg==", "dev": true, "requires": { "has-flag": "3.0.0" @@ -2567,7 +2567,7 @@ "glob": { "version": "7.1.2", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", - "integrity": "sha1-wZyd+aAocC1nhhI4SmVSQExjbRU=", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", "dev": true, "requires": { "fs.realpath": "1.0.0", @@ -2672,7 +2672,7 @@ "growl": { "version": "1.10.3", "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.3.tgz", - "integrity": "sha1-GSa6kM8+3+KttJJ/WIC8IsZseQ8=", + "integrity": "sha512-hKlsbA5Vu3xsh1Cg3J7jSmX/WaW6A5oBeqzM88oNbCRQFz+zUaXm6yxS4RVytp1scBoJzSYl4YAEOQIt6O8V1Q==", "dev": true }, "handlebars": { @@ -2738,7 +2738,7 @@ "hawk": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/hawk/-/hawk-6.0.2.tgz", - "integrity": "sha1-r02RTrBl+bXOTZ0RwcshJu7MMDg=", + "integrity": "sha512-miowhl2+U7Qle4vdLqDdPt9m09K6yZhkLDTWGoUiUzrQCn+mHHSmfJgAyGaLRZbPmTqfFFjRV1QWCW0VWUJBbQ==", "dev": true, "requires": { "boom": "4.3.1", @@ -2756,7 +2756,7 @@ "hoek": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/hoek/-/hoek-4.2.1.tgz", - "integrity": "sha1-ljRQKqEsRF3Vp8VzS1cruHOKrLs=", + "integrity": "sha512-QLg82fGkfnJ/4iy1xZ81/9SIJiq1NGFUMGs6ParyjBZr6jW2Ufj/snDqTHixNlHdPNwN2RLVD0Pi3igeK9+JfA==", "dev": true }, "home-path": { @@ -2791,7 +2791,7 @@ "ignore": { "version": "3.3.7", "resolved": "https://registry.npmjs.org/ignore/-/ignore-3.3.7.tgz", - "integrity": "sha1-YSKJv7PCIOGGpYEYYY1b6MG6sCE=", + "integrity": "sha512-YGG3ejvBNHRqu0559EOxxNFihD0AjpvHlC/pdGKd3X3ofe+CoJkYazwNJYTNebqpPKN+VVQbh4ZFn1DivMNuHA==", "dev": true }, "imurmurhash": { @@ -2828,7 +2828,7 @@ "ini": { "version": "1.3.5", "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", - "integrity": "sha1-7uJfVtscnsYIXgwid4CD9Zar+Sc=", + "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==", "dev": true }, "inquirer": { @@ -2901,7 +2901,7 @@ "is-buffer": { "version": "1.1.6", "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", - "integrity": "sha1-76ouqdqg16suoTqXsritUf776L4=", + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", "dev": true }, "is-builtin-module": { @@ -3054,7 +3054,7 @@ "is-resolvable": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/is-resolvable/-/is-resolvable-1.1.0.tgz", - "integrity": "sha1-+xj4fOH+uSUWnJpAfBkxijIG7Yg=", + "integrity": "sha512-qgDYXFSR5WvEfuS5dMj6oTMEbrrSaM0CrFk2Yiq/gXnBvD9pMa2jGXxyhGLfvhZpuMZe18CJpFxAt3CRs42NMg==", "dev": true }, "is-retry-allowed": { @@ -3204,7 +3204,7 @@ "js-yaml": { "version": "3.11.0", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.11.0.tgz", - "integrity": "sha1-WXwai9VxUvJtYizkEXhRpR9euu8=", + "integrity": "sha512-saJstZWv7oNeOyBh3+Dx1qWzhW0+e6/8eDzo7p5rDFqxntSztloLtuKu+Ejhtq82jsilwOIZYsCz+lIjthg1Hw==", "dev": true, "requires": { "argparse": "1.0.10", @@ -3324,7 +3324,7 @@ "just-extend": { "version": "1.1.27", "resolved": "https://registry.npmjs.org/just-extend/-/just-extend-1.1.27.tgz", - "integrity": "sha1-7G55QQ/5FORyZSq/oOYDwD1g6QU=", + "integrity": "sha512-mJVp13Ix6gFo3SBAy9U/kL+oeZqzlYYYLQBwXVBlVzIsZwBqGREnOro24oC/8s8aox+rJhtZ2DiQof++IrkA+g==", "dev": true }, "kind-of": { @@ -3703,7 +3703,7 @@ "lodash": { "version": "4.17.5", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.5.tgz", - "integrity": "sha1-maktZcAnLevoyWtgV7yPv6O+1RE=", + "integrity": "sha512-svL3uiZf1RwhH+cWrfZn3A4+U58wbP0tGVTLQPbjplZxZ8ROD9VLuNgsRniTlLe7OlSqR79RUehXgpBW/s0IQw==", "dev": true }, "lodash._reinterpolate": { @@ -3740,7 +3740,7 @@ "lolex": { "version": "2.3.2", "resolved": "https://registry.npmjs.org/lolex/-/lolex-2.3.2.tgz", - "integrity": "sha1-hflFBCUQO/nnpgZo6iXcQydMqAc=", + "integrity": "sha512-A5pN2tkFj7H0dGIAM6MFvHKMJcPnjZsOMvR7ujCjfgW5TbV6H9vb1PgxLtHvjqNZTHsUolz+6/WEO0N1xNx2ng==", "dev": true }, "longest": { @@ -3816,7 +3816,7 @@ "marked": { "version": "0.3.17", "resolved": "https://registry.npmjs.org/marked/-/marked-0.3.17.tgz", - "integrity": "sha1-YH8GZos8axJGso8T2nYRasGqLSs=", + "integrity": "sha512-+AKbNsjZl6jFfLPwHhWmGTqE009wTKn3RTmn9K8oUKHrX/abPJjtcRtXpYB/FFrwPJRUA86LX/de3T0knkPCmQ==", "dev": true }, "mem": { @@ -3896,13 +3896,13 @@ "mime-db": { "version": "1.33.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.33.0.tgz", - "integrity": "sha1-o0kgUKXLm2NFBUHjnZeI0icng9s=", + "integrity": "sha512-BHJ/EKruNIqJf/QahvxwQZXKygOQ256myeN/Ew+THcAa5q+PjyTTMMeNQC4DZw5AwfvelsUrA6B67NKMqXDbzQ==", "dev": true }, "mime-types": { "version": "2.1.18", "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.18.tgz", - "integrity": "sha1-bzI/YKg9ERRvgx/xH9ZuL+VQO7g=", + "integrity": "sha512-lc/aahn+t4/SWV/qcmumYjymLsWfN3ELhpmVuUFjgsORruuZPVSwAQryq+HHGvO/SI2KVX26bx+En+zhM8g8hQ==", "dev": true, "requires": { "mime-db": "1.33.0" @@ -3917,7 +3917,7 @@ "minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha1-UWbihkV/AzBgZL5Ul+jbsMPTIIM=", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "dev": true, "requires": { "brace-expansion": "1.1.11" @@ -4071,7 +4071,7 @@ "normalize-package-data": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.4.0.tgz", - "integrity": "sha1-EvlaMH1YNSB1oEkHuErIvpisAS8=", + "integrity": "sha512-9jjUFbTPfEy3R/ad/2oNbKtW9Hgovl5O1FvFWKkKblNXoN/Oou6+9+KKohPK13Yc3/TyunyWhJp6gvRNR/PPAw==", "dev": true, "requires": { "hosted-git-info": "2.5.0", @@ -4511,7 +4511,7 @@ "process-nextick-args": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", - "integrity": "sha1-o31zL0JxtKsa0HDTVQjoKQeI/6o=", + "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==", "dev": true }, "progress": { @@ -4584,7 +4584,7 @@ "qs": { "version": "6.5.1", "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.1.tgz", - "integrity": "sha1-NJzfbu+J7EXBLX1es/wMhwNDptg=", + "integrity": "sha512-eRzhrN1WSINYCDCbrz796z37LOe3m5tmW7RQf6oBntukAG1nmovJvhnwHHRMAfeoItc1m2Hk02WER2aQ/iqs+A==", "dev": true }, "quick-lru": { @@ -4596,7 +4596,7 @@ "randomatic": { "version": "1.1.7", "resolved": "https://registry.npmjs.org/randomatic/-/randomatic-1.1.7.tgz", - "integrity": "sha1-x6vpzIuHwLqodrGf3oP9RkeX44w=", + "integrity": "sha512-D5JUjPyJbaJDkuAazpVnSfVkLlpeO3wDlPROTMLGKG1zMFNFRgrciKo1ltz/AzNTkqE0HzDx655QOL51N06how==", "dev": true, "requires": { "is-number": "3.0.0", @@ -4701,7 +4701,7 @@ "regex-cache": { "version": "0.4.4", "resolved": "https://registry.npmjs.org/regex-cache/-/regex-cache-0.4.4.tgz", - "integrity": "sha1-db3FiioUls7EihKDW8VMjVYjNt0=", + "integrity": "sha512-nVIZwtCjkC9YgvWkpM55B5rBhBYRZhAaJbgcFYXXsHnbZ9UZI9nnVWYZpBlCqv9ho2eZryPnWrZGsOdPwVWXWQ==", "dev": true, "requires": { "is-equal-shallow": "0.1.3" @@ -4729,7 +4729,7 @@ "remap-istanbul": { "version": "0.10.1", "resolved": "https://registry.npmjs.org/remap-istanbul/-/remap-istanbul-0.10.1.tgz", - "integrity": "sha1-OqWN1QIdSZ8zbTulvzu7kcG4jjc=", + "integrity": "sha512-gsNQXs5kJLhErICSyYhzVZ++C8LBW8dgwr874Y2QvzAUS75zBlD/juZgXs39nbYJ09fZDlX2AVLVJAY2jbFJoQ==", "dev": true, "requires": { "amdefine": "1.0.1", @@ -4769,7 +4769,7 @@ "source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha1-dHIq8y6WFOnCh6jQu95IteLxomM=", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", "dev": true }, "through2": { @@ -4883,7 +4883,7 @@ "resolve": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.5.0.tgz", - "integrity": "sha1-HwmsznlsmnYlefMbLBzEw83fnzY=", + "integrity": "sha512-hgoSGrc3pjzAPHNBg+KnFcK2HwlHTs/YrAGUr6qgTVUZmXv1UEXXl0bZNBKMA9fud6lRYFdPGz0xXxycPzmmiw==", "dev": true, "requires": { "path-parse": "1.0.5" @@ -4924,7 +4924,7 @@ "rimraf": { "version": "2.6.2", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", - "integrity": "sha1-LtgVDSShbqhlHm1u8PR8QVjOejY=", + "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", "dev": true, "requires": { "glob": "7.1.2" @@ -5063,19 +5063,19 @@ "safe-buffer": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", - "integrity": "sha1-iTMSr2myEj3vcfV4iQAWce6yyFM=", + "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", "dev": true }, "samsam": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/samsam/-/samsam-1.3.0.tgz", - "integrity": "sha1-jR2TUOJWItow3j5EumkrUiGrfFA=", + "integrity": "sha512-1HwIYD/8UlOtFS3QO3w7ey+SdSDFE4HRNLZoZRYVQefrOY3l17epswImeB1ijgJFQJodIaHcwkp3r/myBjFVbg==", "dev": true }, "semver": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz", - "integrity": "sha1-3Eu8emyp2Rbe5dQ1FvAJK1j3uKs=", + "integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==", "dev": true }, "set-blocking": { @@ -5117,7 +5117,7 @@ "sinon-chai": { "version": "2.14.0", "resolved": "https://registry.npmjs.org/sinon-chai/-/sinon-chai-2.14.0.tgz", - "integrity": "sha1-2n3UzIPNaiYLZ8yg96n9riahIF0=", + "integrity": "sha512-9stIF1utB0ywNHNT7RgiXbdmen8QDCRsrTjw+G9TgKt1Yexjiv8TOWZ6WHsTPz57Yky3DIswZvEqX8fpuHNDtQ==", "dev": true }, "slash": { @@ -5146,7 +5146,7 @@ "sntp": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/sntp/-/sntp-2.1.0.tgz", - "integrity": "sha1-LGzsFP7cIiJznK+bXD2F0cxaLMg=", + "integrity": "sha512-FL1b58BDrqS3A11lJ0zEdnJ3UOKqVxawAkF3k7F0CVN7VQ34aZrV+G8BZ1WC9ZL7NyrwsW0oviwsWDgRuVYtJg==", "dev": true, "requires": { "hoek": "4.2.1" @@ -5203,7 +5203,7 @@ "spdx-correct": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.0.0.tgz", - "integrity": "sha1-BaW01xU6GVvJLDxCW2nzsqlSTII=", + "integrity": "sha512-N19o9z5cEyc8yQQPukRCZ9EUmb4HUpnrmaL/fxS2pBo2jbfcFRVuFZ/oFC+vZz0MNNk0h80iMn5/S6qGZOL5+g==", "dev": true, "requires": { "spdx-expression-parse": "3.0.0", @@ -5213,13 +5213,13 @@ "spdx-exceptions": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.1.0.tgz", - "integrity": "sha1-LHrmEFbHFKW5ubKyr30xHvXHj+k=", + "integrity": "sha512-4K1NsmrlCU1JJgUrtgEeTVyfx8VaYea9J9LvARxhbHtVtohPs/gFGG5yy49beySjlIMhhXZ4QqujIZEfS4l6Cg==", "dev": true }, "spdx-expression-parse": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.0.tgz", - "integrity": "sha1-meEZt6XaAOBUkcn6M4t5BII7QdA=", + "integrity": "sha512-Yg6D3XpRD4kkOmTpdgbUiEJFKghJH03fiC1OPll5h/0sO6neh2jqRDVHOQ4o/LMea0tgCkbMgea5ip/e+MkWyg==", "dev": true, "requires": { "spdx-exceptions": "2.1.0", @@ -5229,7 +5229,7 @@ "spdx-license-ids": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.0.tgz", - "integrity": "sha1-enzShHDMbToc/m1miG9rxDDTrIc=", + "integrity": "sha512-2+EPwgbnmOIl8HjGBXXMd9NAu02vLjOO1nWw4kmeRDFyHn+M/ETfHxQUK0oXg8ctgVnl9t3rosNVsZ1jG61nDA==", "dev": true }, "speedometer": { @@ -5566,7 +5566,7 @@ "tough-cookie": { "version": "2.3.4", "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.4.tgz", - "integrity": "sha1-7GDO44rGdQY//JelwYlwV47oNlU=", + "integrity": "sha512-TZ6TTfI5NtZnuyy/Kecv+CnoROnyXn2DN97LontgQpCwsX2XyLYCC0ENhYkehSOwAp8rTQKc/NUIF7BkQ5rKLA==", "dev": true, "requires": { "punycode": "1.4.1" @@ -5708,13 +5708,13 @@ "uuid": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.2.1.tgz", - "integrity": "sha1-EsUou51Y0LkmXZovbw/ovhf/HxQ=", + "integrity": "sha512-jZnMwlb9Iku/O3smGWvZhauCf6cvvpKi4BKRiliS3cxnI+Gz9j5MEpTz2UFuXiKPJocb7gnsLHwiS05ige5BEA==", "dev": true }, "validate-npm-package-license": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.3.tgz", - "integrity": "sha1-gWQ7y+8b3+zUYjeT3EZIlIupgzg=", + "integrity": "sha512-63ZOUnL4SIXj4L0NixR3L1lcjO38crAbgrTpl28t8jjrfuiOBL5Iygm+60qPs/KsZGzPNg6Smnc/oY16QTjF0g==", "dev": true, "requires": { "spdx-correct": "3.0.0", @@ -5750,7 +5750,7 @@ "which": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/which/-/which-1.3.0.tgz", - "integrity": "sha1-/wS9/AEO5UfXgL7DjhrBwnd9JTo=", + "integrity": "sha512-xcJpopdamTuY5duC/KnTTNBraPK54YwpenP4lzxU8H91GudWpFv38u0CKjclE1Wi2EH2EDz5LRcHcKbCIzqGyg==", "dev": true, "requires": { "isexe": "2.0.0" diff --git a/packages/canvas/canvas-mesh/package.json b/packages/canvas/canvas-mesh/package.json index 691cd2c..6744a17 100644 --- a/packages/canvas/canvas-mesh/package.json +++ b/packages/canvas/canvas-mesh/package.json @@ -24,6 +24,7 @@ "dependencies": { "@pixi/constants": "^5.0.0-alpha.2", "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/mesh-extras": "^5.0.0-alpha.2", "@pixi/settings": "^5.0.0-alpha.2" }, "devDependencies": { diff --git a/bundles/pixi.js/package.json b/bundles/pixi.js/package.json index 49c7276..177e059 100644 --- a/bundles/pixi.js/package.json +++ b/bundles/pixi.js/package.json @@ -49,6 +49,7 @@ "@pixi/loaders": "^5.0.0-alpha.2", "@pixi/math": "^5.0.0-alpha.2", "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/mesh-extras": "^5.0.0-alpha.2", "@pixi/mixin-cache-as-bitmap": "^5.0.0-alpha.2", "@pixi/mixin-get-child-by-name": "^5.0.0-alpha.2", "@pixi/mixin-get-global-position": "^5.0.0-alpha.2", diff --git a/bundles/pixi.js/src/deprecated.js b/bundles/pixi.js/src/deprecated.js index 147617c..dbebeb0 100644 --- a/bundles/pixi.js/src/deprecated.js +++ b/bundles/pixi.js/src/deprecated.js @@ -263,15 +263,15 @@ Object.defineProperties(PIXI.mesh, { /** * @class PIXI.mesh.Mesh - * @see PIXI.Mesh + * @see PIXI.Mesh2d * @deprecated since 5.0.0 */ Mesh: { get() { - warn('PIXI.mesh.Mesh has moved to PIXI.Mesh'); + warn('PIXI.mesh.Mesh has moved to PIXI.Mesh2d'); - return PIXI.Mesh; + return PIXI.Mesh2d; }, }, /** @@ -315,15 +315,15 @@ }, /** * @class PIXI.mesh.RawMesh - * @see PIXI.RawMesh + * @see PIXI.Mesh * @deprecated since 5.0.0 */ RawMesh: { get() { - warn('PIXI.mesh.RawMesh has moved to PIXI.RawMesh'); + warn('PIXI.mesh.RawMesh has moved to PIXI.Mesh'); - return PIXI.RawMesh; + return PIXI.Mesh; }, }, /** diff --git a/bundles/pixi.js/src/index.js b/bundles/pixi.js/src/index.js index a3a0d1b..6fdabf0 100644 --- a/bundles/pixi.js/src/index.js +++ b/bundles/pixi.js/src/index.js @@ -9,6 +9,7 @@ import * as loaders from '@pixi/loaders'; import * as math from '@pixi/math'; import * as mesh from '@pixi/mesh'; +import * as meshExtras from '@pixi/mesh-extras'; import * as particles from '@pixi/particles'; import * as prepare from '@pixi/prepare'; import * as sprite from '@pixi/sprite'; @@ -128,6 +129,7 @@ loaders, math, mesh, + meshExtras, particles, sprite, spriteAnimated, @@ -152,6 +154,7 @@ export * from '@pixi/loaders'; export * from '@pixi/math'; export * from '@pixi/mesh'; +export * from '@pixi/mesh-extras'; export * from '@pixi/particles'; export * from '@pixi/sprite'; export * from '@pixi/spritesheet'; diff --git a/package-lock.json b/package-lock.json index 7fe6db7..0814729 100644 --- a/package-lock.json +++ b/package-lock.json @@ -209,7 +209,7 @@ "argparse": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", - "integrity": "sha1-vNZ5HqWuCXJeF+WtmIE0zUCz2RE=", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", "dev": true, "requires": { "sprintf-js": "1.0.3" @@ -228,7 +228,7 @@ "arr-flatten": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz", - "integrity": "sha1-NgSLv/TntH4TZkQxbJlmnqWukfE=", + "integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==", "dev": true }, "arr-union": { @@ -297,7 +297,7 @@ "assertion-error": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", - "integrity": "sha1-5gtrDo8wG9l+U3UhW9pAbIURjAs=", + "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", "dev": true }, "async": { @@ -396,7 +396,7 @@ "brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha1-PH/L9SnYcibz0vUrlm/1Jx60Qd0=", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, "requires": { "balanced-match": "1.0.0", @@ -568,7 +568,7 @@ "circular-json": { "version": "0.3.3", "resolved": "https://registry.npmjs.org/circular-json/-/circular-json-0.3.3.tgz", - "integrity": "sha1-gVyZ6oT2gJUp0vRXkb34JxE1LWY=", + "integrity": "sha512-UZK3NBx2Mca+b5LsG7bY183pHWt5Y1xts4P3Pz7ENTwGVnJOUWbRb3ocjvX7hx9tq/yTAdclXm9sZ38gNuem4A==", "dev": true }, "cli-cursor": { @@ -638,7 +638,7 @@ "color-convert": { "version": "1.9.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.1.tgz", - "integrity": "sha1-wSYRB66y8pTr/+ye2eytUppgl+0=", + "integrity": "sha512-mjGanIiwQJskCC18rPR6OmrZ6fm2Lc7PeGFYwCmy5J34wC6F1PzdGL6xeMfmgicfYcNLGuVFA3WzXtIDCQSZxQ==", "dev": true, "requires": { "color-name": "1.1.3" @@ -1427,7 +1427,7 @@ "boom": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/boom/-/boom-5.2.0.tgz", - "integrity": "sha1-XdnabuOl8wIHdDYpDLcX0/SlTgI=", + "integrity": "sha512-Z5BTk6ZRe4tXXQlkqftmsAUANpXmuwlsF5Oov8ThoMbQRzdGTA1ngYRW160GexgOgjsFOKJz0LYhoNi+2AMBUw==", "dev": true, "requires": { "hoek": "4.2.1" @@ -1471,7 +1471,7 @@ "debug": { "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha1-XRKFFd8TT/Mn6QpMk/Tgd6U2NB8=", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", "dev": true, "requires": { "ms": "2.0.0" @@ -1585,7 +1585,7 @@ "doctrine": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", - "integrity": "sha1-XNAfwQFiG0LEzX9dGmYkNxbT850=", + "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", "dev": true, "requires": { "esutils": "2.0.2" @@ -1662,7 +1662,7 @@ "es6-promise": { "version": "4.2.4", "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.4.tgz", - "integrity": "sha1-3EIhwrFlGHYL2MOaUtjzVvwA7Sk=", + "integrity": "sha512-/NdNZVJg+uZgtm9eS3O6lrOLYmQag2DjdEXuPaHlZ6RuVqgqaVZfgYCepEIKsLqwdQArOPtC3XzRLqGGfT8KQQ==", "dev": true }, "escape-string-regexp": { @@ -1788,7 +1788,7 @@ "espree": { "version": "3.5.4", "resolved": "https://registry.npmjs.org/espree/-/espree-3.5.4.tgz", - "integrity": "sha1-sPRHGHyKi+2US4FaZgvd9d610ac=", + "integrity": "sha512-yAcIQxtmMiB/jL32dzEp2enBeidsB7xWPLNiw3IIkpVds1P+h7qF9YwJq1yUNzp2OKXgAprs4F61ih66UsoD1A==", "dev": true, "requires": { "acorn": "5.5.0", @@ -1798,7 +1798,7 @@ "esprima": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.0.tgz", - "integrity": "sha1-RJnt3NERDgshi6zy+n9/WfVcqAQ=", + "integrity": "sha512-oftTcaMu/EGrEIu904mWteKIv8vMuOgGYo7EhVJJN00R/EED9DCua/xxHRdYnKtcECzVg7xOWhflvJMnqcFZjw==", "dev": true }, "esquery": { @@ -1813,7 +1813,7 @@ "esrecurse": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.2.1.tgz", - "integrity": "sha1-AHo7n9vCs7uH5IeeoZyS/b05Qs8=", + "integrity": "sha512-64RBB++fIOAXPw3P9cy89qfMlvZEXZkqqJkjqqXIvzP5ezRZjW+lPWjw35UX/3EhUPFYbg5ER4JYgDw4007/DQ==", "dev": true, "requires": { "estraverse": "4.2.0" @@ -2024,7 +2024,7 @@ "find-root": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/find-root/-/find-root-1.1.0.tgz", - "integrity": "sha1-q8/Iunb3CMQql7PWhbfpRQv7nOQ=", + "integrity": "sha512-NKfW6bec6GfKc0SGx1e07QZY9PE99u0Bft/0rzSD5k3sO/vwkVUpDUKVm5Gpp5Ue3YfShPFTX2070tDs5kB9Ng==", "dev": true }, "find-up": { @@ -2103,7 +2103,7 @@ "supports-color": { "version": "5.3.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.3.0.tgz", - "integrity": "sha1-WySsFduA+pJ89SJ6SjP9PEx2dsA=", + "integrity": "sha512-0aP01LLIskjKs3lq52EC0aGBAJhLq7B2Rd8HC/DR/PtNNpcLilNmHC12O+hu0usQpo7wtHNRqtrhBwtDb0+dNg==", "dev": true, "requires": { "has-flag": "3.0.0" @@ -2567,7 +2567,7 @@ "glob": { "version": "7.1.2", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", - "integrity": "sha1-wZyd+aAocC1nhhI4SmVSQExjbRU=", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", "dev": true, "requires": { "fs.realpath": "1.0.0", @@ -2672,7 +2672,7 @@ "growl": { "version": "1.10.3", "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.3.tgz", - "integrity": "sha1-GSa6kM8+3+KttJJ/WIC8IsZseQ8=", + "integrity": "sha512-hKlsbA5Vu3xsh1Cg3J7jSmX/WaW6A5oBeqzM88oNbCRQFz+zUaXm6yxS4RVytp1scBoJzSYl4YAEOQIt6O8V1Q==", "dev": true }, "handlebars": { @@ -2738,7 +2738,7 @@ "hawk": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/hawk/-/hawk-6.0.2.tgz", - "integrity": "sha1-r02RTrBl+bXOTZ0RwcshJu7MMDg=", + "integrity": "sha512-miowhl2+U7Qle4vdLqDdPt9m09K6yZhkLDTWGoUiUzrQCn+mHHSmfJgAyGaLRZbPmTqfFFjRV1QWCW0VWUJBbQ==", "dev": true, "requires": { "boom": "4.3.1", @@ -2756,7 +2756,7 @@ "hoek": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/hoek/-/hoek-4.2.1.tgz", - "integrity": "sha1-ljRQKqEsRF3Vp8VzS1cruHOKrLs=", + "integrity": "sha512-QLg82fGkfnJ/4iy1xZ81/9SIJiq1NGFUMGs6ParyjBZr6jW2Ufj/snDqTHixNlHdPNwN2RLVD0Pi3igeK9+JfA==", "dev": true }, "home-path": { @@ -2791,7 +2791,7 @@ "ignore": { "version": "3.3.7", "resolved": "https://registry.npmjs.org/ignore/-/ignore-3.3.7.tgz", - "integrity": "sha1-YSKJv7PCIOGGpYEYYY1b6MG6sCE=", + "integrity": "sha512-YGG3ejvBNHRqu0559EOxxNFihD0AjpvHlC/pdGKd3X3ofe+CoJkYazwNJYTNebqpPKN+VVQbh4ZFn1DivMNuHA==", "dev": true }, "imurmurhash": { @@ -2828,7 +2828,7 @@ "ini": { "version": "1.3.5", "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", - "integrity": "sha1-7uJfVtscnsYIXgwid4CD9Zar+Sc=", + "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==", "dev": true }, "inquirer": { @@ -2901,7 +2901,7 @@ "is-buffer": { "version": "1.1.6", "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", - "integrity": "sha1-76ouqdqg16suoTqXsritUf776L4=", + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", "dev": true }, "is-builtin-module": { @@ -3054,7 +3054,7 @@ "is-resolvable": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/is-resolvable/-/is-resolvable-1.1.0.tgz", - "integrity": "sha1-+xj4fOH+uSUWnJpAfBkxijIG7Yg=", + "integrity": "sha512-qgDYXFSR5WvEfuS5dMj6oTMEbrrSaM0CrFk2Yiq/gXnBvD9pMa2jGXxyhGLfvhZpuMZe18CJpFxAt3CRs42NMg==", "dev": true }, "is-retry-allowed": { @@ -3204,7 +3204,7 @@ "js-yaml": { "version": "3.11.0", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.11.0.tgz", - "integrity": "sha1-WXwai9VxUvJtYizkEXhRpR9euu8=", + "integrity": "sha512-saJstZWv7oNeOyBh3+Dx1qWzhW0+e6/8eDzo7p5rDFqxntSztloLtuKu+Ejhtq82jsilwOIZYsCz+lIjthg1Hw==", "dev": true, "requires": { "argparse": "1.0.10", @@ -3324,7 +3324,7 @@ "just-extend": { "version": "1.1.27", "resolved": "https://registry.npmjs.org/just-extend/-/just-extend-1.1.27.tgz", - "integrity": "sha1-7G55QQ/5FORyZSq/oOYDwD1g6QU=", + "integrity": "sha512-mJVp13Ix6gFo3SBAy9U/kL+oeZqzlYYYLQBwXVBlVzIsZwBqGREnOro24oC/8s8aox+rJhtZ2DiQof++IrkA+g==", "dev": true }, "kind-of": { @@ -3703,7 +3703,7 @@ "lodash": { "version": "4.17.5", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.5.tgz", - "integrity": "sha1-maktZcAnLevoyWtgV7yPv6O+1RE=", + "integrity": "sha512-svL3uiZf1RwhH+cWrfZn3A4+U58wbP0tGVTLQPbjplZxZ8ROD9VLuNgsRniTlLe7OlSqR79RUehXgpBW/s0IQw==", "dev": true }, "lodash._reinterpolate": { @@ -3740,7 +3740,7 @@ "lolex": { "version": "2.3.2", "resolved": "https://registry.npmjs.org/lolex/-/lolex-2.3.2.tgz", - "integrity": "sha1-hflFBCUQO/nnpgZo6iXcQydMqAc=", + "integrity": "sha512-A5pN2tkFj7H0dGIAM6MFvHKMJcPnjZsOMvR7ujCjfgW5TbV6H9vb1PgxLtHvjqNZTHsUolz+6/WEO0N1xNx2ng==", "dev": true }, "longest": { @@ -3816,7 +3816,7 @@ "marked": { "version": "0.3.17", "resolved": "https://registry.npmjs.org/marked/-/marked-0.3.17.tgz", - "integrity": "sha1-YH8GZos8axJGso8T2nYRasGqLSs=", + "integrity": "sha512-+AKbNsjZl6jFfLPwHhWmGTqE009wTKn3RTmn9K8oUKHrX/abPJjtcRtXpYB/FFrwPJRUA86LX/de3T0knkPCmQ==", "dev": true }, "mem": { @@ -3896,13 +3896,13 @@ "mime-db": { "version": "1.33.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.33.0.tgz", - "integrity": "sha1-o0kgUKXLm2NFBUHjnZeI0icng9s=", + "integrity": "sha512-BHJ/EKruNIqJf/QahvxwQZXKygOQ256myeN/Ew+THcAa5q+PjyTTMMeNQC4DZw5AwfvelsUrA6B67NKMqXDbzQ==", "dev": true }, "mime-types": { "version": "2.1.18", "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.18.tgz", - "integrity": "sha1-bzI/YKg9ERRvgx/xH9ZuL+VQO7g=", + "integrity": "sha512-lc/aahn+t4/SWV/qcmumYjymLsWfN3ELhpmVuUFjgsORruuZPVSwAQryq+HHGvO/SI2KVX26bx+En+zhM8g8hQ==", "dev": true, "requires": { "mime-db": "1.33.0" @@ -3917,7 +3917,7 @@ "minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha1-UWbihkV/AzBgZL5Ul+jbsMPTIIM=", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "dev": true, "requires": { "brace-expansion": "1.1.11" @@ -4071,7 +4071,7 @@ "normalize-package-data": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.4.0.tgz", - "integrity": "sha1-EvlaMH1YNSB1oEkHuErIvpisAS8=", + "integrity": "sha512-9jjUFbTPfEy3R/ad/2oNbKtW9Hgovl5O1FvFWKkKblNXoN/Oou6+9+KKohPK13Yc3/TyunyWhJp6gvRNR/PPAw==", "dev": true, "requires": { "hosted-git-info": "2.5.0", @@ -4511,7 +4511,7 @@ "process-nextick-args": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", - "integrity": "sha1-o31zL0JxtKsa0HDTVQjoKQeI/6o=", + "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==", "dev": true }, "progress": { @@ -4584,7 +4584,7 @@ "qs": { "version": "6.5.1", "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.1.tgz", - "integrity": "sha1-NJzfbu+J7EXBLX1es/wMhwNDptg=", + "integrity": "sha512-eRzhrN1WSINYCDCbrz796z37LOe3m5tmW7RQf6oBntukAG1nmovJvhnwHHRMAfeoItc1m2Hk02WER2aQ/iqs+A==", "dev": true }, "quick-lru": { @@ -4596,7 +4596,7 @@ "randomatic": { "version": "1.1.7", "resolved": "https://registry.npmjs.org/randomatic/-/randomatic-1.1.7.tgz", - "integrity": "sha1-x6vpzIuHwLqodrGf3oP9RkeX44w=", + "integrity": "sha512-D5JUjPyJbaJDkuAazpVnSfVkLlpeO3wDlPROTMLGKG1zMFNFRgrciKo1ltz/AzNTkqE0HzDx655QOL51N06how==", "dev": true, "requires": { "is-number": "3.0.0", @@ -4701,7 +4701,7 @@ "regex-cache": { "version": "0.4.4", "resolved": "https://registry.npmjs.org/regex-cache/-/regex-cache-0.4.4.tgz", - "integrity": "sha1-db3FiioUls7EihKDW8VMjVYjNt0=", + "integrity": "sha512-nVIZwtCjkC9YgvWkpM55B5rBhBYRZhAaJbgcFYXXsHnbZ9UZI9nnVWYZpBlCqv9ho2eZryPnWrZGsOdPwVWXWQ==", "dev": true, "requires": { "is-equal-shallow": "0.1.3" @@ -4729,7 +4729,7 @@ "remap-istanbul": { "version": "0.10.1", "resolved": "https://registry.npmjs.org/remap-istanbul/-/remap-istanbul-0.10.1.tgz", - "integrity": "sha1-OqWN1QIdSZ8zbTulvzu7kcG4jjc=", + "integrity": "sha512-gsNQXs5kJLhErICSyYhzVZ++C8LBW8dgwr874Y2QvzAUS75zBlD/juZgXs39nbYJ09fZDlX2AVLVJAY2jbFJoQ==", "dev": true, "requires": { "amdefine": "1.0.1", @@ -4769,7 +4769,7 @@ "source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha1-dHIq8y6WFOnCh6jQu95IteLxomM=", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", "dev": true }, "through2": { @@ -4883,7 +4883,7 @@ "resolve": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.5.0.tgz", - "integrity": "sha1-HwmsznlsmnYlefMbLBzEw83fnzY=", + "integrity": "sha512-hgoSGrc3pjzAPHNBg+KnFcK2HwlHTs/YrAGUr6qgTVUZmXv1UEXXl0bZNBKMA9fud6lRYFdPGz0xXxycPzmmiw==", "dev": true, "requires": { "path-parse": "1.0.5" @@ -4924,7 +4924,7 @@ "rimraf": { "version": "2.6.2", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", - "integrity": "sha1-LtgVDSShbqhlHm1u8PR8QVjOejY=", + "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", "dev": true, "requires": { "glob": "7.1.2" @@ -5063,19 +5063,19 @@ "safe-buffer": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", - "integrity": "sha1-iTMSr2myEj3vcfV4iQAWce6yyFM=", + "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", "dev": true }, "samsam": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/samsam/-/samsam-1.3.0.tgz", - "integrity": "sha1-jR2TUOJWItow3j5EumkrUiGrfFA=", + "integrity": "sha512-1HwIYD/8UlOtFS3QO3w7ey+SdSDFE4HRNLZoZRYVQefrOY3l17epswImeB1ijgJFQJodIaHcwkp3r/myBjFVbg==", "dev": true }, "semver": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz", - "integrity": "sha1-3Eu8emyp2Rbe5dQ1FvAJK1j3uKs=", + "integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==", "dev": true }, "set-blocking": { @@ -5117,7 +5117,7 @@ "sinon-chai": { "version": "2.14.0", "resolved": "https://registry.npmjs.org/sinon-chai/-/sinon-chai-2.14.0.tgz", - "integrity": "sha1-2n3UzIPNaiYLZ8yg96n9riahIF0=", + "integrity": "sha512-9stIF1utB0ywNHNT7RgiXbdmen8QDCRsrTjw+G9TgKt1Yexjiv8TOWZ6WHsTPz57Yky3DIswZvEqX8fpuHNDtQ==", "dev": true }, "slash": { @@ -5146,7 +5146,7 @@ "sntp": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/sntp/-/sntp-2.1.0.tgz", - "integrity": "sha1-LGzsFP7cIiJznK+bXD2F0cxaLMg=", + "integrity": "sha512-FL1b58BDrqS3A11lJ0zEdnJ3UOKqVxawAkF3k7F0CVN7VQ34aZrV+G8BZ1WC9ZL7NyrwsW0oviwsWDgRuVYtJg==", "dev": true, "requires": { "hoek": "4.2.1" @@ -5203,7 +5203,7 @@ "spdx-correct": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.0.0.tgz", - "integrity": "sha1-BaW01xU6GVvJLDxCW2nzsqlSTII=", + "integrity": "sha512-N19o9z5cEyc8yQQPukRCZ9EUmb4HUpnrmaL/fxS2pBo2jbfcFRVuFZ/oFC+vZz0MNNk0h80iMn5/S6qGZOL5+g==", "dev": true, "requires": { "spdx-expression-parse": "3.0.0", @@ -5213,13 +5213,13 @@ "spdx-exceptions": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.1.0.tgz", - "integrity": "sha1-LHrmEFbHFKW5ubKyr30xHvXHj+k=", + "integrity": "sha512-4K1NsmrlCU1JJgUrtgEeTVyfx8VaYea9J9LvARxhbHtVtohPs/gFGG5yy49beySjlIMhhXZ4QqujIZEfS4l6Cg==", "dev": true }, "spdx-expression-parse": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.0.tgz", - "integrity": "sha1-meEZt6XaAOBUkcn6M4t5BII7QdA=", + "integrity": "sha512-Yg6D3XpRD4kkOmTpdgbUiEJFKghJH03fiC1OPll5h/0sO6neh2jqRDVHOQ4o/LMea0tgCkbMgea5ip/e+MkWyg==", "dev": true, "requires": { "spdx-exceptions": "2.1.0", @@ -5229,7 +5229,7 @@ "spdx-license-ids": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.0.tgz", - "integrity": "sha1-enzShHDMbToc/m1miG9rxDDTrIc=", + "integrity": "sha512-2+EPwgbnmOIl8HjGBXXMd9NAu02vLjOO1nWw4kmeRDFyHn+M/ETfHxQUK0oXg8ctgVnl9t3rosNVsZ1jG61nDA==", "dev": true }, "speedometer": { @@ -5566,7 +5566,7 @@ "tough-cookie": { "version": "2.3.4", "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.4.tgz", - "integrity": "sha1-7GDO44rGdQY//JelwYlwV47oNlU=", + "integrity": "sha512-TZ6TTfI5NtZnuyy/Kecv+CnoROnyXn2DN97LontgQpCwsX2XyLYCC0ENhYkehSOwAp8rTQKc/NUIF7BkQ5rKLA==", "dev": true, "requires": { "punycode": "1.4.1" @@ -5708,13 +5708,13 @@ "uuid": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.2.1.tgz", - "integrity": "sha1-EsUou51Y0LkmXZovbw/ovhf/HxQ=", + "integrity": "sha512-jZnMwlb9Iku/O3smGWvZhauCf6cvvpKi4BKRiliS3cxnI+Gz9j5MEpTz2UFuXiKPJocb7gnsLHwiS05ige5BEA==", "dev": true }, "validate-npm-package-license": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.3.tgz", - "integrity": "sha1-gWQ7y+8b3+zUYjeT3EZIlIupgzg=", + "integrity": "sha512-63ZOUnL4SIXj4L0NixR3L1lcjO38crAbgrTpl28t8jjrfuiOBL5Iygm+60qPs/KsZGzPNg6Smnc/oY16QTjF0g==", "dev": true, "requires": { "spdx-correct": "3.0.0", @@ -5750,7 +5750,7 @@ "which": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/which/-/which-1.3.0.tgz", - "integrity": "sha1-/wS9/AEO5UfXgL7DjhrBwnd9JTo=", + "integrity": "sha512-xcJpopdamTuY5duC/KnTTNBraPK54YwpenP4lzxU8H91GudWpFv38u0CKjclE1Wi2EH2EDz5LRcHcKbCIzqGyg==", "dev": true, "requires": { "isexe": "2.0.0" diff --git a/packages/canvas/canvas-mesh/package.json b/packages/canvas/canvas-mesh/package.json index 691cd2c..6744a17 100644 --- a/packages/canvas/canvas-mesh/package.json +++ b/packages/canvas/canvas-mesh/package.json @@ -24,6 +24,7 @@ "dependencies": { "@pixi/constants": "^5.0.0-alpha.2", "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/mesh-extras": "^5.0.0-alpha.2", "@pixi/settings": "^5.0.0-alpha.2" }, "devDependencies": { diff --git a/packages/canvas/canvas-mesh/src/Mesh.js b/packages/canvas/canvas-mesh/src/Mesh.js index 900a872..c43a74b 100644 --- a/packages/canvas/canvas-mesh/src/Mesh.js +++ b/packages/canvas/canvas-mesh/src/Mesh.js @@ -1,36 +1,14 @@ import { Mesh } from '@pixi/mesh'; -import { settings } from './settings'; - -// IMPORTANT: Please do NOT use this as a precedent to use `settings` after the object is created -// this was merely created to completely decouple canvas from the base Mesh class and we are -// unable to add `canvasPadding` in the constructor anymore, as the case was for PixiJS v4. /** - * Internal variable for `canvasPadding`. + * Renders the object using the Canvas renderer * * @private - * @memberof PIXI.Mesh - * @member {number} - * @default null - */ -Mesh.prototype._canvasPadding = null; - -/** - * Triangles in canvas mode are automatically antialiased, use this value to force triangles - * to overlap a bit with each other. To set the global default, set {@link PIXI.settings.MESH_CANVAS_PADDING} - * - * @see PIXI.settings.MESH_CANVAS_PADDING - * @member {number} canvasPadding + * @method _renderCanvas * @memberof PIXI.Mesh# - * @default 0 + * @param {PIXI.CanvasRenderer} renderer - The canvas renderer. */ -Object.defineProperty(Mesh.prototype, 'canvasPadding', { - get() - { - return this._canvasPadding !== null ? this._canvasPadding : settings.MESH_CANVAS_PADDING; - }, - set(value) - { - this._canvasPadding = value; - }, -}); +Mesh.prototype._renderCanvas = function _renderCanvas(renderer) +{ + renderer.plugins[this.pluginName].render(this); +}; diff --git a/bundles/pixi.js/package.json b/bundles/pixi.js/package.json index 49c7276..177e059 100644 --- a/bundles/pixi.js/package.json +++ b/bundles/pixi.js/package.json @@ -49,6 +49,7 @@ "@pixi/loaders": "^5.0.0-alpha.2", "@pixi/math": "^5.0.0-alpha.2", "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/mesh-extras": "^5.0.0-alpha.2", "@pixi/mixin-cache-as-bitmap": "^5.0.0-alpha.2", "@pixi/mixin-get-child-by-name": "^5.0.0-alpha.2", "@pixi/mixin-get-global-position": "^5.0.0-alpha.2", diff --git a/bundles/pixi.js/src/deprecated.js b/bundles/pixi.js/src/deprecated.js index 147617c..dbebeb0 100644 --- a/bundles/pixi.js/src/deprecated.js +++ b/bundles/pixi.js/src/deprecated.js @@ -263,15 +263,15 @@ Object.defineProperties(PIXI.mesh, { /** * @class PIXI.mesh.Mesh - * @see PIXI.Mesh + * @see PIXI.Mesh2d * @deprecated since 5.0.0 */ Mesh: { get() { - warn('PIXI.mesh.Mesh has moved to PIXI.Mesh'); + warn('PIXI.mesh.Mesh has moved to PIXI.Mesh2d'); - return PIXI.Mesh; + return PIXI.Mesh2d; }, }, /** @@ -315,15 +315,15 @@ }, /** * @class PIXI.mesh.RawMesh - * @see PIXI.RawMesh + * @see PIXI.Mesh * @deprecated since 5.0.0 */ RawMesh: { get() { - warn('PIXI.mesh.RawMesh has moved to PIXI.RawMesh'); + warn('PIXI.mesh.RawMesh has moved to PIXI.Mesh'); - return PIXI.RawMesh; + return PIXI.Mesh; }, }, /** diff --git a/bundles/pixi.js/src/index.js b/bundles/pixi.js/src/index.js index a3a0d1b..6fdabf0 100644 --- a/bundles/pixi.js/src/index.js +++ b/bundles/pixi.js/src/index.js @@ -9,6 +9,7 @@ import * as loaders from '@pixi/loaders'; import * as math from '@pixi/math'; import * as mesh from '@pixi/mesh'; +import * as meshExtras from '@pixi/mesh-extras'; import * as particles from '@pixi/particles'; import * as prepare from '@pixi/prepare'; import * as sprite from '@pixi/sprite'; @@ -128,6 +129,7 @@ loaders, math, mesh, + meshExtras, particles, sprite, spriteAnimated, @@ -152,6 +154,7 @@ export * from '@pixi/loaders'; export * from '@pixi/math'; export * from '@pixi/mesh'; +export * from '@pixi/mesh-extras'; export * from '@pixi/particles'; export * from '@pixi/sprite'; export * from '@pixi/spritesheet'; diff --git a/package-lock.json b/package-lock.json index 7fe6db7..0814729 100644 --- a/package-lock.json +++ b/package-lock.json @@ -209,7 +209,7 @@ "argparse": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", - "integrity": "sha1-vNZ5HqWuCXJeF+WtmIE0zUCz2RE=", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", "dev": true, "requires": { "sprintf-js": "1.0.3" @@ -228,7 +228,7 @@ "arr-flatten": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz", - "integrity": "sha1-NgSLv/TntH4TZkQxbJlmnqWukfE=", + "integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==", "dev": true }, "arr-union": { @@ -297,7 +297,7 @@ "assertion-error": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", - "integrity": "sha1-5gtrDo8wG9l+U3UhW9pAbIURjAs=", + "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", "dev": true }, "async": { @@ -396,7 +396,7 @@ "brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha1-PH/L9SnYcibz0vUrlm/1Jx60Qd0=", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, "requires": { "balanced-match": "1.0.0", @@ -568,7 +568,7 @@ "circular-json": { "version": "0.3.3", "resolved": "https://registry.npmjs.org/circular-json/-/circular-json-0.3.3.tgz", - "integrity": "sha1-gVyZ6oT2gJUp0vRXkb34JxE1LWY=", + "integrity": "sha512-UZK3NBx2Mca+b5LsG7bY183pHWt5Y1xts4P3Pz7ENTwGVnJOUWbRb3ocjvX7hx9tq/yTAdclXm9sZ38gNuem4A==", "dev": true }, "cli-cursor": { @@ -638,7 +638,7 @@ "color-convert": { "version": "1.9.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.1.tgz", - "integrity": "sha1-wSYRB66y8pTr/+ye2eytUppgl+0=", + "integrity": "sha512-mjGanIiwQJskCC18rPR6OmrZ6fm2Lc7PeGFYwCmy5J34wC6F1PzdGL6xeMfmgicfYcNLGuVFA3WzXtIDCQSZxQ==", "dev": true, "requires": { "color-name": "1.1.3" @@ -1427,7 +1427,7 @@ "boom": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/boom/-/boom-5.2.0.tgz", - "integrity": "sha1-XdnabuOl8wIHdDYpDLcX0/SlTgI=", + "integrity": "sha512-Z5BTk6ZRe4tXXQlkqftmsAUANpXmuwlsF5Oov8ThoMbQRzdGTA1ngYRW160GexgOgjsFOKJz0LYhoNi+2AMBUw==", "dev": true, "requires": { "hoek": "4.2.1" @@ -1471,7 +1471,7 @@ "debug": { "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha1-XRKFFd8TT/Mn6QpMk/Tgd6U2NB8=", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", "dev": true, "requires": { "ms": "2.0.0" @@ -1585,7 +1585,7 @@ "doctrine": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", - "integrity": "sha1-XNAfwQFiG0LEzX9dGmYkNxbT850=", + "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", "dev": true, "requires": { "esutils": "2.0.2" @@ -1662,7 +1662,7 @@ "es6-promise": { "version": "4.2.4", "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.4.tgz", - "integrity": "sha1-3EIhwrFlGHYL2MOaUtjzVvwA7Sk=", + "integrity": "sha512-/NdNZVJg+uZgtm9eS3O6lrOLYmQag2DjdEXuPaHlZ6RuVqgqaVZfgYCepEIKsLqwdQArOPtC3XzRLqGGfT8KQQ==", "dev": true }, "escape-string-regexp": { @@ -1788,7 +1788,7 @@ "espree": { "version": "3.5.4", "resolved": "https://registry.npmjs.org/espree/-/espree-3.5.4.tgz", - "integrity": "sha1-sPRHGHyKi+2US4FaZgvd9d610ac=", + "integrity": "sha512-yAcIQxtmMiB/jL32dzEp2enBeidsB7xWPLNiw3IIkpVds1P+h7qF9YwJq1yUNzp2OKXgAprs4F61ih66UsoD1A==", "dev": true, "requires": { "acorn": "5.5.0", @@ -1798,7 +1798,7 @@ "esprima": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.0.tgz", - "integrity": "sha1-RJnt3NERDgshi6zy+n9/WfVcqAQ=", + "integrity": "sha512-oftTcaMu/EGrEIu904mWteKIv8vMuOgGYo7EhVJJN00R/EED9DCua/xxHRdYnKtcECzVg7xOWhflvJMnqcFZjw==", "dev": true }, "esquery": { @@ -1813,7 +1813,7 @@ "esrecurse": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.2.1.tgz", - "integrity": "sha1-AHo7n9vCs7uH5IeeoZyS/b05Qs8=", + "integrity": "sha512-64RBB++fIOAXPw3P9cy89qfMlvZEXZkqqJkjqqXIvzP5ezRZjW+lPWjw35UX/3EhUPFYbg5ER4JYgDw4007/DQ==", "dev": true, "requires": { "estraverse": "4.2.0" @@ -2024,7 +2024,7 @@ "find-root": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/find-root/-/find-root-1.1.0.tgz", - "integrity": "sha1-q8/Iunb3CMQql7PWhbfpRQv7nOQ=", + "integrity": "sha512-NKfW6bec6GfKc0SGx1e07QZY9PE99u0Bft/0rzSD5k3sO/vwkVUpDUKVm5Gpp5Ue3YfShPFTX2070tDs5kB9Ng==", "dev": true }, "find-up": { @@ -2103,7 +2103,7 @@ "supports-color": { "version": "5.3.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.3.0.tgz", - "integrity": "sha1-WySsFduA+pJ89SJ6SjP9PEx2dsA=", + "integrity": "sha512-0aP01LLIskjKs3lq52EC0aGBAJhLq7B2Rd8HC/DR/PtNNpcLilNmHC12O+hu0usQpo7wtHNRqtrhBwtDb0+dNg==", "dev": true, "requires": { "has-flag": "3.0.0" @@ -2567,7 +2567,7 @@ "glob": { "version": "7.1.2", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", - "integrity": "sha1-wZyd+aAocC1nhhI4SmVSQExjbRU=", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", "dev": true, "requires": { "fs.realpath": "1.0.0", @@ -2672,7 +2672,7 @@ "growl": { "version": "1.10.3", "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.3.tgz", - "integrity": "sha1-GSa6kM8+3+KttJJ/WIC8IsZseQ8=", + "integrity": "sha512-hKlsbA5Vu3xsh1Cg3J7jSmX/WaW6A5oBeqzM88oNbCRQFz+zUaXm6yxS4RVytp1scBoJzSYl4YAEOQIt6O8V1Q==", "dev": true }, "handlebars": { @@ -2738,7 +2738,7 @@ "hawk": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/hawk/-/hawk-6.0.2.tgz", - "integrity": "sha1-r02RTrBl+bXOTZ0RwcshJu7MMDg=", + "integrity": "sha512-miowhl2+U7Qle4vdLqDdPt9m09K6yZhkLDTWGoUiUzrQCn+mHHSmfJgAyGaLRZbPmTqfFFjRV1QWCW0VWUJBbQ==", "dev": true, "requires": { "boom": "4.3.1", @@ -2756,7 +2756,7 @@ "hoek": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/hoek/-/hoek-4.2.1.tgz", - "integrity": "sha1-ljRQKqEsRF3Vp8VzS1cruHOKrLs=", + "integrity": "sha512-QLg82fGkfnJ/4iy1xZ81/9SIJiq1NGFUMGs6ParyjBZr6jW2Ufj/snDqTHixNlHdPNwN2RLVD0Pi3igeK9+JfA==", "dev": true }, "home-path": { @@ -2791,7 +2791,7 @@ "ignore": { "version": "3.3.7", "resolved": "https://registry.npmjs.org/ignore/-/ignore-3.3.7.tgz", - "integrity": "sha1-YSKJv7PCIOGGpYEYYY1b6MG6sCE=", + "integrity": "sha512-YGG3ejvBNHRqu0559EOxxNFihD0AjpvHlC/pdGKd3X3ofe+CoJkYazwNJYTNebqpPKN+VVQbh4ZFn1DivMNuHA==", "dev": true }, "imurmurhash": { @@ -2828,7 +2828,7 @@ "ini": { "version": "1.3.5", "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", - "integrity": "sha1-7uJfVtscnsYIXgwid4CD9Zar+Sc=", + "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==", "dev": true }, "inquirer": { @@ -2901,7 +2901,7 @@ "is-buffer": { "version": "1.1.6", "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", - "integrity": "sha1-76ouqdqg16suoTqXsritUf776L4=", + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", "dev": true }, "is-builtin-module": { @@ -3054,7 +3054,7 @@ "is-resolvable": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/is-resolvable/-/is-resolvable-1.1.0.tgz", - "integrity": "sha1-+xj4fOH+uSUWnJpAfBkxijIG7Yg=", + "integrity": "sha512-qgDYXFSR5WvEfuS5dMj6oTMEbrrSaM0CrFk2Yiq/gXnBvD9pMa2jGXxyhGLfvhZpuMZe18CJpFxAt3CRs42NMg==", "dev": true }, "is-retry-allowed": { @@ -3204,7 +3204,7 @@ "js-yaml": { "version": "3.11.0", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.11.0.tgz", - "integrity": "sha1-WXwai9VxUvJtYizkEXhRpR9euu8=", + "integrity": "sha512-saJstZWv7oNeOyBh3+Dx1qWzhW0+e6/8eDzo7p5rDFqxntSztloLtuKu+Ejhtq82jsilwOIZYsCz+lIjthg1Hw==", "dev": true, "requires": { "argparse": "1.0.10", @@ -3324,7 +3324,7 @@ "just-extend": { "version": "1.1.27", "resolved": "https://registry.npmjs.org/just-extend/-/just-extend-1.1.27.tgz", - "integrity": "sha1-7G55QQ/5FORyZSq/oOYDwD1g6QU=", + "integrity": "sha512-mJVp13Ix6gFo3SBAy9U/kL+oeZqzlYYYLQBwXVBlVzIsZwBqGREnOro24oC/8s8aox+rJhtZ2DiQof++IrkA+g==", "dev": true }, "kind-of": { @@ -3703,7 +3703,7 @@ "lodash": { "version": "4.17.5", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.5.tgz", - "integrity": "sha1-maktZcAnLevoyWtgV7yPv6O+1RE=", + "integrity": "sha512-svL3uiZf1RwhH+cWrfZn3A4+U58wbP0tGVTLQPbjplZxZ8ROD9VLuNgsRniTlLe7OlSqR79RUehXgpBW/s0IQw==", "dev": true }, "lodash._reinterpolate": { @@ -3740,7 +3740,7 @@ "lolex": { "version": "2.3.2", "resolved": "https://registry.npmjs.org/lolex/-/lolex-2.3.2.tgz", - "integrity": "sha1-hflFBCUQO/nnpgZo6iXcQydMqAc=", + "integrity": "sha512-A5pN2tkFj7H0dGIAM6MFvHKMJcPnjZsOMvR7ujCjfgW5TbV6H9vb1PgxLtHvjqNZTHsUolz+6/WEO0N1xNx2ng==", "dev": true }, "longest": { @@ -3816,7 +3816,7 @@ "marked": { "version": "0.3.17", "resolved": "https://registry.npmjs.org/marked/-/marked-0.3.17.tgz", - "integrity": "sha1-YH8GZos8axJGso8T2nYRasGqLSs=", + "integrity": "sha512-+AKbNsjZl6jFfLPwHhWmGTqE009wTKn3RTmn9K8oUKHrX/abPJjtcRtXpYB/FFrwPJRUA86LX/de3T0knkPCmQ==", "dev": true }, "mem": { @@ -3896,13 +3896,13 @@ "mime-db": { "version": "1.33.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.33.0.tgz", - "integrity": "sha1-o0kgUKXLm2NFBUHjnZeI0icng9s=", + "integrity": "sha512-BHJ/EKruNIqJf/QahvxwQZXKygOQ256myeN/Ew+THcAa5q+PjyTTMMeNQC4DZw5AwfvelsUrA6B67NKMqXDbzQ==", "dev": true }, "mime-types": { "version": "2.1.18", "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.18.tgz", - "integrity": "sha1-bzI/YKg9ERRvgx/xH9ZuL+VQO7g=", + "integrity": "sha512-lc/aahn+t4/SWV/qcmumYjymLsWfN3ELhpmVuUFjgsORruuZPVSwAQryq+HHGvO/SI2KVX26bx+En+zhM8g8hQ==", "dev": true, "requires": { "mime-db": "1.33.0" @@ -3917,7 +3917,7 @@ "minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha1-UWbihkV/AzBgZL5Ul+jbsMPTIIM=", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "dev": true, "requires": { "brace-expansion": "1.1.11" @@ -4071,7 +4071,7 @@ "normalize-package-data": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.4.0.tgz", - "integrity": "sha1-EvlaMH1YNSB1oEkHuErIvpisAS8=", + "integrity": "sha512-9jjUFbTPfEy3R/ad/2oNbKtW9Hgovl5O1FvFWKkKblNXoN/Oou6+9+KKohPK13Yc3/TyunyWhJp6gvRNR/PPAw==", "dev": true, "requires": { "hosted-git-info": "2.5.0", @@ -4511,7 +4511,7 @@ "process-nextick-args": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", - "integrity": "sha1-o31zL0JxtKsa0HDTVQjoKQeI/6o=", + "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==", "dev": true }, "progress": { @@ -4584,7 +4584,7 @@ "qs": { "version": "6.5.1", "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.1.tgz", - "integrity": "sha1-NJzfbu+J7EXBLX1es/wMhwNDptg=", + "integrity": "sha512-eRzhrN1WSINYCDCbrz796z37LOe3m5tmW7RQf6oBntukAG1nmovJvhnwHHRMAfeoItc1m2Hk02WER2aQ/iqs+A==", "dev": true }, "quick-lru": { @@ -4596,7 +4596,7 @@ "randomatic": { "version": "1.1.7", "resolved": "https://registry.npmjs.org/randomatic/-/randomatic-1.1.7.tgz", - "integrity": "sha1-x6vpzIuHwLqodrGf3oP9RkeX44w=", + "integrity": "sha512-D5JUjPyJbaJDkuAazpVnSfVkLlpeO3wDlPROTMLGKG1zMFNFRgrciKo1ltz/AzNTkqE0HzDx655QOL51N06how==", "dev": true, "requires": { "is-number": "3.0.0", @@ -4701,7 +4701,7 @@ "regex-cache": { "version": "0.4.4", "resolved": "https://registry.npmjs.org/regex-cache/-/regex-cache-0.4.4.tgz", - "integrity": "sha1-db3FiioUls7EihKDW8VMjVYjNt0=", + "integrity": "sha512-nVIZwtCjkC9YgvWkpM55B5rBhBYRZhAaJbgcFYXXsHnbZ9UZI9nnVWYZpBlCqv9ho2eZryPnWrZGsOdPwVWXWQ==", "dev": true, "requires": { "is-equal-shallow": "0.1.3" @@ -4729,7 +4729,7 @@ "remap-istanbul": { "version": "0.10.1", "resolved": "https://registry.npmjs.org/remap-istanbul/-/remap-istanbul-0.10.1.tgz", - "integrity": "sha1-OqWN1QIdSZ8zbTulvzu7kcG4jjc=", + "integrity": "sha512-gsNQXs5kJLhErICSyYhzVZ++C8LBW8dgwr874Y2QvzAUS75zBlD/juZgXs39nbYJ09fZDlX2AVLVJAY2jbFJoQ==", "dev": true, "requires": { "amdefine": "1.0.1", @@ -4769,7 +4769,7 @@ "source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha1-dHIq8y6WFOnCh6jQu95IteLxomM=", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", "dev": true }, "through2": { @@ -4883,7 +4883,7 @@ "resolve": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.5.0.tgz", - "integrity": "sha1-HwmsznlsmnYlefMbLBzEw83fnzY=", + "integrity": "sha512-hgoSGrc3pjzAPHNBg+KnFcK2HwlHTs/YrAGUr6qgTVUZmXv1UEXXl0bZNBKMA9fud6lRYFdPGz0xXxycPzmmiw==", "dev": true, "requires": { "path-parse": "1.0.5" @@ -4924,7 +4924,7 @@ "rimraf": { "version": "2.6.2", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", - "integrity": "sha1-LtgVDSShbqhlHm1u8PR8QVjOejY=", + "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", "dev": true, "requires": { "glob": "7.1.2" @@ -5063,19 +5063,19 @@ "safe-buffer": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", - "integrity": "sha1-iTMSr2myEj3vcfV4iQAWce6yyFM=", + "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", "dev": true }, "samsam": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/samsam/-/samsam-1.3.0.tgz", - "integrity": "sha1-jR2TUOJWItow3j5EumkrUiGrfFA=", + "integrity": "sha512-1HwIYD/8UlOtFS3QO3w7ey+SdSDFE4HRNLZoZRYVQefrOY3l17epswImeB1ijgJFQJodIaHcwkp3r/myBjFVbg==", "dev": true }, "semver": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz", - "integrity": "sha1-3Eu8emyp2Rbe5dQ1FvAJK1j3uKs=", + "integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==", "dev": true }, "set-blocking": { @@ -5117,7 +5117,7 @@ "sinon-chai": { "version": "2.14.0", "resolved": "https://registry.npmjs.org/sinon-chai/-/sinon-chai-2.14.0.tgz", - "integrity": "sha1-2n3UzIPNaiYLZ8yg96n9riahIF0=", + "integrity": "sha512-9stIF1utB0ywNHNT7RgiXbdmen8QDCRsrTjw+G9TgKt1Yexjiv8TOWZ6WHsTPz57Yky3DIswZvEqX8fpuHNDtQ==", "dev": true }, "slash": { @@ -5146,7 +5146,7 @@ "sntp": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/sntp/-/sntp-2.1.0.tgz", - "integrity": "sha1-LGzsFP7cIiJznK+bXD2F0cxaLMg=", + "integrity": "sha512-FL1b58BDrqS3A11lJ0zEdnJ3UOKqVxawAkF3k7F0CVN7VQ34aZrV+G8BZ1WC9ZL7NyrwsW0oviwsWDgRuVYtJg==", "dev": true, "requires": { "hoek": "4.2.1" @@ -5203,7 +5203,7 @@ "spdx-correct": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.0.0.tgz", - "integrity": "sha1-BaW01xU6GVvJLDxCW2nzsqlSTII=", + "integrity": "sha512-N19o9z5cEyc8yQQPukRCZ9EUmb4HUpnrmaL/fxS2pBo2jbfcFRVuFZ/oFC+vZz0MNNk0h80iMn5/S6qGZOL5+g==", "dev": true, "requires": { "spdx-expression-parse": "3.0.0", @@ -5213,13 +5213,13 @@ "spdx-exceptions": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.1.0.tgz", - "integrity": "sha1-LHrmEFbHFKW5ubKyr30xHvXHj+k=", + "integrity": "sha512-4K1NsmrlCU1JJgUrtgEeTVyfx8VaYea9J9LvARxhbHtVtohPs/gFGG5yy49beySjlIMhhXZ4QqujIZEfS4l6Cg==", "dev": true }, "spdx-expression-parse": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.0.tgz", - "integrity": "sha1-meEZt6XaAOBUkcn6M4t5BII7QdA=", + "integrity": "sha512-Yg6D3XpRD4kkOmTpdgbUiEJFKghJH03fiC1OPll5h/0sO6neh2jqRDVHOQ4o/LMea0tgCkbMgea5ip/e+MkWyg==", "dev": true, "requires": { "spdx-exceptions": "2.1.0", @@ -5229,7 +5229,7 @@ "spdx-license-ids": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.0.tgz", - "integrity": "sha1-enzShHDMbToc/m1miG9rxDDTrIc=", + "integrity": "sha512-2+EPwgbnmOIl8HjGBXXMd9NAu02vLjOO1nWw4kmeRDFyHn+M/ETfHxQUK0oXg8ctgVnl9t3rosNVsZ1jG61nDA==", "dev": true }, "speedometer": { @@ -5566,7 +5566,7 @@ "tough-cookie": { "version": "2.3.4", "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.4.tgz", - "integrity": "sha1-7GDO44rGdQY//JelwYlwV47oNlU=", + "integrity": "sha512-TZ6TTfI5NtZnuyy/Kecv+CnoROnyXn2DN97LontgQpCwsX2XyLYCC0ENhYkehSOwAp8rTQKc/NUIF7BkQ5rKLA==", "dev": true, "requires": { "punycode": "1.4.1" @@ -5708,13 +5708,13 @@ "uuid": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.2.1.tgz", - "integrity": "sha1-EsUou51Y0LkmXZovbw/ovhf/HxQ=", + "integrity": "sha512-jZnMwlb9Iku/O3smGWvZhauCf6cvvpKi4BKRiliS3cxnI+Gz9j5MEpTz2UFuXiKPJocb7gnsLHwiS05ige5BEA==", "dev": true }, "validate-npm-package-license": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.3.tgz", - "integrity": "sha1-gWQ7y+8b3+zUYjeT3EZIlIupgzg=", + "integrity": "sha512-63ZOUnL4SIXj4L0NixR3L1lcjO38crAbgrTpl28t8jjrfuiOBL5Iygm+60qPs/KsZGzPNg6Smnc/oY16QTjF0g==", "dev": true, "requires": { "spdx-correct": "3.0.0", @@ -5750,7 +5750,7 @@ "which": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/which/-/which-1.3.0.tgz", - "integrity": "sha1-/wS9/AEO5UfXgL7DjhrBwnd9JTo=", + "integrity": "sha512-xcJpopdamTuY5duC/KnTTNBraPK54YwpenP4lzxU8H91GudWpFv38u0CKjclE1Wi2EH2EDz5LRcHcKbCIzqGyg==", "dev": true, "requires": { "isexe": "2.0.0" diff --git a/packages/canvas/canvas-mesh/package.json b/packages/canvas/canvas-mesh/package.json index 691cd2c..6744a17 100644 --- a/packages/canvas/canvas-mesh/package.json +++ b/packages/canvas/canvas-mesh/package.json @@ -24,6 +24,7 @@ "dependencies": { "@pixi/constants": "^5.0.0-alpha.2", "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/mesh-extras": "^5.0.0-alpha.2", "@pixi/settings": "^5.0.0-alpha.2" }, "devDependencies": { diff --git a/packages/canvas/canvas-mesh/src/Mesh.js b/packages/canvas/canvas-mesh/src/Mesh.js index 900a872..c43a74b 100644 --- a/packages/canvas/canvas-mesh/src/Mesh.js +++ b/packages/canvas/canvas-mesh/src/Mesh.js @@ -1,36 +1,14 @@ import { Mesh } from '@pixi/mesh'; -import { settings } from './settings'; - -// IMPORTANT: Please do NOT use this as a precedent to use `settings` after the object is created -// this was merely created to completely decouple canvas from the base Mesh class and we are -// unable to add `canvasPadding` in the constructor anymore, as the case was for PixiJS v4. /** - * Internal variable for `canvasPadding`. + * Renders the object using the Canvas renderer * * @private - * @memberof PIXI.Mesh - * @member {number} - * @default null - */ -Mesh.prototype._canvasPadding = null; - -/** - * Triangles in canvas mode are automatically antialiased, use this value to force triangles - * to overlap a bit with each other. To set the global default, set {@link PIXI.settings.MESH_CANVAS_PADDING} - * - * @see PIXI.settings.MESH_CANVAS_PADDING - * @member {number} canvasPadding + * @method _renderCanvas * @memberof PIXI.Mesh# - * @default 0 + * @param {PIXI.CanvasRenderer} renderer - The canvas renderer. */ -Object.defineProperty(Mesh.prototype, 'canvasPadding', { - get() - { - return this._canvasPadding !== null ? this._canvasPadding : settings.MESH_CANVAS_PADDING; - }, - set(value) - { - this._canvasPadding = value; - }, -}); +Mesh.prototype._renderCanvas = function _renderCanvas(renderer) +{ + renderer.plugins[this.pluginName].render(this); +}; diff --git a/packages/canvas/canvas-mesh/src/Mesh2d.js b/packages/canvas/canvas-mesh/src/Mesh2d.js new file mode 100644 index 0000000..d0bd80f --- /dev/null +++ b/packages/canvas/canvas-mesh/src/Mesh2d.js @@ -0,0 +1,36 @@ +import { Mesh2d } from '@pixi/mesh-extras'; +import { settings } from './settings'; + +// IMPORTANT: Please do NOT use this as a precedent to use `settings` after the object is created +// this was merely created to completely decouple canvas from the base Mesh class and we are +// unable to add `canvasPadding` in the constructor anymore, as the case was for PixiJS v4. + +/** + * Internal variable for `canvasPadding`. + * + * @private + * @memberof PIXI.Mesh2d + * @member {number} + * @default null + */ +Mesh2d.prototype._canvasPadding = null; + +/** + * Triangles in canvas mode are automatically antialiased, use this value to force triangles + * to overlap a bit with each other. To set the global default, set {@link PIXI.settings.MESH_CANVAS_PADDING} + * + * @see PIXI.settings.MESH_CANVAS_PADDING + * @member {number} canvasPadding + * @memberof PIXI.Mesh2d# + * @default 0 + */ +Object.defineProperty(Mesh2d.prototype, 'canvasPadding', { + get() + { + return this._canvasPadding !== null ? this._canvasPadding : settings.MESH_CANVAS_PADDING; + }, + set(value) + { + this._canvasPadding = value; + }, +}); diff --git a/bundles/pixi.js/package.json b/bundles/pixi.js/package.json index 49c7276..177e059 100644 --- a/bundles/pixi.js/package.json +++ b/bundles/pixi.js/package.json @@ -49,6 +49,7 @@ "@pixi/loaders": "^5.0.0-alpha.2", "@pixi/math": "^5.0.0-alpha.2", "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/mesh-extras": "^5.0.0-alpha.2", "@pixi/mixin-cache-as-bitmap": "^5.0.0-alpha.2", "@pixi/mixin-get-child-by-name": "^5.0.0-alpha.2", "@pixi/mixin-get-global-position": "^5.0.0-alpha.2", diff --git a/bundles/pixi.js/src/deprecated.js b/bundles/pixi.js/src/deprecated.js index 147617c..dbebeb0 100644 --- a/bundles/pixi.js/src/deprecated.js +++ b/bundles/pixi.js/src/deprecated.js @@ -263,15 +263,15 @@ Object.defineProperties(PIXI.mesh, { /** * @class PIXI.mesh.Mesh - * @see PIXI.Mesh + * @see PIXI.Mesh2d * @deprecated since 5.0.0 */ Mesh: { get() { - warn('PIXI.mesh.Mesh has moved to PIXI.Mesh'); + warn('PIXI.mesh.Mesh has moved to PIXI.Mesh2d'); - return PIXI.Mesh; + return PIXI.Mesh2d; }, }, /** @@ -315,15 +315,15 @@ }, /** * @class PIXI.mesh.RawMesh - * @see PIXI.RawMesh + * @see PIXI.Mesh * @deprecated since 5.0.0 */ RawMesh: { get() { - warn('PIXI.mesh.RawMesh has moved to PIXI.RawMesh'); + warn('PIXI.mesh.RawMesh has moved to PIXI.Mesh'); - return PIXI.RawMesh; + return PIXI.Mesh; }, }, /** diff --git a/bundles/pixi.js/src/index.js b/bundles/pixi.js/src/index.js index a3a0d1b..6fdabf0 100644 --- a/bundles/pixi.js/src/index.js +++ b/bundles/pixi.js/src/index.js @@ -9,6 +9,7 @@ import * as loaders from '@pixi/loaders'; import * as math from '@pixi/math'; import * as mesh from '@pixi/mesh'; +import * as meshExtras from '@pixi/mesh-extras'; import * as particles from '@pixi/particles'; import * as prepare from '@pixi/prepare'; import * as sprite from '@pixi/sprite'; @@ -128,6 +129,7 @@ loaders, math, mesh, + meshExtras, particles, sprite, spriteAnimated, @@ -152,6 +154,7 @@ export * from '@pixi/loaders'; export * from '@pixi/math'; export * from '@pixi/mesh'; +export * from '@pixi/mesh-extras'; export * from '@pixi/particles'; export * from '@pixi/sprite'; export * from '@pixi/spritesheet'; diff --git a/package-lock.json b/package-lock.json index 7fe6db7..0814729 100644 --- a/package-lock.json +++ b/package-lock.json @@ -209,7 +209,7 @@ "argparse": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", - "integrity": "sha1-vNZ5HqWuCXJeF+WtmIE0zUCz2RE=", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", "dev": true, "requires": { "sprintf-js": "1.0.3" @@ -228,7 +228,7 @@ "arr-flatten": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz", - "integrity": "sha1-NgSLv/TntH4TZkQxbJlmnqWukfE=", + "integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==", "dev": true }, "arr-union": { @@ -297,7 +297,7 @@ "assertion-error": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", - "integrity": "sha1-5gtrDo8wG9l+U3UhW9pAbIURjAs=", + "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", "dev": true }, "async": { @@ -396,7 +396,7 @@ "brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha1-PH/L9SnYcibz0vUrlm/1Jx60Qd0=", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, "requires": { "balanced-match": "1.0.0", @@ -568,7 +568,7 @@ "circular-json": { "version": "0.3.3", "resolved": "https://registry.npmjs.org/circular-json/-/circular-json-0.3.3.tgz", - "integrity": "sha1-gVyZ6oT2gJUp0vRXkb34JxE1LWY=", + "integrity": "sha512-UZK3NBx2Mca+b5LsG7bY183pHWt5Y1xts4P3Pz7ENTwGVnJOUWbRb3ocjvX7hx9tq/yTAdclXm9sZ38gNuem4A==", "dev": true }, "cli-cursor": { @@ -638,7 +638,7 @@ "color-convert": { "version": "1.9.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.1.tgz", - "integrity": "sha1-wSYRB66y8pTr/+ye2eytUppgl+0=", + "integrity": "sha512-mjGanIiwQJskCC18rPR6OmrZ6fm2Lc7PeGFYwCmy5J34wC6F1PzdGL6xeMfmgicfYcNLGuVFA3WzXtIDCQSZxQ==", "dev": true, "requires": { "color-name": "1.1.3" @@ -1427,7 +1427,7 @@ "boom": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/boom/-/boom-5.2.0.tgz", - "integrity": "sha1-XdnabuOl8wIHdDYpDLcX0/SlTgI=", + "integrity": "sha512-Z5BTk6ZRe4tXXQlkqftmsAUANpXmuwlsF5Oov8ThoMbQRzdGTA1ngYRW160GexgOgjsFOKJz0LYhoNi+2AMBUw==", "dev": true, "requires": { "hoek": "4.2.1" @@ -1471,7 +1471,7 @@ "debug": { "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha1-XRKFFd8TT/Mn6QpMk/Tgd6U2NB8=", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", "dev": true, "requires": { "ms": "2.0.0" @@ -1585,7 +1585,7 @@ "doctrine": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", - "integrity": "sha1-XNAfwQFiG0LEzX9dGmYkNxbT850=", + "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", "dev": true, "requires": { "esutils": "2.0.2" @@ -1662,7 +1662,7 @@ "es6-promise": { "version": "4.2.4", "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.4.tgz", - "integrity": "sha1-3EIhwrFlGHYL2MOaUtjzVvwA7Sk=", + "integrity": "sha512-/NdNZVJg+uZgtm9eS3O6lrOLYmQag2DjdEXuPaHlZ6RuVqgqaVZfgYCepEIKsLqwdQArOPtC3XzRLqGGfT8KQQ==", "dev": true }, "escape-string-regexp": { @@ -1788,7 +1788,7 @@ "espree": { "version": "3.5.4", "resolved": "https://registry.npmjs.org/espree/-/espree-3.5.4.tgz", - "integrity": "sha1-sPRHGHyKi+2US4FaZgvd9d610ac=", + "integrity": "sha512-yAcIQxtmMiB/jL32dzEp2enBeidsB7xWPLNiw3IIkpVds1P+h7qF9YwJq1yUNzp2OKXgAprs4F61ih66UsoD1A==", "dev": true, "requires": { "acorn": "5.5.0", @@ -1798,7 +1798,7 @@ "esprima": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.0.tgz", - "integrity": "sha1-RJnt3NERDgshi6zy+n9/WfVcqAQ=", + "integrity": "sha512-oftTcaMu/EGrEIu904mWteKIv8vMuOgGYo7EhVJJN00R/EED9DCua/xxHRdYnKtcECzVg7xOWhflvJMnqcFZjw==", "dev": true }, "esquery": { @@ -1813,7 +1813,7 @@ "esrecurse": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.2.1.tgz", - "integrity": "sha1-AHo7n9vCs7uH5IeeoZyS/b05Qs8=", + "integrity": "sha512-64RBB++fIOAXPw3P9cy89qfMlvZEXZkqqJkjqqXIvzP5ezRZjW+lPWjw35UX/3EhUPFYbg5ER4JYgDw4007/DQ==", "dev": true, "requires": { "estraverse": "4.2.0" @@ -2024,7 +2024,7 @@ "find-root": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/find-root/-/find-root-1.1.0.tgz", - "integrity": "sha1-q8/Iunb3CMQql7PWhbfpRQv7nOQ=", + "integrity": "sha512-NKfW6bec6GfKc0SGx1e07QZY9PE99u0Bft/0rzSD5k3sO/vwkVUpDUKVm5Gpp5Ue3YfShPFTX2070tDs5kB9Ng==", "dev": true }, "find-up": { @@ -2103,7 +2103,7 @@ "supports-color": { "version": "5.3.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.3.0.tgz", - "integrity": "sha1-WySsFduA+pJ89SJ6SjP9PEx2dsA=", + "integrity": "sha512-0aP01LLIskjKs3lq52EC0aGBAJhLq7B2Rd8HC/DR/PtNNpcLilNmHC12O+hu0usQpo7wtHNRqtrhBwtDb0+dNg==", "dev": true, "requires": { "has-flag": "3.0.0" @@ -2567,7 +2567,7 @@ "glob": { "version": "7.1.2", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", - "integrity": "sha1-wZyd+aAocC1nhhI4SmVSQExjbRU=", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", "dev": true, "requires": { "fs.realpath": "1.0.0", @@ -2672,7 +2672,7 @@ "growl": { "version": "1.10.3", "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.3.tgz", - "integrity": "sha1-GSa6kM8+3+KttJJ/WIC8IsZseQ8=", + "integrity": "sha512-hKlsbA5Vu3xsh1Cg3J7jSmX/WaW6A5oBeqzM88oNbCRQFz+zUaXm6yxS4RVytp1scBoJzSYl4YAEOQIt6O8V1Q==", "dev": true }, "handlebars": { @@ -2738,7 +2738,7 @@ "hawk": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/hawk/-/hawk-6.0.2.tgz", - "integrity": "sha1-r02RTrBl+bXOTZ0RwcshJu7MMDg=", + "integrity": "sha512-miowhl2+U7Qle4vdLqDdPt9m09K6yZhkLDTWGoUiUzrQCn+mHHSmfJgAyGaLRZbPmTqfFFjRV1QWCW0VWUJBbQ==", "dev": true, "requires": { "boom": "4.3.1", @@ -2756,7 +2756,7 @@ "hoek": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/hoek/-/hoek-4.2.1.tgz", - "integrity": "sha1-ljRQKqEsRF3Vp8VzS1cruHOKrLs=", + "integrity": "sha512-QLg82fGkfnJ/4iy1xZ81/9SIJiq1NGFUMGs6ParyjBZr6jW2Ufj/snDqTHixNlHdPNwN2RLVD0Pi3igeK9+JfA==", "dev": true }, "home-path": { @@ -2791,7 +2791,7 @@ "ignore": { "version": "3.3.7", "resolved": "https://registry.npmjs.org/ignore/-/ignore-3.3.7.tgz", - "integrity": "sha1-YSKJv7PCIOGGpYEYYY1b6MG6sCE=", + "integrity": "sha512-YGG3ejvBNHRqu0559EOxxNFihD0AjpvHlC/pdGKd3X3ofe+CoJkYazwNJYTNebqpPKN+VVQbh4ZFn1DivMNuHA==", "dev": true }, "imurmurhash": { @@ -2828,7 +2828,7 @@ "ini": { "version": "1.3.5", "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", - "integrity": "sha1-7uJfVtscnsYIXgwid4CD9Zar+Sc=", + "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==", "dev": true }, "inquirer": { @@ -2901,7 +2901,7 @@ "is-buffer": { "version": "1.1.6", "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", - "integrity": "sha1-76ouqdqg16suoTqXsritUf776L4=", + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", "dev": true }, "is-builtin-module": { @@ -3054,7 +3054,7 @@ "is-resolvable": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/is-resolvable/-/is-resolvable-1.1.0.tgz", - "integrity": "sha1-+xj4fOH+uSUWnJpAfBkxijIG7Yg=", + "integrity": "sha512-qgDYXFSR5WvEfuS5dMj6oTMEbrrSaM0CrFk2Yiq/gXnBvD9pMa2jGXxyhGLfvhZpuMZe18CJpFxAt3CRs42NMg==", "dev": true }, "is-retry-allowed": { @@ -3204,7 +3204,7 @@ "js-yaml": { "version": "3.11.0", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.11.0.tgz", - "integrity": "sha1-WXwai9VxUvJtYizkEXhRpR9euu8=", + "integrity": "sha512-saJstZWv7oNeOyBh3+Dx1qWzhW0+e6/8eDzo7p5rDFqxntSztloLtuKu+Ejhtq82jsilwOIZYsCz+lIjthg1Hw==", "dev": true, "requires": { "argparse": "1.0.10", @@ -3324,7 +3324,7 @@ "just-extend": { "version": "1.1.27", "resolved": "https://registry.npmjs.org/just-extend/-/just-extend-1.1.27.tgz", - "integrity": "sha1-7G55QQ/5FORyZSq/oOYDwD1g6QU=", + "integrity": "sha512-mJVp13Ix6gFo3SBAy9U/kL+oeZqzlYYYLQBwXVBlVzIsZwBqGREnOro24oC/8s8aox+rJhtZ2DiQof++IrkA+g==", "dev": true }, "kind-of": { @@ -3703,7 +3703,7 @@ "lodash": { "version": "4.17.5", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.5.tgz", - "integrity": "sha1-maktZcAnLevoyWtgV7yPv6O+1RE=", + "integrity": "sha512-svL3uiZf1RwhH+cWrfZn3A4+U58wbP0tGVTLQPbjplZxZ8ROD9VLuNgsRniTlLe7OlSqR79RUehXgpBW/s0IQw==", "dev": true }, "lodash._reinterpolate": { @@ -3740,7 +3740,7 @@ "lolex": { "version": "2.3.2", "resolved": "https://registry.npmjs.org/lolex/-/lolex-2.3.2.tgz", - "integrity": "sha1-hflFBCUQO/nnpgZo6iXcQydMqAc=", + "integrity": "sha512-A5pN2tkFj7H0dGIAM6MFvHKMJcPnjZsOMvR7ujCjfgW5TbV6H9vb1PgxLtHvjqNZTHsUolz+6/WEO0N1xNx2ng==", "dev": true }, "longest": { @@ -3816,7 +3816,7 @@ "marked": { "version": "0.3.17", "resolved": "https://registry.npmjs.org/marked/-/marked-0.3.17.tgz", - "integrity": "sha1-YH8GZos8axJGso8T2nYRasGqLSs=", + "integrity": "sha512-+AKbNsjZl6jFfLPwHhWmGTqE009wTKn3RTmn9K8oUKHrX/abPJjtcRtXpYB/FFrwPJRUA86LX/de3T0knkPCmQ==", "dev": true }, "mem": { @@ -3896,13 +3896,13 @@ "mime-db": { "version": "1.33.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.33.0.tgz", - "integrity": "sha1-o0kgUKXLm2NFBUHjnZeI0icng9s=", + "integrity": "sha512-BHJ/EKruNIqJf/QahvxwQZXKygOQ256myeN/Ew+THcAa5q+PjyTTMMeNQC4DZw5AwfvelsUrA6B67NKMqXDbzQ==", "dev": true }, "mime-types": { "version": "2.1.18", "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.18.tgz", - "integrity": "sha1-bzI/YKg9ERRvgx/xH9ZuL+VQO7g=", + "integrity": "sha512-lc/aahn+t4/SWV/qcmumYjymLsWfN3ELhpmVuUFjgsORruuZPVSwAQryq+HHGvO/SI2KVX26bx+En+zhM8g8hQ==", "dev": true, "requires": { "mime-db": "1.33.0" @@ -3917,7 +3917,7 @@ "minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha1-UWbihkV/AzBgZL5Ul+jbsMPTIIM=", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "dev": true, "requires": { "brace-expansion": "1.1.11" @@ -4071,7 +4071,7 @@ "normalize-package-data": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.4.0.tgz", - "integrity": "sha1-EvlaMH1YNSB1oEkHuErIvpisAS8=", + "integrity": "sha512-9jjUFbTPfEy3R/ad/2oNbKtW9Hgovl5O1FvFWKkKblNXoN/Oou6+9+KKohPK13Yc3/TyunyWhJp6gvRNR/PPAw==", "dev": true, "requires": { "hosted-git-info": "2.5.0", @@ -4511,7 +4511,7 @@ "process-nextick-args": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", - "integrity": "sha1-o31zL0JxtKsa0HDTVQjoKQeI/6o=", + "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==", "dev": true }, "progress": { @@ -4584,7 +4584,7 @@ "qs": { "version": "6.5.1", "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.1.tgz", - "integrity": "sha1-NJzfbu+J7EXBLX1es/wMhwNDptg=", + "integrity": "sha512-eRzhrN1WSINYCDCbrz796z37LOe3m5tmW7RQf6oBntukAG1nmovJvhnwHHRMAfeoItc1m2Hk02WER2aQ/iqs+A==", "dev": true }, "quick-lru": { @@ -4596,7 +4596,7 @@ "randomatic": { "version": "1.1.7", "resolved": "https://registry.npmjs.org/randomatic/-/randomatic-1.1.7.tgz", - "integrity": "sha1-x6vpzIuHwLqodrGf3oP9RkeX44w=", + "integrity": "sha512-D5JUjPyJbaJDkuAazpVnSfVkLlpeO3wDlPROTMLGKG1zMFNFRgrciKo1ltz/AzNTkqE0HzDx655QOL51N06how==", "dev": true, "requires": { "is-number": "3.0.0", @@ -4701,7 +4701,7 @@ "regex-cache": { "version": "0.4.4", "resolved": "https://registry.npmjs.org/regex-cache/-/regex-cache-0.4.4.tgz", - "integrity": "sha1-db3FiioUls7EihKDW8VMjVYjNt0=", + "integrity": "sha512-nVIZwtCjkC9YgvWkpM55B5rBhBYRZhAaJbgcFYXXsHnbZ9UZI9nnVWYZpBlCqv9ho2eZryPnWrZGsOdPwVWXWQ==", "dev": true, "requires": { "is-equal-shallow": "0.1.3" @@ -4729,7 +4729,7 @@ "remap-istanbul": { "version": "0.10.1", "resolved": "https://registry.npmjs.org/remap-istanbul/-/remap-istanbul-0.10.1.tgz", - "integrity": "sha1-OqWN1QIdSZ8zbTulvzu7kcG4jjc=", + "integrity": "sha512-gsNQXs5kJLhErICSyYhzVZ++C8LBW8dgwr874Y2QvzAUS75zBlD/juZgXs39nbYJ09fZDlX2AVLVJAY2jbFJoQ==", "dev": true, "requires": { "amdefine": "1.0.1", @@ -4769,7 +4769,7 @@ "source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha1-dHIq8y6WFOnCh6jQu95IteLxomM=", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", "dev": true }, "through2": { @@ -4883,7 +4883,7 @@ "resolve": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.5.0.tgz", - "integrity": "sha1-HwmsznlsmnYlefMbLBzEw83fnzY=", + "integrity": "sha512-hgoSGrc3pjzAPHNBg+KnFcK2HwlHTs/YrAGUr6qgTVUZmXv1UEXXl0bZNBKMA9fud6lRYFdPGz0xXxycPzmmiw==", "dev": true, "requires": { "path-parse": "1.0.5" @@ -4924,7 +4924,7 @@ "rimraf": { "version": "2.6.2", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", - "integrity": "sha1-LtgVDSShbqhlHm1u8PR8QVjOejY=", + "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", "dev": true, "requires": { "glob": "7.1.2" @@ -5063,19 +5063,19 @@ "safe-buffer": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", - "integrity": "sha1-iTMSr2myEj3vcfV4iQAWce6yyFM=", + "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", "dev": true }, "samsam": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/samsam/-/samsam-1.3.0.tgz", - "integrity": "sha1-jR2TUOJWItow3j5EumkrUiGrfFA=", + "integrity": "sha512-1HwIYD/8UlOtFS3QO3w7ey+SdSDFE4HRNLZoZRYVQefrOY3l17epswImeB1ijgJFQJodIaHcwkp3r/myBjFVbg==", "dev": true }, "semver": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz", - "integrity": "sha1-3Eu8emyp2Rbe5dQ1FvAJK1j3uKs=", + "integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==", "dev": true }, "set-blocking": { @@ -5117,7 +5117,7 @@ "sinon-chai": { "version": "2.14.0", "resolved": "https://registry.npmjs.org/sinon-chai/-/sinon-chai-2.14.0.tgz", - "integrity": "sha1-2n3UzIPNaiYLZ8yg96n9riahIF0=", + "integrity": "sha512-9stIF1utB0ywNHNT7RgiXbdmen8QDCRsrTjw+G9TgKt1Yexjiv8TOWZ6WHsTPz57Yky3DIswZvEqX8fpuHNDtQ==", "dev": true }, "slash": { @@ -5146,7 +5146,7 @@ "sntp": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/sntp/-/sntp-2.1.0.tgz", - "integrity": "sha1-LGzsFP7cIiJznK+bXD2F0cxaLMg=", + "integrity": "sha512-FL1b58BDrqS3A11lJ0zEdnJ3UOKqVxawAkF3k7F0CVN7VQ34aZrV+G8BZ1WC9ZL7NyrwsW0oviwsWDgRuVYtJg==", "dev": true, "requires": { "hoek": "4.2.1" @@ -5203,7 +5203,7 @@ "spdx-correct": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.0.0.tgz", - "integrity": "sha1-BaW01xU6GVvJLDxCW2nzsqlSTII=", + "integrity": "sha512-N19o9z5cEyc8yQQPukRCZ9EUmb4HUpnrmaL/fxS2pBo2jbfcFRVuFZ/oFC+vZz0MNNk0h80iMn5/S6qGZOL5+g==", "dev": true, "requires": { "spdx-expression-parse": "3.0.0", @@ -5213,13 +5213,13 @@ "spdx-exceptions": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.1.0.tgz", - "integrity": "sha1-LHrmEFbHFKW5ubKyr30xHvXHj+k=", + "integrity": "sha512-4K1NsmrlCU1JJgUrtgEeTVyfx8VaYea9J9LvARxhbHtVtohPs/gFGG5yy49beySjlIMhhXZ4QqujIZEfS4l6Cg==", "dev": true }, "spdx-expression-parse": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.0.tgz", - "integrity": "sha1-meEZt6XaAOBUkcn6M4t5BII7QdA=", + "integrity": "sha512-Yg6D3XpRD4kkOmTpdgbUiEJFKghJH03fiC1OPll5h/0sO6neh2jqRDVHOQ4o/LMea0tgCkbMgea5ip/e+MkWyg==", "dev": true, "requires": { "spdx-exceptions": "2.1.0", @@ -5229,7 +5229,7 @@ "spdx-license-ids": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.0.tgz", - "integrity": "sha1-enzShHDMbToc/m1miG9rxDDTrIc=", + "integrity": "sha512-2+EPwgbnmOIl8HjGBXXMd9NAu02vLjOO1nWw4kmeRDFyHn+M/ETfHxQUK0oXg8ctgVnl9t3rosNVsZ1jG61nDA==", "dev": true }, "speedometer": { @@ -5566,7 +5566,7 @@ "tough-cookie": { "version": "2.3.4", "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.4.tgz", - "integrity": "sha1-7GDO44rGdQY//JelwYlwV47oNlU=", + "integrity": "sha512-TZ6TTfI5NtZnuyy/Kecv+CnoROnyXn2DN97LontgQpCwsX2XyLYCC0ENhYkehSOwAp8rTQKc/NUIF7BkQ5rKLA==", "dev": true, "requires": { "punycode": "1.4.1" @@ -5708,13 +5708,13 @@ "uuid": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.2.1.tgz", - "integrity": "sha1-EsUou51Y0LkmXZovbw/ovhf/HxQ=", + "integrity": "sha512-jZnMwlb9Iku/O3smGWvZhauCf6cvvpKi4BKRiliS3cxnI+Gz9j5MEpTz2UFuXiKPJocb7gnsLHwiS05ige5BEA==", "dev": true }, "validate-npm-package-license": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.3.tgz", - "integrity": "sha1-gWQ7y+8b3+zUYjeT3EZIlIupgzg=", + "integrity": "sha512-63ZOUnL4SIXj4L0NixR3L1lcjO38crAbgrTpl28t8jjrfuiOBL5Iygm+60qPs/KsZGzPNg6Smnc/oY16QTjF0g==", "dev": true, "requires": { "spdx-correct": "3.0.0", @@ -5750,7 +5750,7 @@ "which": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/which/-/which-1.3.0.tgz", - "integrity": "sha1-/wS9/AEO5UfXgL7DjhrBwnd9JTo=", + "integrity": "sha512-xcJpopdamTuY5duC/KnTTNBraPK54YwpenP4lzxU8H91GudWpFv38u0CKjclE1Wi2EH2EDz5LRcHcKbCIzqGyg==", "dev": true, "requires": { "isexe": "2.0.0" diff --git a/packages/canvas/canvas-mesh/package.json b/packages/canvas/canvas-mesh/package.json index 691cd2c..6744a17 100644 --- a/packages/canvas/canvas-mesh/package.json +++ b/packages/canvas/canvas-mesh/package.json @@ -24,6 +24,7 @@ "dependencies": { "@pixi/constants": "^5.0.0-alpha.2", "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/mesh-extras": "^5.0.0-alpha.2", "@pixi/settings": "^5.0.0-alpha.2" }, "devDependencies": { diff --git a/packages/canvas/canvas-mesh/src/Mesh.js b/packages/canvas/canvas-mesh/src/Mesh.js index 900a872..c43a74b 100644 --- a/packages/canvas/canvas-mesh/src/Mesh.js +++ b/packages/canvas/canvas-mesh/src/Mesh.js @@ -1,36 +1,14 @@ import { Mesh } from '@pixi/mesh'; -import { settings } from './settings'; - -// IMPORTANT: Please do NOT use this as a precedent to use `settings` after the object is created -// this was merely created to completely decouple canvas from the base Mesh class and we are -// unable to add `canvasPadding` in the constructor anymore, as the case was for PixiJS v4. /** - * Internal variable for `canvasPadding`. + * Renders the object using the Canvas renderer * * @private - * @memberof PIXI.Mesh - * @member {number} - * @default null - */ -Mesh.prototype._canvasPadding = null; - -/** - * Triangles in canvas mode are automatically antialiased, use this value to force triangles - * to overlap a bit with each other. To set the global default, set {@link PIXI.settings.MESH_CANVAS_PADDING} - * - * @see PIXI.settings.MESH_CANVAS_PADDING - * @member {number} canvasPadding + * @method _renderCanvas * @memberof PIXI.Mesh# - * @default 0 + * @param {PIXI.CanvasRenderer} renderer - The canvas renderer. */ -Object.defineProperty(Mesh.prototype, 'canvasPadding', { - get() - { - return this._canvasPadding !== null ? this._canvasPadding : settings.MESH_CANVAS_PADDING; - }, - set(value) - { - this._canvasPadding = value; - }, -}); +Mesh.prototype._renderCanvas = function _renderCanvas(renderer) +{ + renderer.plugins[this.pluginName].render(this); +}; diff --git a/packages/canvas/canvas-mesh/src/Mesh2d.js b/packages/canvas/canvas-mesh/src/Mesh2d.js new file mode 100644 index 0000000..d0bd80f --- /dev/null +++ b/packages/canvas/canvas-mesh/src/Mesh2d.js @@ -0,0 +1,36 @@ +import { Mesh2d } from '@pixi/mesh-extras'; +import { settings } from './settings'; + +// IMPORTANT: Please do NOT use this as a precedent to use `settings` after the object is created +// this was merely created to completely decouple canvas from the base Mesh class and we are +// unable to add `canvasPadding` in the constructor anymore, as the case was for PixiJS v4. + +/** + * Internal variable for `canvasPadding`. + * + * @private + * @memberof PIXI.Mesh2d + * @member {number} + * @default null + */ +Mesh2d.prototype._canvasPadding = null; + +/** + * Triangles in canvas mode are automatically antialiased, use this value to force triangles + * to overlap a bit with each other. To set the global default, set {@link PIXI.settings.MESH_CANVAS_PADDING} + * + * @see PIXI.settings.MESH_CANVAS_PADDING + * @member {number} canvasPadding + * @memberof PIXI.Mesh2d# + * @default 0 + */ +Object.defineProperty(Mesh2d.prototype, 'canvasPadding', { + get() + { + return this._canvasPadding !== null ? this._canvasPadding : settings.MESH_CANVAS_PADDING; + }, + set(value) + { + this._canvasPadding = value; + }, +}); diff --git a/packages/canvas/canvas-mesh/src/NineSlicePlane.js b/packages/canvas/canvas-mesh/src/NineSlicePlane.js index 09eaf9c..2fd5acc 100644 --- a/packages/canvas/canvas-mesh/src/NineSlicePlane.js +++ b/packages/canvas/canvas-mesh/src/NineSlicePlane.js @@ -1,4 +1,4 @@ -import { NineSlicePlane } from '@pixi/mesh'; +import { NineSlicePlane } from '@pixi/mesh-extras'; /** * Renders the object using the Canvas renderer diff --git a/bundles/pixi.js/package.json b/bundles/pixi.js/package.json index 49c7276..177e059 100644 --- a/bundles/pixi.js/package.json +++ b/bundles/pixi.js/package.json @@ -49,6 +49,7 @@ "@pixi/loaders": "^5.0.0-alpha.2", "@pixi/math": "^5.0.0-alpha.2", "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/mesh-extras": "^5.0.0-alpha.2", "@pixi/mixin-cache-as-bitmap": "^5.0.0-alpha.2", "@pixi/mixin-get-child-by-name": "^5.0.0-alpha.2", "@pixi/mixin-get-global-position": "^5.0.0-alpha.2", diff --git a/bundles/pixi.js/src/deprecated.js b/bundles/pixi.js/src/deprecated.js index 147617c..dbebeb0 100644 --- a/bundles/pixi.js/src/deprecated.js +++ b/bundles/pixi.js/src/deprecated.js @@ -263,15 +263,15 @@ Object.defineProperties(PIXI.mesh, { /** * @class PIXI.mesh.Mesh - * @see PIXI.Mesh + * @see PIXI.Mesh2d * @deprecated since 5.0.0 */ Mesh: { get() { - warn('PIXI.mesh.Mesh has moved to PIXI.Mesh'); + warn('PIXI.mesh.Mesh has moved to PIXI.Mesh2d'); - return PIXI.Mesh; + return PIXI.Mesh2d; }, }, /** @@ -315,15 +315,15 @@ }, /** * @class PIXI.mesh.RawMesh - * @see PIXI.RawMesh + * @see PIXI.Mesh * @deprecated since 5.0.0 */ RawMesh: { get() { - warn('PIXI.mesh.RawMesh has moved to PIXI.RawMesh'); + warn('PIXI.mesh.RawMesh has moved to PIXI.Mesh'); - return PIXI.RawMesh; + return PIXI.Mesh; }, }, /** diff --git a/bundles/pixi.js/src/index.js b/bundles/pixi.js/src/index.js index a3a0d1b..6fdabf0 100644 --- a/bundles/pixi.js/src/index.js +++ b/bundles/pixi.js/src/index.js @@ -9,6 +9,7 @@ import * as loaders from '@pixi/loaders'; import * as math from '@pixi/math'; import * as mesh from '@pixi/mesh'; +import * as meshExtras from '@pixi/mesh-extras'; import * as particles from '@pixi/particles'; import * as prepare from '@pixi/prepare'; import * as sprite from '@pixi/sprite'; @@ -128,6 +129,7 @@ loaders, math, mesh, + meshExtras, particles, sprite, spriteAnimated, @@ -152,6 +154,7 @@ export * from '@pixi/loaders'; export * from '@pixi/math'; export * from '@pixi/mesh'; +export * from '@pixi/mesh-extras'; export * from '@pixi/particles'; export * from '@pixi/sprite'; export * from '@pixi/spritesheet'; diff --git a/package-lock.json b/package-lock.json index 7fe6db7..0814729 100644 --- a/package-lock.json +++ b/package-lock.json @@ -209,7 +209,7 @@ "argparse": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", - "integrity": "sha1-vNZ5HqWuCXJeF+WtmIE0zUCz2RE=", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", "dev": true, "requires": { "sprintf-js": "1.0.3" @@ -228,7 +228,7 @@ "arr-flatten": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz", - "integrity": "sha1-NgSLv/TntH4TZkQxbJlmnqWukfE=", + "integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==", "dev": true }, "arr-union": { @@ -297,7 +297,7 @@ "assertion-error": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", - "integrity": "sha1-5gtrDo8wG9l+U3UhW9pAbIURjAs=", + "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", "dev": true }, "async": { @@ -396,7 +396,7 @@ "brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha1-PH/L9SnYcibz0vUrlm/1Jx60Qd0=", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, "requires": { "balanced-match": "1.0.0", @@ -568,7 +568,7 @@ "circular-json": { "version": "0.3.3", "resolved": "https://registry.npmjs.org/circular-json/-/circular-json-0.3.3.tgz", - "integrity": "sha1-gVyZ6oT2gJUp0vRXkb34JxE1LWY=", + "integrity": "sha512-UZK3NBx2Mca+b5LsG7bY183pHWt5Y1xts4P3Pz7ENTwGVnJOUWbRb3ocjvX7hx9tq/yTAdclXm9sZ38gNuem4A==", "dev": true }, "cli-cursor": { @@ -638,7 +638,7 @@ "color-convert": { "version": "1.9.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.1.tgz", - "integrity": "sha1-wSYRB66y8pTr/+ye2eytUppgl+0=", + "integrity": "sha512-mjGanIiwQJskCC18rPR6OmrZ6fm2Lc7PeGFYwCmy5J34wC6F1PzdGL6xeMfmgicfYcNLGuVFA3WzXtIDCQSZxQ==", "dev": true, "requires": { "color-name": "1.1.3" @@ -1427,7 +1427,7 @@ "boom": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/boom/-/boom-5.2.0.tgz", - "integrity": "sha1-XdnabuOl8wIHdDYpDLcX0/SlTgI=", + "integrity": "sha512-Z5BTk6ZRe4tXXQlkqftmsAUANpXmuwlsF5Oov8ThoMbQRzdGTA1ngYRW160GexgOgjsFOKJz0LYhoNi+2AMBUw==", "dev": true, "requires": { "hoek": "4.2.1" @@ -1471,7 +1471,7 @@ "debug": { "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha1-XRKFFd8TT/Mn6QpMk/Tgd6U2NB8=", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", "dev": true, "requires": { "ms": "2.0.0" @@ -1585,7 +1585,7 @@ "doctrine": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", - "integrity": "sha1-XNAfwQFiG0LEzX9dGmYkNxbT850=", + "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", "dev": true, "requires": { "esutils": "2.0.2" @@ -1662,7 +1662,7 @@ "es6-promise": { "version": "4.2.4", "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.4.tgz", - "integrity": "sha1-3EIhwrFlGHYL2MOaUtjzVvwA7Sk=", + "integrity": "sha512-/NdNZVJg+uZgtm9eS3O6lrOLYmQag2DjdEXuPaHlZ6RuVqgqaVZfgYCepEIKsLqwdQArOPtC3XzRLqGGfT8KQQ==", "dev": true }, "escape-string-regexp": { @@ -1788,7 +1788,7 @@ "espree": { "version": "3.5.4", "resolved": "https://registry.npmjs.org/espree/-/espree-3.5.4.tgz", - "integrity": "sha1-sPRHGHyKi+2US4FaZgvd9d610ac=", + "integrity": "sha512-yAcIQxtmMiB/jL32dzEp2enBeidsB7xWPLNiw3IIkpVds1P+h7qF9YwJq1yUNzp2OKXgAprs4F61ih66UsoD1A==", "dev": true, "requires": { "acorn": "5.5.0", @@ -1798,7 +1798,7 @@ "esprima": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.0.tgz", - "integrity": "sha1-RJnt3NERDgshi6zy+n9/WfVcqAQ=", + "integrity": "sha512-oftTcaMu/EGrEIu904mWteKIv8vMuOgGYo7EhVJJN00R/EED9DCua/xxHRdYnKtcECzVg7xOWhflvJMnqcFZjw==", "dev": true }, "esquery": { @@ -1813,7 +1813,7 @@ "esrecurse": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.2.1.tgz", - "integrity": "sha1-AHo7n9vCs7uH5IeeoZyS/b05Qs8=", + "integrity": "sha512-64RBB++fIOAXPw3P9cy89qfMlvZEXZkqqJkjqqXIvzP5ezRZjW+lPWjw35UX/3EhUPFYbg5ER4JYgDw4007/DQ==", "dev": true, "requires": { "estraverse": "4.2.0" @@ -2024,7 +2024,7 @@ "find-root": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/find-root/-/find-root-1.1.0.tgz", - "integrity": "sha1-q8/Iunb3CMQql7PWhbfpRQv7nOQ=", + "integrity": "sha512-NKfW6bec6GfKc0SGx1e07QZY9PE99u0Bft/0rzSD5k3sO/vwkVUpDUKVm5Gpp5Ue3YfShPFTX2070tDs5kB9Ng==", "dev": true }, "find-up": { @@ -2103,7 +2103,7 @@ "supports-color": { "version": "5.3.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.3.0.tgz", - "integrity": "sha1-WySsFduA+pJ89SJ6SjP9PEx2dsA=", + "integrity": "sha512-0aP01LLIskjKs3lq52EC0aGBAJhLq7B2Rd8HC/DR/PtNNpcLilNmHC12O+hu0usQpo7wtHNRqtrhBwtDb0+dNg==", "dev": true, "requires": { "has-flag": "3.0.0" @@ -2567,7 +2567,7 @@ "glob": { "version": "7.1.2", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", - "integrity": "sha1-wZyd+aAocC1nhhI4SmVSQExjbRU=", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", "dev": true, "requires": { "fs.realpath": "1.0.0", @@ -2672,7 +2672,7 @@ "growl": { "version": "1.10.3", "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.3.tgz", - "integrity": "sha1-GSa6kM8+3+KttJJ/WIC8IsZseQ8=", + "integrity": "sha512-hKlsbA5Vu3xsh1Cg3J7jSmX/WaW6A5oBeqzM88oNbCRQFz+zUaXm6yxS4RVytp1scBoJzSYl4YAEOQIt6O8V1Q==", "dev": true }, "handlebars": { @@ -2738,7 +2738,7 @@ "hawk": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/hawk/-/hawk-6.0.2.tgz", - "integrity": "sha1-r02RTrBl+bXOTZ0RwcshJu7MMDg=", + "integrity": "sha512-miowhl2+U7Qle4vdLqDdPt9m09K6yZhkLDTWGoUiUzrQCn+mHHSmfJgAyGaLRZbPmTqfFFjRV1QWCW0VWUJBbQ==", "dev": true, "requires": { "boom": "4.3.1", @@ -2756,7 +2756,7 @@ "hoek": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/hoek/-/hoek-4.2.1.tgz", - "integrity": "sha1-ljRQKqEsRF3Vp8VzS1cruHOKrLs=", + "integrity": "sha512-QLg82fGkfnJ/4iy1xZ81/9SIJiq1NGFUMGs6ParyjBZr6jW2Ufj/snDqTHixNlHdPNwN2RLVD0Pi3igeK9+JfA==", "dev": true }, "home-path": { @@ -2791,7 +2791,7 @@ "ignore": { "version": "3.3.7", "resolved": "https://registry.npmjs.org/ignore/-/ignore-3.3.7.tgz", - "integrity": "sha1-YSKJv7PCIOGGpYEYYY1b6MG6sCE=", + "integrity": "sha512-YGG3ejvBNHRqu0559EOxxNFihD0AjpvHlC/pdGKd3X3ofe+CoJkYazwNJYTNebqpPKN+VVQbh4ZFn1DivMNuHA==", "dev": true }, "imurmurhash": { @@ -2828,7 +2828,7 @@ "ini": { "version": "1.3.5", "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", - "integrity": "sha1-7uJfVtscnsYIXgwid4CD9Zar+Sc=", + "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==", "dev": true }, "inquirer": { @@ -2901,7 +2901,7 @@ "is-buffer": { "version": "1.1.6", "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", - "integrity": "sha1-76ouqdqg16suoTqXsritUf776L4=", + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", "dev": true }, "is-builtin-module": { @@ -3054,7 +3054,7 @@ "is-resolvable": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/is-resolvable/-/is-resolvable-1.1.0.tgz", - "integrity": "sha1-+xj4fOH+uSUWnJpAfBkxijIG7Yg=", + "integrity": "sha512-qgDYXFSR5WvEfuS5dMj6oTMEbrrSaM0CrFk2Yiq/gXnBvD9pMa2jGXxyhGLfvhZpuMZe18CJpFxAt3CRs42NMg==", "dev": true }, "is-retry-allowed": { @@ -3204,7 +3204,7 @@ "js-yaml": { "version": "3.11.0", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.11.0.tgz", - "integrity": "sha1-WXwai9VxUvJtYizkEXhRpR9euu8=", + "integrity": "sha512-saJstZWv7oNeOyBh3+Dx1qWzhW0+e6/8eDzo7p5rDFqxntSztloLtuKu+Ejhtq82jsilwOIZYsCz+lIjthg1Hw==", "dev": true, "requires": { "argparse": "1.0.10", @@ -3324,7 +3324,7 @@ "just-extend": { "version": "1.1.27", "resolved": "https://registry.npmjs.org/just-extend/-/just-extend-1.1.27.tgz", - "integrity": "sha1-7G55QQ/5FORyZSq/oOYDwD1g6QU=", + "integrity": "sha512-mJVp13Ix6gFo3SBAy9U/kL+oeZqzlYYYLQBwXVBlVzIsZwBqGREnOro24oC/8s8aox+rJhtZ2DiQof++IrkA+g==", "dev": true }, "kind-of": { @@ -3703,7 +3703,7 @@ "lodash": { "version": "4.17.5", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.5.tgz", - "integrity": "sha1-maktZcAnLevoyWtgV7yPv6O+1RE=", + "integrity": "sha512-svL3uiZf1RwhH+cWrfZn3A4+U58wbP0tGVTLQPbjplZxZ8ROD9VLuNgsRniTlLe7OlSqR79RUehXgpBW/s0IQw==", "dev": true }, "lodash._reinterpolate": { @@ -3740,7 +3740,7 @@ "lolex": { "version": "2.3.2", "resolved": "https://registry.npmjs.org/lolex/-/lolex-2.3.2.tgz", - "integrity": "sha1-hflFBCUQO/nnpgZo6iXcQydMqAc=", + "integrity": "sha512-A5pN2tkFj7H0dGIAM6MFvHKMJcPnjZsOMvR7ujCjfgW5TbV6H9vb1PgxLtHvjqNZTHsUolz+6/WEO0N1xNx2ng==", "dev": true }, "longest": { @@ -3816,7 +3816,7 @@ "marked": { "version": "0.3.17", "resolved": "https://registry.npmjs.org/marked/-/marked-0.3.17.tgz", - "integrity": "sha1-YH8GZos8axJGso8T2nYRasGqLSs=", + "integrity": "sha512-+AKbNsjZl6jFfLPwHhWmGTqE009wTKn3RTmn9K8oUKHrX/abPJjtcRtXpYB/FFrwPJRUA86LX/de3T0knkPCmQ==", "dev": true }, "mem": { @@ -3896,13 +3896,13 @@ "mime-db": { "version": "1.33.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.33.0.tgz", - "integrity": "sha1-o0kgUKXLm2NFBUHjnZeI0icng9s=", + "integrity": "sha512-BHJ/EKruNIqJf/QahvxwQZXKygOQ256myeN/Ew+THcAa5q+PjyTTMMeNQC4DZw5AwfvelsUrA6B67NKMqXDbzQ==", "dev": true }, "mime-types": { "version": "2.1.18", "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.18.tgz", - "integrity": "sha1-bzI/YKg9ERRvgx/xH9ZuL+VQO7g=", + "integrity": "sha512-lc/aahn+t4/SWV/qcmumYjymLsWfN3ELhpmVuUFjgsORruuZPVSwAQryq+HHGvO/SI2KVX26bx+En+zhM8g8hQ==", "dev": true, "requires": { "mime-db": "1.33.0" @@ -3917,7 +3917,7 @@ "minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha1-UWbihkV/AzBgZL5Ul+jbsMPTIIM=", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "dev": true, "requires": { "brace-expansion": "1.1.11" @@ -4071,7 +4071,7 @@ "normalize-package-data": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.4.0.tgz", - "integrity": "sha1-EvlaMH1YNSB1oEkHuErIvpisAS8=", + "integrity": "sha512-9jjUFbTPfEy3R/ad/2oNbKtW9Hgovl5O1FvFWKkKblNXoN/Oou6+9+KKohPK13Yc3/TyunyWhJp6gvRNR/PPAw==", "dev": true, "requires": { "hosted-git-info": "2.5.0", @@ -4511,7 +4511,7 @@ "process-nextick-args": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", - "integrity": "sha1-o31zL0JxtKsa0HDTVQjoKQeI/6o=", + "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==", "dev": true }, "progress": { @@ -4584,7 +4584,7 @@ "qs": { "version": "6.5.1", "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.1.tgz", - "integrity": "sha1-NJzfbu+J7EXBLX1es/wMhwNDptg=", + "integrity": "sha512-eRzhrN1WSINYCDCbrz796z37LOe3m5tmW7RQf6oBntukAG1nmovJvhnwHHRMAfeoItc1m2Hk02WER2aQ/iqs+A==", "dev": true }, "quick-lru": { @@ -4596,7 +4596,7 @@ "randomatic": { "version": "1.1.7", "resolved": "https://registry.npmjs.org/randomatic/-/randomatic-1.1.7.tgz", - "integrity": "sha1-x6vpzIuHwLqodrGf3oP9RkeX44w=", + "integrity": "sha512-D5JUjPyJbaJDkuAazpVnSfVkLlpeO3wDlPROTMLGKG1zMFNFRgrciKo1ltz/AzNTkqE0HzDx655QOL51N06how==", "dev": true, "requires": { "is-number": "3.0.0", @@ -4701,7 +4701,7 @@ "regex-cache": { "version": "0.4.4", "resolved": "https://registry.npmjs.org/regex-cache/-/regex-cache-0.4.4.tgz", - "integrity": "sha1-db3FiioUls7EihKDW8VMjVYjNt0=", + "integrity": "sha512-nVIZwtCjkC9YgvWkpM55B5rBhBYRZhAaJbgcFYXXsHnbZ9UZI9nnVWYZpBlCqv9ho2eZryPnWrZGsOdPwVWXWQ==", "dev": true, "requires": { "is-equal-shallow": "0.1.3" @@ -4729,7 +4729,7 @@ "remap-istanbul": { "version": "0.10.1", "resolved": "https://registry.npmjs.org/remap-istanbul/-/remap-istanbul-0.10.1.tgz", - "integrity": "sha1-OqWN1QIdSZ8zbTulvzu7kcG4jjc=", + "integrity": "sha512-gsNQXs5kJLhErICSyYhzVZ++C8LBW8dgwr874Y2QvzAUS75zBlD/juZgXs39nbYJ09fZDlX2AVLVJAY2jbFJoQ==", "dev": true, "requires": { "amdefine": "1.0.1", @@ -4769,7 +4769,7 @@ "source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha1-dHIq8y6WFOnCh6jQu95IteLxomM=", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", "dev": true }, "through2": { @@ -4883,7 +4883,7 @@ "resolve": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.5.0.tgz", - "integrity": "sha1-HwmsznlsmnYlefMbLBzEw83fnzY=", + "integrity": "sha512-hgoSGrc3pjzAPHNBg+KnFcK2HwlHTs/YrAGUr6qgTVUZmXv1UEXXl0bZNBKMA9fud6lRYFdPGz0xXxycPzmmiw==", "dev": true, "requires": { "path-parse": "1.0.5" @@ -4924,7 +4924,7 @@ "rimraf": { "version": "2.6.2", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", - "integrity": "sha1-LtgVDSShbqhlHm1u8PR8QVjOejY=", + "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", "dev": true, "requires": { "glob": "7.1.2" @@ -5063,19 +5063,19 @@ "safe-buffer": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", - "integrity": "sha1-iTMSr2myEj3vcfV4iQAWce6yyFM=", + "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", "dev": true }, "samsam": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/samsam/-/samsam-1.3.0.tgz", - "integrity": "sha1-jR2TUOJWItow3j5EumkrUiGrfFA=", + "integrity": "sha512-1HwIYD/8UlOtFS3QO3w7ey+SdSDFE4HRNLZoZRYVQefrOY3l17epswImeB1ijgJFQJodIaHcwkp3r/myBjFVbg==", "dev": true }, "semver": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz", - "integrity": "sha1-3Eu8emyp2Rbe5dQ1FvAJK1j3uKs=", + "integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==", "dev": true }, "set-blocking": { @@ -5117,7 +5117,7 @@ "sinon-chai": { "version": "2.14.0", "resolved": "https://registry.npmjs.org/sinon-chai/-/sinon-chai-2.14.0.tgz", - "integrity": "sha1-2n3UzIPNaiYLZ8yg96n9riahIF0=", + "integrity": "sha512-9stIF1utB0ywNHNT7RgiXbdmen8QDCRsrTjw+G9TgKt1Yexjiv8TOWZ6WHsTPz57Yky3DIswZvEqX8fpuHNDtQ==", "dev": true }, "slash": { @@ -5146,7 +5146,7 @@ "sntp": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/sntp/-/sntp-2.1.0.tgz", - "integrity": "sha1-LGzsFP7cIiJznK+bXD2F0cxaLMg=", + "integrity": "sha512-FL1b58BDrqS3A11lJ0zEdnJ3UOKqVxawAkF3k7F0CVN7VQ34aZrV+G8BZ1WC9ZL7NyrwsW0oviwsWDgRuVYtJg==", "dev": true, "requires": { "hoek": "4.2.1" @@ -5203,7 +5203,7 @@ "spdx-correct": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.0.0.tgz", - "integrity": "sha1-BaW01xU6GVvJLDxCW2nzsqlSTII=", + "integrity": "sha512-N19o9z5cEyc8yQQPukRCZ9EUmb4HUpnrmaL/fxS2pBo2jbfcFRVuFZ/oFC+vZz0MNNk0h80iMn5/S6qGZOL5+g==", "dev": true, "requires": { "spdx-expression-parse": "3.0.0", @@ -5213,13 +5213,13 @@ "spdx-exceptions": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.1.0.tgz", - "integrity": "sha1-LHrmEFbHFKW5ubKyr30xHvXHj+k=", + "integrity": "sha512-4K1NsmrlCU1JJgUrtgEeTVyfx8VaYea9J9LvARxhbHtVtohPs/gFGG5yy49beySjlIMhhXZ4QqujIZEfS4l6Cg==", "dev": true }, "spdx-expression-parse": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.0.tgz", - "integrity": "sha1-meEZt6XaAOBUkcn6M4t5BII7QdA=", + "integrity": "sha512-Yg6D3XpRD4kkOmTpdgbUiEJFKghJH03fiC1OPll5h/0sO6neh2jqRDVHOQ4o/LMea0tgCkbMgea5ip/e+MkWyg==", "dev": true, "requires": { "spdx-exceptions": "2.1.0", @@ -5229,7 +5229,7 @@ "spdx-license-ids": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.0.tgz", - "integrity": "sha1-enzShHDMbToc/m1miG9rxDDTrIc=", + "integrity": "sha512-2+EPwgbnmOIl8HjGBXXMd9NAu02vLjOO1nWw4kmeRDFyHn+M/ETfHxQUK0oXg8ctgVnl9t3rosNVsZ1jG61nDA==", "dev": true }, "speedometer": { @@ -5566,7 +5566,7 @@ "tough-cookie": { "version": "2.3.4", "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.4.tgz", - "integrity": "sha1-7GDO44rGdQY//JelwYlwV47oNlU=", + "integrity": "sha512-TZ6TTfI5NtZnuyy/Kecv+CnoROnyXn2DN97LontgQpCwsX2XyLYCC0ENhYkehSOwAp8rTQKc/NUIF7BkQ5rKLA==", "dev": true, "requires": { "punycode": "1.4.1" @@ -5708,13 +5708,13 @@ "uuid": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.2.1.tgz", - "integrity": "sha1-EsUou51Y0LkmXZovbw/ovhf/HxQ=", + "integrity": "sha512-jZnMwlb9Iku/O3smGWvZhauCf6cvvpKi4BKRiliS3cxnI+Gz9j5MEpTz2UFuXiKPJocb7gnsLHwiS05ige5BEA==", "dev": true }, "validate-npm-package-license": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.3.tgz", - "integrity": "sha1-gWQ7y+8b3+zUYjeT3EZIlIupgzg=", + "integrity": "sha512-63ZOUnL4SIXj4L0NixR3L1lcjO38crAbgrTpl28t8jjrfuiOBL5Iygm+60qPs/KsZGzPNg6Smnc/oY16QTjF0g==", "dev": true, "requires": { "spdx-correct": "3.0.0", @@ -5750,7 +5750,7 @@ "which": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/which/-/which-1.3.0.tgz", - "integrity": "sha1-/wS9/AEO5UfXgL7DjhrBwnd9JTo=", + "integrity": "sha512-xcJpopdamTuY5duC/KnTTNBraPK54YwpenP4lzxU8H91GudWpFv38u0CKjclE1Wi2EH2EDz5LRcHcKbCIzqGyg==", "dev": true, "requires": { "isexe": "2.0.0" diff --git a/packages/canvas/canvas-mesh/package.json b/packages/canvas/canvas-mesh/package.json index 691cd2c..6744a17 100644 --- a/packages/canvas/canvas-mesh/package.json +++ b/packages/canvas/canvas-mesh/package.json @@ -24,6 +24,7 @@ "dependencies": { "@pixi/constants": "^5.0.0-alpha.2", "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/mesh-extras": "^5.0.0-alpha.2", "@pixi/settings": "^5.0.0-alpha.2" }, "devDependencies": { diff --git a/packages/canvas/canvas-mesh/src/Mesh.js b/packages/canvas/canvas-mesh/src/Mesh.js index 900a872..c43a74b 100644 --- a/packages/canvas/canvas-mesh/src/Mesh.js +++ b/packages/canvas/canvas-mesh/src/Mesh.js @@ -1,36 +1,14 @@ import { Mesh } from '@pixi/mesh'; -import { settings } from './settings'; - -// IMPORTANT: Please do NOT use this as a precedent to use `settings` after the object is created -// this was merely created to completely decouple canvas from the base Mesh class and we are -// unable to add `canvasPadding` in the constructor anymore, as the case was for PixiJS v4. /** - * Internal variable for `canvasPadding`. + * Renders the object using the Canvas renderer * * @private - * @memberof PIXI.Mesh - * @member {number} - * @default null - */ -Mesh.prototype._canvasPadding = null; - -/** - * Triangles in canvas mode are automatically antialiased, use this value to force triangles - * to overlap a bit with each other. To set the global default, set {@link PIXI.settings.MESH_CANVAS_PADDING} - * - * @see PIXI.settings.MESH_CANVAS_PADDING - * @member {number} canvasPadding + * @method _renderCanvas * @memberof PIXI.Mesh# - * @default 0 + * @param {PIXI.CanvasRenderer} renderer - The canvas renderer. */ -Object.defineProperty(Mesh.prototype, 'canvasPadding', { - get() - { - return this._canvasPadding !== null ? this._canvasPadding : settings.MESH_CANVAS_PADDING; - }, - set(value) - { - this._canvasPadding = value; - }, -}); +Mesh.prototype._renderCanvas = function _renderCanvas(renderer) +{ + renderer.plugins[this.pluginName].render(this); +}; diff --git a/packages/canvas/canvas-mesh/src/Mesh2d.js b/packages/canvas/canvas-mesh/src/Mesh2d.js new file mode 100644 index 0000000..d0bd80f --- /dev/null +++ b/packages/canvas/canvas-mesh/src/Mesh2d.js @@ -0,0 +1,36 @@ +import { Mesh2d } from '@pixi/mesh-extras'; +import { settings } from './settings'; + +// IMPORTANT: Please do NOT use this as a precedent to use `settings` after the object is created +// this was merely created to completely decouple canvas from the base Mesh class and we are +// unable to add `canvasPadding` in the constructor anymore, as the case was for PixiJS v4. + +/** + * Internal variable for `canvasPadding`. + * + * @private + * @memberof PIXI.Mesh2d + * @member {number} + * @default null + */ +Mesh2d.prototype._canvasPadding = null; + +/** + * Triangles in canvas mode are automatically antialiased, use this value to force triangles + * to overlap a bit with each other. To set the global default, set {@link PIXI.settings.MESH_CANVAS_PADDING} + * + * @see PIXI.settings.MESH_CANVAS_PADDING + * @member {number} canvasPadding + * @memberof PIXI.Mesh2d# + * @default 0 + */ +Object.defineProperty(Mesh2d.prototype, 'canvasPadding', { + get() + { + return this._canvasPadding !== null ? this._canvasPadding : settings.MESH_CANVAS_PADDING; + }, + set(value) + { + this._canvasPadding = value; + }, +}); diff --git a/packages/canvas/canvas-mesh/src/NineSlicePlane.js b/packages/canvas/canvas-mesh/src/NineSlicePlane.js index 09eaf9c..2fd5acc 100644 --- a/packages/canvas/canvas-mesh/src/NineSlicePlane.js +++ b/packages/canvas/canvas-mesh/src/NineSlicePlane.js @@ -1,4 +1,4 @@ -import { NineSlicePlane } from '@pixi/mesh'; +import { NineSlicePlane } from '@pixi/mesh-extras'; /** * Renders the object using the Canvas renderer diff --git a/packages/canvas/canvas-mesh/src/RawMesh.js b/packages/canvas/canvas-mesh/src/RawMesh.js deleted file mode 100644 index bf40184..0000000 --- a/packages/canvas/canvas-mesh/src/RawMesh.js +++ /dev/null @@ -1,14 +0,0 @@ -import { RawMesh } from '@pixi/mesh'; - -/** - * Renders the object using the Canvas renderer - * - * @private - * @method _renderCanvas - * @memberof PIXI.RawMesh# - * @param {PIXI.CanvasRenderer} renderer - The canvas renderer. - */ -RawMesh.prototype._renderCanvas = function _renderCanvas(renderer) -{ - renderer.plugins[this.pluginName].render(this); -}; diff --git a/bundles/pixi.js/package.json b/bundles/pixi.js/package.json index 49c7276..177e059 100644 --- a/bundles/pixi.js/package.json +++ b/bundles/pixi.js/package.json @@ -49,6 +49,7 @@ "@pixi/loaders": "^5.0.0-alpha.2", "@pixi/math": "^5.0.0-alpha.2", "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/mesh-extras": "^5.0.0-alpha.2", "@pixi/mixin-cache-as-bitmap": "^5.0.0-alpha.2", "@pixi/mixin-get-child-by-name": "^5.0.0-alpha.2", "@pixi/mixin-get-global-position": "^5.0.0-alpha.2", diff --git a/bundles/pixi.js/src/deprecated.js b/bundles/pixi.js/src/deprecated.js index 147617c..dbebeb0 100644 --- a/bundles/pixi.js/src/deprecated.js +++ b/bundles/pixi.js/src/deprecated.js @@ -263,15 +263,15 @@ Object.defineProperties(PIXI.mesh, { /** * @class PIXI.mesh.Mesh - * @see PIXI.Mesh + * @see PIXI.Mesh2d * @deprecated since 5.0.0 */ Mesh: { get() { - warn('PIXI.mesh.Mesh has moved to PIXI.Mesh'); + warn('PIXI.mesh.Mesh has moved to PIXI.Mesh2d'); - return PIXI.Mesh; + return PIXI.Mesh2d; }, }, /** @@ -315,15 +315,15 @@ }, /** * @class PIXI.mesh.RawMesh - * @see PIXI.RawMesh + * @see PIXI.Mesh * @deprecated since 5.0.0 */ RawMesh: { get() { - warn('PIXI.mesh.RawMesh has moved to PIXI.RawMesh'); + warn('PIXI.mesh.RawMesh has moved to PIXI.Mesh'); - return PIXI.RawMesh; + return PIXI.Mesh; }, }, /** diff --git a/bundles/pixi.js/src/index.js b/bundles/pixi.js/src/index.js index a3a0d1b..6fdabf0 100644 --- a/bundles/pixi.js/src/index.js +++ b/bundles/pixi.js/src/index.js @@ -9,6 +9,7 @@ import * as loaders from '@pixi/loaders'; import * as math from '@pixi/math'; import * as mesh from '@pixi/mesh'; +import * as meshExtras from '@pixi/mesh-extras'; import * as particles from '@pixi/particles'; import * as prepare from '@pixi/prepare'; import * as sprite from '@pixi/sprite'; @@ -128,6 +129,7 @@ loaders, math, mesh, + meshExtras, particles, sprite, spriteAnimated, @@ -152,6 +154,7 @@ export * from '@pixi/loaders'; export * from '@pixi/math'; export * from '@pixi/mesh'; +export * from '@pixi/mesh-extras'; export * from '@pixi/particles'; export * from '@pixi/sprite'; export * from '@pixi/spritesheet'; diff --git a/package-lock.json b/package-lock.json index 7fe6db7..0814729 100644 --- a/package-lock.json +++ b/package-lock.json @@ -209,7 +209,7 @@ "argparse": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", - "integrity": "sha1-vNZ5HqWuCXJeF+WtmIE0zUCz2RE=", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", "dev": true, "requires": { "sprintf-js": "1.0.3" @@ -228,7 +228,7 @@ "arr-flatten": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz", - "integrity": "sha1-NgSLv/TntH4TZkQxbJlmnqWukfE=", + "integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==", "dev": true }, "arr-union": { @@ -297,7 +297,7 @@ "assertion-error": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", - "integrity": "sha1-5gtrDo8wG9l+U3UhW9pAbIURjAs=", + "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", "dev": true }, "async": { @@ -396,7 +396,7 @@ "brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha1-PH/L9SnYcibz0vUrlm/1Jx60Qd0=", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, "requires": { "balanced-match": "1.0.0", @@ -568,7 +568,7 @@ "circular-json": { "version": "0.3.3", "resolved": "https://registry.npmjs.org/circular-json/-/circular-json-0.3.3.tgz", - "integrity": "sha1-gVyZ6oT2gJUp0vRXkb34JxE1LWY=", + "integrity": "sha512-UZK3NBx2Mca+b5LsG7bY183pHWt5Y1xts4P3Pz7ENTwGVnJOUWbRb3ocjvX7hx9tq/yTAdclXm9sZ38gNuem4A==", "dev": true }, "cli-cursor": { @@ -638,7 +638,7 @@ "color-convert": { "version": "1.9.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.1.tgz", - "integrity": "sha1-wSYRB66y8pTr/+ye2eytUppgl+0=", + "integrity": "sha512-mjGanIiwQJskCC18rPR6OmrZ6fm2Lc7PeGFYwCmy5J34wC6F1PzdGL6xeMfmgicfYcNLGuVFA3WzXtIDCQSZxQ==", "dev": true, "requires": { "color-name": "1.1.3" @@ -1427,7 +1427,7 @@ "boom": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/boom/-/boom-5.2.0.tgz", - "integrity": "sha1-XdnabuOl8wIHdDYpDLcX0/SlTgI=", + "integrity": "sha512-Z5BTk6ZRe4tXXQlkqftmsAUANpXmuwlsF5Oov8ThoMbQRzdGTA1ngYRW160GexgOgjsFOKJz0LYhoNi+2AMBUw==", "dev": true, "requires": { "hoek": "4.2.1" @@ -1471,7 +1471,7 @@ "debug": { "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha1-XRKFFd8TT/Mn6QpMk/Tgd6U2NB8=", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", "dev": true, "requires": { "ms": "2.0.0" @@ -1585,7 +1585,7 @@ "doctrine": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", - "integrity": "sha1-XNAfwQFiG0LEzX9dGmYkNxbT850=", + "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", "dev": true, "requires": { "esutils": "2.0.2" @@ -1662,7 +1662,7 @@ "es6-promise": { "version": "4.2.4", "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.4.tgz", - "integrity": "sha1-3EIhwrFlGHYL2MOaUtjzVvwA7Sk=", + "integrity": "sha512-/NdNZVJg+uZgtm9eS3O6lrOLYmQag2DjdEXuPaHlZ6RuVqgqaVZfgYCepEIKsLqwdQArOPtC3XzRLqGGfT8KQQ==", "dev": true }, "escape-string-regexp": { @@ -1788,7 +1788,7 @@ "espree": { "version": "3.5.4", "resolved": "https://registry.npmjs.org/espree/-/espree-3.5.4.tgz", - "integrity": "sha1-sPRHGHyKi+2US4FaZgvd9d610ac=", + "integrity": "sha512-yAcIQxtmMiB/jL32dzEp2enBeidsB7xWPLNiw3IIkpVds1P+h7qF9YwJq1yUNzp2OKXgAprs4F61ih66UsoD1A==", "dev": true, "requires": { "acorn": "5.5.0", @@ -1798,7 +1798,7 @@ "esprima": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.0.tgz", - "integrity": "sha1-RJnt3NERDgshi6zy+n9/WfVcqAQ=", + "integrity": "sha512-oftTcaMu/EGrEIu904mWteKIv8vMuOgGYo7EhVJJN00R/EED9DCua/xxHRdYnKtcECzVg7xOWhflvJMnqcFZjw==", "dev": true }, "esquery": { @@ -1813,7 +1813,7 @@ "esrecurse": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.2.1.tgz", - "integrity": "sha1-AHo7n9vCs7uH5IeeoZyS/b05Qs8=", + "integrity": "sha512-64RBB++fIOAXPw3P9cy89qfMlvZEXZkqqJkjqqXIvzP5ezRZjW+lPWjw35UX/3EhUPFYbg5ER4JYgDw4007/DQ==", "dev": true, "requires": { "estraverse": "4.2.0" @@ -2024,7 +2024,7 @@ "find-root": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/find-root/-/find-root-1.1.0.tgz", - "integrity": "sha1-q8/Iunb3CMQql7PWhbfpRQv7nOQ=", + "integrity": "sha512-NKfW6bec6GfKc0SGx1e07QZY9PE99u0Bft/0rzSD5k3sO/vwkVUpDUKVm5Gpp5Ue3YfShPFTX2070tDs5kB9Ng==", "dev": true }, "find-up": { @@ -2103,7 +2103,7 @@ "supports-color": { "version": "5.3.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.3.0.tgz", - "integrity": "sha1-WySsFduA+pJ89SJ6SjP9PEx2dsA=", + "integrity": "sha512-0aP01LLIskjKs3lq52EC0aGBAJhLq7B2Rd8HC/DR/PtNNpcLilNmHC12O+hu0usQpo7wtHNRqtrhBwtDb0+dNg==", "dev": true, "requires": { "has-flag": "3.0.0" @@ -2567,7 +2567,7 @@ "glob": { "version": "7.1.2", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", - "integrity": "sha1-wZyd+aAocC1nhhI4SmVSQExjbRU=", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", "dev": true, "requires": { "fs.realpath": "1.0.0", @@ -2672,7 +2672,7 @@ "growl": { "version": "1.10.3", "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.3.tgz", - "integrity": "sha1-GSa6kM8+3+KttJJ/WIC8IsZseQ8=", + "integrity": "sha512-hKlsbA5Vu3xsh1Cg3J7jSmX/WaW6A5oBeqzM88oNbCRQFz+zUaXm6yxS4RVytp1scBoJzSYl4YAEOQIt6O8V1Q==", "dev": true }, "handlebars": { @@ -2738,7 +2738,7 @@ "hawk": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/hawk/-/hawk-6.0.2.tgz", - "integrity": "sha1-r02RTrBl+bXOTZ0RwcshJu7MMDg=", + "integrity": "sha512-miowhl2+U7Qle4vdLqDdPt9m09K6yZhkLDTWGoUiUzrQCn+mHHSmfJgAyGaLRZbPmTqfFFjRV1QWCW0VWUJBbQ==", "dev": true, "requires": { "boom": "4.3.1", @@ -2756,7 +2756,7 @@ "hoek": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/hoek/-/hoek-4.2.1.tgz", - "integrity": "sha1-ljRQKqEsRF3Vp8VzS1cruHOKrLs=", + "integrity": "sha512-QLg82fGkfnJ/4iy1xZ81/9SIJiq1NGFUMGs6ParyjBZr6jW2Ufj/snDqTHixNlHdPNwN2RLVD0Pi3igeK9+JfA==", "dev": true }, "home-path": { @@ -2791,7 +2791,7 @@ "ignore": { "version": "3.3.7", "resolved": "https://registry.npmjs.org/ignore/-/ignore-3.3.7.tgz", - "integrity": "sha1-YSKJv7PCIOGGpYEYYY1b6MG6sCE=", + "integrity": "sha512-YGG3ejvBNHRqu0559EOxxNFihD0AjpvHlC/pdGKd3X3ofe+CoJkYazwNJYTNebqpPKN+VVQbh4ZFn1DivMNuHA==", "dev": true }, "imurmurhash": { @@ -2828,7 +2828,7 @@ "ini": { "version": "1.3.5", "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", - "integrity": "sha1-7uJfVtscnsYIXgwid4CD9Zar+Sc=", + "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==", "dev": true }, "inquirer": { @@ -2901,7 +2901,7 @@ "is-buffer": { "version": "1.1.6", "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", - "integrity": "sha1-76ouqdqg16suoTqXsritUf776L4=", + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", "dev": true }, "is-builtin-module": { @@ -3054,7 +3054,7 @@ "is-resolvable": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/is-resolvable/-/is-resolvable-1.1.0.tgz", - "integrity": "sha1-+xj4fOH+uSUWnJpAfBkxijIG7Yg=", + "integrity": "sha512-qgDYXFSR5WvEfuS5dMj6oTMEbrrSaM0CrFk2Yiq/gXnBvD9pMa2jGXxyhGLfvhZpuMZe18CJpFxAt3CRs42NMg==", "dev": true }, "is-retry-allowed": { @@ -3204,7 +3204,7 @@ "js-yaml": { "version": "3.11.0", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.11.0.tgz", - "integrity": "sha1-WXwai9VxUvJtYizkEXhRpR9euu8=", + "integrity": "sha512-saJstZWv7oNeOyBh3+Dx1qWzhW0+e6/8eDzo7p5rDFqxntSztloLtuKu+Ejhtq82jsilwOIZYsCz+lIjthg1Hw==", "dev": true, "requires": { "argparse": "1.0.10", @@ -3324,7 +3324,7 @@ "just-extend": { "version": "1.1.27", "resolved": "https://registry.npmjs.org/just-extend/-/just-extend-1.1.27.tgz", - "integrity": "sha1-7G55QQ/5FORyZSq/oOYDwD1g6QU=", + "integrity": "sha512-mJVp13Ix6gFo3SBAy9U/kL+oeZqzlYYYLQBwXVBlVzIsZwBqGREnOro24oC/8s8aox+rJhtZ2DiQof++IrkA+g==", "dev": true }, "kind-of": { @@ -3703,7 +3703,7 @@ "lodash": { "version": "4.17.5", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.5.tgz", - "integrity": "sha1-maktZcAnLevoyWtgV7yPv6O+1RE=", + "integrity": "sha512-svL3uiZf1RwhH+cWrfZn3A4+U58wbP0tGVTLQPbjplZxZ8ROD9VLuNgsRniTlLe7OlSqR79RUehXgpBW/s0IQw==", "dev": true }, "lodash._reinterpolate": { @@ -3740,7 +3740,7 @@ "lolex": { "version": "2.3.2", "resolved": "https://registry.npmjs.org/lolex/-/lolex-2.3.2.tgz", - "integrity": "sha1-hflFBCUQO/nnpgZo6iXcQydMqAc=", + "integrity": "sha512-A5pN2tkFj7H0dGIAM6MFvHKMJcPnjZsOMvR7ujCjfgW5TbV6H9vb1PgxLtHvjqNZTHsUolz+6/WEO0N1xNx2ng==", "dev": true }, "longest": { @@ -3816,7 +3816,7 @@ "marked": { "version": "0.3.17", "resolved": "https://registry.npmjs.org/marked/-/marked-0.3.17.tgz", - "integrity": "sha1-YH8GZos8axJGso8T2nYRasGqLSs=", + "integrity": "sha512-+AKbNsjZl6jFfLPwHhWmGTqE009wTKn3RTmn9K8oUKHrX/abPJjtcRtXpYB/FFrwPJRUA86LX/de3T0knkPCmQ==", "dev": true }, "mem": { @@ -3896,13 +3896,13 @@ "mime-db": { "version": "1.33.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.33.0.tgz", - "integrity": "sha1-o0kgUKXLm2NFBUHjnZeI0icng9s=", + "integrity": "sha512-BHJ/EKruNIqJf/QahvxwQZXKygOQ256myeN/Ew+THcAa5q+PjyTTMMeNQC4DZw5AwfvelsUrA6B67NKMqXDbzQ==", "dev": true }, "mime-types": { "version": "2.1.18", "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.18.tgz", - "integrity": "sha1-bzI/YKg9ERRvgx/xH9ZuL+VQO7g=", + "integrity": "sha512-lc/aahn+t4/SWV/qcmumYjymLsWfN3ELhpmVuUFjgsORruuZPVSwAQryq+HHGvO/SI2KVX26bx+En+zhM8g8hQ==", "dev": true, "requires": { "mime-db": "1.33.0" @@ -3917,7 +3917,7 @@ "minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha1-UWbihkV/AzBgZL5Ul+jbsMPTIIM=", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "dev": true, "requires": { "brace-expansion": "1.1.11" @@ -4071,7 +4071,7 @@ "normalize-package-data": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.4.0.tgz", - "integrity": "sha1-EvlaMH1YNSB1oEkHuErIvpisAS8=", + "integrity": "sha512-9jjUFbTPfEy3R/ad/2oNbKtW9Hgovl5O1FvFWKkKblNXoN/Oou6+9+KKohPK13Yc3/TyunyWhJp6gvRNR/PPAw==", "dev": true, "requires": { "hosted-git-info": "2.5.0", @@ -4511,7 +4511,7 @@ "process-nextick-args": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", - "integrity": "sha1-o31zL0JxtKsa0HDTVQjoKQeI/6o=", + "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==", "dev": true }, "progress": { @@ -4584,7 +4584,7 @@ "qs": { "version": "6.5.1", "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.1.tgz", - "integrity": "sha1-NJzfbu+J7EXBLX1es/wMhwNDptg=", + "integrity": "sha512-eRzhrN1WSINYCDCbrz796z37LOe3m5tmW7RQf6oBntukAG1nmovJvhnwHHRMAfeoItc1m2Hk02WER2aQ/iqs+A==", "dev": true }, "quick-lru": { @@ -4596,7 +4596,7 @@ "randomatic": { "version": "1.1.7", "resolved": "https://registry.npmjs.org/randomatic/-/randomatic-1.1.7.tgz", - "integrity": "sha1-x6vpzIuHwLqodrGf3oP9RkeX44w=", + "integrity": "sha512-D5JUjPyJbaJDkuAazpVnSfVkLlpeO3wDlPROTMLGKG1zMFNFRgrciKo1ltz/AzNTkqE0HzDx655QOL51N06how==", "dev": true, "requires": { "is-number": "3.0.0", @@ -4701,7 +4701,7 @@ "regex-cache": { "version": "0.4.4", "resolved": "https://registry.npmjs.org/regex-cache/-/regex-cache-0.4.4.tgz", - "integrity": "sha1-db3FiioUls7EihKDW8VMjVYjNt0=", + "integrity": "sha512-nVIZwtCjkC9YgvWkpM55B5rBhBYRZhAaJbgcFYXXsHnbZ9UZI9nnVWYZpBlCqv9ho2eZryPnWrZGsOdPwVWXWQ==", "dev": true, "requires": { "is-equal-shallow": "0.1.3" @@ -4729,7 +4729,7 @@ "remap-istanbul": { "version": "0.10.1", "resolved": "https://registry.npmjs.org/remap-istanbul/-/remap-istanbul-0.10.1.tgz", - "integrity": "sha1-OqWN1QIdSZ8zbTulvzu7kcG4jjc=", + "integrity": "sha512-gsNQXs5kJLhErICSyYhzVZ++C8LBW8dgwr874Y2QvzAUS75zBlD/juZgXs39nbYJ09fZDlX2AVLVJAY2jbFJoQ==", "dev": true, "requires": { "amdefine": "1.0.1", @@ -4769,7 +4769,7 @@ "source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha1-dHIq8y6WFOnCh6jQu95IteLxomM=", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", "dev": true }, "through2": { @@ -4883,7 +4883,7 @@ "resolve": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.5.0.tgz", - "integrity": "sha1-HwmsznlsmnYlefMbLBzEw83fnzY=", + "integrity": "sha512-hgoSGrc3pjzAPHNBg+KnFcK2HwlHTs/YrAGUr6qgTVUZmXv1UEXXl0bZNBKMA9fud6lRYFdPGz0xXxycPzmmiw==", "dev": true, "requires": { "path-parse": "1.0.5" @@ -4924,7 +4924,7 @@ "rimraf": { "version": "2.6.2", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", - "integrity": "sha1-LtgVDSShbqhlHm1u8PR8QVjOejY=", + "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", "dev": true, "requires": { "glob": "7.1.2" @@ -5063,19 +5063,19 @@ "safe-buffer": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", - "integrity": "sha1-iTMSr2myEj3vcfV4iQAWce6yyFM=", + "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", "dev": true }, "samsam": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/samsam/-/samsam-1.3.0.tgz", - "integrity": "sha1-jR2TUOJWItow3j5EumkrUiGrfFA=", + "integrity": "sha512-1HwIYD/8UlOtFS3QO3w7ey+SdSDFE4HRNLZoZRYVQefrOY3l17epswImeB1ijgJFQJodIaHcwkp3r/myBjFVbg==", "dev": true }, "semver": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz", - "integrity": "sha1-3Eu8emyp2Rbe5dQ1FvAJK1j3uKs=", + "integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==", "dev": true }, "set-blocking": { @@ -5117,7 +5117,7 @@ "sinon-chai": { "version": "2.14.0", "resolved": "https://registry.npmjs.org/sinon-chai/-/sinon-chai-2.14.0.tgz", - "integrity": "sha1-2n3UzIPNaiYLZ8yg96n9riahIF0=", + "integrity": "sha512-9stIF1utB0ywNHNT7RgiXbdmen8QDCRsrTjw+G9TgKt1Yexjiv8TOWZ6WHsTPz57Yky3DIswZvEqX8fpuHNDtQ==", "dev": true }, "slash": { @@ -5146,7 +5146,7 @@ "sntp": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/sntp/-/sntp-2.1.0.tgz", - "integrity": "sha1-LGzsFP7cIiJznK+bXD2F0cxaLMg=", + "integrity": "sha512-FL1b58BDrqS3A11lJ0zEdnJ3UOKqVxawAkF3k7F0CVN7VQ34aZrV+G8BZ1WC9ZL7NyrwsW0oviwsWDgRuVYtJg==", "dev": true, "requires": { "hoek": "4.2.1" @@ -5203,7 +5203,7 @@ "spdx-correct": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.0.0.tgz", - "integrity": "sha1-BaW01xU6GVvJLDxCW2nzsqlSTII=", + "integrity": "sha512-N19o9z5cEyc8yQQPukRCZ9EUmb4HUpnrmaL/fxS2pBo2jbfcFRVuFZ/oFC+vZz0MNNk0h80iMn5/S6qGZOL5+g==", "dev": true, "requires": { "spdx-expression-parse": "3.0.0", @@ -5213,13 +5213,13 @@ "spdx-exceptions": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.1.0.tgz", - "integrity": "sha1-LHrmEFbHFKW5ubKyr30xHvXHj+k=", + "integrity": "sha512-4K1NsmrlCU1JJgUrtgEeTVyfx8VaYea9J9LvARxhbHtVtohPs/gFGG5yy49beySjlIMhhXZ4QqujIZEfS4l6Cg==", "dev": true }, "spdx-expression-parse": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.0.tgz", - "integrity": "sha1-meEZt6XaAOBUkcn6M4t5BII7QdA=", + "integrity": "sha512-Yg6D3XpRD4kkOmTpdgbUiEJFKghJH03fiC1OPll5h/0sO6neh2jqRDVHOQ4o/LMea0tgCkbMgea5ip/e+MkWyg==", "dev": true, "requires": { "spdx-exceptions": "2.1.0", @@ -5229,7 +5229,7 @@ "spdx-license-ids": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.0.tgz", - "integrity": "sha1-enzShHDMbToc/m1miG9rxDDTrIc=", + "integrity": "sha512-2+EPwgbnmOIl8HjGBXXMd9NAu02vLjOO1nWw4kmeRDFyHn+M/ETfHxQUK0oXg8ctgVnl9t3rosNVsZ1jG61nDA==", "dev": true }, "speedometer": { @@ -5566,7 +5566,7 @@ "tough-cookie": { "version": "2.3.4", "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.4.tgz", - "integrity": "sha1-7GDO44rGdQY//JelwYlwV47oNlU=", + "integrity": "sha512-TZ6TTfI5NtZnuyy/Kecv+CnoROnyXn2DN97LontgQpCwsX2XyLYCC0ENhYkehSOwAp8rTQKc/NUIF7BkQ5rKLA==", "dev": true, "requires": { "punycode": "1.4.1" @@ -5708,13 +5708,13 @@ "uuid": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.2.1.tgz", - "integrity": "sha1-EsUou51Y0LkmXZovbw/ovhf/HxQ=", + "integrity": "sha512-jZnMwlb9Iku/O3smGWvZhauCf6cvvpKi4BKRiliS3cxnI+Gz9j5MEpTz2UFuXiKPJocb7gnsLHwiS05ige5BEA==", "dev": true }, "validate-npm-package-license": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.3.tgz", - "integrity": "sha1-gWQ7y+8b3+zUYjeT3EZIlIupgzg=", + "integrity": "sha512-63ZOUnL4SIXj4L0NixR3L1lcjO38crAbgrTpl28t8jjrfuiOBL5Iygm+60qPs/KsZGzPNg6Smnc/oY16QTjF0g==", "dev": true, "requires": { "spdx-correct": "3.0.0", @@ -5750,7 +5750,7 @@ "which": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/which/-/which-1.3.0.tgz", - "integrity": "sha1-/wS9/AEO5UfXgL7DjhrBwnd9JTo=", + "integrity": "sha512-xcJpopdamTuY5duC/KnTTNBraPK54YwpenP4lzxU8H91GudWpFv38u0CKjclE1Wi2EH2EDz5LRcHcKbCIzqGyg==", "dev": true, "requires": { "isexe": "2.0.0" diff --git a/packages/canvas/canvas-mesh/package.json b/packages/canvas/canvas-mesh/package.json index 691cd2c..6744a17 100644 --- a/packages/canvas/canvas-mesh/package.json +++ b/packages/canvas/canvas-mesh/package.json @@ -24,6 +24,7 @@ "dependencies": { "@pixi/constants": "^5.0.0-alpha.2", "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/mesh-extras": "^5.0.0-alpha.2", "@pixi/settings": "^5.0.0-alpha.2" }, "devDependencies": { diff --git a/packages/canvas/canvas-mesh/src/Mesh.js b/packages/canvas/canvas-mesh/src/Mesh.js index 900a872..c43a74b 100644 --- a/packages/canvas/canvas-mesh/src/Mesh.js +++ b/packages/canvas/canvas-mesh/src/Mesh.js @@ -1,36 +1,14 @@ import { Mesh } from '@pixi/mesh'; -import { settings } from './settings'; - -// IMPORTANT: Please do NOT use this as a precedent to use `settings` after the object is created -// this was merely created to completely decouple canvas from the base Mesh class and we are -// unable to add `canvasPadding` in the constructor anymore, as the case was for PixiJS v4. /** - * Internal variable for `canvasPadding`. + * Renders the object using the Canvas renderer * * @private - * @memberof PIXI.Mesh - * @member {number} - * @default null - */ -Mesh.prototype._canvasPadding = null; - -/** - * Triangles in canvas mode are automatically antialiased, use this value to force triangles - * to overlap a bit with each other. To set the global default, set {@link PIXI.settings.MESH_CANVAS_PADDING} - * - * @see PIXI.settings.MESH_CANVAS_PADDING - * @member {number} canvasPadding + * @method _renderCanvas * @memberof PIXI.Mesh# - * @default 0 + * @param {PIXI.CanvasRenderer} renderer - The canvas renderer. */ -Object.defineProperty(Mesh.prototype, 'canvasPadding', { - get() - { - return this._canvasPadding !== null ? this._canvasPadding : settings.MESH_CANVAS_PADDING; - }, - set(value) - { - this._canvasPadding = value; - }, -}); +Mesh.prototype._renderCanvas = function _renderCanvas(renderer) +{ + renderer.plugins[this.pluginName].render(this); +}; diff --git a/packages/canvas/canvas-mesh/src/Mesh2d.js b/packages/canvas/canvas-mesh/src/Mesh2d.js new file mode 100644 index 0000000..d0bd80f --- /dev/null +++ b/packages/canvas/canvas-mesh/src/Mesh2d.js @@ -0,0 +1,36 @@ +import { Mesh2d } from '@pixi/mesh-extras'; +import { settings } from './settings'; + +// IMPORTANT: Please do NOT use this as a precedent to use `settings` after the object is created +// this was merely created to completely decouple canvas from the base Mesh class and we are +// unable to add `canvasPadding` in the constructor anymore, as the case was for PixiJS v4. + +/** + * Internal variable for `canvasPadding`. + * + * @private + * @memberof PIXI.Mesh2d + * @member {number} + * @default null + */ +Mesh2d.prototype._canvasPadding = null; + +/** + * Triangles in canvas mode are automatically antialiased, use this value to force triangles + * to overlap a bit with each other. To set the global default, set {@link PIXI.settings.MESH_CANVAS_PADDING} + * + * @see PIXI.settings.MESH_CANVAS_PADDING + * @member {number} canvasPadding + * @memberof PIXI.Mesh2d# + * @default 0 + */ +Object.defineProperty(Mesh2d.prototype, 'canvasPadding', { + get() + { + return this._canvasPadding !== null ? this._canvasPadding : settings.MESH_CANVAS_PADDING; + }, + set(value) + { + this._canvasPadding = value; + }, +}); diff --git a/packages/canvas/canvas-mesh/src/NineSlicePlane.js b/packages/canvas/canvas-mesh/src/NineSlicePlane.js index 09eaf9c..2fd5acc 100644 --- a/packages/canvas/canvas-mesh/src/NineSlicePlane.js +++ b/packages/canvas/canvas-mesh/src/NineSlicePlane.js @@ -1,4 +1,4 @@ -import { NineSlicePlane } from '@pixi/mesh'; +import { NineSlicePlane } from '@pixi/mesh-extras'; /** * Renders the object using the Canvas renderer diff --git a/packages/canvas/canvas-mesh/src/RawMesh.js b/packages/canvas/canvas-mesh/src/RawMesh.js deleted file mode 100644 index bf40184..0000000 --- a/packages/canvas/canvas-mesh/src/RawMesh.js +++ /dev/null @@ -1,14 +0,0 @@ -import { RawMesh } from '@pixi/mesh'; - -/** - * Renders the object using the Canvas renderer - * - * @private - * @method _renderCanvas - * @memberof PIXI.RawMesh# - * @param {PIXI.CanvasRenderer} renderer - The canvas renderer. - */ -RawMesh.prototype._renderCanvas = function _renderCanvas(renderer) -{ - renderer.plugins[this.pluginName].render(this); -}; diff --git a/packages/canvas/canvas-mesh/src/index.js b/packages/canvas/canvas-mesh/src/index.js index 2295016..f4fa31d 100644 --- a/packages/canvas/canvas-mesh/src/index.js +++ b/packages/canvas/canvas-mesh/src/index.js @@ -1,6 +1,6 @@ export { default as CanvasMeshRenderer } from './CanvasMeshRenderer'; import './settings'; -import './Mesh'; +import './Mesh2d'; import './NineSlicePlane'; -import './RawMesh'; +import './Mesh'; diff --git a/bundles/pixi.js/package.json b/bundles/pixi.js/package.json index 49c7276..177e059 100644 --- a/bundles/pixi.js/package.json +++ b/bundles/pixi.js/package.json @@ -49,6 +49,7 @@ "@pixi/loaders": "^5.0.0-alpha.2", "@pixi/math": "^5.0.0-alpha.2", "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/mesh-extras": "^5.0.0-alpha.2", "@pixi/mixin-cache-as-bitmap": "^5.0.0-alpha.2", "@pixi/mixin-get-child-by-name": "^5.0.0-alpha.2", "@pixi/mixin-get-global-position": "^5.0.0-alpha.2", diff --git a/bundles/pixi.js/src/deprecated.js b/bundles/pixi.js/src/deprecated.js index 147617c..dbebeb0 100644 --- a/bundles/pixi.js/src/deprecated.js +++ b/bundles/pixi.js/src/deprecated.js @@ -263,15 +263,15 @@ Object.defineProperties(PIXI.mesh, { /** * @class PIXI.mesh.Mesh - * @see PIXI.Mesh + * @see PIXI.Mesh2d * @deprecated since 5.0.0 */ Mesh: { get() { - warn('PIXI.mesh.Mesh has moved to PIXI.Mesh'); + warn('PIXI.mesh.Mesh has moved to PIXI.Mesh2d'); - return PIXI.Mesh; + return PIXI.Mesh2d; }, }, /** @@ -315,15 +315,15 @@ }, /** * @class PIXI.mesh.RawMesh - * @see PIXI.RawMesh + * @see PIXI.Mesh * @deprecated since 5.0.0 */ RawMesh: { get() { - warn('PIXI.mesh.RawMesh has moved to PIXI.RawMesh'); + warn('PIXI.mesh.RawMesh has moved to PIXI.Mesh'); - return PIXI.RawMesh; + return PIXI.Mesh; }, }, /** diff --git a/bundles/pixi.js/src/index.js b/bundles/pixi.js/src/index.js index a3a0d1b..6fdabf0 100644 --- a/bundles/pixi.js/src/index.js +++ b/bundles/pixi.js/src/index.js @@ -9,6 +9,7 @@ import * as loaders from '@pixi/loaders'; import * as math from '@pixi/math'; import * as mesh from '@pixi/mesh'; +import * as meshExtras from '@pixi/mesh-extras'; import * as particles from '@pixi/particles'; import * as prepare from '@pixi/prepare'; import * as sprite from '@pixi/sprite'; @@ -128,6 +129,7 @@ loaders, math, mesh, + meshExtras, particles, sprite, spriteAnimated, @@ -152,6 +154,7 @@ export * from '@pixi/loaders'; export * from '@pixi/math'; export * from '@pixi/mesh'; +export * from '@pixi/mesh-extras'; export * from '@pixi/particles'; export * from '@pixi/sprite'; export * from '@pixi/spritesheet'; diff --git a/package-lock.json b/package-lock.json index 7fe6db7..0814729 100644 --- a/package-lock.json +++ b/package-lock.json @@ -209,7 +209,7 @@ "argparse": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", - "integrity": "sha1-vNZ5HqWuCXJeF+WtmIE0zUCz2RE=", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", "dev": true, "requires": { "sprintf-js": "1.0.3" @@ -228,7 +228,7 @@ "arr-flatten": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz", - "integrity": "sha1-NgSLv/TntH4TZkQxbJlmnqWukfE=", + "integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==", "dev": true }, "arr-union": { @@ -297,7 +297,7 @@ "assertion-error": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", - "integrity": "sha1-5gtrDo8wG9l+U3UhW9pAbIURjAs=", + "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", "dev": true }, "async": { @@ -396,7 +396,7 @@ "brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha1-PH/L9SnYcibz0vUrlm/1Jx60Qd0=", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, "requires": { "balanced-match": "1.0.0", @@ -568,7 +568,7 @@ "circular-json": { "version": "0.3.3", "resolved": "https://registry.npmjs.org/circular-json/-/circular-json-0.3.3.tgz", - "integrity": "sha1-gVyZ6oT2gJUp0vRXkb34JxE1LWY=", + "integrity": "sha512-UZK3NBx2Mca+b5LsG7bY183pHWt5Y1xts4P3Pz7ENTwGVnJOUWbRb3ocjvX7hx9tq/yTAdclXm9sZ38gNuem4A==", "dev": true }, "cli-cursor": { @@ -638,7 +638,7 @@ "color-convert": { "version": "1.9.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.1.tgz", - "integrity": "sha1-wSYRB66y8pTr/+ye2eytUppgl+0=", + "integrity": "sha512-mjGanIiwQJskCC18rPR6OmrZ6fm2Lc7PeGFYwCmy5J34wC6F1PzdGL6xeMfmgicfYcNLGuVFA3WzXtIDCQSZxQ==", "dev": true, "requires": { "color-name": "1.1.3" @@ -1427,7 +1427,7 @@ "boom": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/boom/-/boom-5.2.0.tgz", - "integrity": "sha1-XdnabuOl8wIHdDYpDLcX0/SlTgI=", + "integrity": "sha512-Z5BTk6ZRe4tXXQlkqftmsAUANpXmuwlsF5Oov8ThoMbQRzdGTA1ngYRW160GexgOgjsFOKJz0LYhoNi+2AMBUw==", "dev": true, "requires": { "hoek": "4.2.1" @@ -1471,7 +1471,7 @@ "debug": { "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha1-XRKFFd8TT/Mn6QpMk/Tgd6U2NB8=", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", "dev": true, "requires": { "ms": "2.0.0" @@ -1585,7 +1585,7 @@ "doctrine": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", - "integrity": "sha1-XNAfwQFiG0LEzX9dGmYkNxbT850=", + "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", "dev": true, "requires": { "esutils": "2.0.2" @@ -1662,7 +1662,7 @@ "es6-promise": { "version": "4.2.4", "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.4.tgz", - "integrity": "sha1-3EIhwrFlGHYL2MOaUtjzVvwA7Sk=", + "integrity": "sha512-/NdNZVJg+uZgtm9eS3O6lrOLYmQag2DjdEXuPaHlZ6RuVqgqaVZfgYCepEIKsLqwdQArOPtC3XzRLqGGfT8KQQ==", "dev": true }, "escape-string-regexp": { @@ -1788,7 +1788,7 @@ "espree": { "version": "3.5.4", "resolved": "https://registry.npmjs.org/espree/-/espree-3.5.4.tgz", - "integrity": "sha1-sPRHGHyKi+2US4FaZgvd9d610ac=", + "integrity": "sha512-yAcIQxtmMiB/jL32dzEp2enBeidsB7xWPLNiw3IIkpVds1P+h7qF9YwJq1yUNzp2OKXgAprs4F61ih66UsoD1A==", "dev": true, "requires": { "acorn": "5.5.0", @@ -1798,7 +1798,7 @@ "esprima": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.0.tgz", - "integrity": "sha1-RJnt3NERDgshi6zy+n9/WfVcqAQ=", + "integrity": "sha512-oftTcaMu/EGrEIu904mWteKIv8vMuOgGYo7EhVJJN00R/EED9DCua/xxHRdYnKtcECzVg7xOWhflvJMnqcFZjw==", "dev": true }, "esquery": { @@ -1813,7 +1813,7 @@ "esrecurse": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.2.1.tgz", - "integrity": "sha1-AHo7n9vCs7uH5IeeoZyS/b05Qs8=", + "integrity": "sha512-64RBB++fIOAXPw3P9cy89qfMlvZEXZkqqJkjqqXIvzP5ezRZjW+lPWjw35UX/3EhUPFYbg5ER4JYgDw4007/DQ==", "dev": true, "requires": { "estraverse": "4.2.0" @@ -2024,7 +2024,7 @@ "find-root": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/find-root/-/find-root-1.1.0.tgz", - "integrity": "sha1-q8/Iunb3CMQql7PWhbfpRQv7nOQ=", + "integrity": "sha512-NKfW6bec6GfKc0SGx1e07QZY9PE99u0Bft/0rzSD5k3sO/vwkVUpDUKVm5Gpp5Ue3YfShPFTX2070tDs5kB9Ng==", "dev": true }, "find-up": { @@ -2103,7 +2103,7 @@ "supports-color": { "version": "5.3.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.3.0.tgz", - "integrity": "sha1-WySsFduA+pJ89SJ6SjP9PEx2dsA=", + "integrity": "sha512-0aP01LLIskjKs3lq52EC0aGBAJhLq7B2Rd8HC/DR/PtNNpcLilNmHC12O+hu0usQpo7wtHNRqtrhBwtDb0+dNg==", "dev": true, "requires": { "has-flag": "3.0.0" @@ -2567,7 +2567,7 @@ "glob": { "version": "7.1.2", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", - "integrity": "sha1-wZyd+aAocC1nhhI4SmVSQExjbRU=", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", "dev": true, "requires": { "fs.realpath": "1.0.0", @@ -2672,7 +2672,7 @@ "growl": { "version": "1.10.3", "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.3.tgz", - "integrity": "sha1-GSa6kM8+3+KttJJ/WIC8IsZseQ8=", + "integrity": "sha512-hKlsbA5Vu3xsh1Cg3J7jSmX/WaW6A5oBeqzM88oNbCRQFz+zUaXm6yxS4RVytp1scBoJzSYl4YAEOQIt6O8V1Q==", "dev": true }, "handlebars": { @@ -2738,7 +2738,7 @@ "hawk": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/hawk/-/hawk-6.0.2.tgz", - "integrity": "sha1-r02RTrBl+bXOTZ0RwcshJu7MMDg=", + "integrity": "sha512-miowhl2+U7Qle4vdLqDdPt9m09K6yZhkLDTWGoUiUzrQCn+mHHSmfJgAyGaLRZbPmTqfFFjRV1QWCW0VWUJBbQ==", "dev": true, "requires": { "boom": "4.3.1", @@ -2756,7 +2756,7 @@ "hoek": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/hoek/-/hoek-4.2.1.tgz", - "integrity": "sha1-ljRQKqEsRF3Vp8VzS1cruHOKrLs=", + "integrity": "sha512-QLg82fGkfnJ/4iy1xZ81/9SIJiq1NGFUMGs6ParyjBZr6jW2Ufj/snDqTHixNlHdPNwN2RLVD0Pi3igeK9+JfA==", "dev": true }, "home-path": { @@ -2791,7 +2791,7 @@ "ignore": { "version": "3.3.7", "resolved": "https://registry.npmjs.org/ignore/-/ignore-3.3.7.tgz", - "integrity": "sha1-YSKJv7PCIOGGpYEYYY1b6MG6sCE=", + "integrity": "sha512-YGG3ejvBNHRqu0559EOxxNFihD0AjpvHlC/pdGKd3X3ofe+CoJkYazwNJYTNebqpPKN+VVQbh4ZFn1DivMNuHA==", "dev": true }, "imurmurhash": { @@ -2828,7 +2828,7 @@ "ini": { "version": "1.3.5", "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", - "integrity": "sha1-7uJfVtscnsYIXgwid4CD9Zar+Sc=", + "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==", "dev": true }, "inquirer": { @@ -2901,7 +2901,7 @@ "is-buffer": { "version": "1.1.6", "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", - "integrity": "sha1-76ouqdqg16suoTqXsritUf776L4=", + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", "dev": true }, "is-builtin-module": { @@ -3054,7 +3054,7 @@ "is-resolvable": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/is-resolvable/-/is-resolvable-1.1.0.tgz", - "integrity": "sha1-+xj4fOH+uSUWnJpAfBkxijIG7Yg=", + "integrity": "sha512-qgDYXFSR5WvEfuS5dMj6oTMEbrrSaM0CrFk2Yiq/gXnBvD9pMa2jGXxyhGLfvhZpuMZe18CJpFxAt3CRs42NMg==", "dev": true }, "is-retry-allowed": { @@ -3204,7 +3204,7 @@ "js-yaml": { "version": "3.11.0", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.11.0.tgz", - "integrity": "sha1-WXwai9VxUvJtYizkEXhRpR9euu8=", + "integrity": "sha512-saJstZWv7oNeOyBh3+Dx1qWzhW0+e6/8eDzo7p5rDFqxntSztloLtuKu+Ejhtq82jsilwOIZYsCz+lIjthg1Hw==", "dev": true, "requires": { "argparse": "1.0.10", @@ -3324,7 +3324,7 @@ "just-extend": { "version": "1.1.27", "resolved": "https://registry.npmjs.org/just-extend/-/just-extend-1.1.27.tgz", - "integrity": "sha1-7G55QQ/5FORyZSq/oOYDwD1g6QU=", + "integrity": "sha512-mJVp13Ix6gFo3SBAy9U/kL+oeZqzlYYYLQBwXVBlVzIsZwBqGREnOro24oC/8s8aox+rJhtZ2DiQof++IrkA+g==", "dev": true }, "kind-of": { @@ -3703,7 +3703,7 @@ "lodash": { "version": "4.17.5", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.5.tgz", - "integrity": "sha1-maktZcAnLevoyWtgV7yPv6O+1RE=", + "integrity": "sha512-svL3uiZf1RwhH+cWrfZn3A4+U58wbP0tGVTLQPbjplZxZ8ROD9VLuNgsRniTlLe7OlSqR79RUehXgpBW/s0IQw==", "dev": true }, "lodash._reinterpolate": { @@ -3740,7 +3740,7 @@ "lolex": { "version": "2.3.2", "resolved": "https://registry.npmjs.org/lolex/-/lolex-2.3.2.tgz", - "integrity": "sha1-hflFBCUQO/nnpgZo6iXcQydMqAc=", + "integrity": "sha512-A5pN2tkFj7H0dGIAM6MFvHKMJcPnjZsOMvR7ujCjfgW5TbV6H9vb1PgxLtHvjqNZTHsUolz+6/WEO0N1xNx2ng==", "dev": true }, "longest": { @@ -3816,7 +3816,7 @@ "marked": { "version": "0.3.17", "resolved": "https://registry.npmjs.org/marked/-/marked-0.3.17.tgz", - "integrity": "sha1-YH8GZos8axJGso8T2nYRasGqLSs=", + "integrity": "sha512-+AKbNsjZl6jFfLPwHhWmGTqE009wTKn3RTmn9K8oUKHrX/abPJjtcRtXpYB/FFrwPJRUA86LX/de3T0knkPCmQ==", "dev": true }, "mem": { @@ -3896,13 +3896,13 @@ "mime-db": { "version": "1.33.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.33.0.tgz", - "integrity": "sha1-o0kgUKXLm2NFBUHjnZeI0icng9s=", + "integrity": "sha512-BHJ/EKruNIqJf/QahvxwQZXKygOQ256myeN/Ew+THcAa5q+PjyTTMMeNQC4DZw5AwfvelsUrA6B67NKMqXDbzQ==", "dev": true }, "mime-types": { "version": "2.1.18", "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.18.tgz", - "integrity": "sha1-bzI/YKg9ERRvgx/xH9ZuL+VQO7g=", + "integrity": "sha512-lc/aahn+t4/SWV/qcmumYjymLsWfN3ELhpmVuUFjgsORruuZPVSwAQryq+HHGvO/SI2KVX26bx+En+zhM8g8hQ==", "dev": true, "requires": { "mime-db": "1.33.0" @@ -3917,7 +3917,7 @@ "minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha1-UWbihkV/AzBgZL5Ul+jbsMPTIIM=", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "dev": true, "requires": { "brace-expansion": "1.1.11" @@ -4071,7 +4071,7 @@ "normalize-package-data": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.4.0.tgz", - "integrity": "sha1-EvlaMH1YNSB1oEkHuErIvpisAS8=", + "integrity": "sha512-9jjUFbTPfEy3R/ad/2oNbKtW9Hgovl5O1FvFWKkKblNXoN/Oou6+9+KKohPK13Yc3/TyunyWhJp6gvRNR/PPAw==", "dev": true, "requires": { "hosted-git-info": "2.5.0", @@ -4511,7 +4511,7 @@ "process-nextick-args": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", - "integrity": "sha1-o31zL0JxtKsa0HDTVQjoKQeI/6o=", + "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==", "dev": true }, "progress": { @@ -4584,7 +4584,7 @@ "qs": { "version": "6.5.1", "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.1.tgz", - "integrity": "sha1-NJzfbu+J7EXBLX1es/wMhwNDptg=", + "integrity": "sha512-eRzhrN1WSINYCDCbrz796z37LOe3m5tmW7RQf6oBntukAG1nmovJvhnwHHRMAfeoItc1m2Hk02WER2aQ/iqs+A==", "dev": true }, "quick-lru": { @@ -4596,7 +4596,7 @@ "randomatic": { "version": "1.1.7", "resolved": "https://registry.npmjs.org/randomatic/-/randomatic-1.1.7.tgz", - "integrity": "sha1-x6vpzIuHwLqodrGf3oP9RkeX44w=", + "integrity": "sha512-D5JUjPyJbaJDkuAazpVnSfVkLlpeO3wDlPROTMLGKG1zMFNFRgrciKo1ltz/AzNTkqE0HzDx655QOL51N06how==", "dev": true, "requires": { "is-number": "3.0.0", @@ -4701,7 +4701,7 @@ "regex-cache": { "version": "0.4.4", "resolved": "https://registry.npmjs.org/regex-cache/-/regex-cache-0.4.4.tgz", - "integrity": "sha1-db3FiioUls7EihKDW8VMjVYjNt0=", + "integrity": "sha512-nVIZwtCjkC9YgvWkpM55B5rBhBYRZhAaJbgcFYXXsHnbZ9UZI9nnVWYZpBlCqv9ho2eZryPnWrZGsOdPwVWXWQ==", "dev": true, "requires": { "is-equal-shallow": "0.1.3" @@ -4729,7 +4729,7 @@ "remap-istanbul": { "version": "0.10.1", "resolved": "https://registry.npmjs.org/remap-istanbul/-/remap-istanbul-0.10.1.tgz", - "integrity": "sha1-OqWN1QIdSZ8zbTulvzu7kcG4jjc=", + "integrity": "sha512-gsNQXs5kJLhErICSyYhzVZ++C8LBW8dgwr874Y2QvzAUS75zBlD/juZgXs39nbYJ09fZDlX2AVLVJAY2jbFJoQ==", "dev": true, "requires": { "amdefine": "1.0.1", @@ -4769,7 +4769,7 @@ "source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha1-dHIq8y6WFOnCh6jQu95IteLxomM=", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", "dev": true }, "through2": { @@ -4883,7 +4883,7 @@ "resolve": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.5.0.tgz", - "integrity": "sha1-HwmsznlsmnYlefMbLBzEw83fnzY=", + "integrity": "sha512-hgoSGrc3pjzAPHNBg+KnFcK2HwlHTs/YrAGUr6qgTVUZmXv1UEXXl0bZNBKMA9fud6lRYFdPGz0xXxycPzmmiw==", "dev": true, "requires": { "path-parse": "1.0.5" @@ -4924,7 +4924,7 @@ "rimraf": { "version": "2.6.2", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", - "integrity": "sha1-LtgVDSShbqhlHm1u8PR8QVjOejY=", + "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", "dev": true, "requires": { "glob": "7.1.2" @@ -5063,19 +5063,19 @@ "safe-buffer": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", - "integrity": "sha1-iTMSr2myEj3vcfV4iQAWce6yyFM=", + "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", "dev": true }, "samsam": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/samsam/-/samsam-1.3.0.tgz", - "integrity": "sha1-jR2TUOJWItow3j5EumkrUiGrfFA=", + "integrity": "sha512-1HwIYD/8UlOtFS3QO3w7ey+SdSDFE4HRNLZoZRYVQefrOY3l17epswImeB1ijgJFQJodIaHcwkp3r/myBjFVbg==", "dev": true }, "semver": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz", - "integrity": "sha1-3Eu8emyp2Rbe5dQ1FvAJK1j3uKs=", + "integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==", "dev": true }, "set-blocking": { @@ -5117,7 +5117,7 @@ "sinon-chai": { "version": "2.14.0", "resolved": "https://registry.npmjs.org/sinon-chai/-/sinon-chai-2.14.0.tgz", - "integrity": "sha1-2n3UzIPNaiYLZ8yg96n9riahIF0=", + "integrity": "sha512-9stIF1utB0ywNHNT7RgiXbdmen8QDCRsrTjw+G9TgKt1Yexjiv8TOWZ6WHsTPz57Yky3DIswZvEqX8fpuHNDtQ==", "dev": true }, "slash": { @@ -5146,7 +5146,7 @@ "sntp": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/sntp/-/sntp-2.1.0.tgz", - "integrity": "sha1-LGzsFP7cIiJznK+bXD2F0cxaLMg=", + "integrity": "sha512-FL1b58BDrqS3A11lJ0zEdnJ3UOKqVxawAkF3k7F0CVN7VQ34aZrV+G8BZ1WC9ZL7NyrwsW0oviwsWDgRuVYtJg==", "dev": true, "requires": { "hoek": "4.2.1" @@ -5203,7 +5203,7 @@ "spdx-correct": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.0.0.tgz", - "integrity": "sha1-BaW01xU6GVvJLDxCW2nzsqlSTII=", + "integrity": "sha512-N19o9z5cEyc8yQQPukRCZ9EUmb4HUpnrmaL/fxS2pBo2jbfcFRVuFZ/oFC+vZz0MNNk0h80iMn5/S6qGZOL5+g==", "dev": true, "requires": { "spdx-expression-parse": "3.0.0", @@ -5213,13 +5213,13 @@ "spdx-exceptions": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.1.0.tgz", - "integrity": "sha1-LHrmEFbHFKW5ubKyr30xHvXHj+k=", + "integrity": "sha512-4K1NsmrlCU1JJgUrtgEeTVyfx8VaYea9J9LvARxhbHtVtohPs/gFGG5yy49beySjlIMhhXZ4QqujIZEfS4l6Cg==", "dev": true }, "spdx-expression-parse": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.0.tgz", - "integrity": "sha1-meEZt6XaAOBUkcn6M4t5BII7QdA=", + "integrity": "sha512-Yg6D3XpRD4kkOmTpdgbUiEJFKghJH03fiC1OPll5h/0sO6neh2jqRDVHOQ4o/LMea0tgCkbMgea5ip/e+MkWyg==", "dev": true, "requires": { "spdx-exceptions": "2.1.0", @@ -5229,7 +5229,7 @@ "spdx-license-ids": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.0.tgz", - "integrity": "sha1-enzShHDMbToc/m1miG9rxDDTrIc=", + "integrity": "sha512-2+EPwgbnmOIl8HjGBXXMd9NAu02vLjOO1nWw4kmeRDFyHn+M/ETfHxQUK0oXg8ctgVnl9t3rosNVsZ1jG61nDA==", "dev": true }, "speedometer": { @@ -5566,7 +5566,7 @@ "tough-cookie": { "version": "2.3.4", "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.4.tgz", - "integrity": "sha1-7GDO44rGdQY//JelwYlwV47oNlU=", + "integrity": "sha512-TZ6TTfI5NtZnuyy/Kecv+CnoROnyXn2DN97LontgQpCwsX2XyLYCC0ENhYkehSOwAp8rTQKc/NUIF7BkQ5rKLA==", "dev": true, "requires": { "punycode": "1.4.1" @@ -5708,13 +5708,13 @@ "uuid": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.2.1.tgz", - "integrity": "sha1-EsUou51Y0LkmXZovbw/ovhf/HxQ=", + "integrity": "sha512-jZnMwlb9Iku/O3smGWvZhauCf6cvvpKi4BKRiliS3cxnI+Gz9j5MEpTz2UFuXiKPJocb7gnsLHwiS05ige5BEA==", "dev": true }, "validate-npm-package-license": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.3.tgz", - "integrity": "sha1-gWQ7y+8b3+zUYjeT3EZIlIupgzg=", + "integrity": "sha512-63ZOUnL4SIXj4L0NixR3L1lcjO38crAbgrTpl28t8jjrfuiOBL5Iygm+60qPs/KsZGzPNg6Smnc/oY16QTjF0g==", "dev": true, "requires": { "spdx-correct": "3.0.0", @@ -5750,7 +5750,7 @@ "which": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/which/-/which-1.3.0.tgz", - "integrity": "sha1-/wS9/AEO5UfXgL7DjhrBwnd9JTo=", + "integrity": "sha512-xcJpopdamTuY5duC/KnTTNBraPK54YwpenP4lzxU8H91GudWpFv38u0CKjclE1Wi2EH2EDz5LRcHcKbCIzqGyg==", "dev": true, "requires": { "isexe": "2.0.0" diff --git a/packages/canvas/canvas-mesh/package.json b/packages/canvas/canvas-mesh/package.json index 691cd2c..6744a17 100644 --- a/packages/canvas/canvas-mesh/package.json +++ b/packages/canvas/canvas-mesh/package.json @@ -24,6 +24,7 @@ "dependencies": { "@pixi/constants": "^5.0.0-alpha.2", "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/mesh-extras": "^5.0.0-alpha.2", "@pixi/settings": "^5.0.0-alpha.2" }, "devDependencies": { diff --git a/packages/canvas/canvas-mesh/src/Mesh.js b/packages/canvas/canvas-mesh/src/Mesh.js index 900a872..c43a74b 100644 --- a/packages/canvas/canvas-mesh/src/Mesh.js +++ b/packages/canvas/canvas-mesh/src/Mesh.js @@ -1,36 +1,14 @@ import { Mesh } from '@pixi/mesh'; -import { settings } from './settings'; - -// IMPORTANT: Please do NOT use this as a precedent to use `settings` after the object is created -// this was merely created to completely decouple canvas from the base Mesh class and we are -// unable to add `canvasPadding` in the constructor anymore, as the case was for PixiJS v4. /** - * Internal variable for `canvasPadding`. + * Renders the object using the Canvas renderer * * @private - * @memberof PIXI.Mesh - * @member {number} - * @default null - */ -Mesh.prototype._canvasPadding = null; - -/** - * Triangles in canvas mode are automatically antialiased, use this value to force triangles - * to overlap a bit with each other. To set the global default, set {@link PIXI.settings.MESH_CANVAS_PADDING} - * - * @see PIXI.settings.MESH_CANVAS_PADDING - * @member {number} canvasPadding + * @method _renderCanvas * @memberof PIXI.Mesh# - * @default 0 + * @param {PIXI.CanvasRenderer} renderer - The canvas renderer. */ -Object.defineProperty(Mesh.prototype, 'canvasPadding', { - get() - { - return this._canvasPadding !== null ? this._canvasPadding : settings.MESH_CANVAS_PADDING; - }, - set(value) - { - this._canvasPadding = value; - }, -}); +Mesh.prototype._renderCanvas = function _renderCanvas(renderer) +{ + renderer.plugins[this.pluginName].render(this); +}; diff --git a/packages/canvas/canvas-mesh/src/Mesh2d.js b/packages/canvas/canvas-mesh/src/Mesh2d.js new file mode 100644 index 0000000..d0bd80f --- /dev/null +++ b/packages/canvas/canvas-mesh/src/Mesh2d.js @@ -0,0 +1,36 @@ +import { Mesh2d } from '@pixi/mesh-extras'; +import { settings } from './settings'; + +// IMPORTANT: Please do NOT use this as a precedent to use `settings` after the object is created +// this was merely created to completely decouple canvas from the base Mesh class and we are +// unable to add `canvasPadding` in the constructor anymore, as the case was for PixiJS v4. + +/** + * Internal variable for `canvasPadding`. + * + * @private + * @memberof PIXI.Mesh2d + * @member {number} + * @default null + */ +Mesh2d.prototype._canvasPadding = null; + +/** + * Triangles in canvas mode are automatically antialiased, use this value to force triangles + * to overlap a bit with each other. To set the global default, set {@link PIXI.settings.MESH_CANVAS_PADDING} + * + * @see PIXI.settings.MESH_CANVAS_PADDING + * @member {number} canvasPadding + * @memberof PIXI.Mesh2d# + * @default 0 + */ +Object.defineProperty(Mesh2d.prototype, 'canvasPadding', { + get() + { + return this._canvasPadding !== null ? this._canvasPadding : settings.MESH_CANVAS_PADDING; + }, + set(value) + { + this._canvasPadding = value; + }, +}); diff --git a/packages/canvas/canvas-mesh/src/NineSlicePlane.js b/packages/canvas/canvas-mesh/src/NineSlicePlane.js index 09eaf9c..2fd5acc 100644 --- a/packages/canvas/canvas-mesh/src/NineSlicePlane.js +++ b/packages/canvas/canvas-mesh/src/NineSlicePlane.js @@ -1,4 +1,4 @@ -import { NineSlicePlane } from '@pixi/mesh'; +import { NineSlicePlane } from '@pixi/mesh-extras'; /** * Renders the object using the Canvas renderer diff --git a/packages/canvas/canvas-mesh/src/RawMesh.js b/packages/canvas/canvas-mesh/src/RawMesh.js deleted file mode 100644 index bf40184..0000000 --- a/packages/canvas/canvas-mesh/src/RawMesh.js +++ /dev/null @@ -1,14 +0,0 @@ -import { RawMesh } from '@pixi/mesh'; - -/** - * Renders the object using the Canvas renderer - * - * @private - * @method _renderCanvas - * @memberof PIXI.RawMesh# - * @param {PIXI.CanvasRenderer} renderer - The canvas renderer. - */ -RawMesh.prototype._renderCanvas = function _renderCanvas(renderer) -{ - renderer.plugins[this.pluginName].render(this); -}; diff --git a/packages/canvas/canvas-mesh/src/index.js b/packages/canvas/canvas-mesh/src/index.js index 2295016..f4fa31d 100644 --- a/packages/canvas/canvas-mesh/src/index.js +++ b/packages/canvas/canvas-mesh/src/index.js @@ -1,6 +1,6 @@ export { default as CanvasMeshRenderer } from './CanvasMeshRenderer'; import './settings'; -import './Mesh'; +import './Mesh2d'; import './NineSlicePlane'; -import './RawMesh'; +import './Mesh'; diff --git a/packages/canvas/canvas-mesh/src/settings.js b/packages/canvas/canvas-mesh/src/settings.js index 4cefb4c..e81b8e0 100644 --- a/packages/canvas/canvas-mesh/src/settings.js +++ b/packages/canvas/canvas-mesh/src/settings.js @@ -3,7 +3,7 @@ /** * Default `canvasPadding` for canvas-based Mesh rendering. * - * @see PIXI.Mesh#canvasPadding + * @see PIXI.Mesh2d#canvasPadding * @static * @constant * @memberof PIXI.settings diff --git a/bundles/pixi.js/package.json b/bundles/pixi.js/package.json index 49c7276..177e059 100644 --- a/bundles/pixi.js/package.json +++ b/bundles/pixi.js/package.json @@ -49,6 +49,7 @@ "@pixi/loaders": "^5.0.0-alpha.2", "@pixi/math": "^5.0.0-alpha.2", "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/mesh-extras": "^5.0.0-alpha.2", "@pixi/mixin-cache-as-bitmap": "^5.0.0-alpha.2", "@pixi/mixin-get-child-by-name": "^5.0.0-alpha.2", "@pixi/mixin-get-global-position": "^5.0.0-alpha.2", diff --git a/bundles/pixi.js/src/deprecated.js b/bundles/pixi.js/src/deprecated.js index 147617c..dbebeb0 100644 --- a/bundles/pixi.js/src/deprecated.js +++ b/bundles/pixi.js/src/deprecated.js @@ -263,15 +263,15 @@ Object.defineProperties(PIXI.mesh, { /** * @class PIXI.mesh.Mesh - * @see PIXI.Mesh + * @see PIXI.Mesh2d * @deprecated since 5.0.0 */ Mesh: { get() { - warn('PIXI.mesh.Mesh has moved to PIXI.Mesh'); + warn('PIXI.mesh.Mesh has moved to PIXI.Mesh2d'); - return PIXI.Mesh; + return PIXI.Mesh2d; }, }, /** @@ -315,15 +315,15 @@ }, /** * @class PIXI.mesh.RawMesh - * @see PIXI.RawMesh + * @see PIXI.Mesh * @deprecated since 5.0.0 */ RawMesh: { get() { - warn('PIXI.mesh.RawMesh has moved to PIXI.RawMesh'); + warn('PIXI.mesh.RawMesh has moved to PIXI.Mesh'); - return PIXI.RawMesh; + return PIXI.Mesh; }, }, /** diff --git a/bundles/pixi.js/src/index.js b/bundles/pixi.js/src/index.js index a3a0d1b..6fdabf0 100644 --- a/bundles/pixi.js/src/index.js +++ b/bundles/pixi.js/src/index.js @@ -9,6 +9,7 @@ import * as loaders from '@pixi/loaders'; import * as math from '@pixi/math'; import * as mesh from '@pixi/mesh'; +import * as meshExtras from '@pixi/mesh-extras'; import * as particles from '@pixi/particles'; import * as prepare from '@pixi/prepare'; import * as sprite from '@pixi/sprite'; @@ -128,6 +129,7 @@ loaders, math, mesh, + meshExtras, particles, sprite, spriteAnimated, @@ -152,6 +154,7 @@ export * from '@pixi/loaders'; export * from '@pixi/math'; export * from '@pixi/mesh'; +export * from '@pixi/mesh-extras'; export * from '@pixi/particles'; export * from '@pixi/sprite'; export * from '@pixi/spritesheet'; diff --git a/package-lock.json b/package-lock.json index 7fe6db7..0814729 100644 --- a/package-lock.json +++ b/package-lock.json @@ -209,7 +209,7 @@ "argparse": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", - "integrity": "sha1-vNZ5HqWuCXJeF+WtmIE0zUCz2RE=", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", "dev": true, "requires": { "sprintf-js": "1.0.3" @@ -228,7 +228,7 @@ "arr-flatten": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz", - "integrity": "sha1-NgSLv/TntH4TZkQxbJlmnqWukfE=", + "integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==", "dev": true }, "arr-union": { @@ -297,7 +297,7 @@ "assertion-error": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", - "integrity": "sha1-5gtrDo8wG9l+U3UhW9pAbIURjAs=", + "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", "dev": true }, "async": { @@ -396,7 +396,7 @@ "brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha1-PH/L9SnYcibz0vUrlm/1Jx60Qd0=", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, "requires": { "balanced-match": "1.0.0", @@ -568,7 +568,7 @@ "circular-json": { "version": "0.3.3", "resolved": "https://registry.npmjs.org/circular-json/-/circular-json-0.3.3.tgz", - "integrity": "sha1-gVyZ6oT2gJUp0vRXkb34JxE1LWY=", + "integrity": "sha512-UZK3NBx2Mca+b5LsG7bY183pHWt5Y1xts4P3Pz7ENTwGVnJOUWbRb3ocjvX7hx9tq/yTAdclXm9sZ38gNuem4A==", "dev": true }, "cli-cursor": { @@ -638,7 +638,7 @@ "color-convert": { "version": "1.9.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.1.tgz", - "integrity": "sha1-wSYRB66y8pTr/+ye2eytUppgl+0=", + "integrity": "sha512-mjGanIiwQJskCC18rPR6OmrZ6fm2Lc7PeGFYwCmy5J34wC6F1PzdGL6xeMfmgicfYcNLGuVFA3WzXtIDCQSZxQ==", "dev": true, "requires": { "color-name": "1.1.3" @@ -1427,7 +1427,7 @@ "boom": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/boom/-/boom-5.2.0.tgz", - "integrity": "sha1-XdnabuOl8wIHdDYpDLcX0/SlTgI=", + "integrity": "sha512-Z5BTk6ZRe4tXXQlkqftmsAUANpXmuwlsF5Oov8ThoMbQRzdGTA1ngYRW160GexgOgjsFOKJz0LYhoNi+2AMBUw==", "dev": true, "requires": { "hoek": "4.2.1" @@ -1471,7 +1471,7 @@ "debug": { "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha1-XRKFFd8TT/Mn6QpMk/Tgd6U2NB8=", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", "dev": true, "requires": { "ms": "2.0.0" @@ -1585,7 +1585,7 @@ "doctrine": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", - "integrity": "sha1-XNAfwQFiG0LEzX9dGmYkNxbT850=", + "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", "dev": true, "requires": { "esutils": "2.0.2" @@ -1662,7 +1662,7 @@ "es6-promise": { "version": "4.2.4", "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.4.tgz", - "integrity": "sha1-3EIhwrFlGHYL2MOaUtjzVvwA7Sk=", + "integrity": "sha512-/NdNZVJg+uZgtm9eS3O6lrOLYmQag2DjdEXuPaHlZ6RuVqgqaVZfgYCepEIKsLqwdQArOPtC3XzRLqGGfT8KQQ==", "dev": true }, "escape-string-regexp": { @@ -1788,7 +1788,7 @@ "espree": { "version": "3.5.4", "resolved": "https://registry.npmjs.org/espree/-/espree-3.5.4.tgz", - "integrity": "sha1-sPRHGHyKi+2US4FaZgvd9d610ac=", + "integrity": "sha512-yAcIQxtmMiB/jL32dzEp2enBeidsB7xWPLNiw3IIkpVds1P+h7qF9YwJq1yUNzp2OKXgAprs4F61ih66UsoD1A==", "dev": true, "requires": { "acorn": "5.5.0", @@ -1798,7 +1798,7 @@ "esprima": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.0.tgz", - "integrity": "sha1-RJnt3NERDgshi6zy+n9/WfVcqAQ=", + "integrity": "sha512-oftTcaMu/EGrEIu904mWteKIv8vMuOgGYo7EhVJJN00R/EED9DCua/xxHRdYnKtcECzVg7xOWhflvJMnqcFZjw==", "dev": true }, "esquery": { @@ -1813,7 +1813,7 @@ "esrecurse": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.2.1.tgz", - "integrity": "sha1-AHo7n9vCs7uH5IeeoZyS/b05Qs8=", + "integrity": "sha512-64RBB++fIOAXPw3P9cy89qfMlvZEXZkqqJkjqqXIvzP5ezRZjW+lPWjw35UX/3EhUPFYbg5ER4JYgDw4007/DQ==", "dev": true, "requires": { "estraverse": "4.2.0" @@ -2024,7 +2024,7 @@ "find-root": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/find-root/-/find-root-1.1.0.tgz", - "integrity": "sha1-q8/Iunb3CMQql7PWhbfpRQv7nOQ=", + "integrity": "sha512-NKfW6bec6GfKc0SGx1e07QZY9PE99u0Bft/0rzSD5k3sO/vwkVUpDUKVm5Gpp5Ue3YfShPFTX2070tDs5kB9Ng==", "dev": true }, "find-up": { @@ -2103,7 +2103,7 @@ "supports-color": { "version": "5.3.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.3.0.tgz", - "integrity": "sha1-WySsFduA+pJ89SJ6SjP9PEx2dsA=", + "integrity": "sha512-0aP01LLIskjKs3lq52EC0aGBAJhLq7B2Rd8HC/DR/PtNNpcLilNmHC12O+hu0usQpo7wtHNRqtrhBwtDb0+dNg==", "dev": true, "requires": { "has-flag": "3.0.0" @@ -2567,7 +2567,7 @@ "glob": { "version": "7.1.2", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", - "integrity": "sha1-wZyd+aAocC1nhhI4SmVSQExjbRU=", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", "dev": true, "requires": { "fs.realpath": "1.0.0", @@ -2672,7 +2672,7 @@ "growl": { "version": "1.10.3", "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.3.tgz", - "integrity": "sha1-GSa6kM8+3+KttJJ/WIC8IsZseQ8=", + "integrity": "sha512-hKlsbA5Vu3xsh1Cg3J7jSmX/WaW6A5oBeqzM88oNbCRQFz+zUaXm6yxS4RVytp1scBoJzSYl4YAEOQIt6O8V1Q==", "dev": true }, "handlebars": { @@ -2738,7 +2738,7 @@ "hawk": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/hawk/-/hawk-6.0.2.tgz", - "integrity": "sha1-r02RTrBl+bXOTZ0RwcshJu7MMDg=", + "integrity": "sha512-miowhl2+U7Qle4vdLqDdPt9m09K6yZhkLDTWGoUiUzrQCn+mHHSmfJgAyGaLRZbPmTqfFFjRV1QWCW0VWUJBbQ==", "dev": true, "requires": { "boom": "4.3.1", @@ -2756,7 +2756,7 @@ "hoek": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/hoek/-/hoek-4.2.1.tgz", - "integrity": "sha1-ljRQKqEsRF3Vp8VzS1cruHOKrLs=", + "integrity": "sha512-QLg82fGkfnJ/4iy1xZ81/9SIJiq1NGFUMGs6ParyjBZr6jW2Ufj/snDqTHixNlHdPNwN2RLVD0Pi3igeK9+JfA==", "dev": true }, "home-path": { @@ -2791,7 +2791,7 @@ "ignore": { "version": "3.3.7", "resolved": "https://registry.npmjs.org/ignore/-/ignore-3.3.7.tgz", - "integrity": "sha1-YSKJv7PCIOGGpYEYYY1b6MG6sCE=", + "integrity": "sha512-YGG3ejvBNHRqu0559EOxxNFihD0AjpvHlC/pdGKd3X3ofe+CoJkYazwNJYTNebqpPKN+VVQbh4ZFn1DivMNuHA==", "dev": true }, "imurmurhash": { @@ -2828,7 +2828,7 @@ "ini": { "version": "1.3.5", "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", - "integrity": "sha1-7uJfVtscnsYIXgwid4CD9Zar+Sc=", + "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==", "dev": true }, "inquirer": { @@ -2901,7 +2901,7 @@ "is-buffer": { "version": "1.1.6", "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", - "integrity": "sha1-76ouqdqg16suoTqXsritUf776L4=", + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", "dev": true }, "is-builtin-module": { @@ -3054,7 +3054,7 @@ "is-resolvable": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/is-resolvable/-/is-resolvable-1.1.0.tgz", - "integrity": "sha1-+xj4fOH+uSUWnJpAfBkxijIG7Yg=", + "integrity": "sha512-qgDYXFSR5WvEfuS5dMj6oTMEbrrSaM0CrFk2Yiq/gXnBvD9pMa2jGXxyhGLfvhZpuMZe18CJpFxAt3CRs42NMg==", "dev": true }, "is-retry-allowed": { @@ -3204,7 +3204,7 @@ "js-yaml": { "version": "3.11.0", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.11.0.tgz", - "integrity": "sha1-WXwai9VxUvJtYizkEXhRpR9euu8=", + "integrity": "sha512-saJstZWv7oNeOyBh3+Dx1qWzhW0+e6/8eDzo7p5rDFqxntSztloLtuKu+Ejhtq82jsilwOIZYsCz+lIjthg1Hw==", "dev": true, "requires": { "argparse": "1.0.10", @@ -3324,7 +3324,7 @@ "just-extend": { "version": "1.1.27", "resolved": "https://registry.npmjs.org/just-extend/-/just-extend-1.1.27.tgz", - "integrity": "sha1-7G55QQ/5FORyZSq/oOYDwD1g6QU=", + "integrity": "sha512-mJVp13Ix6gFo3SBAy9U/kL+oeZqzlYYYLQBwXVBlVzIsZwBqGREnOro24oC/8s8aox+rJhtZ2DiQof++IrkA+g==", "dev": true }, "kind-of": { @@ -3703,7 +3703,7 @@ "lodash": { "version": "4.17.5", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.5.tgz", - "integrity": "sha1-maktZcAnLevoyWtgV7yPv6O+1RE=", + "integrity": "sha512-svL3uiZf1RwhH+cWrfZn3A4+U58wbP0tGVTLQPbjplZxZ8ROD9VLuNgsRniTlLe7OlSqR79RUehXgpBW/s0IQw==", "dev": true }, "lodash._reinterpolate": { @@ -3740,7 +3740,7 @@ "lolex": { "version": "2.3.2", "resolved": "https://registry.npmjs.org/lolex/-/lolex-2.3.2.tgz", - "integrity": "sha1-hflFBCUQO/nnpgZo6iXcQydMqAc=", + "integrity": "sha512-A5pN2tkFj7H0dGIAM6MFvHKMJcPnjZsOMvR7ujCjfgW5TbV6H9vb1PgxLtHvjqNZTHsUolz+6/WEO0N1xNx2ng==", "dev": true }, "longest": { @@ -3816,7 +3816,7 @@ "marked": { "version": "0.3.17", "resolved": "https://registry.npmjs.org/marked/-/marked-0.3.17.tgz", - "integrity": "sha1-YH8GZos8axJGso8T2nYRasGqLSs=", + "integrity": "sha512-+AKbNsjZl6jFfLPwHhWmGTqE009wTKn3RTmn9K8oUKHrX/abPJjtcRtXpYB/FFrwPJRUA86LX/de3T0knkPCmQ==", "dev": true }, "mem": { @@ -3896,13 +3896,13 @@ "mime-db": { "version": "1.33.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.33.0.tgz", - "integrity": "sha1-o0kgUKXLm2NFBUHjnZeI0icng9s=", + "integrity": "sha512-BHJ/EKruNIqJf/QahvxwQZXKygOQ256myeN/Ew+THcAa5q+PjyTTMMeNQC4DZw5AwfvelsUrA6B67NKMqXDbzQ==", "dev": true }, "mime-types": { "version": "2.1.18", "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.18.tgz", - "integrity": "sha1-bzI/YKg9ERRvgx/xH9ZuL+VQO7g=", + "integrity": "sha512-lc/aahn+t4/SWV/qcmumYjymLsWfN3ELhpmVuUFjgsORruuZPVSwAQryq+HHGvO/SI2KVX26bx+En+zhM8g8hQ==", "dev": true, "requires": { "mime-db": "1.33.0" @@ -3917,7 +3917,7 @@ "minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha1-UWbihkV/AzBgZL5Ul+jbsMPTIIM=", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "dev": true, "requires": { "brace-expansion": "1.1.11" @@ -4071,7 +4071,7 @@ "normalize-package-data": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.4.0.tgz", - "integrity": "sha1-EvlaMH1YNSB1oEkHuErIvpisAS8=", + "integrity": "sha512-9jjUFbTPfEy3R/ad/2oNbKtW9Hgovl5O1FvFWKkKblNXoN/Oou6+9+KKohPK13Yc3/TyunyWhJp6gvRNR/PPAw==", "dev": true, "requires": { "hosted-git-info": "2.5.0", @@ -4511,7 +4511,7 @@ "process-nextick-args": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", - "integrity": "sha1-o31zL0JxtKsa0HDTVQjoKQeI/6o=", + "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==", "dev": true }, "progress": { @@ -4584,7 +4584,7 @@ "qs": { "version": "6.5.1", "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.1.tgz", - "integrity": "sha1-NJzfbu+J7EXBLX1es/wMhwNDptg=", + "integrity": "sha512-eRzhrN1WSINYCDCbrz796z37LOe3m5tmW7RQf6oBntukAG1nmovJvhnwHHRMAfeoItc1m2Hk02WER2aQ/iqs+A==", "dev": true }, "quick-lru": { @@ -4596,7 +4596,7 @@ "randomatic": { "version": "1.1.7", "resolved": "https://registry.npmjs.org/randomatic/-/randomatic-1.1.7.tgz", - "integrity": "sha1-x6vpzIuHwLqodrGf3oP9RkeX44w=", + "integrity": "sha512-D5JUjPyJbaJDkuAazpVnSfVkLlpeO3wDlPROTMLGKG1zMFNFRgrciKo1ltz/AzNTkqE0HzDx655QOL51N06how==", "dev": true, "requires": { "is-number": "3.0.0", @@ -4701,7 +4701,7 @@ "regex-cache": { "version": "0.4.4", "resolved": "https://registry.npmjs.org/regex-cache/-/regex-cache-0.4.4.tgz", - "integrity": "sha1-db3FiioUls7EihKDW8VMjVYjNt0=", + "integrity": "sha512-nVIZwtCjkC9YgvWkpM55B5rBhBYRZhAaJbgcFYXXsHnbZ9UZI9nnVWYZpBlCqv9ho2eZryPnWrZGsOdPwVWXWQ==", "dev": true, "requires": { "is-equal-shallow": "0.1.3" @@ -4729,7 +4729,7 @@ "remap-istanbul": { "version": "0.10.1", "resolved": "https://registry.npmjs.org/remap-istanbul/-/remap-istanbul-0.10.1.tgz", - "integrity": "sha1-OqWN1QIdSZ8zbTulvzu7kcG4jjc=", + "integrity": "sha512-gsNQXs5kJLhErICSyYhzVZ++C8LBW8dgwr874Y2QvzAUS75zBlD/juZgXs39nbYJ09fZDlX2AVLVJAY2jbFJoQ==", "dev": true, "requires": { "amdefine": "1.0.1", @@ -4769,7 +4769,7 @@ "source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha1-dHIq8y6WFOnCh6jQu95IteLxomM=", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", "dev": true }, "through2": { @@ -4883,7 +4883,7 @@ "resolve": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.5.0.tgz", - "integrity": "sha1-HwmsznlsmnYlefMbLBzEw83fnzY=", + "integrity": "sha512-hgoSGrc3pjzAPHNBg+KnFcK2HwlHTs/YrAGUr6qgTVUZmXv1UEXXl0bZNBKMA9fud6lRYFdPGz0xXxycPzmmiw==", "dev": true, "requires": { "path-parse": "1.0.5" @@ -4924,7 +4924,7 @@ "rimraf": { "version": "2.6.2", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", - "integrity": "sha1-LtgVDSShbqhlHm1u8PR8QVjOejY=", + "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", "dev": true, "requires": { "glob": "7.1.2" @@ -5063,19 +5063,19 @@ "safe-buffer": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", - "integrity": "sha1-iTMSr2myEj3vcfV4iQAWce6yyFM=", + "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", "dev": true }, "samsam": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/samsam/-/samsam-1.3.0.tgz", - "integrity": "sha1-jR2TUOJWItow3j5EumkrUiGrfFA=", + "integrity": "sha512-1HwIYD/8UlOtFS3QO3w7ey+SdSDFE4HRNLZoZRYVQefrOY3l17epswImeB1ijgJFQJodIaHcwkp3r/myBjFVbg==", "dev": true }, "semver": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz", - "integrity": "sha1-3Eu8emyp2Rbe5dQ1FvAJK1j3uKs=", + "integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==", "dev": true }, "set-blocking": { @@ -5117,7 +5117,7 @@ "sinon-chai": { "version": "2.14.0", "resolved": "https://registry.npmjs.org/sinon-chai/-/sinon-chai-2.14.0.tgz", - "integrity": "sha1-2n3UzIPNaiYLZ8yg96n9riahIF0=", + "integrity": "sha512-9stIF1utB0ywNHNT7RgiXbdmen8QDCRsrTjw+G9TgKt1Yexjiv8TOWZ6WHsTPz57Yky3DIswZvEqX8fpuHNDtQ==", "dev": true }, "slash": { @@ -5146,7 +5146,7 @@ "sntp": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/sntp/-/sntp-2.1.0.tgz", - "integrity": "sha1-LGzsFP7cIiJznK+bXD2F0cxaLMg=", + "integrity": "sha512-FL1b58BDrqS3A11lJ0zEdnJ3UOKqVxawAkF3k7F0CVN7VQ34aZrV+G8BZ1WC9ZL7NyrwsW0oviwsWDgRuVYtJg==", "dev": true, "requires": { "hoek": "4.2.1" @@ -5203,7 +5203,7 @@ "spdx-correct": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.0.0.tgz", - "integrity": "sha1-BaW01xU6GVvJLDxCW2nzsqlSTII=", + "integrity": "sha512-N19o9z5cEyc8yQQPukRCZ9EUmb4HUpnrmaL/fxS2pBo2jbfcFRVuFZ/oFC+vZz0MNNk0h80iMn5/S6qGZOL5+g==", "dev": true, "requires": { "spdx-expression-parse": "3.0.0", @@ -5213,13 +5213,13 @@ "spdx-exceptions": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.1.0.tgz", - "integrity": "sha1-LHrmEFbHFKW5ubKyr30xHvXHj+k=", + "integrity": "sha512-4K1NsmrlCU1JJgUrtgEeTVyfx8VaYea9J9LvARxhbHtVtohPs/gFGG5yy49beySjlIMhhXZ4QqujIZEfS4l6Cg==", "dev": true }, "spdx-expression-parse": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.0.tgz", - "integrity": "sha1-meEZt6XaAOBUkcn6M4t5BII7QdA=", + "integrity": "sha512-Yg6D3XpRD4kkOmTpdgbUiEJFKghJH03fiC1OPll5h/0sO6neh2jqRDVHOQ4o/LMea0tgCkbMgea5ip/e+MkWyg==", "dev": true, "requires": { "spdx-exceptions": "2.1.0", @@ -5229,7 +5229,7 @@ "spdx-license-ids": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.0.tgz", - "integrity": "sha1-enzShHDMbToc/m1miG9rxDDTrIc=", + "integrity": "sha512-2+EPwgbnmOIl8HjGBXXMd9NAu02vLjOO1nWw4kmeRDFyHn+M/ETfHxQUK0oXg8ctgVnl9t3rosNVsZ1jG61nDA==", "dev": true }, "speedometer": { @@ -5566,7 +5566,7 @@ "tough-cookie": { "version": "2.3.4", "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.4.tgz", - "integrity": "sha1-7GDO44rGdQY//JelwYlwV47oNlU=", + "integrity": "sha512-TZ6TTfI5NtZnuyy/Kecv+CnoROnyXn2DN97LontgQpCwsX2XyLYCC0ENhYkehSOwAp8rTQKc/NUIF7BkQ5rKLA==", "dev": true, "requires": { "punycode": "1.4.1" @@ -5708,13 +5708,13 @@ "uuid": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.2.1.tgz", - "integrity": "sha1-EsUou51Y0LkmXZovbw/ovhf/HxQ=", + "integrity": "sha512-jZnMwlb9Iku/O3smGWvZhauCf6cvvpKi4BKRiliS3cxnI+Gz9j5MEpTz2UFuXiKPJocb7gnsLHwiS05ige5BEA==", "dev": true }, "validate-npm-package-license": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.3.tgz", - "integrity": "sha1-gWQ7y+8b3+zUYjeT3EZIlIupgzg=", + "integrity": "sha512-63ZOUnL4SIXj4L0NixR3L1lcjO38crAbgrTpl28t8jjrfuiOBL5Iygm+60qPs/KsZGzPNg6Smnc/oY16QTjF0g==", "dev": true, "requires": { "spdx-correct": "3.0.0", @@ -5750,7 +5750,7 @@ "which": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/which/-/which-1.3.0.tgz", - "integrity": "sha1-/wS9/AEO5UfXgL7DjhrBwnd9JTo=", + "integrity": "sha512-xcJpopdamTuY5duC/KnTTNBraPK54YwpenP4lzxU8H91GudWpFv38u0CKjclE1Wi2EH2EDz5LRcHcKbCIzqGyg==", "dev": true, "requires": { "isexe": "2.0.0" diff --git a/packages/canvas/canvas-mesh/package.json b/packages/canvas/canvas-mesh/package.json index 691cd2c..6744a17 100644 --- a/packages/canvas/canvas-mesh/package.json +++ b/packages/canvas/canvas-mesh/package.json @@ -24,6 +24,7 @@ "dependencies": { "@pixi/constants": "^5.0.0-alpha.2", "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/mesh-extras": "^5.0.0-alpha.2", "@pixi/settings": "^5.0.0-alpha.2" }, "devDependencies": { diff --git a/packages/canvas/canvas-mesh/src/Mesh.js b/packages/canvas/canvas-mesh/src/Mesh.js index 900a872..c43a74b 100644 --- a/packages/canvas/canvas-mesh/src/Mesh.js +++ b/packages/canvas/canvas-mesh/src/Mesh.js @@ -1,36 +1,14 @@ import { Mesh } from '@pixi/mesh'; -import { settings } from './settings'; - -// IMPORTANT: Please do NOT use this as a precedent to use `settings` after the object is created -// this was merely created to completely decouple canvas from the base Mesh class and we are -// unable to add `canvasPadding` in the constructor anymore, as the case was for PixiJS v4. /** - * Internal variable for `canvasPadding`. + * Renders the object using the Canvas renderer * * @private - * @memberof PIXI.Mesh - * @member {number} - * @default null - */ -Mesh.prototype._canvasPadding = null; - -/** - * Triangles in canvas mode are automatically antialiased, use this value to force triangles - * to overlap a bit with each other. To set the global default, set {@link PIXI.settings.MESH_CANVAS_PADDING} - * - * @see PIXI.settings.MESH_CANVAS_PADDING - * @member {number} canvasPadding + * @method _renderCanvas * @memberof PIXI.Mesh# - * @default 0 + * @param {PIXI.CanvasRenderer} renderer - The canvas renderer. */ -Object.defineProperty(Mesh.prototype, 'canvasPadding', { - get() - { - return this._canvasPadding !== null ? this._canvasPadding : settings.MESH_CANVAS_PADDING; - }, - set(value) - { - this._canvasPadding = value; - }, -}); +Mesh.prototype._renderCanvas = function _renderCanvas(renderer) +{ + renderer.plugins[this.pluginName].render(this); +}; diff --git a/packages/canvas/canvas-mesh/src/Mesh2d.js b/packages/canvas/canvas-mesh/src/Mesh2d.js new file mode 100644 index 0000000..d0bd80f --- /dev/null +++ b/packages/canvas/canvas-mesh/src/Mesh2d.js @@ -0,0 +1,36 @@ +import { Mesh2d } from '@pixi/mesh-extras'; +import { settings } from './settings'; + +// IMPORTANT: Please do NOT use this as a precedent to use `settings` after the object is created +// this was merely created to completely decouple canvas from the base Mesh class and we are +// unable to add `canvasPadding` in the constructor anymore, as the case was for PixiJS v4. + +/** + * Internal variable for `canvasPadding`. + * + * @private + * @memberof PIXI.Mesh2d + * @member {number} + * @default null + */ +Mesh2d.prototype._canvasPadding = null; + +/** + * Triangles in canvas mode are automatically antialiased, use this value to force triangles + * to overlap a bit with each other. To set the global default, set {@link PIXI.settings.MESH_CANVAS_PADDING} + * + * @see PIXI.settings.MESH_CANVAS_PADDING + * @member {number} canvasPadding + * @memberof PIXI.Mesh2d# + * @default 0 + */ +Object.defineProperty(Mesh2d.prototype, 'canvasPadding', { + get() + { + return this._canvasPadding !== null ? this._canvasPadding : settings.MESH_CANVAS_PADDING; + }, + set(value) + { + this._canvasPadding = value; + }, +}); diff --git a/packages/canvas/canvas-mesh/src/NineSlicePlane.js b/packages/canvas/canvas-mesh/src/NineSlicePlane.js index 09eaf9c..2fd5acc 100644 --- a/packages/canvas/canvas-mesh/src/NineSlicePlane.js +++ b/packages/canvas/canvas-mesh/src/NineSlicePlane.js @@ -1,4 +1,4 @@ -import { NineSlicePlane } from '@pixi/mesh'; +import { NineSlicePlane } from '@pixi/mesh-extras'; /** * Renders the object using the Canvas renderer diff --git a/packages/canvas/canvas-mesh/src/RawMesh.js b/packages/canvas/canvas-mesh/src/RawMesh.js deleted file mode 100644 index bf40184..0000000 --- a/packages/canvas/canvas-mesh/src/RawMesh.js +++ /dev/null @@ -1,14 +0,0 @@ -import { RawMesh } from '@pixi/mesh'; - -/** - * Renders the object using the Canvas renderer - * - * @private - * @method _renderCanvas - * @memberof PIXI.RawMesh# - * @param {PIXI.CanvasRenderer} renderer - The canvas renderer. - */ -RawMesh.prototype._renderCanvas = function _renderCanvas(renderer) -{ - renderer.plugins[this.pluginName].render(this); -}; diff --git a/packages/canvas/canvas-mesh/src/index.js b/packages/canvas/canvas-mesh/src/index.js index 2295016..f4fa31d 100644 --- a/packages/canvas/canvas-mesh/src/index.js +++ b/packages/canvas/canvas-mesh/src/index.js @@ -1,6 +1,6 @@ export { default as CanvasMeshRenderer } from './CanvasMeshRenderer'; import './settings'; -import './Mesh'; +import './Mesh2d'; import './NineSlicePlane'; -import './RawMesh'; +import './Mesh'; diff --git a/packages/canvas/canvas-mesh/src/settings.js b/packages/canvas/canvas-mesh/src/settings.js index 4cefb4c..e81b8e0 100644 --- a/packages/canvas/canvas-mesh/src/settings.js +++ b/packages/canvas/canvas-mesh/src/settings.js @@ -3,7 +3,7 @@ /** * Default `canvasPadding` for canvas-based Mesh rendering. * - * @see PIXI.Mesh#canvasPadding + * @see PIXI.Mesh2d#canvasPadding * @static * @constant * @memberof PIXI.settings diff --git a/packages/mesh-extras/LICENSE b/packages/mesh-extras/LICENSE new file mode 100644 index 0000000..148e3eb --- /dev/null +++ b/packages/mesh-extras/LICENSE @@ -0,0 +1,21 @@ +The MIT License + +Copyright (c) 2013-2018 Mathew Groves, Chad Engler + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/bundles/pixi.js/package.json b/bundles/pixi.js/package.json index 49c7276..177e059 100644 --- a/bundles/pixi.js/package.json +++ b/bundles/pixi.js/package.json @@ -49,6 +49,7 @@ "@pixi/loaders": "^5.0.0-alpha.2", "@pixi/math": "^5.0.0-alpha.2", "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/mesh-extras": "^5.0.0-alpha.2", "@pixi/mixin-cache-as-bitmap": "^5.0.0-alpha.2", "@pixi/mixin-get-child-by-name": "^5.0.0-alpha.2", "@pixi/mixin-get-global-position": "^5.0.0-alpha.2", diff --git a/bundles/pixi.js/src/deprecated.js b/bundles/pixi.js/src/deprecated.js index 147617c..dbebeb0 100644 --- a/bundles/pixi.js/src/deprecated.js +++ b/bundles/pixi.js/src/deprecated.js @@ -263,15 +263,15 @@ Object.defineProperties(PIXI.mesh, { /** * @class PIXI.mesh.Mesh - * @see PIXI.Mesh + * @see PIXI.Mesh2d * @deprecated since 5.0.0 */ Mesh: { get() { - warn('PIXI.mesh.Mesh has moved to PIXI.Mesh'); + warn('PIXI.mesh.Mesh has moved to PIXI.Mesh2d'); - return PIXI.Mesh; + return PIXI.Mesh2d; }, }, /** @@ -315,15 +315,15 @@ }, /** * @class PIXI.mesh.RawMesh - * @see PIXI.RawMesh + * @see PIXI.Mesh * @deprecated since 5.0.0 */ RawMesh: { get() { - warn('PIXI.mesh.RawMesh has moved to PIXI.RawMesh'); + warn('PIXI.mesh.RawMesh has moved to PIXI.Mesh'); - return PIXI.RawMesh; + return PIXI.Mesh; }, }, /** diff --git a/bundles/pixi.js/src/index.js b/bundles/pixi.js/src/index.js index a3a0d1b..6fdabf0 100644 --- a/bundles/pixi.js/src/index.js +++ b/bundles/pixi.js/src/index.js @@ -9,6 +9,7 @@ import * as loaders from '@pixi/loaders'; import * as math from '@pixi/math'; import * as mesh from '@pixi/mesh'; +import * as meshExtras from '@pixi/mesh-extras'; import * as particles from '@pixi/particles'; import * as prepare from '@pixi/prepare'; import * as sprite from '@pixi/sprite'; @@ -128,6 +129,7 @@ loaders, math, mesh, + meshExtras, particles, sprite, spriteAnimated, @@ -152,6 +154,7 @@ export * from '@pixi/loaders'; export * from '@pixi/math'; export * from '@pixi/mesh'; +export * from '@pixi/mesh-extras'; export * from '@pixi/particles'; export * from '@pixi/sprite'; export * from '@pixi/spritesheet'; diff --git a/package-lock.json b/package-lock.json index 7fe6db7..0814729 100644 --- a/package-lock.json +++ b/package-lock.json @@ -209,7 +209,7 @@ "argparse": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", - "integrity": "sha1-vNZ5HqWuCXJeF+WtmIE0zUCz2RE=", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", "dev": true, "requires": { "sprintf-js": "1.0.3" @@ -228,7 +228,7 @@ "arr-flatten": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz", - "integrity": "sha1-NgSLv/TntH4TZkQxbJlmnqWukfE=", + "integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==", "dev": true }, "arr-union": { @@ -297,7 +297,7 @@ "assertion-error": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", - "integrity": "sha1-5gtrDo8wG9l+U3UhW9pAbIURjAs=", + "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", "dev": true }, "async": { @@ -396,7 +396,7 @@ "brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha1-PH/L9SnYcibz0vUrlm/1Jx60Qd0=", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, "requires": { "balanced-match": "1.0.0", @@ -568,7 +568,7 @@ "circular-json": { "version": "0.3.3", "resolved": "https://registry.npmjs.org/circular-json/-/circular-json-0.3.3.tgz", - "integrity": "sha1-gVyZ6oT2gJUp0vRXkb34JxE1LWY=", + "integrity": "sha512-UZK3NBx2Mca+b5LsG7bY183pHWt5Y1xts4P3Pz7ENTwGVnJOUWbRb3ocjvX7hx9tq/yTAdclXm9sZ38gNuem4A==", "dev": true }, "cli-cursor": { @@ -638,7 +638,7 @@ "color-convert": { "version": "1.9.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.1.tgz", - "integrity": "sha1-wSYRB66y8pTr/+ye2eytUppgl+0=", + "integrity": "sha512-mjGanIiwQJskCC18rPR6OmrZ6fm2Lc7PeGFYwCmy5J34wC6F1PzdGL6xeMfmgicfYcNLGuVFA3WzXtIDCQSZxQ==", "dev": true, "requires": { "color-name": "1.1.3" @@ -1427,7 +1427,7 @@ "boom": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/boom/-/boom-5.2.0.tgz", - "integrity": "sha1-XdnabuOl8wIHdDYpDLcX0/SlTgI=", + "integrity": "sha512-Z5BTk6ZRe4tXXQlkqftmsAUANpXmuwlsF5Oov8ThoMbQRzdGTA1ngYRW160GexgOgjsFOKJz0LYhoNi+2AMBUw==", "dev": true, "requires": { "hoek": "4.2.1" @@ -1471,7 +1471,7 @@ "debug": { "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha1-XRKFFd8TT/Mn6QpMk/Tgd6U2NB8=", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", "dev": true, "requires": { "ms": "2.0.0" @@ -1585,7 +1585,7 @@ "doctrine": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", - "integrity": "sha1-XNAfwQFiG0LEzX9dGmYkNxbT850=", + "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", "dev": true, "requires": { "esutils": "2.0.2" @@ -1662,7 +1662,7 @@ "es6-promise": { "version": "4.2.4", "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.4.tgz", - "integrity": "sha1-3EIhwrFlGHYL2MOaUtjzVvwA7Sk=", + "integrity": "sha512-/NdNZVJg+uZgtm9eS3O6lrOLYmQag2DjdEXuPaHlZ6RuVqgqaVZfgYCepEIKsLqwdQArOPtC3XzRLqGGfT8KQQ==", "dev": true }, "escape-string-regexp": { @@ -1788,7 +1788,7 @@ "espree": { "version": "3.5.4", "resolved": "https://registry.npmjs.org/espree/-/espree-3.5.4.tgz", - "integrity": "sha1-sPRHGHyKi+2US4FaZgvd9d610ac=", + "integrity": "sha512-yAcIQxtmMiB/jL32dzEp2enBeidsB7xWPLNiw3IIkpVds1P+h7qF9YwJq1yUNzp2OKXgAprs4F61ih66UsoD1A==", "dev": true, "requires": { "acorn": "5.5.0", @@ -1798,7 +1798,7 @@ "esprima": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.0.tgz", - "integrity": "sha1-RJnt3NERDgshi6zy+n9/WfVcqAQ=", + "integrity": "sha512-oftTcaMu/EGrEIu904mWteKIv8vMuOgGYo7EhVJJN00R/EED9DCua/xxHRdYnKtcECzVg7xOWhflvJMnqcFZjw==", "dev": true }, "esquery": { @@ -1813,7 +1813,7 @@ "esrecurse": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.2.1.tgz", - "integrity": "sha1-AHo7n9vCs7uH5IeeoZyS/b05Qs8=", + "integrity": "sha512-64RBB++fIOAXPw3P9cy89qfMlvZEXZkqqJkjqqXIvzP5ezRZjW+lPWjw35UX/3EhUPFYbg5ER4JYgDw4007/DQ==", "dev": true, "requires": { "estraverse": "4.2.0" @@ -2024,7 +2024,7 @@ "find-root": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/find-root/-/find-root-1.1.0.tgz", - "integrity": "sha1-q8/Iunb3CMQql7PWhbfpRQv7nOQ=", + "integrity": "sha512-NKfW6bec6GfKc0SGx1e07QZY9PE99u0Bft/0rzSD5k3sO/vwkVUpDUKVm5Gpp5Ue3YfShPFTX2070tDs5kB9Ng==", "dev": true }, "find-up": { @@ -2103,7 +2103,7 @@ "supports-color": { "version": "5.3.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.3.0.tgz", - "integrity": "sha1-WySsFduA+pJ89SJ6SjP9PEx2dsA=", + "integrity": "sha512-0aP01LLIskjKs3lq52EC0aGBAJhLq7B2Rd8HC/DR/PtNNpcLilNmHC12O+hu0usQpo7wtHNRqtrhBwtDb0+dNg==", "dev": true, "requires": { "has-flag": "3.0.0" @@ -2567,7 +2567,7 @@ "glob": { "version": "7.1.2", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", - "integrity": "sha1-wZyd+aAocC1nhhI4SmVSQExjbRU=", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", "dev": true, "requires": { "fs.realpath": "1.0.0", @@ -2672,7 +2672,7 @@ "growl": { "version": "1.10.3", "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.3.tgz", - "integrity": "sha1-GSa6kM8+3+KttJJ/WIC8IsZseQ8=", + "integrity": "sha512-hKlsbA5Vu3xsh1Cg3J7jSmX/WaW6A5oBeqzM88oNbCRQFz+zUaXm6yxS4RVytp1scBoJzSYl4YAEOQIt6O8V1Q==", "dev": true }, "handlebars": { @@ -2738,7 +2738,7 @@ "hawk": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/hawk/-/hawk-6.0.2.tgz", - "integrity": "sha1-r02RTrBl+bXOTZ0RwcshJu7MMDg=", + "integrity": "sha512-miowhl2+U7Qle4vdLqDdPt9m09K6yZhkLDTWGoUiUzrQCn+mHHSmfJgAyGaLRZbPmTqfFFjRV1QWCW0VWUJBbQ==", "dev": true, "requires": { "boom": "4.3.1", @@ -2756,7 +2756,7 @@ "hoek": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/hoek/-/hoek-4.2.1.tgz", - "integrity": "sha1-ljRQKqEsRF3Vp8VzS1cruHOKrLs=", + "integrity": "sha512-QLg82fGkfnJ/4iy1xZ81/9SIJiq1NGFUMGs6ParyjBZr6jW2Ufj/snDqTHixNlHdPNwN2RLVD0Pi3igeK9+JfA==", "dev": true }, "home-path": { @@ -2791,7 +2791,7 @@ "ignore": { "version": "3.3.7", "resolved": "https://registry.npmjs.org/ignore/-/ignore-3.3.7.tgz", - "integrity": "sha1-YSKJv7PCIOGGpYEYYY1b6MG6sCE=", + "integrity": "sha512-YGG3ejvBNHRqu0559EOxxNFihD0AjpvHlC/pdGKd3X3ofe+CoJkYazwNJYTNebqpPKN+VVQbh4ZFn1DivMNuHA==", "dev": true }, "imurmurhash": { @@ -2828,7 +2828,7 @@ "ini": { "version": "1.3.5", "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", - "integrity": "sha1-7uJfVtscnsYIXgwid4CD9Zar+Sc=", + "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==", "dev": true }, "inquirer": { @@ -2901,7 +2901,7 @@ "is-buffer": { "version": "1.1.6", "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", - "integrity": "sha1-76ouqdqg16suoTqXsritUf776L4=", + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", "dev": true }, "is-builtin-module": { @@ -3054,7 +3054,7 @@ "is-resolvable": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/is-resolvable/-/is-resolvable-1.1.0.tgz", - "integrity": "sha1-+xj4fOH+uSUWnJpAfBkxijIG7Yg=", + "integrity": "sha512-qgDYXFSR5WvEfuS5dMj6oTMEbrrSaM0CrFk2Yiq/gXnBvD9pMa2jGXxyhGLfvhZpuMZe18CJpFxAt3CRs42NMg==", "dev": true }, "is-retry-allowed": { @@ -3204,7 +3204,7 @@ "js-yaml": { "version": "3.11.0", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.11.0.tgz", - "integrity": "sha1-WXwai9VxUvJtYizkEXhRpR9euu8=", + "integrity": "sha512-saJstZWv7oNeOyBh3+Dx1qWzhW0+e6/8eDzo7p5rDFqxntSztloLtuKu+Ejhtq82jsilwOIZYsCz+lIjthg1Hw==", "dev": true, "requires": { "argparse": "1.0.10", @@ -3324,7 +3324,7 @@ "just-extend": { "version": "1.1.27", "resolved": "https://registry.npmjs.org/just-extend/-/just-extend-1.1.27.tgz", - "integrity": "sha1-7G55QQ/5FORyZSq/oOYDwD1g6QU=", + "integrity": "sha512-mJVp13Ix6gFo3SBAy9U/kL+oeZqzlYYYLQBwXVBlVzIsZwBqGREnOro24oC/8s8aox+rJhtZ2DiQof++IrkA+g==", "dev": true }, "kind-of": { @@ -3703,7 +3703,7 @@ "lodash": { "version": "4.17.5", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.5.tgz", - "integrity": "sha1-maktZcAnLevoyWtgV7yPv6O+1RE=", + "integrity": "sha512-svL3uiZf1RwhH+cWrfZn3A4+U58wbP0tGVTLQPbjplZxZ8ROD9VLuNgsRniTlLe7OlSqR79RUehXgpBW/s0IQw==", "dev": true }, "lodash._reinterpolate": { @@ -3740,7 +3740,7 @@ "lolex": { "version": "2.3.2", "resolved": "https://registry.npmjs.org/lolex/-/lolex-2.3.2.tgz", - "integrity": "sha1-hflFBCUQO/nnpgZo6iXcQydMqAc=", + "integrity": "sha512-A5pN2tkFj7H0dGIAM6MFvHKMJcPnjZsOMvR7ujCjfgW5TbV6H9vb1PgxLtHvjqNZTHsUolz+6/WEO0N1xNx2ng==", "dev": true }, "longest": { @@ -3816,7 +3816,7 @@ "marked": { "version": "0.3.17", "resolved": "https://registry.npmjs.org/marked/-/marked-0.3.17.tgz", - "integrity": "sha1-YH8GZos8axJGso8T2nYRasGqLSs=", + "integrity": "sha512-+AKbNsjZl6jFfLPwHhWmGTqE009wTKn3RTmn9K8oUKHrX/abPJjtcRtXpYB/FFrwPJRUA86LX/de3T0knkPCmQ==", "dev": true }, "mem": { @@ -3896,13 +3896,13 @@ "mime-db": { "version": "1.33.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.33.0.tgz", - "integrity": "sha1-o0kgUKXLm2NFBUHjnZeI0icng9s=", + "integrity": "sha512-BHJ/EKruNIqJf/QahvxwQZXKygOQ256myeN/Ew+THcAa5q+PjyTTMMeNQC4DZw5AwfvelsUrA6B67NKMqXDbzQ==", "dev": true }, "mime-types": { "version": "2.1.18", "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.18.tgz", - "integrity": "sha1-bzI/YKg9ERRvgx/xH9ZuL+VQO7g=", + "integrity": "sha512-lc/aahn+t4/SWV/qcmumYjymLsWfN3ELhpmVuUFjgsORruuZPVSwAQryq+HHGvO/SI2KVX26bx+En+zhM8g8hQ==", "dev": true, "requires": { "mime-db": "1.33.0" @@ -3917,7 +3917,7 @@ "minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha1-UWbihkV/AzBgZL5Ul+jbsMPTIIM=", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "dev": true, "requires": { "brace-expansion": "1.1.11" @@ -4071,7 +4071,7 @@ "normalize-package-data": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.4.0.tgz", - "integrity": "sha1-EvlaMH1YNSB1oEkHuErIvpisAS8=", + "integrity": "sha512-9jjUFbTPfEy3R/ad/2oNbKtW9Hgovl5O1FvFWKkKblNXoN/Oou6+9+KKohPK13Yc3/TyunyWhJp6gvRNR/PPAw==", "dev": true, "requires": { "hosted-git-info": "2.5.0", @@ -4511,7 +4511,7 @@ "process-nextick-args": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", - "integrity": "sha1-o31zL0JxtKsa0HDTVQjoKQeI/6o=", + "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==", "dev": true }, "progress": { @@ -4584,7 +4584,7 @@ "qs": { "version": "6.5.1", "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.1.tgz", - "integrity": "sha1-NJzfbu+J7EXBLX1es/wMhwNDptg=", + "integrity": "sha512-eRzhrN1WSINYCDCbrz796z37LOe3m5tmW7RQf6oBntukAG1nmovJvhnwHHRMAfeoItc1m2Hk02WER2aQ/iqs+A==", "dev": true }, "quick-lru": { @@ -4596,7 +4596,7 @@ "randomatic": { "version": "1.1.7", "resolved": "https://registry.npmjs.org/randomatic/-/randomatic-1.1.7.tgz", - "integrity": "sha1-x6vpzIuHwLqodrGf3oP9RkeX44w=", + "integrity": "sha512-D5JUjPyJbaJDkuAazpVnSfVkLlpeO3wDlPROTMLGKG1zMFNFRgrciKo1ltz/AzNTkqE0HzDx655QOL51N06how==", "dev": true, "requires": { "is-number": "3.0.0", @@ -4701,7 +4701,7 @@ "regex-cache": { "version": "0.4.4", "resolved": "https://registry.npmjs.org/regex-cache/-/regex-cache-0.4.4.tgz", - "integrity": "sha1-db3FiioUls7EihKDW8VMjVYjNt0=", + "integrity": "sha512-nVIZwtCjkC9YgvWkpM55B5rBhBYRZhAaJbgcFYXXsHnbZ9UZI9nnVWYZpBlCqv9ho2eZryPnWrZGsOdPwVWXWQ==", "dev": true, "requires": { "is-equal-shallow": "0.1.3" @@ -4729,7 +4729,7 @@ "remap-istanbul": { "version": "0.10.1", "resolved": "https://registry.npmjs.org/remap-istanbul/-/remap-istanbul-0.10.1.tgz", - "integrity": "sha1-OqWN1QIdSZ8zbTulvzu7kcG4jjc=", + "integrity": "sha512-gsNQXs5kJLhErICSyYhzVZ++C8LBW8dgwr874Y2QvzAUS75zBlD/juZgXs39nbYJ09fZDlX2AVLVJAY2jbFJoQ==", "dev": true, "requires": { "amdefine": "1.0.1", @@ -4769,7 +4769,7 @@ "source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha1-dHIq8y6WFOnCh6jQu95IteLxomM=", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", "dev": true }, "through2": { @@ -4883,7 +4883,7 @@ "resolve": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.5.0.tgz", - "integrity": "sha1-HwmsznlsmnYlefMbLBzEw83fnzY=", + "integrity": "sha512-hgoSGrc3pjzAPHNBg+KnFcK2HwlHTs/YrAGUr6qgTVUZmXv1UEXXl0bZNBKMA9fud6lRYFdPGz0xXxycPzmmiw==", "dev": true, "requires": { "path-parse": "1.0.5" @@ -4924,7 +4924,7 @@ "rimraf": { "version": "2.6.2", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", - "integrity": "sha1-LtgVDSShbqhlHm1u8PR8QVjOejY=", + "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", "dev": true, "requires": { "glob": "7.1.2" @@ -5063,19 +5063,19 @@ "safe-buffer": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", - "integrity": "sha1-iTMSr2myEj3vcfV4iQAWce6yyFM=", + "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", "dev": true }, "samsam": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/samsam/-/samsam-1.3.0.tgz", - "integrity": "sha1-jR2TUOJWItow3j5EumkrUiGrfFA=", + "integrity": "sha512-1HwIYD/8UlOtFS3QO3w7ey+SdSDFE4HRNLZoZRYVQefrOY3l17epswImeB1ijgJFQJodIaHcwkp3r/myBjFVbg==", "dev": true }, "semver": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz", - "integrity": "sha1-3Eu8emyp2Rbe5dQ1FvAJK1j3uKs=", + "integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==", "dev": true }, "set-blocking": { @@ -5117,7 +5117,7 @@ "sinon-chai": { "version": "2.14.0", "resolved": "https://registry.npmjs.org/sinon-chai/-/sinon-chai-2.14.0.tgz", - "integrity": "sha1-2n3UzIPNaiYLZ8yg96n9riahIF0=", + "integrity": "sha512-9stIF1utB0ywNHNT7RgiXbdmen8QDCRsrTjw+G9TgKt1Yexjiv8TOWZ6WHsTPz57Yky3DIswZvEqX8fpuHNDtQ==", "dev": true }, "slash": { @@ -5146,7 +5146,7 @@ "sntp": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/sntp/-/sntp-2.1.0.tgz", - "integrity": "sha1-LGzsFP7cIiJznK+bXD2F0cxaLMg=", + "integrity": "sha512-FL1b58BDrqS3A11lJ0zEdnJ3UOKqVxawAkF3k7F0CVN7VQ34aZrV+G8BZ1WC9ZL7NyrwsW0oviwsWDgRuVYtJg==", "dev": true, "requires": { "hoek": "4.2.1" @@ -5203,7 +5203,7 @@ "spdx-correct": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.0.0.tgz", - "integrity": "sha1-BaW01xU6GVvJLDxCW2nzsqlSTII=", + "integrity": "sha512-N19o9z5cEyc8yQQPukRCZ9EUmb4HUpnrmaL/fxS2pBo2jbfcFRVuFZ/oFC+vZz0MNNk0h80iMn5/S6qGZOL5+g==", "dev": true, "requires": { "spdx-expression-parse": "3.0.0", @@ -5213,13 +5213,13 @@ "spdx-exceptions": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.1.0.tgz", - "integrity": "sha1-LHrmEFbHFKW5ubKyr30xHvXHj+k=", + "integrity": "sha512-4K1NsmrlCU1JJgUrtgEeTVyfx8VaYea9J9LvARxhbHtVtohPs/gFGG5yy49beySjlIMhhXZ4QqujIZEfS4l6Cg==", "dev": true }, "spdx-expression-parse": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.0.tgz", - "integrity": "sha1-meEZt6XaAOBUkcn6M4t5BII7QdA=", + "integrity": "sha512-Yg6D3XpRD4kkOmTpdgbUiEJFKghJH03fiC1OPll5h/0sO6neh2jqRDVHOQ4o/LMea0tgCkbMgea5ip/e+MkWyg==", "dev": true, "requires": { "spdx-exceptions": "2.1.0", @@ -5229,7 +5229,7 @@ "spdx-license-ids": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.0.tgz", - "integrity": "sha1-enzShHDMbToc/m1miG9rxDDTrIc=", + "integrity": "sha512-2+EPwgbnmOIl8HjGBXXMd9NAu02vLjOO1nWw4kmeRDFyHn+M/ETfHxQUK0oXg8ctgVnl9t3rosNVsZ1jG61nDA==", "dev": true }, "speedometer": { @@ -5566,7 +5566,7 @@ "tough-cookie": { "version": "2.3.4", "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.4.tgz", - "integrity": "sha1-7GDO44rGdQY//JelwYlwV47oNlU=", + "integrity": "sha512-TZ6TTfI5NtZnuyy/Kecv+CnoROnyXn2DN97LontgQpCwsX2XyLYCC0ENhYkehSOwAp8rTQKc/NUIF7BkQ5rKLA==", "dev": true, "requires": { "punycode": "1.4.1" @@ -5708,13 +5708,13 @@ "uuid": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.2.1.tgz", - "integrity": "sha1-EsUou51Y0LkmXZovbw/ovhf/HxQ=", + "integrity": "sha512-jZnMwlb9Iku/O3smGWvZhauCf6cvvpKi4BKRiliS3cxnI+Gz9j5MEpTz2UFuXiKPJocb7gnsLHwiS05ige5BEA==", "dev": true }, "validate-npm-package-license": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.3.tgz", - "integrity": "sha1-gWQ7y+8b3+zUYjeT3EZIlIupgzg=", + "integrity": "sha512-63ZOUnL4SIXj4L0NixR3L1lcjO38crAbgrTpl28t8jjrfuiOBL5Iygm+60qPs/KsZGzPNg6Smnc/oY16QTjF0g==", "dev": true, "requires": { "spdx-correct": "3.0.0", @@ -5750,7 +5750,7 @@ "which": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/which/-/which-1.3.0.tgz", - "integrity": "sha1-/wS9/AEO5UfXgL7DjhrBwnd9JTo=", + "integrity": "sha512-xcJpopdamTuY5duC/KnTTNBraPK54YwpenP4lzxU8H91GudWpFv38u0CKjclE1Wi2EH2EDz5LRcHcKbCIzqGyg==", "dev": true, "requires": { "isexe": "2.0.0" diff --git a/packages/canvas/canvas-mesh/package.json b/packages/canvas/canvas-mesh/package.json index 691cd2c..6744a17 100644 --- a/packages/canvas/canvas-mesh/package.json +++ b/packages/canvas/canvas-mesh/package.json @@ -24,6 +24,7 @@ "dependencies": { "@pixi/constants": "^5.0.0-alpha.2", "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/mesh-extras": "^5.0.0-alpha.2", "@pixi/settings": "^5.0.0-alpha.2" }, "devDependencies": { diff --git a/packages/canvas/canvas-mesh/src/Mesh.js b/packages/canvas/canvas-mesh/src/Mesh.js index 900a872..c43a74b 100644 --- a/packages/canvas/canvas-mesh/src/Mesh.js +++ b/packages/canvas/canvas-mesh/src/Mesh.js @@ -1,36 +1,14 @@ import { Mesh } from '@pixi/mesh'; -import { settings } from './settings'; - -// IMPORTANT: Please do NOT use this as a precedent to use `settings` after the object is created -// this was merely created to completely decouple canvas from the base Mesh class and we are -// unable to add `canvasPadding` in the constructor anymore, as the case was for PixiJS v4. /** - * Internal variable for `canvasPadding`. + * Renders the object using the Canvas renderer * * @private - * @memberof PIXI.Mesh - * @member {number} - * @default null - */ -Mesh.prototype._canvasPadding = null; - -/** - * Triangles in canvas mode are automatically antialiased, use this value to force triangles - * to overlap a bit with each other. To set the global default, set {@link PIXI.settings.MESH_CANVAS_PADDING} - * - * @see PIXI.settings.MESH_CANVAS_PADDING - * @member {number} canvasPadding + * @method _renderCanvas * @memberof PIXI.Mesh# - * @default 0 + * @param {PIXI.CanvasRenderer} renderer - The canvas renderer. */ -Object.defineProperty(Mesh.prototype, 'canvasPadding', { - get() - { - return this._canvasPadding !== null ? this._canvasPadding : settings.MESH_CANVAS_PADDING; - }, - set(value) - { - this._canvasPadding = value; - }, -}); +Mesh.prototype._renderCanvas = function _renderCanvas(renderer) +{ + renderer.plugins[this.pluginName].render(this); +}; diff --git a/packages/canvas/canvas-mesh/src/Mesh2d.js b/packages/canvas/canvas-mesh/src/Mesh2d.js new file mode 100644 index 0000000..d0bd80f --- /dev/null +++ b/packages/canvas/canvas-mesh/src/Mesh2d.js @@ -0,0 +1,36 @@ +import { Mesh2d } from '@pixi/mesh-extras'; +import { settings } from './settings'; + +// IMPORTANT: Please do NOT use this as a precedent to use `settings` after the object is created +// this was merely created to completely decouple canvas from the base Mesh class and we are +// unable to add `canvasPadding` in the constructor anymore, as the case was for PixiJS v4. + +/** + * Internal variable for `canvasPadding`. + * + * @private + * @memberof PIXI.Mesh2d + * @member {number} + * @default null + */ +Mesh2d.prototype._canvasPadding = null; + +/** + * Triangles in canvas mode are automatically antialiased, use this value to force triangles + * to overlap a bit with each other. To set the global default, set {@link PIXI.settings.MESH_CANVAS_PADDING} + * + * @see PIXI.settings.MESH_CANVAS_PADDING + * @member {number} canvasPadding + * @memberof PIXI.Mesh2d# + * @default 0 + */ +Object.defineProperty(Mesh2d.prototype, 'canvasPadding', { + get() + { + return this._canvasPadding !== null ? this._canvasPadding : settings.MESH_CANVAS_PADDING; + }, + set(value) + { + this._canvasPadding = value; + }, +}); diff --git a/packages/canvas/canvas-mesh/src/NineSlicePlane.js b/packages/canvas/canvas-mesh/src/NineSlicePlane.js index 09eaf9c..2fd5acc 100644 --- a/packages/canvas/canvas-mesh/src/NineSlicePlane.js +++ b/packages/canvas/canvas-mesh/src/NineSlicePlane.js @@ -1,4 +1,4 @@ -import { NineSlicePlane } from '@pixi/mesh'; +import { NineSlicePlane } from '@pixi/mesh-extras'; /** * Renders the object using the Canvas renderer diff --git a/packages/canvas/canvas-mesh/src/RawMesh.js b/packages/canvas/canvas-mesh/src/RawMesh.js deleted file mode 100644 index bf40184..0000000 --- a/packages/canvas/canvas-mesh/src/RawMesh.js +++ /dev/null @@ -1,14 +0,0 @@ -import { RawMesh } from '@pixi/mesh'; - -/** - * Renders the object using the Canvas renderer - * - * @private - * @method _renderCanvas - * @memberof PIXI.RawMesh# - * @param {PIXI.CanvasRenderer} renderer - The canvas renderer. - */ -RawMesh.prototype._renderCanvas = function _renderCanvas(renderer) -{ - renderer.plugins[this.pluginName].render(this); -}; diff --git a/packages/canvas/canvas-mesh/src/index.js b/packages/canvas/canvas-mesh/src/index.js index 2295016..f4fa31d 100644 --- a/packages/canvas/canvas-mesh/src/index.js +++ b/packages/canvas/canvas-mesh/src/index.js @@ -1,6 +1,6 @@ export { default as CanvasMeshRenderer } from './CanvasMeshRenderer'; import './settings'; -import './Mesh'; +import './Mesh2d'; import './NineSlicePlane'; -import './RawMesh'; +import './Mesh'; diff --git a/packages/canvas/canvas-mesh/src/settings.js b/packages/canvas/canvas-mesh/src/settings.js index 4cefb4c..e81b8e0 100644 --- a/packages/canvas/canvas-mesh/src/settings.js +++ b/packages/canvas/canvas-mesh/src/settings.js @@ -3,7 +3,7 @@ /** * Default `canvasPadding` for canvas-based Mesh rendering. * - * @see PIXI.Mesh#canvasPadding + * @see PIXI.Mesh2d#canvasPadding * @static * @constant * @memberof PIXI.settings diff --git a/packages/mesh-extras/LICENSE b/packages/mesh-extras/LICENSE new file mode 100644 index 0000000..148e3eb --- /dev/null +++ b/packages/mesh-extras/LICENSE @@ -0,0 +1,21 @@ +The MIT License + +Copyright (c) 2013-2018 Mathew Groves, Chad Engler + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/packages/mesh-extras/README.md b/packages/mesh-extras/README.md new file mode 100644 index 0000000..1d9b0e1 --- /dev/null +++ b/packages/mesh-extras/README.md @@ -0,0 +1,19 @@ +# @pixi/mesh-extras + +## Installation + +```bash +npm install @pixi/mesh-extras +``` + +## Usage + +```js +import { MeshRenderer } from '@pixi/mesh'; +import { Renderer } from '@pixi/core'; +import { Rope } from '@pixi/mesh-extras'; + +Renderer.registerPlugin('mesh', MeshRenderer); + +const rope = new Rope(); +``` \ No newline at end of file diff --git a/bundles/pixi.js/package.json b/bundles/pixi.js/package.json index 49c7276..177e059 100644 --- a/bundles/pixi.js/package.json +++ b/bundles/pixi.js/package.json @@ -49,6 +49,7 @@ "@pixi/loaders": "^5.0.0-alpha.2", "@pixi/math": "^5.0.0-alpha.2", "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/mesh-extras": "^5.0.0-alpha.2", "@pixi/mixin-cache-as-bitmap": "^5.0.0-alpha.2", "@pixi/mixin-get-child-by-name": "^5.0.0-alpha.2", "@pixi/mixin-get-global-position": "^5.0.0-alpha.2", diff --git a/bundles/pixi.js/src/deprecated.js b/bundles/pixi.js/src/deprecated.js index 147617c..dbebeb0 100644 --- a/bundles/pixi.js/src/deprecated.js +++ b/bundles/pixi.js/src/deprecated.js @@ -263,15 +263,15 @@ Object.defineProperties(PIXI.mesh, { /** * @class PIXI.mesh.Mesh - * @see PIXI.Mesh + * @see PIXI.Mesh2d * @deprecated since 5.0.0 */ Mesh: { get() { - warn('PIXI.mesh.Mesh has moved to PIXI.Mesh'); + warn('PIXI.mesh.Mesh has moved to PIXI.Mesh2d'); - return PIXI.Mesh; + return PIXI.Mesh2d; }, }, /** @@ -315,15 +315,15 @@ }, /** * @class PIXI.mesh.RawMesh - * @see PIXI.RawMesh + * @see PIXI.Mesh * @deprecated since 5.0.0 */ RawMesh: { get() { - warn('PIXI.mesh.RawMesh has moved to PIXI.RawMesh'); + warn('PIXI.mesh.RawMesh has moved to PIXI.Mesh'); - return PIXI.RawMesh; + return PIXI.Mesh; }, }, /** diff --git a/bundles/pixi.js/src/index.js b/bundles/pixi.js/src/index.js index a3a0d1b..6fdabf0 100644 --- a/bundles/pixi.js/src/index.js +++ b/bundles/pixi.js/src/index.js @@ -9,6 +9,7 @@ import * as loaders from '@pixi/loaders'; import * as math from '@pixi/math'; import * as mesh from '@pixi/mesh'; +import * as meshExtras from '@pixi/mesh-extras'; import * as particles from '@pixi/particles'; import * as prepare from '@pixi/prepare'; import * as sprite from '@pixi/sprite'; @@ -128,6 +129,7 @@ loaders, math, mesh, + meshExtras, particles, sprite, spriteAnimated, @@ -152,6 +154,7 @@ export * from '@pixi/loaders'; export * from '@pixi/math'; export * from '@pixi/mesh'; +export * from '@pixi/mesh-extras'; export * from '@pixi/particles'; export * from '@pixi/sprite'; export * from '@pixi/spritesheet'; diff --git a/package-lock.json b/package-lock.json index 7fe6db7..0814729 100644 --- a/package-lock.json +++ b/package-lock.json @@ -209,7 +209,7 @@ "argparse": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", - "integrity": "sha1-vNZ5HqWuCXJeF+WtmIE0zUCz2RE=", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", "dev": true, "requires": { "sprintf-js": "1.0.3" @@ -228,7 +228,7 @@ "arr-flatten": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz", - "integrity": "sha1-NgSLv/TntH4TZkQxbJlmnqWukfE=", + "integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==", "dev": true }, "arr-union": { @@ -297,7 +297,7 @@ "assertion-error": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", - "integrity": "sha1-5gtrDo8wG9l+U3UhW9pAbIURjAs=", + "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", "dev": true }, "async": { @@ -396,7 +396,7 @@ "brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha1-PH/L9SnYcibz0vUrlm/1Jx60Qd0=", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, "requires": { "balanced-match": "1.0.0", @@ -568,7 +568,7 @@ "circular-json": { "version": "0.3.3", "resolved": "https://registry.npmjs.org/circular-json/-/circular-json-0.3.3.tgz", - "integrity": "sha1-gVyZ6oT2gJUp0vRXkb34JxE1LWY=", + "integrity": "sha512-UZK3NBx2Mca+b5LsG7bY183pHWt5Y1xts4P3Pz7ENTwGVnJOUWbRb3ocjvX7hx9tq/yTAdclXm9sZ38gNuem4A==", "dev": true }, "cli-cursor": { @@ -638,7 +638,7 @@ "color-convert": { "version": "1.9.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.1.tgz", - "integrity": "sha1-wSYRB66y8pTr/+ye2eytUppgl+0=", + "integrity": "sha512-mjGanIiwQJskCC18rPR6OmrZ6fm2Lc7PeGFYwCmy5J34wC6F1PzdGL6xeMfmgicfYcNLGuVFA3WzXtIDCQSZxQ==", "dev": true, "requires": { "color-name": "1.1.3" @@ -1427,7 +1427,7 @@ "boom": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/boom/-/boom-5.2.0.tgz", - "integrity": "sha1-XdnabuOl8wIHdDYpDLcX0/SlTgI=", + "integrity": "sha512-Z5BTk6ZRe4tXXQlkqftmsAUANpXmuwlsF5Oov8ThoMbQRzdGTA1ngYRW160GexgOgjsFOKJz0LYhoNi+2AMBUw==", "dev": true, "requires": { "hoek": "4.2.1" @@ -1471,7 +1471,7 @@ "debug": { "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha1-XRKFFd8TT/Mn6QpMk/Tgd6U2NB8=", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", "dev": true, "requires": { "ms": "2.0.0" @@ -1585,7 +1585,7 @@ "doctrine": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", - "integrity": "sha1-XNAfwQFiG0LEzX9dGmYkNxbT850=", + "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", "dev": true, "requires": { "esutils": "2.0.2" @@ -1662,7 +1662,7 @@ "es6-promise": { "version": "4.2.4", "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.4.tgz", - "integrity": "sha1-3EIhwrFlGHYL2MOaUtjzVvwA7Sk=", + "integrity": "sha512-/NdNZVJg+uZgtm9eS3O6lrOLYmQag2DjdEXuPaHlZ6RuVqgqaVZfgYCepEIKsLqwdQArOPtC3XzRLqGGfT8KQQ==", "dev": true }, "escape-string-regexp": { @@ -1788,7 +1788,7 @@ "espree": { "version": "3.5.4", "resolved": "https://registry.npmjs.org/espree/-/espree-3.5.4.tgz", - "integrity": "sha1-sPRHGHyKi+2US4FaZgvd9d610ac=", + "integrity": "sha512-yAcIQxtmMiB/jL32dzEp2enBeidsB7xWPLNiw3IIkpVds1P+h7qF9YwJq1yUNzp2OKXgAprs4F61ih66UsoD1A==", "dev": true, "requires": { "acorn": "5.5.0", @@ -1798,7 +1798,7 @@ "esprima": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.0.tgz", - "integrity": "sha1-RJnt3NERDgshi6zy+n9/WfVcqAQ=", + "integrity": "sha512-oftTcaMu/EGrEIu904mWteKIv8vMuOgGYo7EhVJJN00R/EED9DCua/xxHRdYnKtcECzVg7xOWhflvJMnqcFZjw==", "dev": true }, "esquery": { @@ -1813,7 +1813,7 @@ "esrecurse": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.2.1.tgz", - "integrity": "sha1-AHo7n9vCs7uH5IeeoZyS/b05Qs8=", + "integrity": "sha512-64RBB++fIOAXPw3P9cy89qfMlvZEXZkqqJkjqqXIvzP5ezRZjW+lPWjw35UX/3EhUPFYbg5ER4JYgDw4007/DQ==", "dev": true, "requires": { "estraverse": "4.2.0" @@ -2024,7 +2024,7 @@ "find-root": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/find-root/-/find-root-1.1.0.tgz", - "integrity": "sha1-q8/Iunb3CMQql7PWhbfpRQv7nOQ=", + "integrity": "sha512-NKfW6bec6GfKc0SGx1e07QZY9PE99u0Bft/0rzSD5k3sO/vwkVUpDUKVm5Gpp5Ue3YfShPFTX2070tDs5kB9Ng==", "dev": true }, "find-up": { @@ -2103,7 +2103,7 @@ "supports-color": { "version": "5.3.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.3.0.tgz", - "integrity": "sha1-WySsFduA+pJ89SJ6SjP9PEx2dsA=", + "integrity": "sha512-0aP01LLIskjKs3lq52EC0aGBAJhLq7B2Rd8HC/DR/PtNNpcLilNmHC12O+hu0usQpo7wtHNRqtrhBwtDb0+dNg==", "dev": true, "requires": { "has-flag": "3.0.0" @@ -2567,7 +2567,7 @@ "glob": { "version": "7.1.2", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", - "integrity": "sha1-wZyd+aAocC1nhhI4SmVSQExjbRU=", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", "dev": true, "requires": { "fs.realpath": "1.0.0", @@ -2672,7 +2672,7 @@ "growl": { "version": "1.10.3", "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.3.tgz", - "integrity": "sha1-GSa6kM8+3+KttJJ/WIC8IsZseQ8=", + "integrity": "sha512-hKlsbA5Vu3xsh1Cg3J7jSmX/WaW6A5oBeqzM88oNbCRQFz+zUaXm6yxS4RVytp1scBoJzSYl4YAEOQIt6O8V1Q==", "dev": true }, "handlebars": { @@ -2738,7 +2738,7 @@ "hawk": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/hawk/-/hawk-6.0.2.tgz", - "integrity": "sha1-r02RTrBl+bXOTZ0RwcshJu7MMDg=", + "integrity": "sha512-miowhl2+U7Qle4vdLqDdPt9m09K6yZhkLDTWGoUiUzrQCn+mHHSmfJgAyGaLRZbPmTqfFFjRV1QWCW0VWUJBbQ==", "dev": true, "requires": { "boom": "4.3.1", @@ -2756,7 +2756,7 @@ "hoek": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/hoek/-/hoek-4.2.1.tgz", - "integrity": "sha1-ljRQKqEsRF3Vp8VzS1cruHOKrLs=", + "integrity": "sha512-QLg82fGkfnJ/4iy1xZ81/9SIJiq1NGFUMGs6ParyjBZr6jW2Ufj/snDqTHixNlHdPNwN2RLVD0Pi3igeK9+JfA==", "dev": true }, "home-path": { @@ -2791,7 +2791,7 @@ "ignore": { "version": "3.3.7", "resolved": "https://registry.npmjs.org/ignore/-/ignore-3.3.7.tgz", - "integrity": "sha1-YSKJv7PCIOGGpYEYYY1b6MG6sCE=", + "integrity": "sha512-YGG3ejvBNHRqu0559EOxxNFihD0AjpvHlC/pdGKd3X3ofe+CoJkYazwNJYTNebqpPKN+VVQbh4ZFn1DivMNuHA==", "dev": true }, "imurmurhash": { @@ -2828,7 +2828,7 @@ "ini": { "version": "1.3.5", "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", - "integrity": "sha1-7uJfVtscnsYIXgwid4CD9Zar+Sc=", + "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==", "dev": true }, "inquirer": { @@ -2901,7 +2901,7 @@ "is-buffer": { "version": "1.1.6", "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", - "integrity": "sha1-76ouqdqg16suoTqXsritUf776L4=", + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", "dev": true }, "is-builtin-module": { @@ -3054,7 +3054,7 @@ "is-resolvable": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/is-resolvable/-/is-resolvable-1.1.0.tgz", - "integrity": "sha1-+xj4fOH+uSUWnJpAfBkxijIG7Yg=", + "integrity": "sha512-qgDYXFSR5WvEfuS5dMj6oTMEbrrSaM0CrFk2Yiq/gXnBvD9pMa2jGXxyhGLfvhZpuMZe18CJpFxAt3CRs42NMg==", "dev": true }, "is-retry-allowed": { @@ -3204,7 +3204,7 @@ "js-yaml": { "version": "3.11.0", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.11.0.tgz", - "integrity": "sha1-WXwai9VxUvJtYizkEXhRpR9euu8=", + "integrity": "sha512-saJstZWv7oNeOyBh3+Dx1qWzhW0+e6/8eDzo7p5rDFqxntSztloLtuKu+Ejhtq82jsilwOIZYsCz+lIjthg1Hw==", "dev": true, "requires": { "argparse": "1.0.10", @@ -3324,7 +3324,7 @@ "just-extend": { "version": "1.1.27", "resolved": "https://registry.npmjs.org/just-extend/-/just-extend-1.1.27.tgz", - "integrity": "sha1-7G55QQ/5FORyZSq/oOYDwD1g6QU=", + "integrity": "sha512-mJVp13Ix6gFo3SBAy9U/kL+oeZqzlYYYLQBwXVBlVzIsZwBqGREnOro24oC/8s8aox+rJhtZ2DiQof++IrkA+g==", "dev": true }, "kind-of": { @@ -3703,7 +3703,7 @@ "lodash": { "version": "4.17.5", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.5.tgz", - "integrity": "sha1-maktZcAnLevoyWtgV7yPv6O+1RE=", + "integrity": "sha512-svL3uiZf1RwhH+cWrfZn3A4+U58wbP0tGVTLQPbjplZxZ8ROD9VLuNgsRniTlLe7OlSqR79RUehXgpBW/s0IQw==", "dev": true }, "lodash._reinterpolate": { @@ -3740,7 +3740,7 @@ "lolex": { "version": "2.3.2", "resolved": "https://registry.npmjs.org/lolex/-/lolex-2.3.2.tgz", - "integrity": "sha1-hflFBCUQO/nnpgZo6iXcQydMqAc=", + "integrity": "sha512-A5pN2tkFj7H0dGIAM6MFvHKMJcPnjZsOMvR7ujCjfgW5TbV6H9vb1PgxLtHvjqNZTHsUolz+6/WEO0N1xNx2ng==", "dev": true }, "longest": { @@ -3816,7 +3816,7 @@ "marked": { "version": "0.3.17", "resolved": "https://registry.npmjs.org/marked/-/marked-0.3.17.tgz", - "integrity": "sha1-YH8GZos8axJGso8T2nYRasGqLSs=", + "integrity": "sha512-+AKbNsjZl6jFfLPwHhWmGTqE009wTKn3RTmn9K8oUKHrX/abPJjtcRtXpYB/FFrwPJRUA86LX/de3T0knkPCmQ==", "dev": true }, "mem": { @@ -3896,13 +3896,13 @@ "mime-db": { "version": "1.33.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.33.0.tgz", - "integrity": "sha1-o0kgUKXLm2NFBUHjnZeI0icng9s=", + "integrity": "sha512-BHJ/EKruNIqJf/QahvxwQZXKygOQ256myeN/Ew+THcAa5q+PjyTTMMeNQC4DZw5AwfvelsUrA6B67NKMqXDbzQ==", "dev": true }, "mime-types": { "version": "2.1.18", "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.18.tgz", - "integrity": "sha1-bzI/YKg9ERRvgx/xH9ZuL+VQO7g=", + "integrity": "sha512-lc/aahn+t4/SWV/qcmumYjymLsWfN3ELhpmVuUFjgsORruuZPVSwAQryq+HHGvO/SI2KVX26bx+En+zhM8g8hQ==", "dev": true, "requires": { "mime-db": "1.33.0" @@ -3917,7 +3917,7 @@ "minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha1-UWbihkV/AzBgZL5Ul+jbsMPTIIM=", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "dev": true, "requires": { "brace-expansion": "1.1.11" @@ -4071,7 +4071,7 @@ "normalize-package-data": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.4.0.tgz", - "integrity": "sha1-EvlaMH1YNSB1oEkHuErIvpisAS8=", + "integrity": "sha512-9jjUFbTPfEy3R/ad/2oNbKtW9Hgovl5O1FvFWKkKblNXoN/Oou6+9+KKohPK13Yc3/TyunyWhJp6gvRNR/PPAw==", "dev": true, "requires": { "hosted-git-info": "2.5.0", @@ -4511,7 +4511,7 @@ "process-nextick-args": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", - "integrity": "sha1-o31zL0JxtKsa0HDTVQjoKQeI/6o=", + "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==", "dev": true }, "progress": { @@ -4584,7 +4584,7 @@ "qs": { "version": "6.5.1", "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.1.tgz", - "integrity": "sha1-NJzfbu+J7EXBLX1es/wMhwNDptg=", + "integrity": "sha512-eRzhrN1WSINYCDCbrz796z37LOe3m5tmW7RQf6oBntukAG1nmovJvhnwHHRMAfeoItc1m2Hk02WER2aQ/iqs+A==", "dev": true }, "quick-lru": { @@ -4596,7 +4596,7 @@ "randomatic": { "version": "1.1.7", "resolved": "https://registry.npmjs.org/randomatic/-/randomatic-1.1.7.tgz", - "integrity": "sha1-x6vpzIuHwLqodrGf3oP9RkeX44w=", + "integrity": "sha512-D5JUjPyJbaJDkuAazpVnSfVkLlpeO3wDlPROTMLGKG1zMFNFRgrciKo1ltz/AzNTkqE0HzDx655QOL51N06how==", "dev": true, "requires": { "is-number": "3.0.0", @@ -4701,7 +4701,7 @@ "regex-cache": { "version": "0.4.4", "resolved": "https://registry.npmjs.org/regex-cache/-/regex-cache-0.4.4.tgz", - "integrity": "sha1-db3FiioUls7EihKDW8VMjVYjNt0=", + "integrity": "sha512-nVIZwtCjkC9YgvWkpM55B5rBhBYRZhAaJbgcFYXXsHnbZ9UZI9nnVWYZpBlCqv9ho2eZryPnWrZGsOdPwVWXWQ==", "dev": true, "requires": { "is-equal-shallow": "0.1.3" @@ -4729,7 +4729,7 @@ "remap-istanbul": { "version": "0.10.1", "resolved": "https://registry.npmjs.org/remap-istanbul/-/remap-istanbul-0.10.1.tgz", - "integrity": "sha1-OqWN1QIdSZ8zbTulvzu7kcG4jjc=", + "integrity": "sha512-gsNQXs5kJLhErICSyYhzVZ++C8LBW8dgwr874Y2QvzAUS75zBlD/juZgXs39nbYJ09fZDlX2AVLVJAY2jbFJoQ==", "dev": true, "requires": { "amdefine": "1.0.1", @@ -4769,7 +4769,7 @@ "source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha1-dHIq8y6WFOnCh6jQu95IteLxomM=", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", "dev": true }, "through2": { @@ -4883,7 +4883,7 @@ "resolve": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.5.0.tgz", - "integrity": "sha1-HwmsznlsmnYlefMbLBzEw83fnzY=", + "integrity": "sha512-hgoSGrc3pjzAPHNBg+KnFcK2HwlHTs/YrAGUr6qgTVUZmXv1UEXXl0bZNBKMA9fud6lRYFdPGz0xXxycPzmmiw==", "dev": true, "requires": { "path-parse": "1.0.5" @@ -4924,7 +4924,7 @@ "rimraf": { "version": "2.6.2", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", - "integrity": "sha1-LtgVDSShbqhlHm1u8PR8QVjOejY=", + "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", "dev": true, "requires": { "glob": "7.1.2" @@ -5063,19 +5063,19 @@ "safe-buffer": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", - "integrity": "sha1-iTMSr2myEj3vcfV4iQAWce6yyFM=", + "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", "dev": true }, "samsam": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/samsam/-/samsam-1.3.0.tgz", - "integrity": "sha1-jR2TUOJWItow3j5EumkrUiGrfFA=", + "integrity": "sha512-1HwIYD/8UlOtFS3QO3w7ey+SdSDFE4HRNLZoZRYVQefrOY3l17epswImeB1ijgJFQJodIaHcwkp3r/myBjFVbg==", "dev": true }, "semver": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz", - "integrity": "sha1-3Eu8emyp2Rbe5dQ1FvAJK1j3uKs=", + "integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==", "dev": true }, "set-blocking": { @@ -5117,7 +5117,7 @@ "sinon-chai": { "version": "2.14.0", "resolved": "https://registry.npmjs.org/sinon-chai/-/sinon-chai-2.14.0.tgz", - "integrity": "sha1-2n3UzIPNaiYLZ8yg96n9riahIF0=", + "integrity": "sha512-9stIF1utB0ywNHNT7RgiXbdmen8QDCRsrTjw+G9TgKt1Yexjiv8TOWZ6WHsTPz57Yky3DIswZvEqX8fpuHNDtQ==", "dev": true }, "slash": { @@ -5146,7 +5146,7 @@ "sntp": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/sntp/-/sntp-2.1.0.tgz", - "integrity": "sha1-LGzsFP7cIiJznK+bXD2F0cxaLMg=", + "integrity": "sha512-FL1b58BDrqS3A11lJ0zEdnJ3UOKqVxawAkF3k7F0CVN7VQ34aZrV+G8BZ1WC9ZL7NyrwsW0oviwsWDgRuVYtJg==", "dev": true, "requires": { "hoek": "4.2.1" @@ -5203,7 +5203,7 @@ "spdx-correct": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.0.0.tgz", - "integrity": "sha1-BaW01xU6GVvJLDxCW2nzsqlSTII=", + "integrity": "sha512-N19o9z5cEyc8yQQPukRCZ9EUmb4HUpnrmaL/fxS2pBo2jbfcFRVuFZ/oFC+vZz0MNNk0h80iMn5/S6qGZOL5+g==", "dev": true, "requires": { "spdx-expression-parse": "3.0.0", @@ -5213,13 +5213,13 @@ "spdx-exceptions": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.1.0.tgz", - "integrity": "sha1-LHrmEFbHFKW5ubKyr30xHvXHj+k=", + "integrity": "sha512-4K1NsmrlCU1JJgUrtgEeTVyfx8VaYea9J9LvARxhbHtVtohPs/gFGG5yy49beySjlIMhhXZ4QqujIZEfS4l6Cg==", "dev": true }, "spdx-expression-parse": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.0.tgz", - "integrity": "sha1-meEZt6XaAOBUkcn6M4t5BII7QdA=", + "integrity": "sha512-Yg6D3XpRD4kkOmTpdgbUiEJFKghJH03fiC1OPll5h/0sO6neh2jqRDVHOQ4o/LMea0tgCkbMgea5ip/e+MkWyg==", "dev": true, "requires": { "spdx-exceptions": "2.1.0", @@ -5229,7 +5229,7 @@ "spdx-license-ids": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.0.tgz", - "integrity": "sha1-enzShHDMbToc/m1miG9rxDDTrIc=", + "integrity": "sha512-2+EPwgbnmOIl8HjGBXXMd9NAu02vLjOO1nWw4kmeRDFyHn+M/ETfHxQUK0oXg8ctgVnl9t3rosNVsZ1jG61nDA==", "dev": true }, "speedometer": { @@ -5566,7 +5566,7 @@ "tough-cookie": { "version": "2.3.4", "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.4.tgz", - "integrity": "sha1-7GDO44rGdQY//JelwYlwV47oNlU=", + "integrity": "sha512-TZ6TTfI5NtZnuyy/Kecv+CnoROnyXn2DN97LontgQpCwsX2XyLYCC0ENhYkehSOwAp8rTQKc/NUIF7BkQ5rKLA==", "dev": true, "requires": { "punycode": "1.4.1" @@ -5708,13 +5708,13 @@ "uuid": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.2.1.tgz", - "integrity": "sha1-EsUou51Y0LkmXZovbw/ovhf/HxQ=", + "integrity": "sha512-jZnMwlb9Iku/O3smGWvZhauCf6cvvpKi4BKRiliS3cxnI+Gz9j5MEpTz2UFuXiKPJocb7gnsLHwiS05ige5BEA==", "dev": true }, "validate-npm-package-license": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.3.tgz", - "integrity": "sha1-gWQ7y+8b3+zUYjeT3EZIlIupgzg=", + "integrity": "sha512-63ZOUnL4SIXj4L0NixR3L1lcjO38crAbgrTpl28t8jjrfuiOBL5Iygm+60qPs/KsZGzPNg6Smnc/oY16QTjF0g==", "dev": true, "requires": { "spdx-correct": "3.0.0", @@ -5750,7 +5750,7 @@ "which": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/which/-/which-1.3.0.tgz", - "integrity": "sha1-/wS9/AEO5UfXgL7DjhrBwnd9JTo=", + "integrity": "sha512-xcJpopdamTuY5duC/KnTTNBraPK54YwpenP4lzxU8H91GudWpFv38u0CKjclE1Wi2EH2EDz5LRcHcKbCIzqGyg==", "dev": true, "requires": { "isexe": "2.0.0" diff --git a/packages/canvas/canvas-mesh/package.json b/packages/canvas/canvas-mesh/package.json index 691cd2c..6744a17 100644 --- a/packages/canvas/canvas-mesh/package.json +++ b/packages/canvas/canvas-mesh/package.json @@ -24,6 +24,7 @@ "dependencies": { "@pixi/constants": "^5.0.0-alpha.2", "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/mesh-extras": "^5.0.0-alpha.2", "@pixi/settings": "^5.0.0-alpha.2" }, "devDependencies": { diff --git a/packages/canvas/canvas-mesh/src/Mesh.js b/packages/canvas/canvas-mesh/src/Mesh.js index 900a872..c43a74b 100644 --- a/packages/canvas/canvas-mesh/src/Mesh.js +++ b/packages/canvas/canvas-mesh/src/Mesh.js @@ -1,36 +1,14 @@ import { Mesh } from '@pixi/mesh'; -import { settings } from './settings'; - -// IMPORTANT: Please do NOT use this as a precedent to use `settings` after the object is created -// this was merely created to completely decouple canvas from the base Mesh class and we are -// unable to add `canvasPadding` in the constructor anymore, as the case was for PixiJS v4. /** - * Internal variable for `canvasPadding`. + * Renders the object using the Canvas renderer * * @private - * @memberof PIXI.Mesh - * @member {number} - * @default null - */ -Mesh.prototype._canvasPadding = null; - -/** - * Triangles in canvas mode are automatically antialiased, use this value to force triangles - * to overlap a bit with each other. To set the global default, set {@link PIXI.settings.MESH_CANVAS_PADDING} - * - * @see PIXI.settings.MESH_CANVAS_PADDING - * @member {number} canvasPadding + * @method _renderCanvas * @memberof PIXI.Mesh# - * @default 0 + * @param {PIXI.CanvasRenderer} renderer - The canvas renderer. */ -Object.defineProperty(Mesh.prototype, 'canvasPadding', { - get() - { - return this._canvasPadding !== null ? this._canvasPadding : settings.MESH_CANVAS_PADDING; - }, - set(value) - { - this._canvasPadding = value; - }, -}); +Mesh.prototype._renderCanvas = function _renderCanvas(renderer) +{ + renderer.plugins[this.pluginName].render(this); +}; diff --git a/packages/canvas/canvas-mesh/src/Mesh2d.js b/packages/canvas/canvas-mesh/src/Mesh2d.js new file mode 100644 index 0000000..d0bd80f --- /dev/null +++ b/packages/canvas/canvas-mesh/src/Mesh2d.js @@ -0,0 +1,36 @@ +import { Mesh2d } from '@pixi/mesh-extras'; +import { settings } from './settings'; + +// IMPORTANT: Please do NOT use this as a precedent to use `settings` after the object is created +// this was merely created to completely decouple canvas from the base Mesh class and we are +// unable to add `canvasPadding` in the constructor anymore, as the case was for PixiJS v4. + +/** + * Internal variable for `canvasPadding`. + * + * @private + * @memberof PIXI.Mesh2d + * @member {number} + * @default null + */ +Mesh2d.prototype._canvasPadding = null; + +/** + * Triangles in canvas mode are automatically antialiased, use this value to force triangles + * to overlap a bit with each other. To set the global default, set {@link PIXI.settings.MESH_CANVAS_PADDING} + * + * @see PIXI.settings.MESH_CANVAS_PADDING + * @member {number} canvasPadding + * @memberof PIXI.Mesh2d# + * @default 0 + */ +Object.defineProperty(Mesh2d.prototype, 'canvasPadding', { + get() + { + return this._canvasPadding !== null ? this._canvasPadding : settings.MESH_CANVAS_PADDING; + }, + set(value) + { + this._canvasPadding = value; + }, +}); diff --git a/packages/canvas/canvas-mesh/src/NineSlicePlane.js b/packages/canvas/canvas-mesh/src/NineSlicePlane.js index 09eaf9c..2fd5acc 100644 --- a/packages/canvas/canvas-mesh/src/NineSlicePlane.js +++ b/packages/canvas/canvas-mesh/src/NineSlicePlane.js @@ -1,4 +1,4 @@ -import { NineSlicePlane } from '@pixi/mesh'; +import { NineSlicePlane } from '@pixi/mesh-extras'; /** * Renders the object using the Canvas renderer diff --git a/packages/canvas/canvas-mesh/src/RawMesh.js b/packages/canvas/canvas-mesh/src/RawMesh.js deleted file mode 100644 index bf40184..0000000 --- a/packages/canvas/canvas-mesh/src/RawMesh.js +++ /dev/null @@ -1,14 +0,0 @@ -import { RawMesh } from '@pixi/mesh'; - -/** - * Renders the object using the Canvas renderer - * - * @private - * @method _renderCanvas - * @memberof PIXI.RawMesh# - * @param {PIXI.CanvasRenderer} renderer - The canvas renderer. - */ -RawMesh.prototype._renderCanvas = function _renderCanvas(renderer) -{ - renderer.plugins[this.pluginName].render(this); -}; diff --git a/packages/canvas/canvas-mesh/src/index.js b/packages/canvas/canvas-mesh/src/index.js index 2295016..f4fa31d 100644 --- a/packages/canvas/canvas-mesh/src/index.js +++ b/packages/canvas/canvas-mesh/src/index.js @@ -1,6 +1,6 @@ export { default as CanvasMeshRenderer } from './CanvasMeshRenderer'; import './settings'; -import './Mesh'; +import './Mesh2d'; import './NineSlicePlane'; -import './RawMesh'; +import './Mesh'; diff --git a/packages/canvas/canvas-mesh/src/settings.js b/packages/canvas/canvas-mesh/src/settings.js index 4cefb4c..e81b8e0 100644 --- a/packages/canvas/canvas-mesh/src/settings.js +++ b/packages/canvas/canvas-mesh/src/settings.js @@ -3,7 +3,7 @@ /** * Default `canvasPadding` for canvas-based Mesh rendering. * - * @see PIXI.Mesh#canvasPadding + * @see PIXI.Mesh2d#canvasPadding * @static * @constant * @memberof PIXI.settings diff --git a/packages/mesh-extras/LICENSE b/packages/mesh-extras/LICENSE new file mode 100644 index 0000000..148e3eb --- /dev/null +++ b/packages/mesh-extras/LICENSE @@ -0,0 +1,21 @@ +The MIT License + +Copyright (c) 2013-2018 Mathew Groves, Chad Engler + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/packages/mesh-extras/README.md b/packages/mesh-extras/README.md new file mode 100644 index 0000000..1d9b0e1 --- /dev/null +++ b/packages/mesh-extras/README.md @@ -0,0 +1,19 @@ +# @pixi/mesh-extras + +## Installation + +```bash +npm install @pixi/mesh-extras +``` + +## Usage + +```js +import { MeshRenderer } from '@pixi/mesh'; +import { Renderer } from '@pixi/core'; +import { Rope } from '@pixi/mesh-extras'; + +Renderer.registerPlugin('mesh', MeshRenderer); + +const rope = new Rope(); +``` \ No newline at end of file diff --git a/packages/mesh-extras/package.json b/packages/mesh-extras/package.json new file mode 100644 index 0000000..d134f64 --- /dev/null +++ b/packages/mesh-extras/package.json @@ -0,0 +1,38 @@ +{ + "name": "@pixi/mesh-extras", + "version": "5.0.0-alpha.2", + "main": "lib/mesh-extras.js", + "module": "lib/mesh-extras.es.js", + "description": "Custom Mesh display objects, like Rope and Plane", + "author": "Mat Groves", + "contributors": [ + "Matt Karl " + ], + "homepage": "http://pixijs.com/", + "bugs": "https://github.com/pixijs/pixi.js/issues", + "license": "MIT", + "repository": { + "type": "git", + "url": "https://github.com/pixijs/pixi.js.git" + }, + "publishConfig": { + "access": "public" + }, + "scripts": { + "test": "floss --path test" + }, + "files": [ + "lib" + ], + "dependencies": { + "@pixi/constants": "^5.0.0-alpha.2", + "@pixi/core": "^5.0.0-alpha.2", + "@pixi/math": "^5.0.0-alpha.2", + "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/utils": "^5.0.0-alpha.2" + }, + "devDependencies": { + "@pixi/loaders": "^5.0.0-alpha.2", + "floss": "^2.1.3" + } +} diff --git a/bundles/pixi.js/package.json b/bundles/pixi.js/package.json index 49c7276..177e059 100644 --- a/bundles/pixi.js/package.json +++ b/bundles/pixi.js/package.json @@ -49,6 +49,7 @@ "@pixi/loaders": "^5.0.0-alpha.2", "@pixi/math": "^5.0.0-alpha.2", "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/mesh-extras": "^5.0.0-alpha.2", "@pixi/mixin-cache-as-bitmap": "^5.0.0-alpha.2", "@pixi/mixin-get-child-by-name": "^5.0.0-alpha.2", "@pixi/mixin-get-global-position": "^5.0.0-alpha.2", diff --git a/bundles/pixi.js/src/deprecated.js b/bundles/pixi.js/src/deprecated.js index 147617c..dbebeb0 100644 --- a/bundles/pixi.js/src/deprecated.js +++ b/bundles/pixi.js/src/deprecated.js @@ -263,15 +263,15 @@ Object.defineProperties(PIXI.mesh, { /** * @class PIXI.mesh.Mesh - * @see PIXI.Mesh + * @see PIXI.Mesh2d * @deprecated since 5.0.0 */ Mesh: { get() { - warn('PIXI.mesh.Mesh has moved to PIXI.Mesh'); + warn('PIXI.mesh.Mesh has moved to PIXI.Mesh2d'); - return PIXI.Mesh; + return PIXI.Mesh2d; }, }, /** @@ -315,15 +315,15 @@ }, /** * @class PIXI.mesh.RawMesh - * @see PIXI.RawMesh + * @see PIXI.Mesh * @deprecated since 5.0.0 */ RawMesh: { get() { - warn('PIXI.mesh.RawMesh has moved to PIXI.RawMesh'); + warn('PIXI.mesh.RawMesh has moved to PIXI.Mesh'); - return PIXI.RawMesh; + return PIXI.Mesh; }, }, /** diff --git a/bundles/pixi.js/src/index.js b/bundles/pixi.js/src/index.js index a3a0d1b..6fdabf0 100644 --- a/bundles/pixi.js/src/index.js +++ b/bundles/pixi.js/src/index.js @@ -9,6 +9,7 @@ import * as loaders from '@pixi/loaders'; import * as math from '@pixi/math'; import * as mesh from '@pixi/mesh'; +import * as meshExtras from '@pixi/mesh-extras'; import * as particles from '@pixi/particles'; import * as prepare from '@pixi/prepare'; import * as sprite from '@pixi/sprite'; @@ -128,6 +129,7 @@ loaders, math, mesh, + meshExtras, particles, sprite, spriteAnimated, @@ -152,6 +154,7 @@ export * from '@pixi/loaders'; export * from '@pixi/math'; export * from '@pixi/mesh'; +export * from '@pixi/mesh-extras'; export * from '@pixi/particles'; export * from '@pixi/sprite'; export * from '@pixi/spritesheet'; diff --git a/package-lock.json b/package-lock.json index 7fe6db7..0814729 100644 --- a/package-lock.json +++ b/package-lock.json @@ -209,7 +209,7 @@ "argparse": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", - "integrity": "sha1-vNZ5HqWuCXJeF+WtmIE0zUCz2RE=", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", "dev": true, "requires": { "sprintf-js": "1.0.3" @@ -228,7 +228,7 @@ "arr-flatten": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz", - "integrity": "sha1-NgSLv/TntH4TZkQxbJlmnqWukfE=", + "integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==", "dev": true }, "arr-union": { @@ -297,7 +297,7 @@ "assertion-error": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", - "integrity": "sha1-5gtrDo8wG9l+U3UhW9pAbIURjAs=", + "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", "dev": true }, "async": { @@ -396,7 +396,7 @@ "brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha1-PH/L9SnYcibz0vUrlm/1Jx60Qd0=", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, "requires": { "balanced-match": "1.0.0", @@ -568,7 +568,7 @@ "circular-json": { "version": "0.3.3", "resolved": "https://registry.npmjs.org/circular-json/-/circular-json-0.3.3.tgz", - "integrity": "sha1-gVyZ6oT2gJUp0vRXkb34JxE1LWY=", + "integrity": "sha512-UZK3NBx2Mca+b5LsG7bY183pHWt5Y1xts4P3Pz7ENTwGVnJOUWbRb3ocjvX7hx9tq/yTAdclXm9sZ38gNuem4A==", "dev": true }, "cli-cursor": { @@ -638,7 +638,7 @@ "color-convert": { "version": "1.9.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.1.tgz", - "integrity": "sha1-wSYRB66y8pTr/+ye2eytUppgl+0=", + "integrity": "sha512-mjGanIiwQJskCC18rPR6OmrZ6fm2Lc7PeGFYwCmy5J34wC6F1PzdGL6xeMfmgicfYcNLGuVFA3WzXtIDCQSZxQ==", "dev": true, "requires": { "color-name": "1.1.3" @@ -1427,7 +1427,7 @@ "boom": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/boom/-/boom-5.2.0.tgz", - "integrity": "sha1-XdnabuOl8wIHdDYpDLcX0/SlTgI=", + "integrity": "sha512-Z5BTk6ZRe4tXXQlkqftmsAUANpXmuwlsF5Oov8ThoMbQRzdGTA1ngYRW160GexgOgjsFOKJz0LYhoNi+2AMBUw==", "dev": true, "requires": { "hoek": "4.2.1" @@ -1471,7 +1471,7 @@ "debug": { "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha1-XRKFFd8TT/Mn6QpMk/Tgd6U2NB8=", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", "dev": true, "requires": { "ms": "2.0.0" @@ -1585,7 +1585,7 @@ "doctrine": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", - "integrity": "sha1-XNAfwQFiG0LEzX9dGmYkNxbT850=", + "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", "dev": true, "requires": { "esutils": "2.0.2" @@ -1662,7 +1662,7 @@ "es6-promise": { "version": "4.2.4", "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.4.tgz", - "integrity": "sha1-3EIhwrFlGHYL2MOaUtjzVvwA7Sk=", + "integrity": "sha512-/NdNZVJg+uZgtm9eS3O6lrOLYmQag2DjdEXuPaHlZ6RuVqgqaVZfgYCepEIKsLqwdQArOPtC3XzRLqGGfT8KQQ==", "dev": true }, "escape-string-regexp": { @@ -1788,7 +1788,7 @@ "espree": { "version": "3.5.4", "resolved": "https://registry.npmjs.org/espree/-/espree-3.5.4.tgz", - "integrity": "sha1-sPRHGHyKi+2US4FaZgvd9d610ac=", + "integrity": "sha512-yAcIQxtmMiB/jL32dzEp2enBeidsB7xWPLNiw3IIkpVds1P+h7qF9YwJq1yUNzp2OKXgAprs4F61ih66UsoD1A==", "dev": true, "requires": { "acorn": "5.5.0", @@ -1798,7 +1798,7 @@ "esprima": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.0.tgz", - "integrity": "sha1-RJnt3NERDgshi6zy+n9/WfVcqAQ=", + "integrity": "sha512-oftTcaMu/EGrEIu904mWteKIv8vMuOgGYo7EhVJJN00R/EED9DCua/xxHRdYnKtcECzVg7xOWhflvJMnqcFZjw==", "dev": true }, "esquery": { @@ -1813,7 +1813,7 @@ "esrecurse": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.2.1.tgz", - "integrity": "sha1-AHo7n9vCs7uH5IeeoZyS/b05Qs8=", + "integrity": "sha512-64RBB++fIOAXPw3P9cy89qfMlvZEXZkqqJkjqqXIvzP5ezRZjW+lPWjw35UX/3EhUPFYbg5ER4JYgDw4007/DQ==", "dev": true, "requires": { "estraverse": "4.2.0" @@ -2024,7 +2024,7 @@ "find-root": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/find-root/-/find-root-1.1.0.tgz", - "integrity": "sha1-q8/Iunb3CMQql7PWhbfpRQv7nOQ=", + "integrity": "sha512-NKfW6bec6GfKc0SGx1e07QZY9PE99u0Bft/0rzSD5k3sO/vwkVUpDUKVm5Gpp5Ue3YfShPFTX2070tDs5kB9Ng==", "dev": true }, "find-up": { @@ -2103,7 +2103,7 @@ "supports-color": { "version": "5.3.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.3.0.tgz", - "integrity": "sha1-WySsFduA+pJ89SJ6SjP9PEx2dsA=", + "integrity": "sha512-0aP01LLIskjKs3lq52EC0aGBAJhLq7B2Rd8HC/DR/PtNNpcLilNmHC12O+hu0usQpo7wtHNRqtrhBwtDb0+dNg==", "dev": true, "requires": { "has-flag": "3.0.0" @@ -2567,7 +2567,7 @@ "glob": { "version": "7.1.2", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", - "integrity": "sha1-wZyd+aAocC1nhhI4SmVSQExjbRU=", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", "dev": true, "requires": { "fs.realpath": "1.0.0", @@ -2672,7 +2672,7 @@ "growl": { "version": "1.10.3", "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.3.tgz", - "integrity": "sha1-GSa6kM8+3+KttJJ/WIC8IsZseQ8=", + "integrity": "sha512-hKlsbA5Vu3xsh1Cg3J7jSmX/WaW6A5oBeqzM88oNbCRQFz+zUaXm6yxS4RVytp1scBoJzSYl4YAEOQIt6O8V1Q==", "dev": true }, "handlebars": { @@ -2738,7 +2738,7 @@ "hawk": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/hawk/-/hawk-6.0.2.tgz", - "integrity": "sha1-r02RTrBl+bXOTZ0RwcshJu7MMDg=", + "integrity": "sha512-miowhl2+U7Qle4vdLqDdPt9m09K6yZhkLDTWGoUiUzrQCn+mHHSmfJgAyGaLRZbPmTqfFFjRV1QWCW0VWUJBbQ==", "dev": true, "requires": { "boom": "4.3.1", @@ -2756,7 +2756,7 @@ "hoek": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/hoek/-/hoek-4.2.1.tgz", - "integrity": "sha1-ljRQKqEsRF3Vp8VzS1cruHOKrLs=", + "integrity": "sha512-QLg82fGkfnJ/4iy1xZ81/9SIJiq1NGFUMGs6ParyjBZr6jW2Ufj/snDqTHixNlHdPNwN2RLVD0Pi3igeK9+JfA==", "dev": true }, "home-path": { @@ -2791,7 +2791,7 @@ "ignore": { "version": "3.3.7", "resolved": "https://registry.npmjs.org/ignore/-/ignore-3.3.7.tgz", - "integrity": "sha1-YSKJv7PCIOGGpYEYYY1b6MG6sCE=", + "integrity": "sha512-YGG3ejvBNHRqu0559EOxxNFihD0AjpvHlC/pdGKd3X3ofe+CoJkYazwNJYTNebqpPKN+VVQbh4ZFn1DivMNuHA==", "dev": true }, "imurmurhash": { @@ -2828,7 +2828,7 @@ "ini": { "version": "1.3.5", "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", - "integrity": "sha1-7uJfVtscnsYIXgwid4CD9Zar+Sc=", + "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==", "dev": true }, "inquirer": { @@ -2901,7 +2901,7 @@ "is-buffer": { "version": "1.1.6", "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", - "integrity": "sha1-76ouqdqg16suoTqXsritUf776L4=", + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", "dev": true }, "is-builtin-module": { @@ -3054,7 +3054,7 @@ "is-resolvable": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/is-resolvable/-/is-resolvable-1.1.0.tgz", - "integrity": "sha1-+xj4fOH+uSUWnJpAfBkxijIG7Yg=", + "integrity": "sha512-qgDYXFSR5WvEfuS5dMj6oTMEbrrSaM0CrFk2Yiq/gXnBvD9pMa2jGXxyhGLfvhZpuMZe18CJpFxAt3CRs42NMg==", "dev": true }, "is-retry-allowed": { @@ -3204,7 +3204,7 @@ "js-yaml": { "version": "3.11.0", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.11.0.tgz", - "integrity": "sha1-WXwai9VxUvJtYizkEXhRpR9euu8=", + "integrity": "sha512-saJstZWv7oNeOyBh3+Dx1qWzhW0+e6/8eDzo7p5rDFqxntSztloLtuKu+Ejhtq82jsilwOIZYsCz+lIjthg1Hw==", "dev": true, "requires": { "argparse": "1.0.10", @@ -3324,7 +3324,7 @@ "just-extend": { "version": "1.1.27", "resolved": "https://registry.npmjs.org/just-extend/-/just-extend-1.1.27.tgz", - "integrity": "sha1-7G55QQ/5FORyZSq/oOYDwD1g6QU=", + "integrity": "sha512-mJVp13Ix6gFo3SBAy9U/kL+oeZqzlYYYLQBwXVBlVzIsZwBqGREnOro24oC/8s8aox+rJhtZ2DiQof++IrkA+g==", "dev": true }, "kind-of": { @@ -3703,7 +3703,7 @@ "lodash": { "version": "4.17.5", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.5.tgz", - "integrity": "sha1-maktZcAnLevoyWtgV7yPv6O+1RE=", + "integrity": "sha512-svL3uiZf1RwhH+cWrfZn3A4+U58wbP0tGVTLQPbjplZxZ8ROD9VLuNgsRniTlLe7OlSqR79RUehXgpBW/s0IQw==", "dev": true }, "lodash._reinterpolate": { @@ -3740,7 +3740,7 @@ "lolex": { "version": "2.3.2", "resolved": "https://registry.npmjs.org/lolex/-/lolex-2.3.2.tgz", - "integrity": "sha1-hflFBCUQO/nnpgZo6iXcQydMqAc=", + "integrity": "sha512-A5pN2tkFj7H0dGIAM6MFvHKMJcPnjZsOMvR7ujCjfgW5TbV6H9vb1PgxLtHvjqNZTHsUolz+6/WEO0N1xNx2ng==", "dev": true }, "longest": { @@ -3816,7 +3816,7 @@ "marked": { "version": "0.3.17", "resolved": "https://registry.npmjs.org/marked/-/marked-0.3.17.tgz", - "integrity": "sha1-YH8GZos8axJGso8T2nYRasGqLSs=", + "integrity": "sha512-+AKbNsjZl6jFfLPwHhWmGTqE009wTKn3RTmn9K8oUKHrX/abPJjtcRtXpYB/FFrwPJRUA86LX/de3T0knkPCmQ==", "dev": true }, "mem": { @@ -3896,13 +3896,13 @@ "mime-db": { "version": "1.33.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.33.0.tgz", - "integrity": "sha1-o0kgUKXLm2NFBUHjnZeI0icng9s=", + "integrity": "sha512-BHJ/EKruNIqJf/QahvxwQZXKygOQ256myeN/Ew+THcAa5q+PjyTTMMeNQC4DZw5AwfvelsUrA6B67NKMqXDbzQ==", "dev": true }, "mime-types": { "version": "2.1.18", "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.18.tgz", - "integrity": "sha1-bzI/YKg9ERRvgx/xH9ZuL+VQO7g=", + "integrity": "sha512-lc/aahn+t4/SWV/qcmumYjymLsWfN3ELhpmVuUFjgsORruuZPVSwAQryq+HHGvO/SI2KVX26bx+En+zhM8g8hQ==", "dev": true, "requires": { "mime-db": "1.33.0" @@ -3917,7 +3917,7 @@ "minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha1-UWbihkV/AzBgZL5Ul+jbsMPTIIM=", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "dev": true, "requires": { "brace-expansion": "1.1.11" @@ -4071,7 +4071,7 @@ "normalize-package-data": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.4.0.tgz", - "integrity": "sha1-EvlaMH1YNSB1oEkHuErIvpisAS8=", + "integrity": "sha512-9jjUFbTPfEy3R/ad/2oNbKtW9Hgovl5O1FvFWKkKblNXoN/Oou6+9+KKohPK13Yc3/TyunyWhJp6gvRNR/PPAw==", "dev": true, "requires": { "hosted-git-info": "2.5.0", @@ -4511,7 +4511,7 @@ "process-nextick-args": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", - "integrity": "sha1-o31zL0JxtKsa0HDTVQjoKQeI/6o=", + "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==", "dev": true }, "progress": { @@ -4584,7 +4584,7 @@ "qs": { "version": "6.5.1", "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.1.tgz", - "integrity": "sha1-NJzfbu+J7EXBLX1es/wMhwNDptg=", + "integrity": "sha512-eRzhrN1WSINYCDCbrz796z37LOe3m5tmW7RQf6oBntukAG1nmovJvhnwHHRMAfeoItc1m2Hk02WER2aQ/iqs+A==", "dev": true }, "quick-lru": { @@ -4596,7 +4596,7 @@ "randomatic": { "version": "1.1.7", "resolved": "https://registry.npmjs.org/randomatic/-/randomatic-1.1.7.tgz", - "integrity": "sha1-x6vpzIuHwLqodrGf3oP9RkeX44w=", + "integrity": "sha512-D5JUjPyJbaJDkuAazpVnSfVkLlpeO3wDlPROTMLGKG1zMFNFRgrciKo1ltz/AzNTkqE0HzDx655QOL51N06how==", "dev": true, "requires": { "is-number": "3.0.0", @@ -4701,7 +4701,7 @@ "regex-cache": { "version": "0.4.4", "resolved": "https://registry.npmjs.org/regex-cache/-/regex-cache-0.4.4.tgz", - "integrity": "sha1-db3FiioUls7EihKDW8VMjVYjNt0=", + "integrity": "sha512-nVIZwtCjkC9YgvWkpM55B5rBhBYRZhAaJbgcFYXXsHnbZ9UZI9nnVWYZpBlCqv9ho2eZryPnWrZGsOdPwVWXWQ==", "dev": true, "requires": { "is-equal-shallow": "0.1.3" @@ -4729,7 +4729,7 @@ "remap-istanbul": { "version": "0.10.1", "resolved": "https://registry.npmjs.org/remap-istanbul/-/remap-istanbul-0.10.1.tgz", - "integrity": "sha1-OqWN1QIdSZ8zbTulvzu7kcG4jjc=", + "integrity": "sha512-gsNQXs5kJLhErICSyYhzVZ++C8LBW8dgwr874Y2QvzAUS75zBlD/juZgXs39nbYJ09fZDlX2AVLVJAY2jbFJoQ==", "dev": true, "requires": { "amdefine": "1.0.1", @@ -4769,7 +4769,7 @@ "source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha1-dHIq8y6WFOnCh6jQu95IteLxomM=", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", "dev": true }, "through2": { @@ -4883,7 +4883,7 @@ "resolve": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.5.0.tgz", - "integrity": "sha1-HwmsznlsmnYlefMbLBzEw83fnzY=", + "integrity": "sha512-hgoSGrc3pjzAPHNBg+KnFcK2HwlHTs/YrAGUr6qgTVUZmXv1UEXXl0bZNBKMA9fud6lRYFdPGz0xXxycPzmmiw==", "dev": true, "requires": { "path-parse": "1.0.5" @@ -4924,7 +4924,7 @@ "rimraf": { "version": "2.6.2", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", - "integrity": "sha1-LtgVDSShbqhlHm1u8PR8QVjOejY=", + "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", "dev": true, "requires": { "glob": "7.1.2" @@ -5063,19 +5063,19 @@ "safe-buffer": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", - "integrity": "sha1-iTMSr2myEj3vcfV4iQAWce6yyFM=", + "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", "dev": true }, "samsam": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/samsam/-/samsam-1.3.0.tgz", - "integrity": "sha1-jR2TUOJWItow3j5EumkrUiGrfFA=", + "integrity": "sha512-1HwIYD/8UlOtFS3QO3w7ey+SdSDFE4HRNLZoZRYVQefrOY3l17epswImeB1ijgJFQJodIaHcwkp3r/myBjFVbg==", "dev": true }, "semver": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz", - "integrity": "sha1-3Eu8emyp2Rbe5dQ1FvAJK1j3uKs=", + "integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==", "dev": true }, "set-blocking": { @@ -5117,7 +5117,7 @@ "sinon-chai": { "version": "2.14.0", "resolved": "https://registry.npmjs.org/sinon-chai/-/sinon-chai-2.14.0.tgz", - "integrity": "sha1-2n3UzIPNaiYLZ8yg96n9riahIF0=", + "integrity": "sha512-9stIF1utB0ywNHNT7RgiXbdmen8QDCRsrTjw+G9TgKt1Yexjiv8TOWZ6WHsTPz57Yky3DIswZvEqX8fpuHNDtQ==", "dev": true }, "slash": { @@ -5146,7 +5146,7 @@ "sntp": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/sntp/-/sntp-2.1.0.tgz", - "integrity": "sha1-LGzsFP7cIiJznK+bXD2F0cxaLMg=", + "integrity": "sha512-FL1b58BDrqS3A11lJ0zEdnJ3UOKqVxawAkF3k7F0CVN7VQ34aZrV+G8BZ1WC9ZL7NyrwsW0oviwsWDgRuVYtJg==", "dev": true, "requires": { "hoek": "4.2.1" @@ -5203,7 +5203,7 @@ "spdx-correct": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.0.0.tgz", - "integrity": "sha1-BaW01xU6GVvJLDxCW2nzsqlSTII=", + "integrity": "sha512-N19o9z5cEyc8yQQPukRCZ9EUmb4HUpnrmaL/fxS2pBo2jbfcFRVuFZ/oFC+vZz0MNNk0h80iMn5/S6qGZOL5+g==", "dev": true, "requires": { "spdx-expression-parse": "3.0.0", @@ -5213,13 +5213,13 @@ "spdx-exceptions": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.1.0.tgz", - "integrity": "sha1-LHrmEFbHFKW5ubKyr30xHvXHj+k=", + "integrity": "sha512-4K1NsmrlCU1JJgUrtgEeTVyfx8VaYea9J9LvARxhbHtVtohPs/gFGG5yy49beySjlIMhhXZ4QqujIZEfS4l6Cg==", "dev": true }, "spdx-expression-parse": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.0.tgz", - "integrity": "sha1-meEZt6XaAOBUkcn6M4t5BII7QdA=", + "integrity": "sha512-Yg6D3XpRD4kkOmTpdgbUiEJFKghJH03fiC1OPll5h/0sO6neh2jqRDVHOQ4o/LMea0tgCkbMgea5ip/e+MkWyg==", "dev": true, "requires": { "spdx-exceptions": "2.1.0", @@ -5229,7 +5229,7 @@ "spdx-license-ids": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.0.tgz", - "integrity": "sha1-enzShHDMbToc/m1miG9rxDDTrIc=", + "integrity": "sha512-2+EPwgbnmOIl8HjGBXXMd9NAu02vLjOO1nWw4kmeRDFyHn+M/ETfHxQUK0oXg8ctgVnl9t3rosNVsZ1jG61nDA==", "dev": true }, "speedometer": { @@ -5566,7 +5566,7 @@ "tough-cookie": { "version": "2.3.4", "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.4.tgz", - "integrity": "sha1-7GDO44rGdQY//JelwYlwV47oNlU=", + "integrity": "sha512-TZ6TTfI5NtZnuyy/Kecv+CnoROnyXn2DN97LontgQpCwsX2XyLYCC0ENhYkehSOwAp8rTQKc/NUIF7BkQ5rKLA==", "dev": true, "requires": { "punycode": "1.4.1" @@ -5708,13 +5708,13 @@ "uuid": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.2.1.tgz", - "integrity": "sha1-EsUou51Y0LkmXZovbw/ovhf/HxQ=", + "integrity": "sha512-jZnMwlb9Iku/O3smGWvZhauCf6cvvpKi4BKRiliS3cxnI+Gz9j5MEpTz2UFuXiKPJocb7gnsLHwiS05ige5BEA==", "dev": true }, "validate-npm-package-license": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.3.tgz", - "integrity": "sha1-gWQ7y+8b3+zUYjeT3EZIlIupgzg=", + "integrity": "sha512-63ZOUnL4SIXj4L0NixR3L1lcjO38crAbgrTpl28t8jjrfuiOBL5Iygm+60qPs/KsZGzPNg6Smnc/oY16QTjF0g==", "dev": true, "requires": { "spdx-correct": "3.0.0", @@ -5750,7 +5750,7 @@ "which": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/which/-/which-1.3.0.tgz", - "integrity": "sha1-/wS9/AEO5UfXgL7DjhrBwnd9JTo=", + "integrity": "sha512-xcJpopdamTuY5duC/KnTTNBraPK54YwpenP4lzxU8H91GudWpFv38u0CKjclE1Wi2EH2EDz5LRcHcKbCIzqGyg==", "dev": true, "requires": { "isexe": "2.0.0" diff --git a/packages/canvas/canvas-mesh/package.json b/packages/canvas/canvas-mesh/package.json index 691cd2c..6744a17 100644 --- a/packages/canvas/canvas-mesh/package.json +++ b/packages/canvas/canvas-mesh/package.json @@ -24,6 +24,7 @@ "dependencies": { "@pixi/constants": "^5.0.0-alpha.2", "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/mesh-extras": "^5.0.0-alpha.2", "@pixi/settings": "^5.0.0-alpha.2" }, "devDependencies": { diff --git a/packages/canvas/canvas-mesh/src/Mesh.js b/packages/canvas/canvas-mesh/src/Mesh.js index 900a872..c43a74b 100644 --- a/packages/canvas/canvas-mesh/src/Mesh.js +++ b/packages/canvas/canvas-mesh/src/Mesh.js @@ -1,36 +1,14 @@ import { Mesh } from '@pixi/mesh'; -import { settings } from './settings'; - -// IMPORTANT: Please do NOT use this as a precedent to use `settings` after the object is created -// this was merely created to completely decouple canvas from the base Mesh class and we are -// unable to add `canvasPadding` in the constructor anymore, as the case was for PixiJS v4. /** - * Internal variable for `canvasPadding`. + * Renders the object using the Canvas renderer * * @private - * @memberof PIXI.Mesh - * @member {number} - * @default null - */ -Mesh.prototype._canvasPadding = null; - -/** - * Triangles in canvas mode are automatically antialiased, use this value to force triangles - * to overlap a bit with each other. To set the global default, set {@link PIXI.settings.MESH_CANVAS_PADDING} - * - * @see PIXI.settings.MESH_CANVAS_PADDING - * @member {number} canvasPadding + * @method _renderCanvas * @memberof PIXI.Mesh# - * @default 0 + * @param {PIXI.CanvasRenderer} renderer - The canvas renderer. */ -Object.defineProperty(Mesh.prototype, 'canvasPadding', { - get() - { - return this._canvasPadding !== null ? this._canvasPadding : settings.MESH_CANVAS_PADDING; - }, - set(value) - { - this._canvasPadding = value; - }, -}); +Mesh.prototype._renderCanvas = function _renderCanvas(renderer) +{ + renderer.plugins[this.pluginName].render(this); +}; diff --git a/packages/canvas/canvas-mesh/src/Mesh2d.js b/packages/canvas/canvas-mesh/src/Mesh2d.js new file mode 100644 index 0000000..d0bd80f --- /dev/null +++ b/packages/canvas/canvas-mesh/src/Mesh2d.js @@ -0,0 +1,36 @@ +import { Mesh2d } from '@pixi/mesh-extras'; +import { settings } from './settings'; + +// IMPORTANT: Please do NOT use this as a precedent to use `settings` after the object is created +// this was merely created to completely decouple canvas from the base Mesh class and we are +// unable to add `canvasPadding` in the constructor anymore, as the case was for PixiJS v4. + +/** + * Internal variable for `canvasPadding`. + * + * @private + * @memberof PIXI.Mesh2d + * @member {number} + * @default null + */ +Mesh2d.prototype._canvasPadding = null; + +/** + * Triangles in canvas mode are automatically antialiased, use this value to force triangles + * to overlap a bit with each other. To set the global default, set {@link PIXI.settings.MESH_CANVAS_PADDING} + * + * @see PIXI.settings.MESH_CANVAS_PADDING + * @member {number} canvasPadding + * @memberof PIXI.Mesh2d# + * @default 0 + */ +Object.defineProperty(Mesh2d.prototype, 'canvasPadding', { + get() + { + return this._canvasPadding !== null ? this._canvasPadding : settings.MESH_CANVAS_PADDING; + }, + set(value) + { + this._canvasPadding = value; + }, +}); diff --git a/packages/canvas/canvas-mesh/src/NineSlicePlane.js b/packages/canvas/canvas-mesh/src/NineSlicePlane.js index 09eaf9c..2fd5acc 100644 --- a/packages/canvas/canvas-mesh/src/NineSlicePlane.js +++ b/packages/canvas/canvas-mesh/src/NineSlicePlane.js @@ -1,4 +1,4 @@ -import { NineSlicePlane } from '@pixi/mesh'; +import { NineSlicePlane } from '@pixi/mesh-extras'; /** * Renders the object using the Canvas renderer diff --git a/packages/canvas/canvas-mesh/src/RawMesh.js b/packages/canvas/canvas-mesh/src/RawMesh.js deleted file mode 100644 index bf40184..0000000 --- a/packages/canvas/canvas-mesh/src/RawMesh.js +++ /dev/null @@ -1,14 +0,0 @@ -import { RawMesh } from '@pixi/mesh'; - -/** - * Renders the object using the Canvas renderer - * - * @private - * @method _renderCanvas - * @memberof PIXI.RawMesh# - * @param {PIXI.CanvasRenderer} renderer - The canvas renderer. - */ -RawMesh.prototype._renderCanvas = function _renderCanvas(renderer) -{ - renderer.plugins[this.pluginName].render(this); -}; diff --git a/packages/canvas/canvas-mesh/src/index.js b/packages/canvas/canvas-mesh/src/index.js index 2295016..f4fa31d 100644 --- a/packages/canvas/canvas-mesh/src/index.js +++ b/packages/canvas/canvas-mesh/src/index.js @@ -1,6 +1,6 @@ export { default as CanvasMeshRenderer } from './CanvasMeshRenderer'; import './settings'; -import './Mesh'; +import './Mesh2d'; import './NineSlicePlane'; -import './RawMesh'; +import './Mesh'; diff --git a/packages/canvas/canvas-mesh/src/settings.js b/packages/canvas/canvas-mesh/src/settings.js index 4cefb4c..e81b8e0 100644 --- a/packages/canvas/canvas-mesh/src/settings.js +++ b/packages/canvas/canvas-mesh/src/settings.js @@ -3,7 +3,7 @@ /** * Default `canvasPadding` for canvas-based Mesh rendering. * - * @see PIXI.Mesh#canvasPadding + * @see PIXI.Mesh2d#canvasPadding * @static * @constant * @memberof PIXI.settings diff --git a/packages/mesh-extras/LICENSE b/packages/mesh-extras/LICENSE new file mode 100644 index 0000000..148e3eb --- /dev/null +++ b/packages/mesh-extras/LICENSE @@ -0,0 +1,21 @@ +The MIT License + +Copyright (c) 2013-2018 Mathew Groves, Chad Engler + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/packages/mesh-extras/README.md b/packages/mesh-extras/README.md new file mode 100644 index 0000000..1d9b0e1 --- /dev/null +++ b/packages/mesh-extras/README.md @@ -0,0 +1,19 @@ +# @pixi/mesh-extras + +## Installation + +```bash +npm install @pixi/mesh-extras +``` + +## Usage + +```js +import { MeshRenderer } from '@pixi/mesh'; +import { Renderer } from '@pixi/core'; +import { Rope } from '@pixi/mesh-extras'; + +Renderer.registerPlugin('mesh', MeshRenderer); + +const rope = new Rope(); +``` \ No newline at end of file diff --git a/packages/mesh-extras/package.json b/packages/mesh-extras/package.json new file mode 100644 index 0000000..d134f64 --- /dev/null +++ b/packages/mesh-extras/package.json @@ -0,0 +1,38 @@ +{ + "name": "@pixi/mesh-extras", + "version": "5.0.0-alpha.2", + "main": "lib/mesh-extras.js", + "module": "lib/mesh-extras.es.js", + "description": "Custom Mesh display objects, like Rope and Plane", + "author": "Mat Groves", + "contributors": [ + "Matt Karl " + ], + "homepage": "http://pixijs.com/", + "bugs": "https://github.com/pixijs/pixi.js/issues", + "license": "MIT", + "repository": { + "type": "git", + "url": "https://github.com/pixijs/pixi.js.git" + }, + "publishConfig": { + "access": "public" + }, + "scripts": { + "test": "floss --path test" + }, + "files": [ + "lib" + ], + "dependencies": { + "@pixi/constants": "^5.0.0-alpha.2", + "@pixi/core": "^5.0.0-alpha.2", + "@pixi/math": "^5.0.0-alpha.2", + "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/utils": "^5.0.0-alpha.2" + }, + "devDependencies": { + "@pixi/loaders": "^5.0.0-alpha.2", + "floss": "^2.1.3" + } +} diff --git a/packages/mesh-extras/src/Mesh2d.js b/packages/mesh-extras/src/Mesh2d.js new file mode 100644 index 0000000..d113a5e --- /dev/null +++ b/packages/mesh-extras/src/Mesh2d.js @@ -0,0 +1,263 @@ +import { Mesh } from '@pixi/mesh'; +import { Geometry, Program, Shader, Texture, TextureMatrix } from '@pixi/core'; +import { Matrix } from '@pixi/math'; +import { BLEND_MODES } from '@pixi/constants'; +import { hex2rgb, premultiplyRgba } from '@pixi/utils'; +import vertex from './mesh.vert'; +import fragment from './mesh.frag'; + +let meshProgram; + +/** + * Base mesh class + * @class + * @extends PIXI.Container + * @memberof PIXI + */ +export default class Mesh2d extends Mesh +{ + /** + * @param {PIXI.Texture} [texture=Texture.EMPTY] - The texture to use + * @param {Float32Array} [vertices] - if you want to specify the vertices + * @param {Float32Array} [uvs] - if you want to specify the uvs + * @param {Uint16Array} [indices] - if you want to specify the indices + * @param {number} [drawMode] - the drawMode, can be any of the Mesh.DRAW_MODES consts + */ + constructor(texture = Texture.EMPTY, vertices, uvs, indices, drawMode) + { + const geometry = new Geometry(); + + if (!meshProgram) + { + meshProgram = new Program(vertex, fragment); + } + + geometry.addAttribute('aVertexPosition', vertices) + .addAttribute('aTextureCoord', uvs) + .addIndex(indices); + + geometry.getAttribute('aVertexPosition').static = false; + + const uniforms = { + uSampler: texture, + uTextureMatrix: Matrix.IDENTITY, + alpha: 1, + uColor: new Float32Array([1, 1, 1, 1]), + }; + + super(geometry, new Shader(meshProgram, uniforms), null, drawMode); + + /** + * The Uvs of the Mesh + * + * @member {Float32Array} + */ + this.uvs = geometry.getAttribute('aTextureCoord').data; + + /** + * An array of vertices + * + * @member {Float32Array} + */ + this.vertices = geometry.getAttribute('aVertexPosition').data; + + this.uniforms = uniforms; + + /** + * The texture of the Mesh + * + * @member {PIXI.Texture} + * @default PIXI.Texture.EMPTY + * @private + */ + this.texture = texture; + + /** + * The tint applied to the mesh. This is a [r,g,b] value. A value of [1,1,1] will remove any + * tint effect. + * + * @member {number} + * @private + */ + this._tintRGB = new Float32Array([1, 1, 1]); + + // Set default tint + this.tint = 0xFFFFFF; + + this.blendMode = BLEND_MODES.NORMAL; + + /** + * TextureMatrix instance for this Mesh, used to track Texture changes + * + * @member {PIXI.TextureMatrix} + * @readonly + */ + this.uvMatrix = new TextureMatrix(this._texture); + + /** + * whether or not upload uvMatrix to shader + * if its false, then uvs should be pre-multiplied + * if you change it for generated mesh, please call 'refresh(true)' + * @member {boolean} + * @default false + */ + this.uploadUvMatrix = false; + + /** + * Uploads vertices buffer every frame, like in PixiJS V3 and V4. + * + * @member {boolean} + * @default true + */ + this.autoUpdate = true; + } + + /** + * The tint applied to the Rope. This is a hex value. A value of + * 0xFFFFFF will remove any tint effect. + * + * @member {number} + * @memberof PIXI.Sprite# + * @default 0xFFFFFF + */ + get tint() + { + return this._tint; + } + + /** + * Sets the tint of the rope. + * + * @param {number} value - The value to set to. + */ + set tint(value) + { + this._tint = value; + + hex2rgb(this._tint, this._tintRGB); + } + + /** + * The blend mode to be applied to the sprite. Set to `PIXI.BLEND_MODES.NORMAL` to remove any blend mode. + * + * @member {number} + * @default PIXI.BLEND_MODES.NORMAL + * @see PIXI.BLEND_MODES + */ + get blendMode() + { + return this.state.blendMode; + } + + set blendMode(value) // eslint-disable-line require-jsdoc + { + this.state.blendMode = value; + } + + /** + * The texture that the mesh uses. + * + * @member {PIXI.Texture} + */ + get texture() + { + return this._texture; + } + + set texture(value) // eslint-disable-line require-jsdoc + { + if (this._texture === value) + { + return; + } + + this._texture = value; + this.uniforms.uSampler = this.texture; + + if (value) + { + // wait for the texture to load + if (value.baseTexture.valid) + { + this._onTextureUpdate(); + } + else + { + value.once('update', this._onTextureUpdate, this); + } + } + } + + _render(renderer) + { + const baseTex = this._texture.baseTexture; + + premultiplyRgba(this._tintRGB, this.worldAlpha, this.uniforms.uColor, baseTex.premultiplyAlpha); + super._render(renderer); + } + /** + * When the texture is updated, this event will fire to update the scale and frame + * + * @private + */ + _onTextureUpdate() + { + // constructor texture update stop + if (!this.uvMatrix) + { + return; + } + this.uvMatrix.texture = this._texture; + this.refresh(); + } + + /** + * multiplies uvs only if uploadUvMatrix is false + * call it after you change uvs manually + * make sure that texture is valid + */ + multiplyUvs() + { + if (!this.uploadUvMatrix) + { + this.uvMatrix.multiplyUvs(this.uvs); + } + } + + /** + * Refreshes uvs for generated meshes (rope, plane) + * sometimes refreshes vertices too + * + * @param {boolean} [forceUpdate=false] if true, matrices will be updated any case + */ + refresh(forceUpdate) + { + if (this.uvMatrix.update(forceUpdate)) + { + this._refresh(); + } + } + + /** + * Updates the object transform for rendering + * + * @private + */ + updateTransform() + { + if (this.autoUpdate) + { + this.geometry.buffers[0].update(); + } + this.containerUpdateTransform(); + } + + /** + * re-calculates mesh coords + * @private + */ + _refresh() + { + /* empty */ + } +} diff --git a/bundles/pixi.js/package.json b/bundles/pixi.js/package.json index 49c7276..177e059 100644 --- a/bundles/pixi.js/package.json +++ b/bundles/pixi.js/package.json @@ -49,6 +49,7 @@ "@pixi/loaders": "^5.0.0-alpha.2", "@pixi/math": "^5.0.0-alpha.2", "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/mesh-extras": "^5.0.0-alpha.2", "@pixi/mixin-cache-as-bitmap": "^5.0.0-alpha.2", "@pixi/mixin-get-child-by-name": "^5.0.0-alpha.2", "@pixi/mixin-get-global-position": "^5.0.0-alpha.2", diff --git a/bundles/pixi.js/src/deprecated.js b/bundles/pixi.js/src/deprecated.js index 147617c..dbebeb0 100644 --- a/bundles/pixi.js/src/deprecated.js +++ b/bundles/pixi.js/src/deprecated.js @@ -263,15 +263,15 @@ Object.defineProperties(PIXI.mesh, { /** * @class PIXI.mesh.Mesh - * @see PIXI.Mesh + * @see PIXI.Mesh2d * @deprecated since 5.0.0 */ Mesh: { get() { - warn('PIXI.mesh.Mesh has moved to PIXI.Mesh'); + warn('PIXI.mesh.Mesh has moved to PIXI.Mesh2d'); - return PIXI.Mesh; + return PIXI.Mesh2d; }, }, /** @@ -315,15 +315,15 @@ }, /** * @class PIXI.mesh.RawMesh - * @see PIXI.RawMesh + * @see PIXI.Mesh * @deprecated since 5.0.0 */ RawMesh: { get() { - warn('PIXI.mesh.RawMesh has moved to PIXI.RawMesh'); + warn('PIXI.mesh.RawMesh has moved to PIXI.Mesh'); - return PIXI.RawMesh; + return PIXI.Mesh; }, }, /** diff --git a/bundles/pixi.js/src/index.js b/bundles/pixi.js/src/index.js index a3a0d1b..6fdabf0 100644 --- a/bundles/pixi.js/src/index.js +++ b/bundles/pixi.js/src/index.js @@ -9,6 +9,7 @@ import * as loaders from '@pixi/loaders'; import * as math from '@pixi/math'; import * as mesh from '@pixi/mesh'; +import * as meshExtras from '@pixi/mesh-extras'; import * as particles from '@pixi/particles'; import * as prepare from '@pixi/prepare'; import * as sprite from '@pixi/sprite'; @@ -128,6 +129,7 @@ loaders, math, mesh, + meshExtras, particles, sprite, spriteAnimated, @@ -152,6 +154,7 @@ export * from '@pixi/loaders'; export * from '@pixi/math'; export * from '@pixi/mesh'; +export * from '@pixi/mesh-extras'; export * from '@pixi/particles'; export * from '@pixi/sprite'; export * from '@pixi/spritesheet'; diff --git a/package-lock.json b/package-lock.json index 7fe6db7..0814729 100644 --- a/package-lock.json +++ b/package-lock.json @@ -209,7 +209,7 @@ "argparse": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", - "integrity": "sha1-vNZ5HqWuCXJeF+WtmIE0zUCz2RE=", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", "dev": true, "requires": { "sprintf-js": "1.0.3" @@ -228,7 +228,7 @@ "arr-flatten": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz", - "integrity": "sha1-NgSLv/TntH4TZkQxbJlmnqWukfE=", + "integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==", "dev": true }, "arr-union": { @@ -297,7 +297,7 @@ "assertion-error": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", - "integrity": "sha1-5gtrDo8wG9l+U3UhW9pAbIURjAs=", + "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", "dev": true }, "async": { @@ -396,7 +396,7 @@ "brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha1-PH/L9SnYcibz0vUrlm/1Jx60Qd0=", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, "requires": { "balanced-match": "1.0.0", @@ -568,7 +568,7 @@ "circular-json": { "version": "0.3.3", "resolved": "https://registry.npmjs.org/circular-json/-/circular-json-0.3.3.tgz", - "integrity": "sha1-gVyZ6oT2gJUp0vRXkb34JxE1LWY=", + "integrity": "sha512-UZK3NBx2Mca+b5LsG7bY183pHWt5Y1xts4P3Pz7ENTwGVnJOUWbRb3ocjvX7hx9tq/yTAdclXm9sZ38gNuem4A==", "dev": true }, "cli-cursor": { @@ -638,7 +638,7 @@ "color-convert": { "version": "1.9.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.1.tgz", - "integrity": "sha1-wSYRB66y8pTr/+ye2eytUppgl+0=", + "integrity": "sha512-mjGanIiwQJskCC18rPR6OmrZ6fm2Lc7PeGFYwCmy5J34wC6F1PzdGL6xeMfmgicfYcNLGuVFA3WzXtIDCQSZxQ==", "dev": true, "requires": { "color-name": "1.1.3" @@ -1427,7 +1427,7 @@ "boom": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/boom/-/boom-5.2.0.tgz", - "integrity": "sha1-XdnabuOl8wIHdDYpDLcX0/SlTgI=", + "integrity": "sha512-Z5BTk6ZRe4tXXQlkqftmsAUANpXmuwlsF5Oov8ThoMbQRzdGTA1ngYRW160GexgOgjsFOKJz0LYhoNi+2AMBUw==", "dev": true, "requires": { "hoek": "4.2.1" @@ -1471,7 +1471,7 @@ "debug": { "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha1-XRKFFd8TT/Mn6QpMk/Tgd6U2NB8=", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", "dev": true, "requires": { "ms": "2.0.0" @@ -1585,7 +1585,7 @@ "doctrine": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", - "integrity": "sha1-XNAfwQFiG0LEzX9dGmYkNxbT850=", + "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", "dev": true, "requires": { "esutils": "2.0.2" @@ -1662,7 +1662,7 @@ "es6-promise": { "version": "4.2.4", "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.4.tgz", - "integrity": "sha1-3EIhwrFlGHYL2MOaUtjzVvwA7Sk=", + "integrity": "sha512-/NdNZVJg+uZgtm9eS3O6lrOLYmQag2DjdEXuPaHlZ6RuVqgqaVZfgYCepEIKsLqwdQArOPtC3XzRLqGGfT8KQQ==", "dev": true }, "escape-string-regexp": { @@ -1788,7 +1788,7 @@ "espree": { "version": "3.5.4", "resolved": "https://registry.npmjs.org/espree/-/espree-3.5.4.tgz", - "integrity": "sha1-sPRHGHyKi+2US4FaZgvd9d610ac=", + "integrity": "sha512-yAcIQxtmMiB/jL32dzEp2enBeidsB7xWPLNiw3IIkpVds1P+h7qF9YwJq1yUNzp2OKXgAprs4F61ih66UsoD1A==", "dev": true, "requires": { "acorn": "5.5.0", @@ -1798,7 +1798,7 @@ "esprima": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.0.tgz", - "integrity": "sha1-RJnt3NERDgshi6zy+n9/WfVcqAQ=", + "integrity": "sha512-oftTcaMu/EGrEIu904mWteKIv8vMuOgGYo7EhVJJN00R/EED9DCua/xxHRdYnKtcECzVg7xOWhflvJMnqcFZjw==", "dev": true }, "esquery": { @@ -1813,7 +1813,7 @@ "esrecurse": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.2.1.tgz", - "integrity": "sha1-AHo7n9vCs7uH5IeeoZyS/b05Qs8=", + "integrity": "sha512-64RBB++fIOAXPw3P9cy89qfMlvZEXZkqqJkjqqXIvzP5ezRZjW+lPWjw35UX/3EhUPFYbg5ER4JYgDw4007/DQ==", "dev": true, "requires": { "estraverse": "4.2.0" @@ -2024,7 +2024,7 @@ "find-root": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/find-root/-/find-root-1.1.0.tgz", - "integrity": "sha1-q8/Iunb3CMQql7PWhbfpRQv7nOQ=", + "integrity": "sha512-NKfW6bec6GfKc0SGx1e07QZY9PE99u0Bft/0rzSD5k3sO/vwkVUpDUKVm5Gpp5Ue3YfShPFTX2070tDs5kB9Ng==", "dev": true }, "find-up": { @@ -2103,7 +2103,7 @@ "supports-color": { "version": "5.3.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.3.0.tgz", - "integrity": "sha1-WySsFduA+pJ89SJ6SjP9PEx2dsA=", + "integrity": "sha512-0aP01LLIskjKs3lq52EC0aGBAJhLq7B2Rd8HC/DR/PtNNpcLilNmHC12O+hu0usQpo7wtHNRqtrhBwtDb0+dNg==", "dev": true, "requires": { "has-flag": "3.0.0" @@ -2567,7 +2567,7 @@ "glob": { "version": "7.1.2", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", - "integrity": "sha1-wZyd+aAocC1nhhI4SmVSQExjbRU=", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", "dev": true, "requires": { "fs.realpath": "1.0.0", @@ -2672,7 +2672,7 @@ "growl": { "version": "1.10.3", "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.3.tgz", - "integrity": "sha1-GSa6kM8+3+KttJJ/WIC8IsZseQ8=", + "integrity": "sha512-hKlsbA5Vu3xsh1Cg3J7jSmX/WaW6A5oBeqzM88oNbCRQFz+zUaXm6yxS4RVytp1scBoJzSYl4YAEOQIt6O8V1Q==", "dev": true }, "handlebars": { @@ -2738,7 +2738,7 @@ "hawk": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/hawk/-/hawk-6.0.2.tgz", - "integrity": "sha1-r02RTrBl+bXOTZ0RwcshJu7MMDg=", + "integrity": "sha512-miowhl2+U7Qle4vdLqDdPt9m09K6yZhkLDTWGoUiUzrQCn+mHHSmfJgAyGaLRZbPmTqfFFjRV1QWCW0VWUJBbQ==", "dev": true, "requires": { "boom": "4.3.1", @@ -2756,7 +2756,7 @@ "hoek": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/hoek/-/hoek-4.2.1.tgz", - "integrity": "sha1-ljRQKqEsRF3Vp8VzS1cruHOKrLs=", + "integrity": "sha512-QLg82fGkfnJ/4iy1xZ81/9SIJiq1NGFUMGs6ParyjBZr6jW2Ufj/snDqTHixNlHdPNwN2RLVD0Pi3igeK9+JfA==", "dev": true }, "home-path": { @@ -2791,7 +2791,7 @@ "ignore": { "version": "3.3.7", "resolved": "https://registry.npmjs.org/ignore/-/ignore-3.3.7.tgz", - "integrity": "sha1-YSKJv7PCIOGGpYEYYY1b6MG6sCE=", + "integrity": "sha512-YGG3ejvBNHRqu0559EOxxNFihD0AjpvHlC/pdGKd3X3ofe+CoJkYazwNJYTNebqpPKN+VVQbh4ZFn1DivMNuHA==", "dev": true }, "imurmurhash": { @@ -2828,7 +2828,7 @@ "ini": { "version": "1.3.5", "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", - "integrity": "sha1-7uJfVtscnsYIXgwid4CD9Zar+Sc=", + "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==", "dev": true }, "inquirer": { @@ -2901,7 +2901,7 @@ "is-buffer": { "version": "1.1.6", "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", - "integrity": "sha1-76ouqdqg16suoTqXsritUf776L4=", + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", "dev": true }, "is-builtin-module": { @@ -3054,7 +3054,7 @@ "is-resolvable": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/is-resolvable/-/is-resolvable-1.1.0.tgz", - "integrity": "sha1-+xj4fOH+uSUWnJpAfBkxijIG7Yg=", + "integrity": "sha512-qgDYXFSR5WvEfuS5dMj6oTMEbrrSaM0CrFk2Yiq/gXnBvD9pMa2jGXxyhGLfvhZpuMZe18CJpFxAt3CRs42NMg==", "dev": true }, "is-retry-allowed": { @@ -3204,7 +3204,7 @@ "js-yaml": { "version": "3.11.0", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.11.0.tgz", - "integrity": "sha1-WXwai9VxUvJtYizkEXhRpR9euu8=", + "integrity": "sha512-saJstZWv7oNeOyBh3+Dx1qWzhW0+e6/8eDzo7p5rDFqxntSztloLtuKu+Ejhtq82jsilwOIZYsCz+lIjthg1Hw==", "dev": true, "requires": { "argparse": "1.0.10", @@ -3324,7 +3324,7 @@ "just-extend": { "version": "1.1.27", "resolved": "https://registry.npmjs.org/just-extend/-/just-extend-1.1.27.tgz", - "integrity": "sha1-7G55QQ/5FORyZSq/oOYDwD1g6QU=", + "integrity": "sha512-mJVp13Ix6gFo3SBAy9U/kL+oeZqzlYYYLQBwXVBlVzIsZwBqGREnOro24oC/8s8aox+rJhtZ2DiQof++IrkA+g==", "dev": true }, "kind-of": { @@ -3703,7 +3703,7 @@ "lodash": { "version": "4.17.5", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.5.tgz", - "integrity": "sha1-maktZcAnLevoyWtgV7yPv6O+1RE=", + "integrity": "sha512-svL3uiZf1RwhH+cWrfZn3A4+U58wbP0tGVTLQPbjplZxZ8ROD9VLuNgsRniTlLe7OlSqR79RUehXgpBW/s0IQw==", "dev": true }, "lodash._reinterpolate": { @@ -3740,7 +3740,7 @@ "lolex": { "version": "2.3.2", "resolved": "https://registry.npmjs.org/lolex/-/lolex-2.3.2.tgz", - "integrity": "sha1-hflFBCUQO/nnpgZo6iXcQydMqAc=", + "integrity": "sha512-A5pN2tkFj7H0dGIAM6MFvHKMJcPnjZsOMvR7ujCjfgW5TbV6H9vb1PgxLtHvjqNZTHsUolz+6/WEO0N1xNx2ng==", "dev": true }, "longest": { @@ -3816,7 +3816,7 @@ "marked": { "version": "0.3.17", "resolved": "https://registry.npmjs.org/marked/-/marked-0.3.17.tgz", - "integrity": "sha1-YH8GZos8axJGso8T2nYRasGqLSs=", + "integrity": "sha512-+AKbNsjZl6jFfLPwHhWmGTqE009wTKn3RTmn9K8oUKHrX/abPJjtcRtXpYB/FFrwPJRUA86LX/de3T0knkPCmQ==", "dev": true }, "mem": { @@ -3896,13 +3896,13 @@ "mime-db": { "version": "1.33.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.33.0.tgz", - "integrity": "sha1-o0kgUKXLm2NFBUHjnZeI0icng9s=", + "integrity": "sha512-BHJ/EKruNIqJf/QahvxwQZXKygOQ256myeN/Ew+THcAa5q+PjyTTMMeNQC4DZw5AwfvelsUrA6B67NKMqXDbzQ==", "dev": true }, "mime-types": { "version": "2.1.18", "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.18.tgz", - "integrity": "sha1-bzI/YKg9ERRvgx/xH9ZuL+VQO7g=", + "integrity": "sha512-lc/aahn+t4/SWV/qcmumYjymLsWfN3ELhpmVuUFjgsORruuZPVSwAQryq+HHGvO/SI2KVX26bx+En+zhM8g8hQ==", "dev": true, "requires": { "mime-db": "1.33.0" @@ -3917,7 +3917,7 @@ "minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha1-UWbihkV/AzBgZL5Ul+jbsMPTIIM=", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "dev": true, "requires": { "brace-expansion": "1.1.11" @@ -4071,7 +4071,7 @@ "normalize-package-data": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.4.0.tgz", - "integrity": "sha1-EvlaMH1YNSB1oEkHuErIvpisAS8=", + "integrity": "sha512-9jjUFbTPfEy3R/ad/2oNbKtW9Hgovl5O1FvFWKkKblNXoN/Oou6+9+KKohPK13Yc3/TyunyWhJp6gvRNR/PPAw==", "dev": true, "requires": { "hosted-git-info": "2.5.0", @@ -4511,7 +4511,7 @@ "process-nextick-args": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", - "integrity": "sha1-o31zL0JxtKsa0HDTVQjoKQeI/6o=", + "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==", "dev": true }, "progress": { @@ -4584,7 +4584,7 @@ "qs": { "version": "6.5.1", "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.1.tgz", - "integrity": "sha1-NJzfbu+J7EXBLX1es/wMhwNDptg=", + "integrity": "sha512-eRzhrN1WSINYCDCbrz796z37LOe3m5tmW7RQf6oBntukAG1nmovJvhnwHHRMAfeoItc1m2Hk02WER2aQ/iqs+A==", "dev": true }, "quick-lru": { @@ -4596,7 +4596,7 @@ "randomatic": { "version": "1.1.7", "resolved": "https://registry.npmjs.org/randomatic/-/randomatic-1.1.7.tgz", - "integrity": "sha1-x6vpzIuHwLqodrGf3oP9RkeX44w=", + "integrity": "sha512-D5JUjPyJbaJDkuAazpVnSfVkLlpeO3wDlPROTMLGKG1zMFNFRgrciKo1ltz/AzNTkqE0HzDx655QOL51N06how==", "dev": true, "requires": { "is-number": "3.0.0", @@ -4701,7 +4701,7 @@ "regex-cache": { "version": "0.4.4", "resolved": "https://registry.npmjs.org/regex-cache/-/regex-cache-0.4.4.tgz", - "integrity": "sha1-db3FiioUls7EihKDW8VMjVYjNt0=", + "integrity": "sha512-nVIZwtCjkC9YgvWkpM55B5rBhBYRZhAaJbgcFYXXsHnbZ9UZI9nnVWYZpBlCqv9ho2eZryPnWrZGsOdPwVWXWQ==", "dev": true, "requires": { "is-equal-shallow": "0.1.3" @@ -4729,7 +4729,7 @@ "remap-istanbul": { "version": "0.10.1", "resolved": "https://registry.npmjs.org/remap-istanbul/-/remap-istanbul-0.10.1.tgz", - "integrity": "sha1-OqWN1QIdSZ8zbTulvzu7kcG4jjc=", + "integrity": "sha512-gsNQXs5kJLhErICSyYhzVZ++C8LBW8dgwr874Y2QvzAUS75zBlD/juZgXs39nbYJ09fZDlX2AVLVJAY2jbFJoQ==", "dev": true, "requires": { "amdefine": "1.0.1", @@ -4769,7 +4769,7 @@ "source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha1-dHIq8y6WFOnCh6jQu95IteLxomM=", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", "dev": true }, "through2": { @@ -4883,7 +4883,7 @@ "resolve": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.5.0.tgz", - "integrity": "sha1-HwmsznlsmnYlefMbLBzEw83fnzY=", + "integrity": "sha512-hgoSGrc3pjzAPHNBg+KnFcK2HwlHTs/YrAGUr6qgTVUZmXv1UEXXl0bZNBKMA9fud6lRYFdPGz0xXxycPzmmiw==", "dev": true, "requires": { "path-parse": "1.0.5" @@ -4924,7 +4924,7 @@ "rimraf": { "version": "2.6.2", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", - "integrity": "sha1-LtgVDSShbqhlHm1u8PR8QVjOejY=", + "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", "dev": true, "requires": { "glob": "7.1.2" @@ -5063,19 +5063,19 @@ "safe-buffer": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", - "integrity": "sha1-iTMSr2myEj3vcfV4iQAWce6yyFM=", + "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", "dev": true }, "samsam": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/samsam/-/samsam-1.3.0.tgz", - "integrity": "sha1-jR2TUOJWItow3j5EumkrUiGrfFA=", + "integrity": "sha512-1HwIYD/8UlOtFS3QO3w7ey+SdSDFE4HRNLZoZRYVQefrOY3l17epswImeB1ijgJFQJodIaHcwkp3r/myBjFVbg==", "dev": true }, "semver": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz", - "integrity": "sha1-3Eu8emyp2Rbe5dQ1FvAJK1j3uKs=", + "integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==", "dev": true }, "set-blocking": { @@ -5117,7 +5117,7 @@ "sinon-chai": { "version": "2.14.0", "resolved": "https://registry.npmjs.org/sinon-chai/-/sinon-chai-2.14.0.tgz", - "integrity": "sha1-2n3UzIPNaiYLZ8yg96n9riahIF0=", + "integrity": "sha512-9stIF1utB0ywNHNT7RgiXbdmen8QDCRsrTjw+G9TgKt1Yexjiv8TOWZ6WHsTPz57Yky3DIswZvEqX8fpuHNDtQ==", "dev": true }, "slash": { @@ -5146,7 +5146,7 @@ "sntp": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/sntp/-/sntp-2.1.0.tgz", - "integrity": "sha1-LGzsFP7cIiJznK+bXD2F0cxaLMg=", + "integrity": "sha512-FL1b58BDrqS3A11lJ0zEdnJ3UOKqVxawAkF3k7F0CVN7VQ34aZrV+G8BZ1WC9ZL7NyrwsW0oviwsWDgRuVYtJg==", "dev": true, "requires": { "hoek": "4.2.1" @@ -5203,7 +5203,7 @@ "spdx-correct": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.0.0.tgz", - "integrity": "sha1-BaW01xU6GVvJLDxCW2nzsqlSTII=", + "integrity": "sha512-N19o9z5cEyc8yQQPukRCZ9EUmb4HUpnrmaL/fxS2pBo2jbfcFRVuFZ/oFC+vZz0MNNk0h80iMn5/S6qGZOL5+g==", "dev": true, "requires": { "spdx-expression-parse": "3.0.0", @@ -5213,13 +5213,13 @@ "spdx-exceptions": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.1.0.tgz", - "integrity": "sha1-LHrmEFbHFKW5ubKyr30xHvXHj+k=", + "integrity": "sha512-4K1NsmrlCU1JJgUrtgEeTVyfx8VaYea9J9LvARxhbHtVtohPs/gFGG5yy49beySjlIMhhXZ4QqujIZEfS4l6Cg==", "dev": true }, "spdx-expression-parse": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.0.tgz", - "integrity": "sha1-meEZt6XaAOBUkcn6M4t5BII7QdA=", + "integrity": "sha512-Yg6D3XpRD4kkOmTpdgbUiEJFKghJH03fiC1OPll5h/0sO6neh2jqRDVHOQ4o/LMea0tgCkbMgea5ip/e+MkWyg==", "dev": true, "requires": { "spdx-exceptions": "2.1.0", @@ -5229,7 +5229,7 @@ "spdx-license-ids": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.0.tgz", - "integrity": "sha1-enzShHDMbToc/m1miG9rxDDTrIc=", + "integrity": "sha512-2+EPwgbnmOIl8HjGBXXMd9NAu02vLjOO1nWw4kmeRDFyHn+M/ETfHxQUK0oXg8ctgVnl9t3rosNVsZ1jG61nDA==", "dev": true }, "speedometer": { @@ -5566,7 +5566,7 @@ "tough-cookie": { "version": "2.3.4", "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.4.tgz", - "integrity": "sha1-7GDO44rGdQY//JelwYlwV47oNlU=", + "integrity": "sha512-TZ6TTfI5NtZnuyy/Kecv+CnoROnyXn2DN97LontgQpCwsX2XyLYCC0ENhYkehSOwAp8rTQKc/NUIF7BkQ5rKLA==", "dev": true, "requires": { "punycode": "1.4.1" @@ -5708,13 +5708,13 @@ "uuid": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.2.1.tgz", - "integrity": "sha1-EsUou51Y0LkmXZovbw/ovhf/HxQ=", + "integrity": "sha512-jZnMwlb9Iku/O3smGWvZhauCf6cvvpKi4BKRiliS3cxnI+Gz9j5MEpTz2UFuXiKPJocb7gnsLHwiS05ige5BEA==", "dev": true }, "validate-npm-package-license": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.3.tgz", - "integrity": "sha1-gWQ7y+8b3+zUYjeT3EZIlIupgzg=", + "integrity": "sha512-63ZOUnL4SIXj4L0NixR3L1lcjO38crAbgrTpl28t8jjrfuiOBL5Iygm+60qPs/KsZGzPNg6Smnc/oY16QTjF0g==", "dev": true, "requires": { "spdx-correct": "3.0.0", @@ -5750,7 +5750,7 @@ "which": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/which/-/which-1.3.0.tgz", - "integrity": "sha1-/wS9/AEO5UfXgL7DjhrBwnd9JTo=", + "integrity": "sha512-xcJpopdamTuY5duC/KnTTNBraPK54YwpenP4lzxU8H91GudWpFv38u0CKjclE1Wi2EH2EDz5LRcHcKbCIzqGyg==", "dev": true, "requires": { "isexe": "2.0.0" diff --git a/packages/canvas/canvas-mesh/package.json b/packages/canvas/canvas-mesh/package.json index 691cd2c..6744a17 100644 --- a/packages/canvas/canvas-mesh/package.json +++ b/packages/canvas/canvas-mesh/package.json @@ -24,6 +24,7 @@ "dependencies": { "@pixi/constants": "^5.0.0-alpha.2", "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/mesh-extras": "^5.0.0-alpha.2", "@pixi/settings": "^5.0.0-alpha.2" }, "devDependencies": { diff --git a/packages/canvas/canvas-mesh/src/Mesh.js b/packages/canvas/canvas-mesh/src/Mesh.js index 900a872..c43a74b 100644 --- a/packages/canvas/canvas-mesh/src/Mesh.js +++ b/packages/canvas/canvas-mesh/src/Mesh.js @@ -1,36 +1,14 @@ import { Mesh } from '@pixi/mesh'; -import { settings } from './settings'; - -// IMPORTANT: Please do NOT use this as a precedent to use `settings` after the object is created -// this was merely created to completely decouple canvas from the base Mesh class and we are -// unable to add `canvasPadding` in the constructor anymore, as the case was for PixiJS v4. /** - * Internal variable for `canvasPadding`. + * Renders the object using the Canvas renderer * * @private - * @memberof PIXI.Mesh - * @member {number} - * @default null - */ -Mesh.prototype._canvasPadding = null; - -/** - * Triangles in canvas mode are automatically antialiased, use this value to force triangles - * to overlap a bit with each other. To set the global default, set {@link PIXI.settings.MESH_CANVAS_PADDING} - * - * @see PIXI.settings.MESH_CANVAS_PADDING - * @member {number} canvasPadding + * @method _renderCanvas * @memberof PIXI.Mesh# - * @default 0 + * @param {PIXI.CanvasRenderer} renderer - The canvas renderer. */ -Object.defineProperty(Mesh.prototype, 'canvasPadding', { - get() - { - return this._canvasPadding !== null ? this._canvasPadding : settings.MESH_CANVAS_PADDING; - }, - set(value) - { - this._canvasPadding = value; - }, -}); +Mesh.prototype._renderCanvas = function _renderCanvas(renderer) +{ + renderer.plugins[this.pluginName].render(this); +}; diff --git a/packages/canvas/canvas-mesh/src/Mesh2d.js b/packages/canvas/canvas-mesh/src/Mesh2d.js new file mode 100644 index 0000000..d0bd80f --- /dev/null +++ b/packages/canvas/canvas-mesh/src/Mesh2d.js @@ -0,0 +1,36 @@ +import { Mesh2d } from '@pixi/mesh-extras'; +import { settings } from './settings'; + +// IMPORTANT: Please do NOT use this as a precedent to use `settings` after the object is created +// this was merely created to completely decouple canvas from the base Mesh class and we are +// unable to add `canvasPadding` in the constructor anymore, as the case was for PixiJS v4. + +/** + * Internal variable for `canvasPadding`. + * + * @private + * @memberof PIXI.Mesh2d + * @member {number} + * @default null + */ +Mesh2d.prototype._canvasPadding = null; + +/** + * Triangles in canvas mode are automatically antialiased, use this value to force triangles + * to overlap a bit with each other. To set the global default, set {@link PIXI.settings.MESH_CANVAS_PADDING} + * + * @see PIXI.settings.MESH_CANVAS_PADDING + * @member {number} canvasPadding + * @memberof PIXI.Mesh2d# + * @default 0 + */ +Object.defineProperty(Mesh2d.prototype, 'canvasPadding', { + get() + { + return this._canvasPadding !== null ? this._canvasPadding : settings.MESH_CANVAS_PADDING; + }, + set(value) + { + this._canvasPadding = value; + }, +}); diff --git a/packages/canvas/canvas-mesh/src/NineSlicePlane.js b/packages/canvas/canvas-mesh/src/NineSlicePlane.js index 09eaf9c..2fd5acc 100644 --- a/packages/canvas/canvas-mesh/src/NineSlicePlane.js +++ b/packages/canvas/canvas-mesh/src/NineSlicePlane.js @@ -1,4 +1,4 @@ -import { NineSlicePlane } from '@pixi/mesh'; +import { NineSlicePlane } from '@pixi/mesh-extras'; /** * Renders the object using the Canvas renderer diff --git a/packages/canvas/canvas-mesh/src/RawMesh.js b/packages/canvas/canvas-mesh/src/RawMesh.js deleted file mode 100644 index bf40184..0000000 --- a/packages/canvas/canvas-mesh/src/RawMesh.js +++ /dev/null @@ -1,14 +0,0 @@ -import { RawMesh } from '@pixi/mesh'; - -/** - * Renders the object using the Canvas renderer - * - * @private - * @method _renderCanvas - * @memberof PIXI.RawMesh# - * @param {PIXI.CanvasRenderer} renderer - The canvas renderer. - */ -RawMesh.prototype._renderCanvas = function _renderCanvas(renderer) -{ - renderer.plugins[this.pluginName].render(this); -}; diff --git a/packages/canvas/canvas-mesh/src/index.js b/packages/canvas/canvas-mesh/src/index.js index 2295016..f4fa31d 100644 --- a/packages/canvas/canvas-mesh/src/index.js +++ b/packages/canvas/canvas-mesh/src/index.js @@ -1,6 +1,6 @@ export { default as CanvasMeshRenderer } from './CanvasMeshRenderer'; import './settings'; -import './Mesh'; +import './Mesh2d'; import './NineSlicePlane'; -import './RawMesh'; +import './Mesh'; diff --git a/packages/canvas/canvas-mesh/src/settings.js b/packages/canvas/canvas-mesh/src/settings.js index 4cefb4c..e81b8e0 100644 --- a/packages/canvas/canvas-mesh/src/settings.js +++ b/packages/canvas/canvas-mesh/src/settings.js @@ -3,7 +3,7 @@ /** * Default `canvasPadding` for canvas-based Mesh rendering. * - * @see PIXI.Mesh#canvasPadding + * @see PIXI.Mesh2d#canvasPadding * @static * @constant * @memberof PIXI.settings diff --git a/packages/mesh-extras/LICENSE b/packages/mesh-extras/LICENSE new file mode 100644 index 0000000..148e3eb --- /dev/null +++ b/packages/mesh-extras/LICENSE @@ -0,0 +1,21 @@ +The MIT License + +Copyright (c) 2013-2018 Mathew Groves, Chad Engler + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/packages/mesh-extras/README.md b/packages/mesh-extras/README.md new file mode 100644 index 0000000..1d9b0e1 --- /dev/null +++ b/packages/mesh-extras/README.md @@ -0,0 +1,19 @@ +# @pixi/mesh-extras + +## Installation + +```bash +npm install @pixi/mesh-extras +``` + +## Usage + +```js +import { MeshRenderer } from '@pixi/mesh'; +import { Renderer } from '@pixi/core'; +import { Rope } from '@pixi/mesh-extras'; + +Renderer.registerPlugin('mesh', MeshRenderer); + +const rope = new Rope(); +``` \ No newline at end of file diff --git a/packages/mesh-extras/package.json b/packages/mesh-extras/package.json new file mode 100644 index 0000000..d134f64 --- /dev/null +++ b/packages/mesh-extras/package.json @@ -0,0 +1,38 @@ +{ + "name": "@pixi/mesh-extras", + "version": "5.0.0-alpha.2", + "main": "lib/mesh-extras.js", + "module": "lib/mesh-extras.es.js", + "description": "Custom Mesh display objects, like Rope and Plane", + "author": "Mat Groves", + "contributors": [ + "Matt Karl " + ], + "homepage": "http://pixijs.com/", + "bugs": "https://github.com/pixijs/pixi.js/issues", + "license": "MIT", + "repository": { + "type": "git", + "url": "https://github.com/pixijs/pixi.js.git" + }, + "publishConfig": { + "access": "public" + }, + "scripts": { + "test": "floss --path test" + }, + "files": [ + "lib" + ], + "dependencies": { + "@pixi/constants": "^5.0.0-alpha.2", + "@pixi/core": "^5.0.0-alpha.2", + "@pixi/math": "^5.0.0-alpha.2", + "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/utils": "^5.0.0-alpha.2" + }, + "devDependencies": { + "@pixi/loaders": "^5.0.0-alpha.2", + "floss": "^2.1.3" + } +} diff --git a/packages/mesh-extras/src/Mesh2d.js b/packages/mesh-extras/src/Mesh2d.js new file mode 100644 index 0000000..d113a5e --- /dev/null +++ b/packages/mesh-extras/src/Mesh2d.js @@ -0,0 +1,263 @@ +import { Mesh } from '@pixi/mesh'; +import { Geometry, Program, Shader, Texture, TextureMatrix } from '@pixi/core'; +import { Matrix } from '@pixi/math'; +import { BLEND_MODES } from '@pixi/constants'; +import { hex2rgb, premultiplyRgba } from '@pixi/utils'; +import vertex from './mesh.vert'; +import fragment from './mesh.frag'; + +let meshProgram; + +/** + * Base mesh class + * @class + * @extends PIXI.Container + * @memberof PIXI + */ +export default class Mesh2d extends Mesh +{ + /** + * @param {PIXI.Texture} [texture=Texture.EMPTY] - The texture to use + * @param {Float32Array} [vertices] - if you want to specify the vertices + * @param {Float32Array} [uvs] - if you want to specify the uvs + * @param {Uint16Array} [indices] - if you want to specify the indices + * @param {number} [drawMode] - the drawMode, can be any of the Mesh.DRAW_MODES consts + */ + constructor(texture = Texture.EMPTY, vertices, uvs, indices, drawMode) + { + const geometry = new Geometry(); + + if (!meshProgram) + { + meshProgram = new Program(vertex, fragment); + } + + geometry.addAttribute('aVertexPosition', vertices) + .addAttribute('aTextureCoord', uvs) + .addIndex(indices); + + geometry.getAttribute('aVertexPosition').static = false; + + const uniforms = { + uSampler: texture, + uTextureMatrix: Matrix.IDENTITY, + alpha: 1, + uColor: new Float32Array([1, 1, 1, 1]), + }; + + super(geometry, new Shader(meshProgram, uniforms), null, drawMode); + + /** + * The Uvs of the Mesh + * + * @member {Float32Array} + */ + this.uvs = geometry.getAttribute('aTextureCoord').data; + + /** + * An array of vertices + * + * @member {Float32Array} + */ + this.vertices = geometry.getAttribute('aVertexPosition').data; + + this.uniforms = uniforms; + + /** + * The texture of the Mesh + * + * @member {PIXI.Texture} + * @default PIXI.Texture.EMPTY + * @private + */ + this.texture = texture; + + /** + * The tint applied to the mesh. This is a [r,g,b] value. A value of [1,1,1] will remove any + * tint effect. + * + * @member {number} + * @private + */ + this._tintRGB = new Float32Array([1, 1, 1]); + + // Set default tint + this.tint = 0xFFFFFF; + + this.blendMode = BLEND_MODES.NORMAL; + + /** + * TextureMatrix instance for this Mesh, used to track Texture changes + * + * @member {PIXI.TextureMatrix} + * @readonly + */ + this.uvMatrix = new TextureMatrix(this._texture); + + /** + * whether or not upload uvMatrix to shader + * if its false, then uvs should be pre-multiplied + * if you change it for generated mesh, please call 'refresh(true)' + * @member {boolean} + * @default false + */ + this.uploadUvMatrix = false; + + /** + * Uploads vertices buffer every frame, like in PixiJS V3 and V4. + * + * @member {boolean} + * @default true + */ + this.autoUpdate = true; + } + + /** + * The tint applied to the Rope. This is a hex value. A value of + * 0xFFFFFF will remove any tint effect. + * + * @member {number} + * @memberof PIXI.Sprite# + * @default 0xFFFFFF + */ + get tint() + { + return this._tint; + } + + /** + * Sets the tint of the rope. + * + * @param {number} value - The value to set to. + */ + set tint(value) + { + this._tint = value; + + hex2rgb(this._tint, this._tintRGB); + } + + /** + * The blend mode to be applied to the sprite. Set to `PIXI.BLEND_MODES.NORMAL` to remove any blend mode. + * + * @member {number} + * @default PIXI.BLEND_MODES.NORMAL + * @see PIXI.BLEND_MODES + */ + get blendMode() + { + return this.state.blendMode; + } + + set blendMode(value) // eslint-disable-line require-jsdoc + { + this.state.blendMode = value; + } + + /** + * The texture that the mesh uses. + * + * @member {PIXI.Texture} + */ + get texture() + { + return this._texture; + } + + set texture(value) // eslint-disable-line require-jsdoc + { + if (this._texture === value) + { + return; + } + + this._texture = value; + this.uniforms.uSampler = this.texture; + + if (value) + { + // wait for the texture to load + if (value.baseTexture.valid) + { + this._onTextureUpdate(); + } + else + { + value.once('update', this._onTextureUpdate, this); + } + } + } + + _render(renderer) + { + const baseTex = this._texture.baseTexture; + + premultiplyRgba(this._tintRGB, this.worldAlpha, this.uniforms.uColor, baseTex.premultiplyAlpha); + super._render(renderer); + } + /** + * When the texture is updated, this event will fire to update the scale and frame + * + * @private + */ + _onTextureUpdate() + { + // constructor texture update stop + if (!this.uvMatrix) + { + return; + } + this.uvMatrix.texture = this._texture; + this.refresh(); + } + + /** + * multiplies uvs only if uploadUvMatrix is false + * call it after you change uvs manually + * make sure that texture is valid + */ + multiplyUvs() + { + if (!this.uploadUvMatrix) + { + this.uvMatrix.multiplyUvs(this.uvs); + } + } + + /** + * Refreshes uvs for generated meshes (rope, plane) + * sometimes refreshes vertices too + * + * @param {boolean} [forceUpdate=false] if true, matrices will be updated any case + */ + refresh(forceUpdate) + { + if (this.uvMatrix.update(forceUpdate)) + { + this._refresh(); + } + } + + /** + * Updates the object transform for rendering + * + * @private + */ + updateTransform() + { + if (this.autoUpdate) + { + this.geometry.buffers[0].update(); + } + this.containerUpdateTransform(); + } + + /** + * re-calculates mesh coords + * @private + */ + _refresh() + { + /* empty */ + } +} diff --git a/packages/mesh-extras/src/NineSlicePlane.js b/packages/mesh-extras/src/NineSlicePlane.js new file mode 100644 index 0000000..0bae92c --- /dev/null +++ b/packages/mesh-extras/src/NineSlicePlane.js @@ -0,0 +1,270 @@ +import Plane from './Plane'; + +const DEFAULT_BORDER_SIZE = 10; + +/** + * The NineSlicePlane allows you to stretch a texture using 9-slice scaling. The corners will remain unscaled (useful + * for buttons with rounded corners for example) and the other areas will be scaled horizontally and or vertically + * + *```js + * let Plane9 = new PIXI.NineSlicePlane(PIXI.Texture.from('BoxWithRoundedCorners.png'), 15, 15, 15, 15); + * ``` + *
+ *      A                          B
+ *    +---+----------------------+---+
+ *  C | 1 |          2           | 3 |
+ *    +---+----------------------+---+
+ *    |   |                      |   |
+ *    | 4 |          5           | 6 |
+ *    |   |                      |   |
+ *    +---+----------------------+---+
+ *  D | 7 |          8           | 9 |
+ *    +---+----------------------+---+
+
+ *  When changing this objects width and/or height:
+ *     areas 1 3 7 and 9 will remain unscaled.
+ *     areas 2 and 8 will be stretched horizontally
+ *     areas 4 and 6 will be stretched vertically
+ *     area 5 will be stretched both horizontally and vertically
+ * 
+ * + * @class + * @extends PIXI.Plane + * @memberof PIXI + * + */ +export default class NineSlicePlane extends Plane +{ + /** + * @param {PIXI.Texture} texture - The texture to use on the NineSlicePlane. + * @param {int} [leftWidth=10] size of the left vertical bar (A) + * @param {int} [topHeight=10] size of the top horizontal bar (C) + * @param {int} [rightWidth=10] size of the right vertical bar (B) + * @param {int} [bottomHeight=10] size of the bottom horizontal bar (D) + */ + constructor(texture, leftWidth, topHeight, rightWidth, bottomHeight) + { + super(texture, 4, 4); + + this._origWidth = texture.orig.width; + this._origHeight = texture.orig.height; + + /** + * The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._width = this._origWidth; + + /** + * The height of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._height = this._origHeight; + + /** + * The width of the left column (a) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._leftWidth = typeof leftWidth !== 'undefined' ? leftWidth : DEFAULT_BORDER_SIZE; + + /** + * The width of the right column (b) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._rightWidth = typeof rightWidth !== 'undefined' ? rightWidth : DEFAULT_BORDER_SIZE; + + /** + * The height of the top row (c) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._topHeight = typeof topHeight !== 'undefined' ? topHeight : DEFAULT_BORDER_SIZE; + + /** + * The height of the bottom row (d) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._bottomHeight = typeof bottomHeight !== 'undefined' ? bottomHeight : DEFAULT_BORDER_SIZE; + + this.refresh(true); + } + + /** + * Updates the horizontal vertices. + * + */ + updateHorizontalVertices() + { + const vertices = this.vertices; + + const h = this._topHeight + this._bottomHeight; + const scale = this._height > h ? 1.0 : this._height / h; + + vertices[9] = vertices[11] = vertices[13] = vertices[15] = this._topHeight * scale; + vertices[17] = vertices[19] = vertices[21] = vertices[23] = this._height - (this._bottomHeight * scale); + vertices[25] = vertices[27] = vertices[29] = vertices[31] = this._height; + } + + /** + * Updates the vertical vertices. + * + */ + updateVerticalVertices() + { + const vertices = this.vertices; + + const w = this._leftWidth + this._rightWidth; + const scale = this._width > w ? 1.0 : this._width / w; + + vertices[2] = vertices[10] = vertices[18] = vertices[26] = this._leftWidth * scale; + vertices[4] = vertices[12] = vertices[20] = vertices[28] = this._width - (this._rightWidth * scale); + vertices[6] = vertices[14] = vertices[22] = vertices[30] = this._width; + } + + /** + * The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + */ + get width() + { + return this._width; + } + + set width(value) // eslint-disable-line require-jsdoc + { + this._width = value; + this._refresh(); + } + + /** + * The height of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + */ + get height() + { + return this._height; + } + + set height(value) // eslint-disable-line require-jsdoc + { + this._height = value; + this._refresh(); + } + + /** + * The width of the left column + * + * @member {number} + */ + get leftWidth() + { + return this._leftWidth; + } + + set leftWidth(value) // eslint-disable-line require-jsdoc + { + this._leftWidth = value; + this._refresh(); + } + + /** + * The width of the right column + * + * @member {number} + */ + get rightWidth() + { + return this._rightWidth; + } + + set rightWidth(value) // eslint-disable-line require-jsdoc + { + this._rightWidth = value; + this._refresh(); + } + + /** + * The height of the top row + * + * @member {number} + */ + get topHeight() + { + return this._topHeight; + } + + set topHeight(value) // eslint-disable-line require-jsdoc + { + this._topHeight = value; + this._refresh(); + } + + /** + * The height of the bottom row + * + * @member {number} + */ + get bottomHeight() + { + return this._bottomHeight; + } + + set bottomHeight(value) // eslint-disable-line require-jsdoc + { + this._bottomHeight = value; + this._refresh(); + } + + /** + * Refreshes NineSlicePlane coords. All of them. + */ + _refresh() + { + super._refresh(); + + const uvs = this.uvs; + const texture = this._texture; + + this._origWidth = texture.orig.width; + this._origHeight = texture.orig.height; + + const _uvw = 1.0 / this._origWidth; + const _uvh = 1.0 / this._origHeight; + + uvs[0] = uvs[8] = uvs[16] = uvs[24] = 0; + uvs[1] = uvs[3] = uvs[5] = uvs[7] = 0; + uvs[6] = uvs[14] = uvs[22] = uvs[30] = 1; + uvs[25] = uvs[27] = uvs[29] = uvs[31] = 1; + + uvs[2] = uvs[10] = uvs[18] = uvs[26] = _uvw * this._leftWidth; + uvs[4] = uvs[12] = uvs[20] = uvs[28] = 1 - (_uvw * this._rightWidth); + uvs[9] = uvs[11] = uvs[13] = uvs[15] = _uvh * this._topHeight; + uvs[17] = uvs[19] = uvs[21] = uvs[23] = 1 - (_uvh * this._bottomHeight); + + this.updateHorizontalVertices(); + this.updateVerticalVertices(); + + this.geometry.buffers[1].update(); + + this.multiplyUvs(); + } +} diff --git a/bundles/pixi.js/package.json b/bundles/pixi.js/package.json index 49c7276..177e059 100644 --- a/bundles/pixi.js/package.json +++ b/bundles/pixi.js/package.json @@ -49,6 +49,7 @@ "@pixi/loaders": "^5.0.0-alpha.2", "@pixi/math": "^5.0.0-alpha.2", "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/mesh-extras": "^5.0.0-alpha.2", "@pixi/mixin-cache-as-bitmap": "^5.0.0-alpha.2", "@pixi/mixin-get-child-by-name": "^5.0.0-alpha.2", "@pixi/mixin-get-global-position": "^5.0.0-alpha.2", diff --git a/bundles/pixi.js/src/deprecated.js b/bundles/pixi.js/src/deprecated.js index 147617c..dbebeb0 100644 --- a/bundles/pixi.js/src/deprecated.js +++ b/bundles/pixi.js/src/deprecated.js @@ -263,15 +263,15 @@ Object.defineProperties(PIXI.mesh, { /** * @class PIXI.mesh.Mesh - * @see PIXI.Mesh + * @see PIXI.Mesh2d * @deprecated since 5.0.0 */ Mesh: { get() { - warn('PIXI.mesh.Mesh has moved to PIXI.Mesh'); + warn('PIXI.mesh.Mesh has moved to PIXI.Mesh2d'); - return PIXI.Mesh; + return PIXI.Mesh2d; }, }, /** @@ -315,15 +315,15 @@ }, /** * @class PIXI.mesh.RawMesh - * @see PIXI.RawMesh + * @see PIXI.Mesh * @deprecated since 5.0.0 */ RawMesh: { get() { - warn('PIXI.mesh.RawMesh has moved to PIXI.RawMesh'); + warn('PIXI.mesh.RawMesh has moved to PIXI.Mesh'); - return PIXI.RawMesh; + return PIXI.Mesh; }, }, /** diff --git a/bundles/pixi.js/src/index.js b/bundles/pixi.js/src/index.js index a3a0d1b..6fdabf0 100644 --- a/bundles/pixi.js/src/index.js +++ b/bundles/pixi.js/src/index.js @@ -9,6 +9,7 @@ import * as loaders from '@pixi/loaders'; import * as math from '@pixi/math'; import * as mesh from '@pixi/mesh'; +import * as meshExtras from '@pixi/mesh-extras'; import * as particles from '@pixi/particles'; import * as prepare from '@pixi/prepare'; import * as sprite from '@pixi/sprite'; @@ -128,6 +129,7 @@ loaders, math, mesh, + meshExtras, particles, sprite, spriteAnimated, @@ -152,6 +154,7 @@ export * from '@pixi/loaders'; export * from '@pixi/math'; export * from '@pixi/mesh'; +export * from '@pixi/mesh-extras'; export * from '@pixi/particles'; export * from '@pixi/sprite'; export * from '@pixi/spritesheet'; diff --git a/package-lock.json b/package-lock.json index 7fe6db7..0814729 100644 --- a/package-lock.json +++ b/package-lock.json @@ -209,7 +209,7 @@ "argparse": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", - "integrity": "sha1-vNZ5HqWuCXJeF+WtmIE0zUCz2RE=", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", "dev": true, "requires": { "sprintf-js": "1.0.3" @@ -228,7 +228,7 @@ "arr-flatten": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz", - "integrity": "sha1-NgSLv/TntH4TZkQxbJlmnqWukfE=", + "integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==", "dev": true }, "arr-union": { @@ -297,7 +297,7 @@ "assertion-error": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", - "integrity": "sha1-5gtrDo8wG9l+U3UhW9pAbIURjAs=", + "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", "dev": true }, "async": { @@ -396,7 +396,7 @@ "brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha1-PH/L9SnYcibz0vUrlm/1Jx60Qd0=", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, "requires": { "balanced-match": "1.0.0", @@ -568,7 +568,7 @@ "circular-json": { "version": "0.3.3", "resolved": "https://registry.npmjs.org/circular-json/-/circular-json-0.3.3.tgz", - "integrity": "sha1-gVyZ6oT2gJUp0vRXkb34JxE1LWY=", + "integrity": "sha512-UZK3NBx2Mca+b5LsG7bY183pHWt5Y1xts4P3Pz7ENTwGVnJOUWbRb3ocjvX7hx9tq/yTAdclXm9sZ38gNuem4A==", "dev": true }, "cli-cursor": { @@ -638,7 +638,7 @@ "color-convert": { "version": "1.9.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.1.tgz", - "integrity": "sha1-wSYRB66y8pTr/+ye2eytUppgl+0=", + "integrity": "sha512-mjGanIiwQJskCC18rPR6OmrZ6fm2Lc7PeGFYwCmy5J34wC6F1PzdGL6xeMfmgicfYcNLGuVFA3WzXtIDCQSZxQ==", "dev": true, "requires": { "color-name": "1.1.3" @@ -1427,7 +1427,7 @@ "boom": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/boom/-/boom-5.2.0.tgz", - "integrity": "sha1-XdnabuOl8wIHdDYpDLcX0/SlTgI=", + "integrity": "sha512-Z5BTk6ZRe4tXXQlkqftmsAUANpXmuwlsF5Oov8ThoMbQRzdGTA1ngYRW160GexgOgjsFOKJz0LYhoNi+2AMBUw==", "dev": true, "requires": { "hoek": "4.2.1" @@ -1471,7 +1471,7 @@ "debug": { "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha1-XRKFFd8TT/Mn6QpMk/Tgd6U2NB8=", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", "dev": true, "requires": { "ms": "2.0.0" @@ -1585,7 +1585,7 @@ "doctrine": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", - "integrity": "sha1-XNAfwQFiG0LEzX9dGmYkNxbT850=", + "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", "dev": true, "requires": { "esutils": "2.0.2" @@ -1662,7 +1662,7 @@ "es6-promise": { "version": "4.2.4", "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.4.tgz", - "integrity": "sha1-3EIhwrFlGHYL2MOaUtjzVvwA7Sk=", + "integrity": "sha512-/NdNZVJg+uZgtm9eS3O6lrOLYmQag2DjdEXuPaHlZ6RuVqgqaVZfgYCepEIKsLqwdQArOPtC3XzRLqGGfT8KQQ==", "dev": true }, "escape-string-regexp": { @@ -1788,7 +1788,7 @@ "espree": { "version": "3.5.4", "resolved": "https://registry.npmjs.org/espree/-/espree-3.5.4.tgz", - "integrity": "sha1-sPRHGHyKi+2US4FaZgvd9d610ac=", + "integrity": "sha512-yAcIQxtmMiB/jL32dzEp2enBeidsB7xWPLNiw3IIkpVds1P+h7qF9YwJq1yUNzp2OKXgAprs4F61ih66UsoD1A==", "dev": true, "requires": { "acorn": "5.5.0", @@ -1798,7 +1798,7 @@ "esprima": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.0.tgz", - "integrity": "sha1-RJnt3NERDgshi6zy+n9/WfVcqAQ=", + "integrity": "sha512-oftTcaMu/EGrEIu904mWteKIv8vMuOgGYo7EhVJJN00R/EED9DCua/xxHRdYnKtcECzVg7xOWhflvJMnqcFZjw==", "dev": true }, "esquery": { @@ -1813,7 +1813,7 @@ "esrecurse": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.2.1.tgz", - "integrity": "sha1-AHo7n9vCs7uH5IeeoZyS/b05Qs8=", + "integrity": "sha512-64RBB++fIOAXPw3P9cy89qfMlvZEXZkqqJkjqqXIvzP5ezRZjW+lPWjw35UX/3EhUPFYbg5ER4JYgDw4007/DQ==", "dev": true, "requires": { "estraverse": "4.2.0" @@ -2024,7 +2024,7 @@ "find-root": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/find-root/-/find-root-1.1.0.tgz", - "integrity": "sha1-q8/Iunb3CMQql7PWhbfpRQv7nOQ=", + "integrity": "sha512-NKfW6bec6GfKc0SGx1e07QZY9PE99u0Bft/0rzSD5k3sO/vwkVUpDUKVm5Gpp5Ue3YfShPFTX2070tDs5kB9Ng==", "dev": true }, "find-up": { @@ -2103,7 +2103,7 @@ "supports-color": { "version": "5.3.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.3.0.tgz", - "integrity": "sha1-WySsFduA+pJ89SJ6SjP9PEx2dsA=", + "integrity": "sha512-0aP01LLIskjKs3lq52EC0aGBAJhLq7B2Rd8HC/DR/PtNNpcLilNmHC12O+hu0usQpo7wtHNRqtrhBwtDb0+dNg==", "dev": true, "requires": { "has-flag": "3.0.0" @@ -2567,7 +2567,7 @@ "glob": { "version": "7.1.2", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", - "integrity": "sha1-wZyd+aAocC1nhhI4SmVSQExjbRU=", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", "dev": true, "requires": { "fs.realpath": "1.0.0", @@ -2672,7 +2672,7 @@ "growl": { "version": "1.10.3", "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.3.tgz", - "integrity": "sha1-GSa6kM8+3+KttJJ/WIC8IsZseQ8=", + "integrity": "sha512-hKlsbA5Vu3xsh1Cg3J7jSmX/WaW6A5oBeqzM88oNbCRQFz+zUaXm6yxS4RVytp1scBoJzSYl4YAEOQIt6O8V1Q==", "dev": true }, "handlebars": { @@ -2738,7 +2738,7 @@ "hawk": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/hawk/-/hawk-6.0.2.tgz", - "integrity": "sha1-r02RTrBl+bXOTZ0RwcshJu7MMDg=", + "integrity": "sha512-miowhl2+U7Qle4vdLqDdPt9m09K6yZhkLDTWGoUiUzrQCn+mHHSmfJgAyGaLRZbPmTqfFFjRV1QWCW0VWUJBbQ==", "dev": true, "requires": { "boom": "4.3.1", @@ -2756,7 +2756,7 @@ "hoek": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/hoek/-/hoek-4.2.1.tgz", - "integrity": "sha1-ljRQKqEsRF3Vp8VzS1cruHOKrLs=", + "integrity": "sha512-QLg82fGkfnJ/4iy1xZ81/9SIJiq1NGFUMGs6ParyjBZr6jW2Ufj/snDqTHixNlHdPNwN2RLVD0Pi3igeK9+JfA==", "dev": true }, "home-path": { @@ -2791,7 +2791,7 @@ "ignore": { "version": "3.3.7", "resolved": "https://registry.npmjs.org/ignore/-/ignore-3.3.7.tgz", - "integrity": "sha1-YSKJv7PCIOGGpYEYYY1b6MG6sCE=", + "integrity": "sha512-YGG3ejvBNHRqu0559EOxxNFihD0AjpvHlC/pdGKd3X3ofe+CoJkYazwNJYTNebqpPKN+VVQbh4ZFn1DivMNuHA==", "dev": true }, "imurmurhash": { @@ -2828,7 +2828,7 @@ "ini": { "version": "1.3.5", "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", - "integrity": "sha1-7uJfVtscnsYIXgwid4CD9Zar+Sc=", + "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==", "dev": true }, "inquirer": { @@ -2901,7 +2901,7 @@ "is-buffer": { "version": "1.1.6", "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", - "integrity": "sha1-76ouqdqg16suoTqXsritUf776L4=", + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", "dev": true }, "is-builtin-module": { @@ -3054,7 +3054,7 @@ "is-resolvable": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/is-resolvable/-/is-resolvable-1.1.0.tgz", - "integrity": "sha1-+xj4fOH+uSUWnJpAfBkxijIG7Yg=", + "integrity": "sha512-qgDYXFSR5WvEfuS5dMj6oTMEbrrSaM0CrFk2Yiq/gXnBvD9pMa2jGXxyhGLfvhZpuMZe18CJpFxAt3CRs42NMg==", "dev": true }, "is-retry-allowed": { @@ -3204,7 +3204,7 @@ "js-yaml": { "version": "3.11.0", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.11.0.tgz", - "integrity": "sha1-WXwai9VxUvJtYizkEXhRpR9euu8=", + "integrity": "sha512-saJstZWv7oNeOyBh3+Dx1qWzhW0+e6/8eDzo7p5rDFqxntSztloLtuKu+Ejhtq82jsilwOIZYsCz+lIjthg1Hw==", "dev": true, "requires": { "argparse": "1.0.10", @@ -3324,7 +3324,7 @@ "just-extend": { "version": "1.1.27", "resolved": "https://registry.npmjs.org/just-extend/-/just-extend-1.1.27.tgz", - "integrity": "sha1-7G55QQ/5FORyZSq/oOYDwD1g6QU=", + "integrity": "sha512-mJVp13Ix6gFo3SBAy9U/kL+oeZqzlYYYLQBwXVBlVzIsZwBqGREnOro24oC/8s8aox+rJhtZ2DiQof++IrkA+g==", "dev": true }, "kind-of": { @@ -3703,7 +3703,7 @@ "lodash": { "version": "4.17.5", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.5.tgz", - "integrity": "sha1-maktZcAnLevoyWtgV7yPv6O+1RE=", + "integrity": "sha512-svL3uiZf1RwhH+cWrfZn3A4+U58wbP0tGVTLQPbjplZxZ8ROD9VLuNgsRniTlLe7OlSqR79RUehXgpBW/s0IQw==", "dev": true }, "lodash._reinterpolate": { @@ -3740,7 +3740,7 @@ "lolex": { "version": "2.3.2", "resolved": "https://registry.npmjs.org/lolex/-/lolex-2.3.2.tgz", - "integrity": "sha1-hflFBCUQO/nnpgZo6iXcQydMqAc=", + "integrity": "sha512-A5pN2tkFj7H0dGIAM6MFvHKMJcPnjZsOMvR7ujCjfgW5TbV6H9vb1PgxLtHvjqNZTHsUolz+6/WEO0N1xNx2ng==", "dev": true }, "longest": { @@ -3816,7 +3816,7 @@ "marked": { "version": "0.3.17", "resolved": "https://registry.npmjs.org/marked/-/marked-0.3.17.tgz", - "integrity": "sha1-YH8GZos8axJGso8T2nYRasGqLSs=", + "integrity": "sha512-+AKbNsjZl6jFfLPwHhWmGTqE009wTKn3RTmn9K8oUKHrX/abPJjtcRtXpYB/FFrwPJRUA86LX/de3T0knkPCmQ==", "dev": true }, "mem": { @@ -3896,13 +3896,13 @@ "mime-db": { "version": "1.33.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.33.0.tgz", - "integrity": "sha1-o0kgUKXLm2NFBUHjnZeI0icng9s=", + "integrity": "sha512-BHJ/EKruNIqJf/QahvxwQZXKygOQ256myeN/Ew+THcAa5q+PjyTTMMeNQC4DZw5AwfvelsUrA6B67NKMqXDbzQ==", "dev": true }, "mime-types": { "version": "2.1.18", "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.18.tgz", - "integrity": "sha1-bzI/YKg9ERRvgx/xH9ZuL+VQO7g=", + "integrity": "sha512-lc/aahn+t4/SWV/qcmumYjymLsWfN3ELhpmVuUFjgsORruuZPVSwAQryq+HHGvO/SI2KVX26bx+En+zhM8g8hQ==", "dev": true, "requires": { "mime-db": "1.33.0" @@ -3917,7 +3917,7 @@ "minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha1-UWbihkV/AzBgZL5Ul+jbsMPTIIM=", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "dev": true, "requires": { "brace-expansion": "1.1.11" @@ -4071,7 +4071,7 @@ "normalize-package-data": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.4.0.tgz", - "integrity": "sha1-EvlaMH1YNSB1oEkHuErIvpisAS8=", + "integrity": "sha512-9jjUFbTPfEy3R/ad/2oNbKtW9Hgovl5O1FvFWKkKblNXoN/Oou6+9+KKohPK13Yc3/TyunyWhJp6gvRNR/PPAw==", "dev": true, "requires": { "hosted-git-info": "2.5.0", @@ -4511,7 +4511,7 @@ "process-nextick-args": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", - "integrity": "sha1-o31zL0JxtKsa0HDTVQjoKQeI/6o=", + "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==", "dev": true }, "progress": { @@ -4584,7 +4584,7 @@ "qs": { "version": "6.5.1", "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.1.tgz", - "integrity": "sha1-NJzfbu+J7EXBLX1es/wMhwNDptg=", + "integrity": "sha512-eRzhrN1WSINYCDCbrz796z37LOe3m5tmW7RQf6oBntukAG1nmovJvhnwHHRMAfeoItc1m2Hk02WER2aQ/iqs+A==", "dev": true }, "quick-lru": { @@ -4596,7 +4596,7 @@ "randomatic": { "version": "1.1.7", "resolved": "https://registry.npmjs.org/randomatic/-/randomatic-1.1.7.tgz", - "integrity": "sha1-x6vpzIuHwLqodrGf3oP9RkeX44w=", + "integrity": "sha512-D5JUjPyJbaJDkuAazpVnSfVkLlpeO3wDlPROTMLGKG1zMFNFRgrciKo1ltz/AzNTkqE0HzDx655QOL51N06how==", "dev": true, "requires": { "is-number": "3.0.0", @@ -4701,7 +4701,7 @@ "regex-cache": { "version": "0.4.4", "resolved": "https://registry.npmjs.org/regex-cache/-/regex-cache-0.4.4.tgz", - "integrity": "sha1-db3FiioUls7EihKDW8VMjVYjNt0=", + "integrity": "sha512-nVIZwtCjkC9YgvWkpM55B5rBhBYRZhAaJbgcFYXXsHnbZ9UZI9nnVWYZpBlCqv9ho2eZryPnWrZGsOdPwVWXWQ==", "dev": true, "requires": { "is-equal-shallow": "0.1.3" @@ -4729,7 +4729,7 @@ "remap-istanbul": { "version": "0.10.1", "resolved": "https://registry.npmjs.org/remap-istanbul/-/remap-istanbul-0.10.1.tgz", - "integrity": "sha1-OqWN1QIdSZ8zbTulvzu7kcG4jjc=", + "integrity": "sha512-gsNQXs5kJLhErICSyYhzVZ++C8LBW8dgwr874Y2QvzAUS75zBlD/juZgXs39nbYJ09fZDlX2AVLVJAY2jbFJoQ==", "dev": true, "requires": { "amdefine": "1.0.1", @@ -4769,7 +4769,7 @@ "source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha1-dHIq8y6WFOnCh6jQu95IteLxomM=", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", "dev": true }, "through2": { @@ -4883,7 +4883,7 @@ "resolve": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.5.0.tgz", - "integrity": "sha1-HwmsznlsmnYlefMbLBzEw83fnzY=", + "integrity": "sha512-hgoSGrc3pjzAPHNBg+KnFcK2HwlHTs/YrAGUr6qgTVUZmXv1UEXXl0bZNBKMA9fud6lRYFdPGz0xXxycPzmmiw==", "dev": true, "requires": { "path-parse": "1.0.5" @@ -4924,7 +4924,7 @@ "rimraf": { "version": "2.6.2", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", - "integrity": "sha1-LtgVDSShbqhlHm1u8PR8QVjOejY=", + "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", "dev": true, "requires": { "glob": "7.1.2" @@ -5063,19 +5063,19 @@ "safe-buffer": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", - "integrity": "sha1-iTMSr2myEj3vcfV4iQAWce6yyFM=", + "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", "dev": true }, "samsam": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/samsam/-/samsam-1.3.0.tgz", - "integrity": "sha1-jR2TUOJWItow3j5EumkrUiGrfFA=", + "integrity": "sha512-1HwIYD/8UlOtFS3QO3w7ey+SdSDFE4HRNLZoZRYVQefrOY3l17epswImeB1ijgJFQJodIaHcwkp3r/myBjFVbg==", "dev": true }, "semver": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz", - "integrity": "sha1-3Eu8emyp2Rbe5dQ1FvAJK1j3uKs=", + "integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==", "dev": true }, "set-blocking": { @@ -5117,7 +5117,7 @@ "sinon-chai": { "version": "2.14.0", "resolved": "https://registry.npmjs.org/sinon-chai/-/sinon-chai-2.14.0.tgz", - "integrity": "sha1-2n3UzIPNaiYLZ8yg96n9riahIF0=", + "integrity": "sha512-9stIF1utB0ywNHNT7RgiXbdmen8QDCRsrTjw+G9TgKt1Yexjiv8TOWZ6WHsTPz57Yky3DIswZvEqX8fpuHNDtQ==", "dev": true }, "slash": { @@ -5146,7 +5146,7 @@ "sntp": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/sntp/-/sntp-2.1.0.tgz", - "integrity": "sha1-LGzsFP7cIiJznK+bXD2F0cxaLMg=", + "integrity": "sha512-FL1b58BDrqS3A11lJ0zEdnJ3UOKqVxawAkF3k7F0CVN7VQ34aZrV+G8BZ1WC9ZL7NyrwsW0oviwsWDgRuVYtJg==", "dev": true, "requires": { "hoek": "4.2.1" @@ -5203,7 +5203,7 @@ "spdx-correct": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.0.0.tgz", - "integrity": "sha1-BaW01xU6GVvJLDxCW2nzsqlSTII=", + "integrity": "sha512-N19o9z5cEyc8yQQPukRCZ9EUmb4HUpnrmaL/fxS2pBo2jbfcFRVuFZ/oFC+vZz0MNNk0h80iMn5/S6qGZOL5+g==", "dev": true, "requires": { "spdx-expression-parse": "3.0.0", @@ -5213,13 +5213,13 @@ "spdx-exceptions": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.1.0.tgz", - "integrity": "sha1-LHrmEFbHFKW5ubKyr30xHvXHj+k=", + "integrity": "sha512-4K1NsmrlCU1JJgUrtgEeTVyfx8VaYea9J9LvARxhbHtVtohPs/gFGG5yy49beySjlIMhhXZ4QqujIZEfS4l6Cg==", "dev": true }, "spdx-expression-parse": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.0.tgz", - "integrity": "sha1-meEZt6XaAOBUkcn6M4t5BII7QdA=", + "integrity": "sha512-Yg6D3XpRD4kkOmTpdgbUiEJFKghJH03fiC1OPll5h/0sO6neh2jqRDVHOQ4o/LMea0tgCkbMgea5ip/e+MkWyg==", "dev": true, "requires": { "spdx-exceptions": "2.1.0", @@ -5229,7 +5229,7 @@ "spdx-license-ids": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.0.tgz", - "integrity": "sha1-enzShHDMbToc/m1miG9rxDDTrIc=", + "integrity": "sha512-2+EPwgbnmOIl8HjGBXXMd9NAu02vLjOO1nWw4kmeRDFyHn+M/ETfHxQUK0oXg8ctgVnl9t3rosNVsZ1jG61nDA==", "dev": true }, "speedometer": { @@ -5566,7 +5566,7 @@ "tough-cookie": { "version": "2.3.4", "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.4.tgz", - "integrity": "sha1-7GDO44rGdQY//JelwYlwV47oNlU=", + "integrity": "sha512-TZ6TTfI5NtZnuyy/Kecv+CnoROnyXn2DN97LontgQpCwsX2XyLYCC0ENhYkehSOwAp8rTQKc/NUIF7BkQ5rKLA==", "dev": true, "requires": { "punycode": "1.4.1" @@ -5708,13 +5708,13 @@ "uuid": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.2.1.tgz", - "integrity": "sha1-EsUou51Y0LkmXZovbw/ovhf/HxQ=", + "integrity": "sha512-jZnMwlb9Iku/O3smGWvZhauCf6cvvpKi4BKRiliS3cxnI+Gz9j5MEpTz2UFuXiKPJocb7gnsLHwiS05ige5BEA==", "dev": true }, "validate-npm-package-license": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.3.tgz", - "integrity": "sha1-gWQ7y+8b3+zUYjeT3EZIlIupgzg=", + "integrity": "sha512-63ZOUnL4SIXj4L0NixR3L1lcjO38crAbgrTpl28t8jjrfuiOBL5Iygm+60qPs/KsZGzPNg6Smnc/oY16QTjF0g==", "dev": true, "requires": { "spdx-correct": "3.0.0", @@ -5750,7 +5750,7 @@ "which": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/which/-/which-1.3.0.tgz", - "integrity": "sha1-/wS9/AEO5UfXgL7DjhrBwnd9JTo=", + "integrity": "sha512-xcJpopdamTuY5duC/KnTTNBraPK54YwpenP4lzxU8H91GudWpFv38u0CKjclE1Wi2EH2EDz5LRcHcKbCIzqGyg==", "dev": true, "requires": { "isexe": "2.0.0" diff --git a/packages/canvas/canvas-mesh/package.json b/packages/canvas/canvas-mesh/package.json index 691cd2c..6744a17 100644 --- a/packages/canvas/canvas-mesh/package.json +++ b/packages/canvas/canvas-mesh/package.json @@ -24,6 +24,7 @@ "dependencies": { "@pixi/constants": "^5.0.0-alpha.2", "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/mesh-extras": "^5.0.0-alpha.2", "@pixi/settings": "^5.0.0-alpha.2" }, "devDependencies": { diff --git a/packages/canvas/canvas-mesh/src/Mesh.js b/packages/canvas/canvas-mesh/src/Mesh.js index 900a872..c43a74b 100644 --- a/packages/canvas/canvas-mesh/src/Mesh.js +++ b/packages/canvas/canvas-mesh/src/Mesh.js @@ -1,36 +1,14 @@ import { Mesh } from '@pixi/mesh'; -import { settings } from './settings'; - -// IMPORTANT: Please do NOT use this as a precedent to use `settings` after the object is created -// this was merely created to completely decouple canvas from the base Mesh class and we are -// unable to add `canvasPadding` in the constructor anymore, as the case was for PixiJS v4. /** - * Internal variable for `canvasPadding`. + * Renders the object using the Canvas renderer * * @private - * @memberof PIXI.Mesh - * @member {number} - * @default null - */ -Mesh.prototype._canvasPadding = null; - -/** - * Triangles in canvas mode are automatically antialiased, use this value to force triangles - * to overlap a bit with each other. To set the global default, set {@link PIXI.settings.MESH_CANVAS_PADDING} - * - * @see PIXI.settings.MESH_CANVAS_PADDING - * @member {number} canvasPadding + * @method _renderCanvas * @memberof PIXI.Mesh# - * @default 0 + * @param {PIXI.CanvasRenderer} renderer - The canvas renderer. */ -Object.defineProperty(Mesh.prototype, 'canvasPadding', { - get() - { - return this._canvasPadding !== null ? this._canvasPadding : settings.MESH_CANVAS_PADDING; - }, - set(value) - { - this._canvasPadding = value; - }, -}); +Mesh.prototype._renderCanvas = function _renderCanvas(renderer) +{ + renderer.plugins[this.pluginName].render(this); +}; diff --git a/packages/canvas/canvas-mesh/src/Mesh2d.js b/packages/canvas/canvas-mesh/src/Mesh2d.js new file mode 100644 index 0000000..d0bd80f --- /dev/null +++ b/packages/canvas/canvas-mesh/src/Mesh2d.js @@ -0,0 +1,36 @@ +import { Mesh2d } from '@pixi/mesh-extras'; +import { settings } from './settings'; + +// IMPORTANT: Please do NOT use this as a precedent to use `settings` after the object is created +// this was merely created to completely decouple canvas from the base Mesh class and we are +// unable to add `canvasPadding` in the constructor anymore, as the case was for PixiJS v4. + +/** + * Internal variable for `canvasPadding`. + * + * @private + * @memberof PIXI.Mesh2d + * @member {number} + * @default null + */ +Mesh2d.prototype._canvasPadding = null; + +/** + * Triangles in canvas mode are automatically antialiased, use this value to force triangles + * to overlap a bit with each other. To set the global default, set {@link PIXI.settings.MESH_CANVAS_PADDING} + * + * @see PIXI.settings.MESH_CANVAS_PADDING + * @member {number} canvasPadding + * @memberof PIXI.Mesh2d# + * @default 0 + */ +Object.defineProperty(Mesh2d.prototype, 'canvasPadding', { + get() + { + return this._canvasPadding !== null ? this._canvasPadding : settings.MESH_CANVAS_PADDING; + }, + set(value) + { + this._canvasPadding = value; + }, +}); diff --git a/packages/canvas/canvas-mesh/src/NineSlicePlane.js b/packages/canvas/canvas-mesh/src/NineSlicePlane.js index 09eaf9c..2fd5acc 100644 --- a/packages/canvas/canvas-mesh/src/NineSlicePlane.js +++ b/packages/canvas/canvas-mesh/src/NineSlicePlane.js @@ -1,4 +1,4 @@ -import { NineSlicePlane } from '@pixi/mesh'; +import { NineSlicePlane } from '@pixi/mesh-extras'; /** * Renders the object using the Canvas renderer diff --git a/packages/canvas/canvas-mesh/src/RawMesh.js b/packages/canvas/canvas-mesh/src/RawMesh.js deleted file mode 100644 index bf40184..0000000 --- a/packages/canvas/canvas-mesh/src/RawMesh.js +++ /dev/null @@ -1,14 +0,0 @@ -import { RawMesh } from '@pixi/mesh'; - -/** - * Renders the object using the Canvas renderer - * - * @private - * @method _renderCanvas - * @memberof PIXI.RawMesh# - * @param {PIXI.CanvasRenderer} renderer - The canvas renderer. - */ -RawMesh.prototype._renderCanvas = function _renderCanvas(renderer) -{ - renderer.plugins[this.pluginName].render(this); -}; diff --git a/packages/canvas/canvas-mesh/src/index.js b/packages/canvas/canvas-mesh/src/index.js index 2295016..f4fa31d 100644 --- a/packages/canvas/canvas-mesh/src/index.js +++ b/packages/canvas/canvas-mesh/src/index.js @@ -1,6 +1,6 @@ export { default as CanvasMeshRenderer } from './CanvasMeshRenderer'; import './settings'; -import './Mesh'; +import './Mesh2d'; import './NineSlicePlane'; -import './RawMesh'; +import './Mesh'; diff --git a/packages/canvas/canvas-mesh/src/settings.js b/packages/canvas/canvas-mesh/src/settings.js index 4cefb4c..e81b8e0 100644 --- a/packages/canvas/canvas-mesh/src/settings.js +++ b/packages/canvas/canvas-mesh/src/settings.js @@ -3,7 +3,7 @@ /** * Default `canvasPadding` for canvas-based Mesh rendering. * - * @see PIXI.Mesh#canvasPadding + * @see PIXI.Mesh2d#canvasPadding * @static * @constant * @memberof PIXI.settings diff --git a/packages/mesh-extras/LICENSE b/packages/mesh-extras/LICENSE new file mode 100644 index 0000000..148e3eb --- /dev/null +++ b/packages/mesh-extras/LICENSE @@ -0,0 +1,21 @@ +The MIT License + +Copyright (c) 2013-2018 Mathew Groves, Chad Engler + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/packages/mesh-extras/README.md b/packages/mesh-extras/README.md new file mode 100644 index 0000000..1d9b0e1 --- /dev/null +++ b/packages/mesh-extras/README.md @@ -0,0 +1,19 @@ +# @pixi/mesh-extras + +## Installation + +```bash +npm install @pixi/mesh-extras +``` + +## Usage + +```js +import { MeshRenderer } from '@pixi/mesh'; +import { Renderer } from '@pixi/core'; +import { Rope } from '@pixi/mesh-extras'; + +Renderer.registerPlugin('mesh', MeshRenderer); + +const rope = new Rope(); +``` \ No newline at end of file diff --git a/packages/mesh-extras/package.json b/packages/mesh-extras/package.json new file mode 100644 index 0000000..d134f64 --- /dev/null +++ b/packages/mesh-extras/package.json @@ -0,0 +1,38 @@ +{ + "name": "@pixi/mesh-extras", + "version": "5.0.0-alpha.2", + "main": "lib/mesh-extras.js", + "module": "lib/mesh-extras.es.js", + "description": "Custom Mesh display objects, like Rope and Plane", + "author": "Mat Groves", + "contributors": [ + "Matt Karl " + ], + "homepage": "http://pixijs.com/", + "bugs": "https://github.com/pixijs/pixi.js/issues", + "license": "MIT", + "repository": { + "type": "git", + "url": "https://github.com/pixijs/pixi.js.git" + }, + "publishConfig": { + "access": "public" + }, + "scripts": { + "test": "floss --path test" + }, + "files": [ + "lib" + ], + "dependencies": { + "@pixi/constants": "^5.0.0-alpha.2", + "@pixi/core": "^5.0.0-alpha.2", + "@pixi/math": "^5.0.0-alpha.2", + "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/utils": "^5.0.0-alpha.2" + }, + "devDependencies": { + "@pixi/loaders": "^5.0.0-alpha.2", + "floss": "^2.1.3" + } +} diff --git a/packages/mesh-extras/src/Mesh2d.js b/packages/mesh-extras/src/Mesh2d.js new file mode 100644 index 0000000..d113a5e --- /dev/null +++ b/packages/mesh-extras/src/Mesh2d.js @@ -0,0 +1,263 @@ +import { Mesh } from '@pixi/mesh'; +import { Geometry, Program, Shader, Texture, TextureMatrix } from '@pixi/core'; +import { Matrix } from '@pixi/math'; +import { BLEND_MODES } from '@pixi/constants'; +import { hex2rgb, premultiplyRgba } from '@pixi/utils'; +import vertex from './mesh.vert'; +import fragment from './mesh.frag'; + +let meshProgram; + +/** + * Base mesh class + * @class + * @extends PIXI.Container + * @memberof PIXI + */ +export default class Mesh2d extends Mesh +{ + /** + * @param {PIXI.Texture} [texture=Texture.EMPTY] - The texture to use + * @param {Float32Array} [vertices] - if you want to specify the vertices + * @param {Float32Array} [uvs] - if you want to specify the uvs + * @param {Uint16Array} [indices] - if you want to specify the indices + * @param {number} [drawMode] - the drawMode, can be any of the Mesh.DRAW_MODES consts + */ + constructor(texture = Texture.EMPTY, vertices, uvs, indices, drawMode) + { + const geometry = new Geometry(); + + if (!meshProgram) + { + meshProgram = new Program(vertex, fragment); + } + + geometry.addAttribute('aVertexPosition', vertices) + .addAttribute('aTextureCoord', uvs) + .addIndex(indices); + + geometry.getAttribute('aVertexPosition').static = false; + + const uniforms = { + uSampler: texture, + uTextureMatrix: Matrix.IDENTITY, + alpha: 1, + uColor: new Float32Array([1, 1, 1, 1]), + }; + + super(geometry, new Shader(meshProgram, uniforms), null, drawMode); + + /** + * The Uvs of the Mesh + * + * @member {Float32Array} + */ + this.uvs = geometry.getAttribute('aTextureCoord').data; + + /** + * An array of vertices + * + * @member {Float32Array} + */ + this.vertices = geometry.getAttribute('aVertexPosition').data; + + this.uniforms = uniforms; + + /** + * The texture of the Mesh + * + * @member {PIXI.Texture} + * @default PIXI.Texture.EMPTY + * @private + */ + this.texture = texture; + + /** + * The tint applied to the mesh. This is a [r,g,b] value. A value of [1,1,1] will remove any + * tint effect. + * + * @member {number} + * @private + */ + this._tintRGB = new Float32Array([1, 1, 1]); + + // Set default tint + this.tint = 0xFFFFFF; + + this.blendMode = BLEND_MODES.NORMAL; + + /** + * TextureMatrix instance for this Mesh, used to track Texture changes + * + * @member {PIXI.TextureMatrix} + * @readonly + */ + this.uvMatrix = new TextureMatrix(this._texture); + + /** + * whether or not upload uvMatrix to shader + * if its false, then uvs should be pre-multiplied + * if you change it for generated mesh, please call 'refresh(true)' + * @member {boolean} + * @default false + */ + this.uploadUvMatrix = false; + + /** + * Uploads vertices buffer every frame, like in PixiJS V3 and V4. + * + * @member {boolean} + * @default true + */ + this.autoUpdate = true; + } + + /** + * The tint applied to the Rope. This is a hex value. A value of + * 0xFFFFFF will remove any tint effect. + * + * @member {number} + * @memberof PIXI.Sprite# + * @default 0xFFFFFF + */ + get tint() + { + return this._tint; + } + + /** + * Sets the tint of the rope. + * + * @param {number} value - The value to set to. + */ + set tint(value) + { + this._tint = value; + + hex2rgb(this._tint, this._tintRGB); + } + + /** + * The blend mode to be applied to the sprite. Set to `PIXI.BLEND_MODES.NORMAL` to remove any blend mode. + * + * @member {number} + * @default PIXI.BLEND_MODES.NORMAL + * @see PIXI.BLEND_MODES + */ + get blendMode() + { + return this.state.blendMode; + } + + set blendMode(value) // eslint-disable-line require-jsdoc + { + this.state.blendMode = value; + } + + /** + * The texture that the mesh uses. + * + * @member {PIXI.Texture} + */ + get texture() + { + return this._texture; + } + + set texture(value) // eslint-disable-line require-jsdoc + { + if (this._texture === value) + { + return; + } + + this._texture = value; + this.uniforms.uSampler = this.texture; + + if (value) + { + // wait for the texture to load + if (value.baseTexture.valid) + { + this._onTextureUpdate(); + } + else + { + value.once('update', this._onTextureUpdate, this); + } + } + } + + _render(renderer) + { + const baseTex = this._texture.baseTexture; + + premultiplyRgba(this._tintRGB, this.worldAlpha, this.uniforms.uColor, baseTex.premultiplyAlpha); + super._render(renderer); + } + /** + * When the texture is updated, this event will fire to update the scale and frame + * + * @private + */ + _onTextureUpdate() + { + // constructor texture update stop + if (!this.uvMatrix) + { + return; + } + this.uvMatrix.texture = this._texture; + this.refresh(); + } + + /** + * multiplies uvs only if uploadUvMatrix is false + * call it after you change uvs manually + * make sure that texture is valid + */ + multiplyUvs() + { + if (!this.uploadUvMatrix) + { + this.uvMatrix.multiplyUvs(this.uvs); + } + } + + /** + * Refreshes uvs for generated meshes (rope, plane) + * sometimes refreshes vertices too + * + * @param {boolean} [forceUpdate=false] if true, matrices will be updated any case + */ + refresh(forceUpdate) + { + if (this.uvMatrix.update(forceUpdate)) + { + this._refresh(); + } + } + + /** + * Updates the object transform for rendering + * + * @private + */ + updateTransform() + { + if (this.autoUpdate) + { + this.geometry.buffers[0].update(); + } + this.containerUpdateTransform(); + } + + /** + * re-calculates mesh coords + * @private + */ + _refresh() + { + /* empty */ + } +} diff --git a/packages/mesh-extras/src/NineSlicePlane.js b/packages/mesh-extras/src/NineSlicePlane.js new file mode 100644 index 0000000..0bae92c --- /dev/null +++ b/packages/mesh-extras/src/NineSlicePlane.js @@ -0,0 +1,270 @@ +import Plane from './Plane'; + +const DEFAULT_BORDER_SIZE = 10; + +/** + * The NineSlicePlane allows you to stretch a texture using 9-slice scaling. The corners will remain unscaled (useful + * for buttons with rounded corners for example) and the other areas will be scaled horizontally and or vertically + * + *```js + * let Plane9 = new PIXI.NineSlicePlane(PIXI.Texture.from('BoxWithRoundedCorners.png'), 15, 15, 15, 15); + * ``` + *
+ *      A                          B
+ *    +---+----------------------+---+
+ *  C | 1 |          2           | 3 |
+ *    +---+----------------------+---+
+ *    |   |                      |   |
+ *    | 4 |          5           | 6 |
+ *    |   |                      |   |
+ *    +---+----------------------+---+
+ *  D | 7 |          8           | 9 |
+ *    +---+----------------------+---+
+
+ *  When changing this objects width and/or height:
+ *     areas 1 3 7 and 9 will remain unscaled.
+ *     areas 2 and 8 will be stretched horizontally
+ *     areas 4 and 6 will be stretched vertically
+ *     area 5 will be stretched both horizontally and vertically
+ * 
+ * + * @class + * @extends PIXI.Plane + * @memberof PIXI + * + */ +export default class NineSlicePlane extends Plane +{ + /** + * @param {PIXI.Texture} texture - The texture to use on the NineSlicePlane. + * @param {int} [leftWidth=10] size of the left vertical bar (A) + * @param {int} [topHeight=10] size of the top horizontal bar (C) + * @param {int} [rightWidth=10] size of the right vertical bar (B) + * @param {int} [bottomHeight=10] size of the bottom horizontal bar (D) + */ + constructor(texture, leftWidth, topHeight, rightWidth, bottomHeight) + { + super(texture, 4, 4); + + this._origWidth = texture.orig.width; + this._origHeight = texture.orig.height; + + /** + * The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._width = this._origWidth; + + /** + * The height of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._height = this._origHeight; + + /** + * The width of the left column (a) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._leftWidth = typeof leftWidth !== 'undefined' ? leftWidth : DEFAULT_BORDER_SIZE; + + /** + * The width of the right column (b) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._rightWidth = typeof rightWidth !== 'undefined' ? rightWidth : DEFAULT_BORDER_SIZE; + + /** + * The height of the top row (c) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._topHeight = typeof topHeight !== 'undefined' ? topHeight : DEFAULT_BORDER_SIZE; + + /** + * The height of the bottom row (d) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._bottomHeight = typeof bottomHeight !== 'undefined' ? bottomHeight : DEFAULT_BORDER_SIZE; + + this.refresh(true); + } + + /** + * Updates the horizontal vertices. + * + */ + updateHorizontalVertices() + { + const vertices = this.vertices; + + const h = this._topHeight + this._bottomHeight; + const scale = this._height > h ? 1.0 : this._height / h; + + vertices[9] = vertices[11] = vertices[13] = vertices[15] = this._topHeight * scale; + vertices[17] = vertices[19] = vertices[21] = vertices[23] = this._height - (this._bottomHeight * scale); + vertices[25] = vertices[27] = vertices[29] = vertices[31] = this._height; + } + + /** + * Updates the vertical vertices. + * + */ + updateVerticalVertices() + { + const vertices = this.vertices; + + const w = this._leftWidth + this._rightWidth; + const scale = this._width > w ? 1.0 : this._width / w; + + vertices[2] = vertices[10] = vertices[18] = vertices[26] = this._leftWidth * scale; + vertices[4] = vertices[12] = vertices[20] = vertices[28] = this._width - (this._rightWidth * scale); + vertices[6] = vertices[14] = vertices[22] = vertices[30] = this._width; + } + + /** + * The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + */ + get width() + { + return this._width; + } + + set width(value) // eslint-disable-line require-jsdoc + { + this._width = value; + this._refresh(); + } + + /** + * The height of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + */ + get height() + { + return this._height; + } + + set height(value) // eslint-disable-line require-jsdoc + { + this._height = value; + this._refresh(); + } + + /** + * The width of the left column + * + * @member {number} + */ + get leftWidth() + { + return this._leftWidth; + } + + set leftWidth(value) // eslint-disable-line require-jsdoc + { + this._leftWidth = value; + this._refresh(); + } + + /** + * The width of the right column + * + * @member {number} + */ + get rightWidth() + { + return this._rightWidth; + } + + set rightWidth(value) // eslint-disable-line require-jsdoc + { + this._rightWidth = value; + this._refresh(); + } + + /** + * The height of the top row + * + * @member {number} + */ + get topHeight() + { + return this._topHeight; + } + + set topHeight(value) // eslint-disable-line require-jsdoc + { + this._topHeight = value; + this._refresh(); + } + + /** + * The height of the bottom row + * + * @member {number} + */ + get bottomHeight() + { + return this._bottomHeight; + } + + set bottomHeight(value) // eslint-disable-line require-jsdoc + { + this._bottomHeight = value; + this._refresh(); + } + + /** + * Refreshes NineSlicePlane coords. All of them. + */ + _refresh() + { + super._refresh(); + + const uvs = this.uvs; + const texture = this._texture; + + this._origWidth = texture.orig.width; + this._origHeight = texture.orig.height; + + const _uvw = 1.0 / this._origWidth; + const _uvh = 1.0 / this._origHeight; + + uvs[0] = uvs[8] = uvs[16] = uvs[24] = 0; + uvs[1] = uvs[3] = uvs[5] = uvs[7] = 0; + uvs[6] = uvs[14] = uvs[22] = uvs[30] = 1; + uvs[25] = uvs[27] = uvs[29] = uvs[31] = 1; + + uvs[2] = uvs[10] = uvs[18] = uvs[26] = _uvw * this._leftWidth; + uvs[4] = uvs[12] = uvs[20] = uvs[28] = 1 - (_uvw * this._rightWidth); + uvs[9] = uvs[11] = uvs[13] = uvs[15] = _uvh * this._topHeight; + uvs[17] = uvs[19] = uvs[21] = uvs[23] = 1 - (_uvh * this._bottomHeight); + + this.updateHorizontalVertices(); + this.updateVerticalVertices(); + + this.geometry.buffers[1].update(); + + this.multiplyUvs(); + } +} diff --git a/packages/mesh-extras/src/Plane.js b/packages/mesh-extras/src/Plane.js new file mode 100644 index 0000000..1c240c4 --- /dev/null +++ b/packages/mesh-extras/src/Plane.js @@ -0,0 +1,100 @@ +import Mesh2d from './Mesh2d'; + +/** + * The Plane allows you to draw a texture across several points and them manipulate these points + * + *```js + * for (let i = 0; i < 20; i++) { + * points.push(new PIXI.Point(i * 50, 0)); + * }; + * let Plane = new PIXI.Plane(PIXI.Texture.from("snake.png"), points); + * ``` + * + * @class + * @extends PIXI.Mesh + * @memberof PIXI + * + */ +export default class Plane extends Mesh2d +{ + /** + * @param {PIXI.Texture} texture - The texture to use on the Plane. + * @param {number} verticesX - The number of vertices in the x-axis + * @param {number} verticesY - The number of vertices in the y-axis + * @param {object} [opts] - an options object - add meshWidth and meshHeight, temporary object for PixiJS v5 alpha + */ + constructor(texture, verticesX, verticesY, opts = {}) + { + super(texture, new Float32Array(1), new Float32Array(1), new Uint16Array(1), 4); + + this.verticesX = verticesX || 10; + this.verticesY = verticesY || 10; + + this.meshWidth = opts.meshWidth || 0; + this.meshHeight = opts.meshHeight || 0; + + this.refresh(); + } + + /** + * Refreshes plane coordinates + * @private + */ + _refresh() + { + const texture = this._texture; + const total = this.verticesX * this.verticesY; + const verts = []; + const uvs = []; + const indices = []; + + const segmentsX = this.verticesX - 1; + const segmentsY = this.verticesY - 1; + + const sizeX = (this.meshWidth || texture.width) / segmentsX; + const sizeY = (this.meshHeight || texture.height) / segmentsY; + + for (let i = 0; i < total; i++) + { + const x = (i % this.verticesX); + const y = ((i / this.verticesX) | 0); + + verts.push(x * sizeX, y * sizeY); + + uvs.push(x / segmentsX, y / segmentsY); + } + + // cons + + const totalSub = segmentsX * segmentsY; + + for (let i = 0; i < totalSub; i++) + { + const xpos = i % segmentsX; + const ypos = (i / segmentsX) | 0; + + const value = (ypos * this.verticesX) + xpos; + const value2 = (ypos * this.verticesX) + xpos + 1; + const value3 = ((ypos + 1) * this.verticesX) + xpos; + const value4 = ((ypos + 1) * this.verticesX) + xpos + 1; + + indices.push(value, value2, value3); + indices.push(value2, value4, value3); + } + + this.vertices = new Float32Array(verts); + this.uvs = new Float32Array(uvs); + this.indices = new Uint16Array(indices); + + this.geometry.buffers[0].data = this.vertices; + this.geometry.buffers[1].data = this.uvs; + this.geometry.indexBuffer.data = this.indices; + + // ensure that the changes are uploaded + this.geometry.buffers[0].update(); + this.geometry.buffers[1].update(); + this.geometry.indexBuffer.update(); + + this.multiplyUvs(); + } +} diff --git a/bundles/pixi.js/package.json b/bundles/pixi.js/package.json index 49c7276..177e059 100644 --- a/bundles/pixi.js/package.json +++ b/bundles/pixi.js/package.json @@ -49,6 +49,7 @@ "@pixi/loaders": "^5.0.0-alpha.2", "@pixi/math": "^5.0.0-alpha.2", "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/mesh-extras": "^5.0.0-alpha.2", "@pixi/mixin-cache-as-bitmap": "^5.0.0-alpha.2", "@pixi/mixin-get-child-by-name": "^5.0.0-alpha.2", "@pixi/mixin-get-global-position": "^5.0.0-alpha.2", diff --git a/bundles/pixi.js/src/deprecated.js b/bundles/pixi.js/src/deprecated.js index 147617c..dbebeb0 100644 --- a/bundles/pixi.js/src/deprecated.js +++ b/bundles/pixi.js/src/deprecated.js @@ -263,15 +263,15 @@ Object.defineProperties(PIXI.mesh, { /** * @class PIXI.mesh.Mesh - * @see PIXI.Mesh + * @see PIXI.Mesh2d * @deprecated since 5.0.0 */ Mesh: { get() { - warn('PIXI.mesh.Mesh has moved to PIXI.Mesh'); + warn('PIXI.mesh.Mesh has moved to PIXI.Mesh2d'); - return PIXI.Mesh; + return PIXI.Mesh2d; }, }, /** @@ -315,15 +315,15 @@ }, /** * @class PIXI.mesh.RawMesh - * @see PIXI.RawMesh + * @see PIXI.Mesh * @deprecated since 5.0.0 */ RawMesh: { get() { - warn('PIXI.mesh.RawMesh has moved to PIXI.RawMesh'); + warn('PIXI.mesh.RawMesh has moved to PIXI.Mesh'); - return PIXI.RawMesh; + return PIXI.Mesh; }, }, /** diff --git a/bundles/pixi.js/src/index.js b/bundles/pixi.js/src/index.js index a3a0d1b..6fdabf0 100644 --- a/bundles/pixi.js/src/index.js +++ b/bundles/pixi.js/src/index.js @@ -9,6 +9,7 @@ import * as loaders from '@pixi/loaders'; import * as math from '@pixi/math'; import * as mesh from '@pixi/mesh'; +import * as meshExtras from '@pixi/mesh-extras'; import * as particles from '@pixi/particles'; import * as prepare from '@pixi/prepare'; import * as sprite from '@pixi/sprite'; @@ -128,6 +129,7 @@ loaders, math, mesh, + meshExtras, particles, sprite, spriteAnimated, @@ -152,6 +154,7 @@ export * from '@pixi/loaders'; export * from '@pixi/math'; export * from '@pixi/mesh'; +export * from '@pixi/mesh-extras'; export * from '@pixi/particles'; export * from '@pixi/sprite'; export * from '@pixi/spritesheet'; diff --git a/package-lock.json b/package-lock.json index 7fe6db7..0814729 100644 --- a/package-lock.json +++ b/package-lock.json @@ -209,7 +209,7 @@ "argparse": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", - "integrity": "sha1-vNZ5HqWuCXJeF+WtmIE0zUCz2RE=", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", "dev": true, "requires": { "sprintf-js": "1.0.3" @@ -228,7 +228,7 @@ "arr-flatten": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz", - "integrity": "sha1-NgSLv/TntH4TZkQxbJlmnqWukfE=", + "integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==", "dev": true }, "arr-union": { @@ -297,7 +297,7 @@ "assertion-error": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", - "integrity": "sha1-5gtrDo8wG9l+U3UhW9pAbIURjAs=", + "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", "dev": true }, "async": { @@ -396,7 +396,7 @@ "brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha1-PH/L9SnYcibz0vUrlm/1Jx60Qd0=", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, "requires": { "balanced-match": "1.0.0", @@ -568,7 +568,7 @@ "circular-json": { "version": "0.3.3", "resolved": "https://registry.npmjs.org/circular-json/-/circular-json-0.3.3.tgz", - "integrity": "sha1-gVyZ6oT2gJUp0vRXkb34JxE1LWY=", + "integrity": "sha512-UZK3NBx2Mca+b5LsG7bY183pHWt5Y1xts4P3Pz7ENTwGVnJOUWbRb3ocjvX7hx9tq/yTAdclXm9sZ38gNuem4A==", "dev": true }, "cli-cursor": { @@ -638,7 +638,7 @@ "color-convert": { "version": "1.9.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.1.tgz", - "integrity": "sha1-wSYRB66y8pTr/+ye2eytUppgl+0=", + "integrity": "sha512-mjGanIiwQJskCC18rPR6OmrZ6fm2Lc7PeGFYwCmy5J34wC6F1PzdGL6xeMfmgicfYcNLGuVFA3WzXtIDCQSZxQ==", "dev": true, "requires": { "color-name": "1.1.3" @@ -1427,7 +1427,7 @@ "boom": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/boom/-/boom-5.2.0.tgz", - "integrity": "sha1-XdnabuOl8wIHdDYpDLcX0/SlTgI=", + "integrity": "sha512-Z5BTk6ZRe4tXXQlkqftmsAUANpXmuwlsF5Oov8ThoMbQRzdGTA1ngYRW160GexgOgjsFOKJz0LYhoNi+2AMBUw==", "dev": true, "requires": { "hoek": "4.2.1" @@ -1471,7 +1471,7 @@ "debug": { "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha1-XRKFFd8TT/Mn6QpMk/Tgd6U2NB8=", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", "dev": true, "requires": { "ms": "2.0.0" @@ -1585,7 +1585,7 @@ "doctrine": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", - "integrity": "sha1-XNAfwQFiG0LEzX9dGmYkNxbT850=", + "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", "dev": true, "requires": { "esutils": "2.0.2" @@ -1662,7 +1662,7 @@ "es6-promise": { "version": "4.2.4", "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.4.tgz", - "integrity": "sha1-3EIhwrFlGHYL2MOaUtjzVvwA7Sk=", + "integrity": "sha512-/NdNZVJg+uZgtm9eS3O6lrOLYmQag2DjdEXuPaHlZ6RuVqgqaVZfgYCepEIKsLqwdQArOPtC3XzRLqGGfT8KQQ==", "dev": true }, "escape-string-regexp": { @@ -1788,7 +1788,7 @@ "espree": { "version": "3.5.4", "resolved": "https://registry.npmjs.org/espree/-/espree-3.5.4.tgz", - "integrity": "sha1-sPRHGHyKi+2US4FaZgvd9d610ac=", + "integrity": "sha512-yAcIQxtmMiB/jL32dzEp2enBeidsB7xWPLNiw3IIkpVds1P+h7qF9YwJq1yUNzp2OKXgAprs4F61ih66UsoD1A==", "dev": true, "requires": { "acorn": "5.5.0", @@ -1798,7 +1798,7 @@ "esprima": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.0.tgz", - "integrity": "sha1-RJnt3NERDgshi6zy+n9/WfVcqAQ=", + "integrity": "sha512-oftTcaMu/EGrEIu904mWteKIv8vMuOgGYo7EhVJJN00R/EED9DCua/xxHRdYnKtcECzVg7xOWhflvJMnqcFZjw==", "dev": true }, "esquery": { @@ -1813,7 +1813,7 @@ "esrecurse": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.2.1.tgz", - "integrity": "sha1-AHo7n9vCs7uH5IeeoZyS/b05Qs8=", + "integrity": "sha512-64RBB++fIOAXPw3P9cy89qfMlvZEXZkqqJkjqqXIvzP5ezRZjW+lPWjw35UX/3EhUPFYbg5ER4JYgDw4007/DQ==", "dev": true, "requires": { "estraverse": "4.2.0" @@ -2024,7 +2024,7 @@ "find-root": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/find-root/-/find-root-1.1.0.tgz", - "integrity": "sha1-q8/Iunb3CMQql7PWhbfpRQv7nOQ=", + "integrity": "sha512-NKfW6bec6GfKc0SGx1e07QZY9PE99u0Bft/0rzSD5k3sO/vwkVUpDUKVm5Gpp5Ue3YfShPFTX2070tDs5kB9Ng==", "dev": true }, "find-up": { @@ -2103,7 +2103,7 @@ "supports-color": { "version": "5.3.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.3.0.tgz", - "integrity": "sha1-WySsFduA+pJ89SJ6SjP9PEx2dsA=", + "integrity": "sha512-0aP01LLIskjKs3lq52EC0aGBAJhLq7B2Rd8HC/DR/PtNNpcLilNmHC12O+hu0usQpo7wtHNRqtrhBwtDb0+dNg==", "dev": true, "requires": { "has-flag": "3.0.0" @@ -2567,7 +2567,7 @@ "glob": { "version": "7.1.2", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", - "integrity": "sha1-wZyd+aAocC1nhhI4SmVSQExjbRU=", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", "dev": true, "requires": { "fs.realpath": "1.0.0", @@ -2672,7 +2672,7 @@ "growl": { "version": "1.10.3", "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.3.tgz", - "integrity": "sha1-GSa6kM8+3+KttJJ/WIC8IsZseQ8=", + "integrity": "sha512-hKlsbA5Vu3xsh1Cg3J7jSmX/WaW6A5oBeqzM88oNbCRQFz+zUaXm6yxS4RVytp1scBoJzSYl4YAEOQIt6O8V1Q==", "dev": true }, "handlebars": { @@ -2738,7 +2738,7 @@ "hawk": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/hawk/-/hawk-6.0.2.tgz", - "integrity": "sha1-r02RTrBl+bXOTZ0RwcshJu7MMDg=", + "integrity": "sha512-miowhl2+U7Qle4vdLqDdPt9m09K6yZhkLDTWGoUiUzrQCn+mHHSmfJgAyGaLRZbPmTqfFFjRV1QWCW0VWUJBbQ==", "dev": true, "requires": { "boom": "4.3.1", @@ -2756,7 +2756,7 @@ "hoek": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/hoek/-/hoek-4.2.1.tgz", - "integrity": "sha1-ljRQKqEsRF3Vp8VzS1cruHOKrLs=", + "integrity": "sha512-QLg82fGkfnJ/4iy1xZ81/9SIJiq1NGFUMGs6ParyjBZr6jW2Ufj/snDqTHixNlHdPNwN2RLVD0Pi3igeK9+JfA==", "dev": true }, "home-path": { @@ -2791,7 +2791,7 @@ "ignore": { "version": "3.3.7", "resolved": "https://registry.npmjs.org/ignore/-/ignore-3.3.7.tgz", - "integrity": "sha1-YSKJv7PCIOGGpYEYYY1b6MG6sCE=", + "integrity": "sha512-YGG3ejvBNHRqu0559EOxxNFihD0AjpvHlC/pdGKd3X3ofe+CoJkYazwNJYTNebqpPKN+VVQbh4ZFn1DivMNuHA==", "dev": true }, "imurmurhash": { @@ -2828,7 +2828,7 @@ "ini": { "version": "1.3.5", "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", - "integrity": "sha1-7uJfVtscnsYIXgwid4CD9Zar+Sc=", + "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==", "dev": true }, "inquirer": { @@ -2901,7 +2901,7 @@ "is-buffer": { "version": "1.1.6", "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", - "integrity": "sha1-76ouqdqg16suoTqXsritUf776L4=", + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", "dev": true }, "is-builtin-module": { @@ -3054,7 +3054,7 @@ "is-resolvable": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/is-resolvable/-/is-resolvable-1.1.0.tgz", - "integrity": "sha1-+xj4fOH+uSUWnJpAfBkxijIG7Yg=", + "integrity": "sha512-qgDYXFSR5WvEfuS5dMj6oTMEbrrSaM0CrFk2Yiq/gXnBvD9pMa2jGXxyhGLfvhZpuMZe18CJpFxAt3CRs42NMg==", "dev": true }, "is-retry-allowed": { @@ -3204,7 +3204,7 @@ "js-yaml": { "version": "3.11.0", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.11.0.tgz", - "integrity": "sha1-WXwai9VxUvJtYizkEXhRpR9euu8=", + "integrity": "sha512-saJstZWv7oNeOyBh3+Dx1qWzhW0+e6/8eDzo7p5rDFqxntSztloLtuKu+Ejhtq82jsilwOIZYsCz+lIjthg1Hw==", "dev": true, "requires": { "argparse": "1.0.10", @@ -3324,7 +3324,7 @@ "just-extend": { "version": "1.1.27", "resolved": "https://registry.npmjs.org/just-extend/-/just-extend-1.1.27.tgz", - "integrity": "sha1-7G55QQ/5FORyZSq/oOYDwD1g6QU=", + "integrity": "sha512-mJVp13Ix6gFo3SBAy9U/kL+oeZqzlYYYLQBwXVBlVzIsZwBqGREnOro24oC/8s8aox+rJhtZ2DiQof++IrkA+g==", "dev": true }, "kind-of": { @@ -3703,7 +3703,7 @@ "lodash": { "version": "4.17.5", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.5.tgz", - "integrity": "sha1-maktZcAnLevoyWtgV7yPv6O+1RE=", + "integrity": "sha512-svL3uiZf1RwhH+cWrfZn3A4+U58wbP0tGVTLQPbjplZxZ8ROD9VLuNgsRniTlLe7OlSqR79RUehXgpBW/s0IQw==", "dev": true }, "lodash._reinterpolate": { @@ -3740,7 +3740,7 @@ "lolex": { "version": "2.3.2", "resolved": "https://registry.npmjs.org/lolex/-/lolex-2.3.2.tgz", - "integrity": "sha1-hflFBCUQO/nnpgZo6iXcQydMqAc=", + "integrity": "sha512-A5pN2tkFj7H0dGIAM6MFvHKMJcPnjZsOMvR7ujCjfgW5TbV6H9vb1PgxLtHvjqNZTHsUolz+6/WEO0N1xNx2ng==", "dev": true }, "longest": { @@ -3816,7 +3816,7 @@ "marked": { "version": "0.3.17", "resolved": "https://registry.npmjs.org/marked/-/marked-0.3.17.tgz", - "integrity": "sha1-YH8GZos8axJGso8T2nYRasGqLSs=", + "integrity": "sha512-+AKbNsjZl6jFfLPwHhWmGTqE009wTKn3RTmn9K8oUKHrX/abPJjtcRtXpYB/FFrwPJRUA86LX/de3T0knkPCmQ==", "dev": true }, "mem": { @@ -3896,13 +3896,13 @@ "mime-db": { "version": "1.33.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.33.0.tgz", - "integrity": "sha1-o0kgUKXLm2NFBUHjnZeI0icng9s=", + "integrity": "sha512-BHJ/EKruNIqJf/QahvxwQZXKygOQ256myeN/Ew+THcAa5q+PjyTTMMeNQC4DZw5AwfvelsUrA6B67NKMqXDbzQ==", "dev": true }, "mime-types": { "version": "2.1.18", "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.18.tgz", - "integrity": "sha1-bzI/YKg9ERRvgx/xH9ZuL+VQO7g=", + "integrity": "sha512-lc/aahn+t4/SWV/qcmumYjymLsWfN3ELhpmVuUFjgsORruuZPVSwAQryq+HHGvO/SI2KVX26bx+En+zhM8g8hQ==", "dev": true, "requires": { "mime-db": "1.33.0" @@ -3917,7 +3917,7 @@ "minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha1-UWbihkV/AzBgZL5Ul+jbsMPTIIM=", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "dev": true, "requires": { "brace-expansion": "1.1.11" @@ -4071,7 +4071,7 @@ "normalize-package-data": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.4.0.tgz", - "integrity": "sha1-EvlaMH1YNSB1oEkHuErIvpisAS8=", + "integrity": "sha512-9jjUFbTPfEy3R/ad/2oNbKtW9Hgovl5O1FvFWKkKblNXoN/Oou6+9+KKohPK13Yc3/TyunyWhJp6gvRNR/PPAw==", "dev": true, "requires": { "hosted-git-info": "2.5.0", @@ -4511,7 +4511,7 @@ "process-nextick-args": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", - "integrity": "sha1-o31zL0JxtKsa0HDTVQjoKQeI/6o=", + "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==", "dev": true }, "progress": { @@ -4584,7 +4584,7 @@ "qs": { "version": "6.5.1", "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.1.tgz", - "integrity": "sha1-NJzfbu+J7EXBLX1es/wMhwNDptg=", + "integrity": "sha512-eRzhrN1WSINYCDCbrz796z37LOe3m5tmW7RQf6oBntukAG1nmovJvhnwHHRMAfeoItc1m2Hk02WER2aQ/iqs+A==", "dev": true }, "quick-lru": { @@ -4596,7 +4596,7 @@ "randomatic": { "version": "1.1.7", "resolved": "https://registry.npmjs.org/randomatic/-/randomatic-1.1.7.tgz", - "integrity": "sha1-x6vpzIuHwLqodrGf3oP9RkeX44w=", + "integrity": "sha512-D5JUjPyJbaJDkuAazpVnSfVkLlpeO3wDlPROTMLGKG1zMFNFRgrciKo1ltz/AzNTkqE0HzDx655QOL51N06how==", "dev": true, "requires": { "is-number": "3.0.0", @@ -4701,7 +4701,7 @@ "regex-cache": { "version": "0.4.4", "resolved": "https://registry.npmjs.org/regex-cache/-/regex-cache-0.4.4.tgz", - "integrity": "sha1-db3FiioUls7EihKDW8VMjVYjNt0=", + "integrity": "sha512-nVIZwtCjkC9YgvWkpM55B5rBhBYRZhAaJbgcFYXXsHnbZ9UZI9nnVWYZpBlCqv9ho2eZryPnWrZGsOdPwVWXWQ==", "dev": true, "requires": { "is-equal-shallow": "0.1.3" @@ -4729,7 +4729,7 @@ "remap-istanbul": { "version": "0.10.1", "resolved": "https://registry.npmjs.org/remap-istanbul/-/remap-istanbul-0.10.1.tgz", - "integrity": "sha1-OqWN1QIdSZ8zbTulvzu7kcG4jjc=", + "integrity": "sha512-gsNQXs5kJLhErICSyYhzVZ++C8LBW8dgwr874Y2QvzAUS75zBlD/juZgXs39nbYJ09fZDlX2AVLVJAY2jbFJoQ==", "dev": true, "requires": { "amdefine": "1.0.1", @@ -4769,7 +4769,7 @@ "source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha1-dHIq8y6WFOnCh6jQu95IteLxomM=", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", "dev": true }, "through2": { @@ -4883,7 +4883,7 @@ "resolve": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.5.0.tgz", - "integrity": "sha1-HwmsznlsmnYlefMbLBzEw83fnzY=", + "integrity": "sha512-hgoSGrc3pjzAPHNBg+KnFcK2HwlHTs/YrAGUr6qgTVUZmXv1UEXXl0bZNBKMA9fud6lRYFdPGz0xXxycPzmmiw==", "dev": true, "requires": { "path-parse": "1.0.5" @@ -4924,7 +4924,7 @@ "rimraf": { "version": "2.6.2", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", - "integrity": "sha1-LtgVDSShbqhlHm1u8PR8QVjOejY=", + "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", "dev": true, "requires": { "glob": "7.1.2" @@ -5063,19 +5063,19 @@ "safe-buffer": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", - "integrity": "sha1-iTMSr2myEj3vcfV4iQAWce6yyFM=", + "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", "dev": true }, "samsam": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/samsam/-/samsam-1.3.0.tgz", - "integrity": "sha1-jR2TUOJWItow3j5EumkrUiGrfFA=", + "integrity": "sha512-1HwIYD/8UlOtFS3QO3w7ey+SdSDFE4HRNLZoZRYVQefrOY3l17epswImeB1ijgJFQJodIaHcwkp3r/myBjFVbg==", "dev": true }, "semver": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz", - "integrity": "sha1-3Eu8emyp2Rbe5dQ1FvAJK1j3uKs=", + "integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==", "dev": true }, "set-blocking": { @@ -5117,7 +5117,7 @@ "sinon-chai": { "version": "2.14.0", "resolved": "https://registry.npmjs.org/sinon-chai/-/sinon-chai-2.14.0.tgz", - "integrity": "sha1-2n3UzIPNaiYLZ8yg96n9riahIF0=", + "integrity": "sha512-9stIF1utB0ywNHNT7RgiXbdmen8QDCRsrTjw+G9TgKt1Yexjiv8TOWZ6WHsTPz57Yky3DIswZvEqX8fpuHNDtQ==", "dev": true }, "slash": { @@ -5146,7 +5146,7 @@ "sntp": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/sntp/-/sntp-2.1.0.tgz", - "integrity": "sha1-LGzsFP7cIiJznK+bXD2F0cxaLMg=", + "integrity": "sha512-FL1b58BDrqS3A11lJ0zEdnJ3UOKqVxawAkF3k7F0CVN7VQ34aZrV+G8BZ1WC9ZL7NyrwsW0oviwsWDgRuVYtJg==", "dev": true, "requires": { "hoek": "4.2.1" @@ -5203,7 +5203,7 @@ "spdx-correct": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.0.0.tgz", - "integrity": "sha1-BaW01xU6GVvJLDxCW2nzsqlSTII=", + "integrity": "sha512-N19o9z5cEyc8yQQPukRCZ9EUmb4HUpnrmaL/fxS2pBo2jbfcFRVuFZ/oFC+vZz0MNNk0h80iMn5/S6qGZOL5+g==", "dev": true, "requires": { "spdx-expression-parse": "3.0.0", @@ -5213,13 +5213,13 @@ "spdx-exceptions": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.1.0.tgz", - "integrity": "sha1-LHrmEFbHFKW5ubKyr30xHvXHj+k=", + "integrity": "sha512-4K1NsmrlCU1JJgUrtgEeTVyfx8VaYea9J9LvARxhbHtVtohPs/gFGG5yy49beySjlIMhhXZ4QqujIZEfS4l6Cg==", "dev": true }, "spdx-expression-parse": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.0.tgz", - "integrity": "sha1-meEZt6XaAOBUkcn6M4t5BII7QdA=", + "integrity": "sha512-Yg6D3XpRD4kkOmTpdgbUiEJFKghJH03fiC1OPll5h/0sO6neh2jqRDVHOQ4o/LMea0tgCkbMgea5ip/e+MkWyg==", "dev": true, "requires": { "spdx-exceptions": "2.1.0", @@ -5229,7 +5229,7 @@ "spdx-license-ids": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.0.tgz", - "integrity": "sha1-enzShHDMbToc/m1miG9rxDDTrIc=", + "integrity": "sha512-2+EPwgbnmOIl8HjGBXXMd9NAu02vLjOO1nWw4kmeRDFyHn+M/ETfHxQUK0oXg8ctgVnl9t3rosNVsZ1jG61nDA==", "dev": true }, "speedometer": { @@ -5566,7 +5566,7 @@ "tough-cookie": { "version": "2.3.4", "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.4.tgz", - "integrity": "sha1-7GDO44rGdQY//JelwYlwV47oNlU=", + "integrity": "sha512-TZ6TTfI5NtZnuyy/Kecv+CnoROnyXn2DN97LontgQpCwsX2XyLYCC0ENhYkehSOwAp8rTQKc/NUIF7BkQ5rKLA==", "dev": true, "requires": { "punycode": "1.4.1" @@ -5708,13 +5708,13 @@ "uuid": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.2.1.tgz", - "integrity": "sha1-EsUou51Y0LkmXZovbw/ovhf/HxQ=", + "integrity": "sha512-jZnMwlb9Iku/O3smGWvZhauCf6cvvpKi4BKRiliS3cxnI+Gz9j5MEpTz2UFuXiKPJocb7gnsLHwiS05ige5BEA==", "dev": true }, "validate-npm-package-license": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.3.tgz", - "integrity": "sha1-gWQ7y+8b3+zUYjeT3EZIlIupgzg=", + "integrity": "sha512-63ZOUnL4SIXj4L0NixR3L1lcjO38crAbgrTpl28t8jjrfuiOBL5Iygm+60qPs/KsZGzPNg6Smnc/oY16QTjF0g==", "dev": true, "requires": { "spdx-correct": "3.0.0", @@ -5750,7 +5750,7 @@ "which": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/which/-/which-1.3.0.tgz", - "integrity": "sha1-/wS9/AEO5UfXgL7DjhrBwnd9JTo=", + "integrity": "sha512-xcJpopdamTuY5duC/KnTTNBraPK54YwpenP4lzxU8H91GudWpFv38u0CKjclE1Wi2EH2EDz5LRcHcKbCIzqGyg==", "dev": true, "requires": { "isexe": "2.0.0" diff --git a/packages/canvas/canvas-mesh/package.json b/packages/canvas/canvas-mesh/package.json index 691cd2c..6744a17 100644 --- a/packages/canvas/canvas-mesh/package.json +++ b/packages/canvas/canvas-mesh/package.json @@ -24,6 +24,7 @@ "dependencies": { "@pixi/constants": "^5.0.0-alpha.2", "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/mesh-extras": "^5.0.0-alpha.2", "@pixi/settings": "^5.0.0-alpha.2" }, "devDependencies": { diff --git a/packages/canvas/canvas-mesh/src/Mesh.js b/packages/canvas/canvas-mesh/src/Mesh.js index 900a872..c43a74b 100644 --- a/packages/canvas/canvas-mesh/src/Mesh.js +++ b/packages/canvas/canvas-mesh/src/Mesh.js @@ -1,36 +1,14 @@ import { Mesh } from '@pixi/mesh'; -import { settings } from './settings'; - -// IMPORTANT: Please do NOT use this as a precedent to use `settings` after the object is created -// this was merely created to completely decouple canvas from the base Mesh class and we are -// unable to add `canvasPadding` in the constructor anymore, as the case was for PixiJS v4. /** - * Internal variable for `canvasPadding`. + * Renders the object using the Canvas renderer * * @private - * @memberof PIXI.Mesh - * @member {number} - * @default null - */ -Mesh.prototype._canvasPadding = null; - -/** - * Triangles in canvas mode are automatically antialiased, use this value to force triangles - * to overlap a bit with each other. To set the global default, set {@link PIXI.settings.MESH_CANVAS_PADDING} - * - * @see PIXI.settings.MESH_CANVAS_PADDING - * @member {number} canvasPadding + * @method _renderCanvas * @memberof PIXI.Mesh# - * @default 0 + * @param {PIXI.CanvasRenderer} renderer - The canvas renderer. */ -Object.defineProperty(Mesh.prototype, 'canvasPadding', { - get() - { - return this._canvasPadding !== null ? this._canvasPadding : settings.MESH_CANVAS_PADDING; - }, - set(value) - { - this._canvasPadding = value; - }, -}); +Mesh.prototype._renderCanvas = function _renderCanvas(renderer) +{ + renderer.plugins[this.pluginName].render(this); +}; diff --git a/packages/canvas/canvas-mesh/src/Mesh2d.js b/packages/canvas/canvas-mesh/src/Mesh2d.js new file mode 100644 index 0000000..d0bd80f --- /dev/null +++ b/packages/canvas/canvas-mesh/src/Mesh2d.js @@ -0,0 +1,36 @@ +import { Mesh2d } from '@pixi/mesh-extras'; +import { settings } from './settings'; + +// IMPORTANT: Please do NOT use this as a precedent to use `settings` after the object is created +// this was merely created to completely decouple canvas from the base Mesh class and we are +// unable to add `canvasPadding` in the constructor anymore, as the case was for PixiJS v4. + +/** + * Internal variable for `canvasPadding`. + * + * @private + * @memberof PIXI.Mesh2d + * @member {number} + * @default null + */ +Mesh2d.prototype._canvasPadding = null; + +/** + * Triangles in canvas mode are automatically antialiased, use this value to force triangles + * to overlap a bit with each other. To set the global default, set {@link PIXI.settings.MESH_CANVAS_PADDING} + * + * @see PIXI.settings.MESH_CANVAS_PADDING + * @member {number} canvasPadding + * @memberof PIXI.Mesh2d# + * @default 0 + */ +Object.defineProperty(Mesh2d.prototype, 'canvasPadding', { + get() + { + return this._canvasPadding !== null ? this._canvasPadding : settings.MESH_CANVAS_PADDING; + }, + set(value) + { + this._canvasPadding = value; + }, +}); diff --git a/packages/canvas/canvas-mesh/src/NineSlicePlane.js b/packages/canvas/canvas-mesh/src/NineSlicePlane.js index 09eaf9c..2fd5acc 100644 --- a/packages/canvas/canvas-mesh/src/NineSlicePlane.js +++ b/packages/canvas/canvas-mesh/src/NineSlicePlane.js @@ -1,4 +1,4 @@ -import { NineSlicePlane } from '@pixi/mesh'; +import { NineSlicePlane } from '@pixi/mesh-extras'; /** * Renders the object using the Canvas renderer diff --git a/packages/canvas/canvas-mesh/src/RawMesh.js b/packages/canvas/canvas-mesh/src/RawMesh.js deleted file mode 100644 index bf40184..0000000 --- a/packages/canvas/canvas-mesh/src/RawMesh.js +++ /dev/null @@ -1,14 +0,0 @@ -import { RawMesh } from '@pixi/mesh'; - -/** - * Renders the object using the Canvas renderer - * - * @private - * @method _renderCanvas - * @memberof PIXI.RawMesh# - * @param {PIXI.CanvasRenderer} renderer - The canvas renderer. - */ -RawMesh.prototype._renderCanvas = function _renderCanvas(renderer) -{ - renderer.plugins[this.pluginName].render(this); -}; diff --git a/packages/canvas/canvas-mesh/src/index.js b/packages/canvas/canvas-mesh/src/index.js index 2295016..f4fa31d 100644 --- a/packages/canvas/canvas-mesh/src/index.js +++ b/packages/canvas/canvas-mesh/src/index.js @@ -1,6 +1,6 @@ export { default as CanvasMeshRenderer } from './CanvasMeshRenderer'; import './settings'; -import './Mesh'; +import './Mesh2d'; import './NineSlicePlane'; -import './RawMesh'; +import './Mesh'; diff --git a/packages/canvas/canvas-mesh/src/settings.js b/packages/canvas/canvas-mesh/src/settings.js index 4cefb4c..e81b8e0 100644 --- a/packages/canvas/canvas-mesh/src/settings.js +++ b/packages/canvas/canvas-mesh/src/settings.js @@ -3,7 +3,7 @@ /** * Default `canvasPadding` for canvas-based Mesh rendering. * - * @see PIXI.Mesh#canvasPadding + * @see PIXI.Mesh2d#canvasPadding * @static * @constant * @memberof PIXI.settings diff --git a/packages/mesh-extras/LICENSE b/packages/mesh-extras/LICENSE new file mode 100644 index 0000000..148e3eb --- /dev/null +++ b/packages/mesh-extras/LICENSE @@ -0,0 +1,21 @@ +The MIT License + +Copyright (c) 2013-2018 Mathew Groves, Chad Engler + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/packages/mesh-extras/README.md b/packages/mesh-extras/README.md new file mode 100644 index 0000000..1d9b0e1 --- /dev/null +++ b/packages/mesh-extras/README.md @@ -0,0 +1,19 @@ +# @pixi/mesh-extras + +## Installation + +```bash +npm install @pixi/mesh-extras +``` + +## Usage + +```js +import { MeshRenderer } from '@pixi/mesh'; +import { Renderer } from '@pixi/core'; +import { Rope } from '@pixi/mesh-extras'; + +Renderer.registerPlugin('mesh', MeshRenderer); + +const rope = new Rope(); +``` \ No newline at end of file diff --git a/packages/mesh-extras/package.json b/packages/mesh-extras/package.json new file mode 100644 index 0000000..d134f64 --- /dev/null +++ b/packages/mesh-extras/package.json @@ -0,0 +1,38 @@ +{ + "name": "@pixi/mesh-extras", + "version": "5.0.0-alpha.2", + "main": "lib/mesh-extras.js", + "module": "lib/mesh-extras.es.js", + "description": "Custom Mesh display objects, like Rope and Plane", + "author": "Mat Groves", + "contributors": [ + "Matt Karl " + ], + "homepage": "http://pixijs.com/", + "bugs": "https://github.com/pixijs/pixi.js/issues", + "license": "MIT", + "repository": { + "type": "git", + "url": "https://github.com/pixijs/pixi.js.git" + }, + "publishConfig": { + "access": "public" + }, + "scripts": { + "test": "floss --path test" + }, + "files": [ + "lib" + ], + "dependencies": { + "@pixi/constants": "^5.0.0-alpha.2", + "@pixi/core": "^5.0.0-alpha.2", + "@pixi/math": "^5.0.0-alpha.2", + "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/utils": "^5.0.0-alpha.2" + }, + "devDependencies": { + "@pixi/loaders": "^5.0.0-alpha.2", + "floss": "^2.1.3" + } +} diff --git a/packages/mesh-extras/src/Mesh2d.js b/packages/mesh-extras/src/Mesh2d.js new file mode 100644 index 0000000..d113a5e --- /dev/null +++ b/packages/mesh-extras/src/Mesh2d.js @@ -0,0 +1,263 @@ +import { Mesh } from '@pixi/mesh'; +import { Geometry, Program, Shader, Texture, TextureMatrix } from '@pixi/core'; +import { Matrix } from '@pixi/math'; +import { BLEND_MODES } from '@pixi/constants'; +import { hex2rgb, premultiplyRgba } from '@pixi/utils'; +import vertex from './mesh.vert'; +import fragment from './mesh.frag'; + +let meshProgram; + +/** + * Base mesh class + * @class + * @extends PIXI.Container + * @memberof PIXI + */ +export default class Mesh2d extends Mesh +{ + /** + * @param {PIXI.Texture} [texture=Texture.EMPTY] - The texture to use + * @param {Float32Array} [vertices] - if you want to specify the vertices + * @param {Float32Array} [uvs] - if you want to specify the uvs + * @param {Uint16Array} [indices] - if you want to specify the indices + * @param {number} [drawMode] - the drawMode, can be any of the Mesh.DRAW_MODES consts + */ + constructor(texture = Texture.EMPTY, vertices, uvs, indices, drawMode) + { + const geometry = new Geometry(); + + if (!meshProgram) + { + meshProgram = new Program(vertex, fragment); + } + + geometry.addAttribute('aVertexPosition', vertices) + .addAttribute('aTextureCoord', uvs) + .addIndex(indices); + + geometry.getAttribute('aVertexPosition').static = false; + + const uniforms = { + uSampler: texture, + uTextureMatrix: Matrix.IDENTITY, + alpha: 1, + uColor: new Float32Array([1, 1, 1, 1]), + }; + + super(geometry, new Shader(meshProgram, uniforms), null, drawMode); + + /** + * The Uvs of the Mesh + * + * @member {Float32Array} + */ + this.uvs = geometry.getAttribute('aTextureCoord').data; + + /** + * An array of vertices + * + * @member {Float32Array} + */ + this.vertices = geometry.getAttribute('aVertexPosition').data; + + this.uniforms = uniforms; + + /** + * The texture of the Mesh + * + * @member {PIXI.Texture} + * @default PIXI.Texture.EMPTY + * @private + */ + this.texture = texture; + + /** + * The tint applied to the mesh. This is a [r,g,b] value. A value of [1,1,1] will remove any + * tint effect. + * + * @member {number} + * @private + */ + this._tintRGB = new Float32Array([1, 1, 1]); + + // Set default tint + this.tint = 0xFFFFFF; + + this.blendMode = BLEND_MODES.NORMAL; + + /** + * TextureMatrix instance for this Mesh, used to track Texture changes + * + * @member {PIXI.TextureMatrix} + * @readonly + */ + this.uvMatrix = new TextureMatrix(this._texture); + + /** + * whether or not upload uvMatrix to shader + * if its false, then uvs should be pre-multiplied + * if you change it for generated mesh, please call 'refresh(true)' + * @member {boolean} + * @default false + */ + this.uploadUvMatrix = false; + + /** + * Uploads vertices buffer every frame, like in PixiJS V3 and V4. + * + * @member {boolean} + * @default true + */ + this.autoUpdate = true; + } + + /** + * The tint applied to the Rope. This is a hex value. A value of + * 0xFFFFFF will remove any tint effect. + * + * @member {number} + * @memberof PIXI.Sprite# + * @default 0xFFFFFF + */ + get tint() + { + return this._tint; + } + + /** + * Sets the tint of the rope. + * + * @param {number} value - The value to set to. + */ + set tint(value) + { + this._tint = value; + + hex2rgb(this._tint, this._tintRGB); + } + + /** + * The blend mode to be applied to the sprite. Set to `PIXI.BLEND_MODES.NORMAL` to remove any blend mode. + * + * @member {number} + * @default PIXI.BLEND_MODES.NORMAL + * @see PIXI.BLEND_MODES + */ + get blendMode() + { + return this.state.blendMode; + } + + set blendMode(value) // eslint-disable-line require-jsdoc + { + this.state.blendMode = value; + } + + /** + * The texture that the mesh uses. + * + * @member {PIXI.Texture} + */ + get texture() + { + return this._texture; + } + + set texture(value) // eslint-disable-line require-jsdoc + { + if (this._texture === value) + { + return; + } + + this._texture = value; + this.uniforms.uSampler = this.texture; + + if (value) + { + // wait for the texture to load + if (value.baseTexture.valid) + { + this._onTextureUpdate(); + } + else + { + value.once('update', this._onTextureUpdate, this); + } + } + } + + _render(renderer) + { + const baseTex = this._texture.baseTexture; + + premultiplyRgba(this._tintRGB, this.worldAlpha, this.uniforms.uColor, baseTex.premultiplyAlpha); + super._render(renderer); + } + /** + * When the texture is updated, this event will fire to update the scale and frame + * + * @private + */ + _onTextureUpdate() + { + // constructor texture update stop + if (!this.uvMatrix) + { + return; + } + this.uvMatrix.texture = this._texture; + this.refresh(); + } + + /** + * multiplies uvs only if uploadUvMatrix is false + * call it after you change uvs manually + * make sure that texture is valid + */ + multiplyUvs() + { + if (!this.uploadUvMatrix) + { + this.uvMatrix.multiplyUvs(this.uvs); + } + } + + /** + * Refreshes uvs for generated meshes (rope, plane) + * sometimes refreshes vertices too + * + * @param {boolean} [forceUpdate=false] if true, matrices will be updated any case + */ + refresh(forceUpdate) + { + if (this.uvMatrix.update(forceUpdate)) + { + this._refresh(); + } + } + + /** + * Updates the object transform for rendering + * + * @private + */ + updateTransform() + { + if (this.autoUpdate) + { + this.geometry.buffers[0].update(); + } + this.containerUpdateTransform(); + } + + /** + * re-calculates mesh coords + * @private + */ + _refresh() + { + /* empty */ + } +} diff --git a/packages/mesh-extras/src/NineSlicePlane.js b/packages/mesh-extras/src/NineSlicePlane.js new file mode 100644 index 0000000..0bae92c --- /dev/null +++ b/packages/mesh-extras/src/NineSlicePlane.js @@ -0,0 +1,270 @@ +import Plane from './Plane'; + +const DEFAULT_BORDER_SIZE = 10; + +/** + * The NineSlicePlane allows you to stretch a texture using 9-slice scaling. The corners will remain unscaled (useful + * for buttons with rounded corners for example) and the other areas will be scaled horizontally and or vertically + * + *```js + * let Plane9 = new PIXI.NineSlicePlane(PIXI.Texture.from('BoxWithRoundedCorners.png'), 15, 15, 15, 15); + * ``` + *
+ *      A                          B
+ *    +---+----------------------+---+
+ *  C | 1 |          2           | 3 |
+ *    +---+----------------------+---+
+ *    |   |                      |   |
+ *    | 4 |          5           | 6 |
+ *    |   |                      |   |
+ *    +---+----------------------+---+
+ *  D | 7 |          8           | 9 |
+ *    +---+----------------------+---+
+
+ *  When changing this objects width and/or height:
+ *     areas 1 3 7 and 9 will remain unscaled.
+ *     areas 2 and 8 will be stretched horizontally
+ *     areas 4 and 6 will be stretched vertically
+ *     area 5 will be stretched both horizontally and vertically
+ * 
+ * + * @class + * @extends PIXI.Plane + * @memberof PIXI + * + */ +export default class NineSlicePlane extends Plane +{ + /** + * @param {PIXI.Texture} texture - The texture to use on the NineSlicePlane. + * @param {int} [leftWidth=10] size of the left vertical bar (A) + * @param {int} [topHeight=10] size of the top horizontal bar (C) + * @param {int} [rightWidth=10] size of the right vertical bar (B) + * @param {int} [bottomHeight=10] size of the bottom horizontal bar (D) + */ + constructor(texture, leftWidth, topHeight, rightWidth, bottomHeight) + { + super(texture, 4, 4); + + this._origWidth = texture.orig.width; + this._origHeight = texture.orig.height; + + /** + * The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._width = this._origWidth; + + /** + * The height of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._height = this._origHeight; + + /** + * The width of the left column (a) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._leftWidth = typeof leftWidth !== 'undefined' ? leftWidth : DEFAULT_BORDER_SIZE; + + /** + * The width of the right column (b) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._rightWidth = typeof rightWidth !== 'undefined' ? rightWidth : DEFAULT_BORDER_SIZE; + + /** + * The height of the top row (c) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._topHeight = typeof topHeight !== 'undefined' ? topHeight : DEFAULT_BORDER_SIZE; + + /** + * The height of the bottom row (d) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._bottomHeight = typeof bottomHeight !== 'undefined' ? bottomHeight : DEFAULT_BORDER_SIZE; + + this.refresh(true); + } + + /** + * Updates the horizontal vertices. + * + */ + updateHorizontalVertices() + { + const vertices = this.vertices; + + const h = this._topHeight + this._bottomHeight; + const scale = this._height > h ? 1.0 : this._height / h; + + vertices[9] = vertices[11] = vertices[13] = vertices[15] = this._topHeight * scale; + vertices[17] = vertices[19] = vertices[21] = vertices[23] = this._height - (this._bottomHeight * scale); + vertices[25] = vertices[27] = vertices[29] = vertices[31] = this._height; + } + + /** + * Updates the vertical vertices. + * + */ + updateVerticalVertices() + { + const vertices = this.vertices; + + const w = this._leftWidth + this._rightWidth; + const scale = this._width > w ? 1.0 : this._width / w; + + vertices[2] = vertices[10] = vertices[18] = vertices[26] = this._leftWidth * scale; + vertices[4] = vertices[12] = vertices[20] = vertices[28] = this._width - (this._rightWidth * scale); + vertices[6] = vertices[14] = vertices[22] = vertices[30] = this._width; + } + + /** + * The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + */ + get width() + { + return this._width; + } + + set width(value) // eslint-disable-line require-jsdoc + { + this._width = value; + this._refresh(); + } + + /** + * The height of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + */ + get height() + { + return this._height; + } + + set height(value) // eslint-disable-line require-jsdoc + { + this._height = value; + this._refresh(); + } + + /** + * The width of the left column + * + * @member {number} + */ + get leftWidth() + { + return this._leftWidth; + } + + set leftWidth(value) // eslint-disable-line require-jsdoc + { + this._leftWidth = value; + this._refresh(); + } + + /** + * The width of the right column + * + * @member {number} + */ + get rightWidth() + { + return this._rightWidth; + } + + set rightWidth(value) // eslint-disable-line require-jsdoc + { + this._rightWidth = value; + this._refresh(); + } + + /** + * The height of the top row + * + * @member {number} + */ + get topHeight() + { + return this._topHeight; + } + + set topHeight(value) // eslint-disable-line require-jsdoc + { + this._topHeight = value; + this._refresh(); + } + + /** + * The height of the bottom row + * + * @member {number} + */ + get bottomHeight() + { + return this._bottomHeight; + } + + set bottomHeight(value) // eslint-disable-line require-jsdoc + { + this._bottomHeight = value; + this._refresh(); + } + + /** + * Refreshes NineSlicePlane coords. All of them. + */ + _refresh() + { + super._refresh(); + + const uvs = this.uvs; + const texture = this._texture; + + this._origWidth = texture.orig.width; + this._origHeight = texture.orig.height; + + const _uvw = 1.0 / this._origWidth; + const _uvh = 1.0 / this._origHeight; + + uvs[0] = uvs[8] = uvs[16] = uvs[24] = 0; + uvs[1] = uvs[3] = uvs[5] = uvs[7] = 0; + uvs[6] = uvs[14] = uvs[22] = uvs[30] = 1; + uvs[25] = uvs[27] = uvs[29] = uvs[31] = 1; + + uvs[2] = uvs[10] = uvs[18] = uvs[26] = _uvw * this._leftWidth; + uvs[4] = uvs[12] = uvs[20] = uvs[28] = 1 - (_uvw * this._rightWidth); + uvs[9] = uvs[11] = uvs[13] = uvs[15] = _uvh * this._topHeight; + uvs[17] = uvs[19] = uvs[21] = uvs[23] = 1 - (_uvh * this._bottomHeight); + + this.updateHorizontalVertices(); + this.updateVerticalVertices(); + + this.geometry.buffers[1].update(); + + this.multiplyUvs(); + } +} diff --git a/packages/mesh-extras/src/Plane.js b/packages/mesh-extras/src/Plane.js new file mode 100644 index 0000000..1c240c4 --- /dev/null +++ b/packages/mesh-extras/src/Plane.js @@ -0,0 +1,100 @@ +import Mesh2d from './Mesh2d'; + +/** + * The Plane allows you to draw a texture across several points and them manipulate these points + * + *```js + * for (let i = 0; i < 20; i++) { + * points.push(new PIXI.Point(i * 50, 0)); + * }; + * let Plane = new PIXI.Plane(PIXI.Texture.from("snake.png"), points); + * ``` + * + * @class + * @extends PIXI.Mesh + * @memberof PIXI + * + */ +export default class Plane extends Mesh2d +{ + /** + * @param {PIXI.Texture} texture - The texture to use on the Plane. + * @param {number} verticesX - The number of vertices in the x-axis + * @param {number} verticesY - The number of vertices in the y-axis + * @param {object} [opts] - an options object - add meshWidth and meshHeight, temporary object for PixiJS v5 alpha + */ + constructor(texture, verticesX, verticesY, opts = {}) + { + super(texture, new Float32Array(1), new Float32Array(1), new Uint16Array(1), 4); + + this.verticesX = verticesX || 10; + this.verticesY = verticesY || 10; + + this.meshWidth = opts.meshWidth || 0; + this.meshHeight = opts.meshHeight || 0; + + this.refresh(); + } + + /** + * Refreshes plane coordinates + * @private + */ + _refresh() + { + const texture = this._texture; + const total = this.verticesX * this.verticesY; + const verts = []; + const uvs = []; + const indices = []; + + const segmentsX = this.verticesX - 1; + const segmentsY = this.verticesY - 1; + + const sizeX = (this.meshWidth || texture.width) / segmentsX; + const sizeY = (this.meshHeight || texture.height) / segmentsY; + + for (let i = 0; i < total; i++) + { + const x = (i % this.verticesX); + const y = ((i / this.verticesX) | 0); + + verts.push(x * sizeX, y * sizeY); + + uvs.push(x / segmentsX, y / segmentsY); + } + + // cons + + const totalSub = segmentsX * segmentsY; + + for (let i = 0; i < totalSub; i++) + { + const xpos = i % segmentsX; + const ypos = (i / segmentsX) | 0; + + const value = (ypos * this.verticesX) + xpos; + const value2 = (ypos * this.verticesX) + xpos + 1; + const value3 = ((ypos + 1) * this.verticesX) + xpos; + const value4 = ((ypos + 1) * this.verticesX) + xpos + 1; + + indices.push(value, value2, value3); + indices.push(value2, value4, value3); + } + + this.vertices = new Float32Array(verts); + this.uvs = new Float32Array(uvs); + this.indices = new Uint16Array(indices); + + this.geometry.buffers[0].data = this.vertices; + this.geometry.buffers[1].data = this.uvs; + this.geometry.indexBuffer.data = this.indices; + + // ensure that the changes are uploaded + this.geometry.buffers[0].update(); + this.geometry.buffers[1].update(); + this.geometry.indexBuffer.update(); + + this.multiplyUvs(); + } +} diff --git a/packages/mesh-extras/src/Rope.js b/packages/mesh-extras/src/Rope.js new file mode 100644 index 0000000..9cfde38 --- /dev/null +++ b/packages/mesh-extras/src/Rope.js @@ -0,0 +1,182 @@ +import Mesh2d from './Mesh2d'; + +/** + * The rope allows you to draw a texture across several points and them manipulate these points + * + *```js + * for (let i = 0; i < 20; i++) { + * points.push(new PIXI.Point(i * 50, 0)); + * }; + * let rope = new PIXI.Rope(PIXI.Texture.from("snake.png"), points); + * ``` + * + * @class + * @extends PIXI.Mesh + * @memberof PIXI + * + */ +export default class Rope extends Mesh2d +{ + /** + * @param {PIXI.Texture} texture - The texture to use on the rope. + * @param {PIXI.Point[]} points - An array of {@link PIXI.Point} objects to construct this rope. + */ + constructor(texture, points) + { + super(texture, new Float32Array(points.length * 4), + new Float32Array(points.length * 4), + new Uint16Array(points.length * 2), + 5); + + /* + * @member {PIXI.Point[]} An array of points that determine the rope + */ + this.points = points; + this.refresh(); + } + /** + * Refreshes Rope indices and uvs + * @private + */ + _refresh() + { + const points = this.points; + + if (!points) return; + + const vertexBuffer = this.geometry.getAttribute('aVertexPosition'); + const uvBuffer = this.geometry.getAttribute('aTextureCoord'); + const indexBuffer = this.geometry.getIndex(); + + // if too little points, or texture hasn't got UVs set yet just move on. + if (points.length < 1 || !this.texture._uvs) + { + return; + } + + // if the number of points has changed we will need to recreate the arraybuffers + if (vertexBuffer.data.length / 4 !== points.length) + { + vertexBuffer.data = new Float32Array(points.length * 4); + uvBuffer.data = new Float32Array(points.length * 4); + indexBuffer.data = new Uint16Array(points.length * 2); + } + + const uvs = uvBuffer.data; + const indices = indexBuffer.data; + + uvs[0] = 0; + uvs[1] = 0; + uvs[2] = 0; + uvs[3] = 1; + + indices[0] = 0; + indices[1] = 1; + + const total = points.length; + + for (let i = 1; i < total; i++) + { + // time to do some smart drawing! + let index = i * 4; + const amount = i / (total - 1); + + uvs[index] = amount; + uvs[index + 1] = 0; + + uvs[index + 2] = amount; + uvs[index + 3] = 1; + + index = i * 2; + indices[index] = index; + indices[index + 1] = index + 1; + } + + // ensure that the changes are uploaded + uvBuffer.update(); + indexBuffer.update(); + + this.multiplyUvs(); + this.refreshVertices(); + } + + /** + * refreshes vertices of Rope mesh + */ + refreshVertices() + { + const points = this.points; + + if (points.length < 1) + { + return; + } + + let lastPoint = points[0]; + let nextPoint; + let perpX = 0; + let perpY = 0; + + // this.count -= 0.2; + + const vertices = this.vertices; + const total = points.length; + + for (let i = 0; i < total; i++) + { + const point = points[i]; + const index = i * 4; + + if (i < points.length - 1) + { + nextPoint = points[i + 1]; + } + else + { + nextPoint = point; + } + + perpY = -(nextPoint.x - lastPoint.x); + perpX = nextPoint.y - lastPoint.y; + + let ratio = (1 - (i / (total - 1))) * 10; + + if (ratio > 1) + { + ratio = 1; + } + + const perpLength = Math.sqrt((perpX * perpX) + (perpY * perpY)); + const num = this._texture.height / 2; // (20 + Math.abs(Math.sin((i + this.count) * 0.3) * 50) )* ratio; + + perpX /= perpLength; + perpY /= perpLength; + + perpX *= num; + perpY *= num; + + vertices[index] = point.x + perpX; + vertices[index + 1] = point.y + perpY; + vertices[index + 2] = point.x - perpX; + vertices[index + 3] = point.y - perpY; + + lastPoint = point; + } + + this.geometry.buffers[0].update(); + } + + /** + * Updates the object transform for rendering + * + * @private + */ + updateTransform() + { + if (this.autoUpdate) + { + this.refreshVertices(); + } + this.containerUpdateTransform(); + } +} diff --git a/bundles/pixi.js/package.json b/bundles/pixi.js/package.json index 49c7276..177e059 100644 --- a/bundles/pixi.js/package.json +++ b/bundles/pixi.js/package.json @@ -49,6 +49,7 @@ "@pixi/loaders": "^5.0.0-alpha.2", "@pixi/math": "^5.0.0-alpha.2", "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/mesh-extras": "^5.0.0-alpha.2", "@pixi/mixin-cache-as-bitmap": "^5.0.0-alpha.2", "@pixi/mixin-get-child-by-name": "^5.0.0-alpha.2", "@pixi/mixin-get-global-position": "^5.0.0-alpha.2", diff --git a/bundles/pixi.js/src/deprecated.js b/bundles/pixi.js/src/deprecated.js index 147617c..dbebeb0 100644 --- a/bundles/pixi.js/src/deprecated.js +++ b/bundles/pixi.js/src/deprecated.js @@ -263,15 +263,15 @@ Object.defineProperties(PIXI.mesh, { /** * @class PIXI.mesh.Mesh - * @see PIXI.Mesh + * @see PIXI.Mesh2d * @deprecated since 5.0.0 */ Mesh: { get() { - warn('PIXI.mesh.Mesh has moved to PIXI.Mesh'); + warn('PIXI.mesh.Mesh has moved to PIXI.Mesh2d'); - return PIXI.Mesh; + return PIXI.Mesh2d; }, }, /** @@ -315,15 +315,15 @@ }, /** * @class PIXI.mesh.RawMesh - * @see PIXI.RawMesh + * @see PIXI.Mesh * @deprecated since 5.0.0 */ RawMesh: { get() { - warn('PIXI.mesh.RawMesh has moved to PIXI.RawMesh'); + warn('PIXI.mesh.RawMesh has moved to PIXI.Mesh'); - return PIXI.RawMesh; + return PIXI.Mesh; }, }, /** diff --git a/bundles/pixi.js/src/index.js b/bundles/pixi.js/src/index.js index a3a0d1b..6fdabf0 100644 --- a/bundles/pixi.js/src/index.js +++ b/bundles/pixi.js/src/index.js @@ -9,6 +9,7 @@ import * as loaders from '@pixi/loaders'; import * as math from '@pixi/math'; import * as mesh from '@pixi/mesh'; +import * as meshExtras from '@pixi/mesh-extras'; import * as particles from '@pixi/particles'; import * as prepare from '@pixi/prepare'; import * as sprite from '@pixi/sprite'; @@ -128,6 +129,7 @@ loaders, math, mesh, + meshExtras, particles, sprite, spriteAnimated, @@ -152,6 +154,7 @@ export * from '@pixi/loaders'; export * from '@pixi/math'; export * from '@pixi/mesh'; +export * from '@pixi/mesh-extras'; export * from '@pixi/particles'; export * from '@pixi/sprite'; export * from '@pixi/spritesheet'; diff --git a/package-lock.json b/package-lock.json index 7fe6db7..0814729 100644 --- a/package-lock.json +++ b/package-lock.json @@ -209,7 +209,7 @@ "argparse": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", - "integrity": "sha1-vNZ5HqWuCXJeF+WtmIE0zUCz2RE=", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", "dev": true, "requires": { "sprintf-js": "1.0.3" @@ -228,7 +228,7 @@ "arr-flatten": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz", - "integrity": "sha1-NgSLv/TntH4TZkQxbJlmnqWukfE=", + "integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==", "dev": true }, "arr-union": { @@ -297,7 +297,7 @@ "assertion-error": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", - "integrity": "sha1-5gtrDo8wG9l+U3UhW9pAbIURjAs=", + "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", "dev": true }, "async": { @@ -396,7 +396,7 @@ "brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha1-PH/L9SnYcibz0vUrlm/1Jx60Qd0=", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, "requires": { "balanced-match": "1.0.0", @@ -568,7 +568,7 @@ "circular-json": { "version": "0.3.3", "resolved": "https://registry.npmjs.org/circular-json/-/circular-json-0.3.3.tgz", - "integrity": "sha1-gVyZ6oT2gJUp0vRXkb34JxE1LWY=", + "integrity": "sha512-UZK3NBx2Mca+b5LsG7bY183pHWt5Y1xts4P3Pz7ENTwGVnJOUWbRb3ocjvX7hx9tq/yTAdclXm9sZ38gNuem4A==", "dev": true }, "cli-cursor": { @@ -638,7 +638,7 @@ "color-convert": { "version": "1.9.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.1.tgz", - "integrity": "sha1-wSYRB66y8pTr/+ye2eytUppgl+0=", + "integrity": "sha512-mjGanIiwQJskCC18rPR6OmrZ6fm2Lc7PeGFYwCmy5J34wC6F1PzdGL6xeMfmgicfYcNLGuVFA3WzXtIDCQSZxQ==", "dev": true, "requires": { "color-name": "1.1.3" @@ -1427,7 +1427,7 @@ "boom": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/boom/-/boom-5.2.0.tgz", - "integrity": "sha1-XdnabuOl8wIHdDYpDLcX0/SlTgI=", + "integrity": "sha512-Z5BTk6ZRe4tXXQlkqftmsAUANpXmuwlsF5Oov8ThoMbQRzdGTA1ngYRW160GexgOgjsFOKJz0LYhoNi+2AMBUw==", "dev": true, "requires": { "hoek": "4.2.1" @@ -1471,7 +1471,7 @@ "debug": { "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha1-XRKFFd8TT/Mn6QpMk/Tgd6U2NB8=", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", "dev": true, "requires": { "ms": "2.0.0" @@ -1585,7 +1585,7 @@ "doctrine": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", - "integrity": "sha1-XNAfwQFiG0LEzX9dGmYkNxbT850=", + "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", "dev": true, "requires": { "esutils": "2.0.2" @@ -1662,7 +1662,7 @@ "es6-promise": { "version": "4.2.4", "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.4.tgz", - "integrity": "sha1-3EIhwrFlGHYL2MOaUtjzVvwA7Sk=", + "integrity": "sha512-/NdNZVJg+uZgtm9eS3O6lrOLYmQag2DjdEXuPaHlZ6RuVqgqaVZfgYCepEIKsLqwdQArOPtC3XzRLqGGfT8KQQ==", "dev": true }, "escape-string-regexp": { @@ -1788,7 +1788,7 @@ "espree": { "version": "3.5.4", "resolved": "https://registry.npmjs.org/espree/-/espree-3.5.4.tgz", - "integrity": "sha1-sPRHGHyKi+2US4FaZgvd9d610ac=", + "integrity": "sha512-yAcIQxtmMiB/jL32dzEp2enBeidsB7xWPLNiw3IIkpVds1P+h7qF9YwJq1yUNzp2OKXgAprs4F61ih66UsoD1A==", "dev": true, "requires": { "acorn": "5.5.0", @@ -1798,7 +1798,7 @@ "esprima": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.0.tgz", - "integrity": "sha1-RJnt3NERDgshi6zy+n9/WfVcqAQ=", + "integrity": "sha512-oftTcaMu/EGrEIu904mWteKIv8vMuOgGYo7EhVJJN00R/EED9DCua/xxHRdYnKtcECzVg7xOWhflvJMnqcFZjw==", "dev": true }, "esquery": { @@ -1813,7 +1813,7 @@ "esrecurse": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.2.1.tgz", - "integrity": "sha1-AHo7n9vCs7uH5IeeoZyS/b05Qs8=", + "integrity": "sha512-64RBB++fIOAXPw3P9cy89qfMlvZEXZkqqJkjqqXIvzP5ezRZjW+lPWjw35UX/3EhUPFYbg5ER4JYgDw4007/DQ==", "dev": true, "requires": { "estraverse": "4.2.0" @@ -2024,7 +2024,7 @@ "find-root": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/find-root/-/find-root-1.1.0.tgz", - "integrity": "sha1-q8/Iunb3CMQql7PWhbfpRQv7nOQ=", + "integrity": "sha512-NKfW6bec6GfKc0SGx1e07QZY9PE99u0Bft/0rzSD5k3sO/vwkVUpDUKVm5Gpp5Ue3YfShPFTX2070tDs5kB9Ng==", "dev": true }, "find-up": { @@ -2103,7 +2103,7 @@ "supports-color": { "version": "5.3.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.3.0.tgz", - "integrity": "sha1-WySsFduA+pJ89SJ6SjP9PEx2dsA=", + "integrity": "sha512-0aP01LLIskjKs3lq52EC0aGBAJhLq7B2Rd8HC/DR/PtNNpcLilNmHC12O+hu0usQpo7wtHNRqtrhBwtDb0+dNg==", "dev": true, "requires": { "has-flag": "3.0.0" @@ -2567,7 +2567,7 @@ "glob": { "version": "7.1.2", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", - "integrity": "sha1-wZyd+aAocC1nhhI4SmVSQExjbRU=", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", "dev": true, "requires": { "fs.realpath": "1.0.0", @@ -2672,7 +2672,7 @@ "growl": { "version": "1.10.3", "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.3.tgz", - "integrity": "sha1-GSa6kM8+3+KttJJ/WIC8IsZseQ8=", + "integrity": "sha512-hKlsbA5Vu3xsh1Cg3J7jSmX/WaW6A5oBeqzM88oNbCRQFz+zUaXm6yxS4RVytp1scBoJzSYl4YAEOQIt6O8V1Q==", "dev": true }, "handlebars": { @@ -2738,7 +2738,7 @@ "hawk": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/hawk/-/hawk-6.0.2.tgz", - "integrity": "sha1-r02RTrBl+bXOTZ0RwcshJu7MMDg=", + "integrity": "sha512-miowhl2+U7Qle4vdLqDdPt9m09K6yZhkLDTWGoUiUzrQCn+mHHSmfJgAyGaLRZbPmTqfFFjRV1QWCW0VWUJBbQ==", "dev": true, "requires": { "boom": "4.3.1", @@ -2756,7 +2756,7 @@ "hoek": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/hoek/-/hoek-4.2.1.tgz", - "integrity": "sha1-ljRQKqEsRF3Vp8VzS1cruHOKrLs=", + "integrity": "sha512-QLg82fGkfnJ/4iy1xZ81/9SIJiq1NGFUMGs6ParyjBZr6jW2Ufj/snDqTHixNlHdPNwN2RLVD0Pi3igeK9+JfA==", "dev": true }, "home-path": { @@ -2791,7 +2791,7 @@ "ignore": { "version": "3.3.7", "resolved": "https://registry.npmjs.org/ignore/-/ignore-3.3.7.tgz", - "integrity": "sha1-YSKJv7PCIOGGpYEYYY1b6MG6sCE=", + "integrity": "sha512-YGG3ejvBNHRqu0559EOxxNFihD0AjpvHlC/pdGKd3X3ofe+CoJkYazwNJYTNebqpPKN+VVQbh4ZFn1DivMNuHA==", "dev": true }, "imurmurhash": { @@ -2828,7 +2828,7 @@ "ini": { "version": "1.3.5", "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", - "integrity": "sha1-7uJfVtscnsYIXgwid4CD9Zar+Sc=", + "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==", "dev": true }, "inquirer": { @@ -2901,7 +2901,7 @@ "is-buffer": { "version": "1.1.6", "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", - "integrity": "sha1-76ouqdqg16suoTqXsritUf776L4=", + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", "dev": true }, "is-builtin-module": { @@ -3054,7 +3054,7 @@ "is-resolvable": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/is-resolvable/-/is-resolvable-1.1.0.tgz", - "integrity": "sha1-+xj4fOH+uSUWnJpAfBkxijIG7Yg=", + "integrity": "sha512-qgDYXFSR5WvEfuS5dMj6oTMEbrrSaM0CrFk2Yiq/gXnBvD9pMa2jGXxyhGLfvhZpuMZe18CJpFxAt3CRs42NMg==", "dev": true }, "is-retry-allowed": { @@ -3204,7 +3204,7 @@ "js-yaml": { "version": "3.11.0", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.11.0.tgz", - "integrity": "sha1-WXwai9VxUvJtYizkEXhRpR9euu8=", + "integrity": "sha512-saJstZWv7oNeOyBh3+Dx1qWzhW0+e6/8eDzo7p5rDFqxntSztloLtuKu+Ejhtq82jsilwOIZYsCz+lIjthg1Hw==", "dev": true, "requires": { "argparse": "1.0.10", @@ -3324,7 +3324,7 @@ "just-extend": { "version": "1.1.27", "resolved": "https://registry.npmjs.org/just-extend/-/just-extend-1.1.27.tgz", - "integrity": "sha1-7G55QQ/5FORyZSq/oOYDwD1g6QU=", + "integrity": "sha512-mJVp13Ix6gFo3SBAy9U/kL+oeZqzlYYYLQBwXVBlVzIsZwBqGREnOro24oC/8s8aox+rJhtZ2DiQof++IrkA+g==", "dev": true }, "kind-of": { @@ -3703,7 +3703,7 @@ "lodash": { "version": "4.17.5", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.5.tgz", - "integrity": "sha1-maktZcAnLevoyWtgV7yPv6O+1RE=", + "integrity": "sha512-svL3uiZf1RwhH+cWrfZn3A4+U58wbP0tGVTLQPbjplZxZ8ROD9VLuNgsRniTlLe7OlSqR79RUehXgpBW/s0IQw==", "dev": true }, "lodash._reinterpolate": { @@ -3740,7 +3740,7 @@ "lolex": { "version": "2.3.2", "resolved": "https://registry.npmjs.org/lolex/-/lolex-2.3.2.tgz", - "integrity": "sha1-hflFBCUQO/nnpgZo6iXcQydMqAc=", + "integrity": "sha512-A5pN2tkFj7H0dGIAM6MFvHKMJcPnjZsOMvR7ujCjfgW5TbV6H9vb1PgxLtHvjqNZTHsUolz+6/WEO0N1xNx2ng==", "dev": true }, "longest": { @@ -3816,7 +3816,7 @@ "marked": { "version": "0.3.17", "resolved": "https://registry.npmjs.org/marked/-/marked-0.3.17.tgz", - "integrity": "sha1-YH8GZos8axJGso8T2nYRasGqLSs=", + "integrity": "sha512-+AKbNsjZl6jFfLPwHhWmGTqE009wTKn3RTmn9K8oUKHrX/abPJjtcRtXpYB/FFrwPJRUA86LX/de3T0knkPCmQ==", "dev": true }, "mem": { @@ -3896,13 +3896,13 @@ "mime-db": { "version": "1.33.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.33.0.tgz", - "integrity": "sha1-o0kgUKXLm2NFBUHjnZeI0icng9s=", + "integrity": "sha512-BHJ/EKruNIqJf/QahvxwQZXKygOQ256myeN/Ew+THcAa5q+PjyTTMMeNQC4DZw5AwfvelsUrA6B67NKMqXDbzQ==", "dev": true }, "mime-types": { "version": "2.1.18", "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.18.tgz", - "integrity": "sha1-bzI/YKg9ERRvgx/xH9ZuL+VQO7g=", + "integrity": "sha512-lc/aahn+t4/SWV/qcmumYjymLsWfN3ELhpmVuUFjgsORruuZPVSwAQryq+HHGvO/SI2KVX26bx+En+zhM8g8hQ==", "dev": true, "requires": { "mime-db": "1.33.0" @@ -3917,7 +3917,7 @@ "minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha1-UWbihkV/AzBgZL5Ul+jbsMPTIIM=", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "dev": true, "requires": { "brace-expansion": "1.1.11" @@ -4071,7 +4071,7 @@ "normalize-package-data": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.4.0.tgz", - "integrity": "sha1-EvlaMH1YNSB1oEkHuErIvpisAS8=", + "integrity": "sha512-9jjUFbTPfEy3R/ad/2oNbKtW9Hgovl5O1FvFWKkKblNXoN/Oou6+9+KKohPK13Yc3/TyunyWhJp6gvRNR/PPAw==", "dev": true, "requires": { "hosted-git-info": "2.5.0", @@ -4511,7 +4511,7 @@ "process-nextick-args": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", - "integrity": "sha1-o31zL0JxtKsa0HDTVQjoKQeI/6o=", + "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==", "dev": true }, "progress": { @@ -4584,7 +4584,7 @@ "qs": { "version": "6.5.1", "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.1.tgz", - "integrity": "sha1-NJzfbu+J7EXBLX1es/wMhwNDptg=", + "integrity": "sha512-eRzhrN1WSINYCDCbrz796z37LOe3m5tmW7RQf6oBntukAG1nmovJvhnwHHRMAfeoItc1m2Hk02WER2aQ/iqs+A==", "dev": true }, "quick-lru": { @@ -4596,7 +4596,7 @@ "randomatic": { "version": "1.1.7", "resolved": "https://registry.npmjs.org/randomatic/-/randomatic-1.1.7.tgz", - "integrity": "sha1-x6vpzIuHwLqodrGf3oP9RkeX44w=", + "integrity": "sha512-D5JUjPyJbaJDkuAazpVnSfVkLlpeO3wDlPROTMLGKG1zMFNFRgrciKo1ltz/AzNTkqE0HzDx655QOL51N06how==", "dev": true, "requires": { "is-number": "3.0.0", @@ -4701,7 +4701,7 @@ "regex-cache": { "version": "0.4.4", "resolved": "https://registry.npmjs.org/regex-cache/-/regex-cache-0.4.4.tgz", - "integrity": "sha1-db3FiioUls7EihKDW8VMjVYjNt0=", + "integrity": "sha512-nVIZwtCjkC9YgvWkpM55B5rBhBYRZhAaJbgcFYXXsHnbZ9UZI9nnVWYZpBlCqv9ho2eZryPnWrZGsOdPwVWXWQ==", "dev": true, "requires": { "is-equal-shallow": "0.1.3" @@ -4729,7 +4729,7 @@ "remap-istanbul": { "version": "0.10.1", "resolved": "https://registry.npmjs.org/remap-istanbul/-/remap-istanbul-0.10.1.tgz", - "integrity": "sha1-OqWN1QIdSZ8zbTulvzu7kcG4jjc=", + "integrity": "sha512-gsNQXs5kJLhErICSyYhzVZ++C8LBW8dgwr874Y2QvzAUS75zBlD/juZgXs39nbYJ09fZDlX2AVLVJAY2jbFJoQ==", "dev": true, "requires": { "amdefine": "1.0.1", @@ -4769,7 +4769,7 @@ "source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha1-dHIq8y6WFOnCh6jQu95IteLxomM=", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", "dev": true }, "through2": { @@ -4883,7 +4883,7 @@ "resolve": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.5.0.tgz", - "integrity": "sha1-HwmsznlsmnYlefMbLBzEw83fnzY=", + "integrity": "sha512-hgoSGrc3pjzAPHNBg+KnFcK2HwlHTs/YrAGUr6qgTVUZmXv1UEXXl0bZNBKMA9fud6lRYFdPGz0xXxycPzmmiw==", "dev": true, "requires": { "path-parse": "1.0.5" @@ -4924,7 +4924,7 @@ "rimraf": { "version": "2.6.2", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", - "integrity": "sha1-LtgVDSShbqhlHm1u8PR8QVjOejY=", + "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", "dev": true, "requires": { "glob": "7.1.2" @@ -5063,19 +5063,19 @@ "safe-buffer": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", - "integrity": "sha1-iTMSr2myEj3vcfV4iQAWce6yyFM=", + "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", "dev": true }, "samsam": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/samsam/-/samsam-1.3.0.tgz", - "integrity": "sha1-jR2TUOJWItow3j5EumkrUiGrfFA=", + "integrity": "sha512-1HwIYD/8UlOtFS3QO3w7ey+SdSDFE4HRNLZoZRYVQefrOY3l17epswImeB1ijgJFQJodIaHcwkp3r/myBjFVbg==", "dev": true }, "semver": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz", - "integrity": "sha1-3Eu8emyp2Rbe5dQ1FvAJK1j3uKs=", + "integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==", "dev": true }, "set-blocking": { @@ -5117,7 +5117,7 @@ "sinon-chai": { "version": "2.14.0", "resolved": "https://registry.npmjs.org/sinon-chai/-/sinon-chai-2.14.0.tgz", - "integrity": "sha1-2n3UzIPNaiYLZ8yg96n9riahIF0=", + "integrity": "sha512-9stIF1utB0ywNHNT7RgiXbdmen8QDCRsrTjw+G9TgKt1Yexjiv8TOWZ6WHsTPz57Yky3DIswZvEqX8fpuHNDtQ==", "dev": true }, "slash": { @@ -5146,7 +5146,7 @@ "sntp": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/sntp/-/sntp-2.1.0.tgz", - "integrity": "sha1-LGzsFP7cIiJznK+bXD2F0cxaLMg=", + "integrity": "sha512-FL1b58BDrqS3A11lJ0zEdnJ3UOKqVxawAkF3k7F0CVN7VQ34aZrV+G8BZ1WC9ZL7NyrwsW0oviwsWDgRuVYtJg==", "dev": true, "requires": { "hoek": "4.2.1" @@ -5203,7 +5203,7 @@ "spdx-correct": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.0.0.tgz", - "integrity": "sha1-BaW01xU6GVvJLDxCW2nzsqlSTII=", + "integrity": "sha512-N19o9z5cEyc8yQQPukRCZ9EUmb4HUpnrmaL/fxS2pBo2jbfcFRVuFZ/oFC+vZz0MNNk0h80iMn5/S6qGZOL5+g==", "dev": true, "requires": { "spdx-expression-parse": "3.0.0", @@ -5213,13 +5213,13 @@ "spdx-exceptions": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.1.0.tgz", - "integrity": "sha1-LHrmEFbHFKW5ubKyr30xHvXHj+k=", + "integrity": "sha512-4K1NsmrlCU1JJgUrtgEeTVyfx8VaYea9J9LvARxhbHtVtohPs/gFGG5yy49beySjlIMhhXZ4QqujIZEfS4l6Cg==", "dev": true }, "spdx-expression-parse": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.0.tgz", - "integrity": "sha1-meEZt6XaAOBUkcn6M4t5BII7QdA=", + "integrity": "sha512-Yg6D3XpRD4kkOmTpdgbUiEJFKghJH03fiC1OPll5h/0sO6neh2jqRDVHOQ4o/LMea0tgCkbMgea5ip/e+MkWyg==", "dev": true, "requires": { "spdx-exceptions": "2.1.0", @@ -5229,7 +5229,7 @@ "spdx-license-ids": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.0.tgz", - "integrity": "sha1-enzShHDMbToc/m1miG9rxDDTrIc=", + "integrity": "sha512-2+EPwgbnmOIl8HjGBXXMd9NAu02vLjOO1nWw4kmeRDFyHn+M/ETfHxQUK0oXg8ctgVnl9t3rosNVsZ1jG61nDA==", "dev": true }, "speedometer": { @@ -5566,7 +5566,7 @@ "tough-cookie": { "version": "2.3.4", "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.4.tgz", - "integrity": "sha1-7GDO44rGdQY//JelwYlwV47oNlU=", + "integrity": "sha512-TZ6TTfI5NtZnuyy/Kecv+CnoROnyXn2DN97LontgQpCwsX2XyLYCC0ENhYkehSOwAp8rTQKc/NUIF7BkQ5rKLA==", "dev": true, "requires": { "punycode": "1.4.1" @@ -5708,13 +5708,13 @@ "uuid": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.2.1.tgz", - "integrity": "sha1-EsUou51Y0LkmXZovbw/ovhf/HxQ=", + "integrity": "sha512-jZnMwlb9Iku/O3smGWvZhauCf6cvvpKi4BKRiliS3cxnI+Gz9j5MEpTz2UFuXiKPJocb7gnsLHwiS05ige5BEA==", "dev": true }, "validate-npm-package-license": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.3.tgz", - "integrity": "sha1-gWQ7y+8b3+zUYjeT3EZIlIupgzg=", + "integrity": "sha512-63ZOUnL4SIXj4L0NixR3L1lcjO38crAbgrTpl28t8jjrfuiOBL5Iygm+60qPs/KsZGzPNg6Smnc/oY16QTjF0g==", "dev": true, "requires": { "spdx-correct": "3.0.0", @@ -5750,7 +5750,7 @@ "which": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/which/-/which-1.3.0.tgz", - "integrity": "sha1-/wS9/AEO5UfXgL7DjhrBwnd9JTo=", + "integrity": "sha512-xcJpopdamTuY5duC/KnTTNBraPK54YwpenP4lzxU8H91GudWpFv38u0CKjclE1Wi2EH2EDz5LRcHcKbCIzqGyg==", "dev": true, "requires": { "isexe": "2.0.0" diff --git a/packages/canvas/canvas-mesh/package.json b/packages/canvas/canvas-mesh/package.json index 691cd2c..6744a17 100644 --- a/packages/canvas/canvas-mesh/package.json +++ b/packages/canvas/canvas-mesh/package.json @@ -24,6 +24,7 @@ "dependencies": { "@pixi/constants": "^5.0.0-alpha.2", "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/mesh-extras": "^5.0.0-alpha.2", "@pixi/settings": "^5.0.0-alpha.2" }, "devDependencies": { diff --git a/packages/canvas/canvas-mesh/src/Mesh.js b/packages/canvas/canvas-mesh/src/Mesh.js index 900a872..c43a74b 100644 --- a/packages/canvas/canvas-mesh/src/Mesh.js +++ b/packages/canvas/canvas-mesh/src/Mesh.js @@ -1,36 +1,14 @@ import { Mesh } from '@pixi/mesh'; -import { settings } from './settings'; - -// IMPORTANT: Please do NOT use this as a precedent to use `settings` after the object is created -// this was merely created to completely decouple canvas from the base Mesh class and we are -// unable to add `canvasPadding` in the constructor anymore, as the case was for PixiJS v4. /** - * Internal variable for `canvasPadding`. + * Renders the object using the Canvas renderer * * @private - * @memberof PIXI.Mesh - * @member {number} - * @default null - */ -Mesh.prototype._canvasPadding = null; - -/** - * Triangles in canvas mode are automatically antialiased, use this value to force triangles - * to overlap a bit with each other. To set the global default, set {@link PIXI.settings.MESH_CANVAS_PADDING} - * - * @see PIXI.settings.MESH_CANVAS_PADDING - * @member {number} canvasPadding + * @method _renderCanvas * @memberof PIXI.Mesh# - * @default 0 + * @param {PIXI.CanvasRenderer} renderer - The canvas renderer. */ -Object.defineProperty(Mesh.prototype, 'canvasPadding', { - get() - { - return this._canvasPadding !== null ? this._canvasPadding : settings.MESH_CANVAS_PADDING; - }, - set(value) - { - this._canvasPadding = value; - }, -}); +Mesh.prototype._renderCanvas = function _renderCanvas(renderer) +{ + renderer.plugins[this.pluginName].render(this); +}; diff --git a/packages/canvas/canvas-mesh/src/Mesh2d.js b/packages/canvas/canvas-mesh/src/Mesh2d.js new file mode 100644 index 0000000..d0bd80f --- /dev/null +++ b/packages/canvas/canvas-mesh/src/Mesh2d.js @@ -0,0 +1,36 @@ +import { Mesh2d } from '@pixi/mesh-extras'; +import { settings } from './settings'; + +// IMPORTANT: Please do NOT use this as a precedent to use `settings` after the object is created +// this was merely created to completely decouple canvas from the base Mesh class and we are +// unable to add `canvasPadding` in the constructor anymore, as the case was for PixiJS v4. + +/** + * Internal variable for `canvasPadding`. + * + * @private + * @memberof PIXI.Mesh2d + * @member {number} + * @default null + */ +Mesh2d.prototype._canvasPadding = null; + +/** + * Triangles in canvas mode are automatically antialiased, use this value to force triangles + * to overlap a bit with each other. To set the global default, set {@link PIXI.settings.MESH_CANVAS_PADDING} + * + * @see PIXI.settings.MESH_CANVAS_PADDING + * @member {number} canvasPadding + * @memberof PIXI.Mesh2d# + * @default 0 + */ +Object.defineProperty(Mesh2d.prototype, 'canvasPadding', { + get() + { + return this._canvasPadding !== null ? this._canvasPadding : settings.MESH_CANVAS_PADDING; + }, + set(value) + { + this._canvasPadding = value; + }, +}); diff --git a/packages/canvas/canvas-mesh/src/NineSlicePlane.js b/packages/canvas/canvas-mesh/src/NineSlicePlane.js index 09eaf9c..2fd5acc 100644 --- a/packages/canvas/canvas-mesh/src/NineSlicePlane.js +++ b/packages/canvas/canvas-mesh/src/NineSlicePlane.js @@ -1,4 +1,4 @@ -import { NineSlicePlane } from '@pixi/mesh'; +import { NineSlicePlane } from '@pixi/mesh-extras'; /** * Renders the object using the Canvas renderer diff --git a/packages/canvas/canvas-mesh/src/RawMesh.js b/packages/canvas/canvas-mesh/src/RawMesh.js deleted file mode 100644 index bf40184..0000000 --- a/packages/canvas/canvas-mesh/src/RawMesh.js +++ /dev/null @@ -1,14 +0,0 @@ -import { RawMesh } from '@pixi/mesh'; - -/** - * Renders the object using the Canvas renderer - * - * @private - * @method _renderCanvas - * @memberof PIXI.RawMesh# - * @param {PIXI.CanvasRenderer} renderer - The canvas renderer. - */ -RawMesh.prototype._renderCanvas = function _renderCanvas(renderer) -{ - renderer.plugins[this.pluginName].render(this); -}; diff --git a/packages/canvas/canvas-mesh/src/index.js b/packages/canvas/canvas-mesh/src/index.js index 2295016..f4fa31d 100644 --- a/packages/canvas/canvas-mesh/src/index.js +++ b/packages/canvas/canvas-mesh/src/index.js @@ -1,6 +1,6 @@ export { default as CanvasMeshRenderer } from './CanvasMeshRenderer'; import './settings'; -import './Mesh'; +import './Mesh2d'; import './NineSlicePlane'; -import './RawMesh'; +import './Mesh'; diff --git a/packages/canvas/canvas-mesh/src/settings.js b/packages/canvas/canvas-mesh/src/settings.js index 4cefb4c..e81b8e0 100644 --- a/packages/canvas/canvas-mesh/src/settings.js +++ b/packages/canvas/canvas-mesh/src/settings.js @@ -3,7 +3,7 @@ /** * Default `canvasPadding` for canvas-based Mesh rendering. * - * @see PIXI.Mesh#canvasPadding + * @see PIXI.Mesh2d#canvasPadding * @static * @constant * @memberof PIXI.settings diff --git a/packages/mesh-extras/LICENSE b/packages/mesh-extras/LICENSE new file mode 100644 index 0000000..148e3eb --- /dev/null +++ b/packages/mesh-extras/LICENSE @@ -0,0 +1,21 @@ +The MIT License + +Copyright (c) 2013-2018 Mathew Groves, Chad Engler + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/packages/mesh-extras/README.md b/packages/mesh-extras/README.md new file mode 100644 index 0000000..1d9b0e1 --- /dev/null +++ b/packages/mesh-extras/README.md @@ -0,0 +1,19 @@ +# @pixi/mesh-extras + +## Installation + +```bash +npm install @pixi/mesh-extras +``` + +## Usage + +```js +import { MeshRenderer } from '@pixi/mesh'; +import { Renderer } from '@pixi/core'; +import { Rope } from '@pixi/mesh-extras'; + +Renderer.registerPlugin('mesh', MeshRenderer); + +const rope = new Rope(); +``` \ No newline at end of file diff --git a/packages/mesh-extras/package.json b/packages/mesh-extras/package.json new file mode 100644 index 0000000..d134f64 --- /dev/null +++ b/packages/mesh-extras/package.json @@ -0,0 +1,38 @@ +{ + "name": "@pixi/mesh-extras", + "version": "5.0.0-alpha.2", + "main": "lib/mesh-extras.js", + "module": "lib/mesh-extras.es.js", + "description": "Custom Mesh display objects, like Rope and Plane", + "author": "Mat Groves", + "contributors": [ + "Matt Karl " + ], + "homepage": "http://pixijs.com/", + "bugs": "https://github.com/pixijs/pixi.js/issues", + "license": "MIT", + "repository": { + "type": "git", + "url": "https://github.com/pixijs/pixi.js.git" + }, + "publishConfig": { + "access": "public" + }, + "scripts": { + "test": "floss --path test" + }, + "files": [ + "lib" + ], + "dependencies": { + "@pixi/constants": "^5.0.0-alpha.2", + "@pixi/core": "^5.0.0-alpha.2", + "@pixi/math": "^5.0.0-alpha.2", + "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/utils": "^5.0.0-alpha.2" + }, + "devDependencies": { + "@pixi/loaders": "^5.0.0-alpha.2", + "floss": "^2.1.3" + } +} diff --git a/packages/mesh-extras/src/Mesh2d.js b/packages/mesh-extras/src/Mesh2d.js new file mode 100644 index 0000000..d113a5e --- /dev/null +++ b/packages/mesh-extras/src/Mesh2d.js @@ -0,0 +1,263 @@ +import { Mesh } from '@pixi/mesh'; +import { Geometry, Program, Shader, Texture, TextureMatrix } from '@pixi/core'; +import { Matrix } from '@pixi/math'; +import { BLEND_MODES } from '@pixi/constants'; +import { hex2rgb, premultiplyRgba } from '@pixi/utils'; +import vertex from './mesh.vert'; +import fragment from './mesh.frag'; + +let meshProgram; + +/** + * Base mesh class + * @class + * @extends PIXI.Container + * @memberof PIXI + */ +export default class Mesh2d extends Mesh +{ + /** + * @param {PIXI.Texture} [texture=Texture.EMPTY] - The texture to use + * @param {Float32Array} [vertices] - if you want to specify the vertices + * @param {Float32Array} [uvs] - if you want to specify the uvs + * @param {Uint16Array} [indices] - if you want to specify the indices + * @param {number} [drawMode] - the drawMode, can be any of the Mesh.DRAW_MODES consts + */ + constructor(texture = Texture.EMPTY, vertices, uvs, indices, drawMode) + { + const geometry = new Geometry(); + + if (!meshProgram) + { + meshProgram = new Program(vertex, fragment); + } + + geometry.addAttribute('aVertexPosition', vertices) + .addAttribute('aTextureCoord', uvs) + .addIndex(indices); + + geometry.getAttribute('aVertexPosition').static = false; + + const uniforms = { + uSampler: texture, + uTextureMatrix: Matrix.IDENTITY, + alpha: 1, + uColor: new Float32Array([1, 1, 1, 1]), + }; + + super(geometry, new Shader(meshProgram, uniforms), null, drawMode); + + /** + * The Uvs of the Mesh + * + * @member {Float32Array} + */ + this.uvs = geometry.getAttribute('aTextureCoord').data; + + /** + * An array of vertices + * + * @member {Float32Array} + */ + this.vertices = geometry.getAttribute('aVertexPosition').data; + + this.uniforms = uniforms; + + /** + * The texture of the Mesh + * + * @member {PIXI.Texture} + * @default PIXI.Texture.EMPTY + * @private + */ + this.texture = texture; + + /** + * The tint applied to the mesh. This is a [r,g,b] value. A value of [1,1,1] will remove any + * tint effect. + * + * @member {number} + * @private + */ + this._tintRGB = new Float32Array([1, 1, 1]); + + // Set default tint + this.tint = 0xFFFFFF; + + this.blendMode = BLEND_MODES.NORMAL; + + /** + * TextureMatrix instance for this Mesh, used to track Texture changes + * + * @member {PIXI.TextureMatrix} + * @readonly + */ + this.uvMatrix = new TextureMatrix(this._texture); + + /** + * whether or not upload uvMatrix to shader + * if its false, then uvs should be pre-multiplied + * if you change it for generated mesh, please call 'refresh(true)' + * @member {boolean} + * @default false + */ + this.uploadUvMatrix = false; + + /** + * Uploads vertices buffer every frame, like in PixiJS V3 and V4. + * + * @member {boolean} + * @default true + */ + this.autoUpdate = true; + } + + /** + * The tint applied to the Rope. This is a hex value. A value of + * 0xFFFFFF will remove any tint effect. + * + * @member {number} + * @memberof PIXI.Sprite# + * @default 0xFFFFFF + */ + get tint() + { + return this._tint; + } + + /** + * Sets the tint of the rope. + * + * @param {number} value - The value to set to. + */ + set tint(value) + { + this._tint = value; + + hex2rgb(this._tint, this._tintRGB); + } + + /** + * The blend mode to be applied to the sprite. Set to `PIXI.BLEND_MODES.NORMAL` to remove any blend mode. + * + * @member {number} + * @default PIXI.BLEND_MODES.NORMAL + * @see PIXI.BLEND_MODES + */ + get blendMode() + { + return this.state.blendMode; + } + + set blendMode(value) // eslint-disable-line require-jsdoc + { + this.state.blendMode = value; + } + + /** + * The texture that the mesh uses. + * + * @member {PIXI.Texture} + */ + get texture() + { + return this._texture; + } + + set texture(value) // eslint-disable-line require-jsdoc + { + if (this._texture === value) + { + return; + } + + this._texture = value; + this.uniforms.uSampler = this.texture; + + if (value) + { + // wait for the texture to load + if (value.baseTexture.valid) + { + this._onTextureUpdate(); + } + else + { + value.once('update', this._onTextureUpdate, this); + } + } + } + + _render(renderer) + { + const baseTex = this._texture.baseTexture; + + premultiplyRgba(this._tintRGB, this.worldAlpha, this.uniforms.uColor, baseTex.premultiplyAlpha); + super._render(renderer); + } + /** + * When the texture is updated, this event will fire to update the scale and frame + * + * @private + */ + _onTextureUpdate() + { + // constructor texture update stop + if (!this.uvMatrix) + { + return; + } + this.uvMatrix.texture = this._texture; + this.refresh(); + } + + /** + * multiplies uvs only if uploadUvMatrix is false + * call it after you change uvs manually + * make sure that texture is valid + */ + multiplyUvs() + { + if (!this.uploadUvMatrix) + { + this.uvMatrix.multiplyUvs(this.uvs); + } + } + + /** + * Refreshes uvs for generated meshes (rope, plane) + * sometimes refreshes vertices too + * + * @param {boolean} [forceUpdate=false] if true, matrices will be updated any case + */ + refresh(forceUpdate) + { + if (this.uvMatrix.update(forceUpdate)) + { + this._refresh(); + } + } + + /** + * Updates the object transform for rendering + * + * @private + */ + updateTransform() + { + if (this.autoUpdate) + { + this.geometry.buffers[0].update(); + } + this.containerUpdateTransform(); + } + + /** + * re-calculates mesh coords + * @private + */ + _refresh() + { + /* empty */ + } +} diff --git a/packages/mesh-extras/src/NineSlicePlane.js b/packages/mesh-extras/src/NineSlicePlane.js new file mode 100644 index 0000000..0bae92c --- /dev/null +++ b/packages/mesh-extras/src/NineSlicePlane.js @@ -0,0 +1,270 @@ +import Plane from './Plane'; + +const DEFAULT_BORDER_SIZE = 10; + +/** + * The NineSlicePlane allows you to stretch a texture using 9-slice scaling. The corners will remain unscaled (useful + * for buttons with rounded corners for example) and the other areas will be scaled horizontally and or vertically + * + *```js + * let Plane9 = new PIXI.NineSlicePlane(PIXI.Texture.from('BoxWithRoundedCorners.png'), 15, 15, 15, 15); + * ``` + *
+ *      A                          B
+ *    +---+----------------------+---+
+ *  C | 1 |          2           | 3 |
+ *    +---+----------------------+---+
+ *    |   |                      |   |
+ *    | 4 |          5           | 6 |
+ *    |   |                      |   |
+ *    +---+----------------------+---+
+ *  D | 7 |          8           | 9 |
+ *    +---+----------------------+---+
+
+ *  When changing this objects width and/or height:
+ *     areas 1 3 7 and 9 will remain unscaled.
+ *     areas 2 and 8 will be stretched horizontally
+ *     areas 4 and 6 will be stretched vertically
+ *     area 5 will be stretched both horizontally and vertically
+ * 
+ * + * @class + * @extends PIXI.Plane + * @memberof PIXI + * + */ +export default class NineSlicePlane extends Plane +{ + /** + * @param {PIXI.Texture} texture - The texture to use on the NineSlicePlane. + * @param {int} [leftWidth=10] size of the left vertical bar (A) + * @param {int} [topHeight=10] size of the top horizontal bar (C) + * @param {int} [rightWidth=10] size of the right vertical bar (B) + * @param {int} [bottomHeight=10] size of the bottom horizontal bar (D) + */ + constructor(texture, leftWidth, topHeight, rightWidth, bottomHeight) + { + super(texture, 4, 4); + + this._origWidth = texture.orig.width; + this._origHeight = texture.orig.height; + + /** + * The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._width = this._origWidth; + + /** + * The height of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._height = this._origHeight; + + /** + * The width of the left column (a) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._leftWidth = typeof leftWidth !== 'undefined' ? leftWidth : DEFAULT_BORDER_SIZE; + + /** + * The width of the right column (b) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._rightWidth = typeof rightWidth !== 'undefined' ? rightWidth : DEFAULT_BORDER_SIZE; + + /** + * The height of the top row (c) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._topHeight = typeof topHeight !== 'undefined' ? topHeight : DEFAULT_BORDER_SIZE; + + /** + * The height of the bottom row (d) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._bottomHeight = typeof bottomHeight !== 'undefined' ? bottomHeight : DEFAULT_BORDER_SIZE; + + this.refresh(true); + } + + /** + * Updates the horizontal vertices. + * + */ + updateHorizontalVertices() + { + const vertices = this.vertices; + + const h = this._topHeight + this._bottomHeight; + const scale = this._height > h ? 1.0 : this._height / h; + + vertices[9] = vertices[11] = vertices[13] = vertices[15] = this._topHeight * scale; + vertices[17] = vertices[19] = vertices[21] = vertices[23] = this._height - (this._bottomHeight * scale); + vertices[25] = vertices[27] = vertices[29] = vertices[31] = this._height; + } + + /** + * Updates the vertical vertices. + * + */ + updateVerticalVertices() + { + const vertices = this.vertices; + + const w = this._leftWidth + this._rightWidth; + const scale = this._width > w ? 1.0 : this._width / w; + + vertices[2] = vertices[10] = vertices[18] = vertices[26] = this._leftWidth * scale; + vertices[4] = vertices[12] = vertices[20] = vertices[28] = this._width - (this._rightWidth * scale); + vertices[6] = vertices[14] = vertices[22] = vertices[30] = this._width; + } + + /** + * The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + */ + get width() + { + return this._width; + } + + set width(value) // eslint-disable-line require-jsdoc + { + this._width = value; + this._refresh(); + } + + /** + * The height of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + */ + get height() + { + return this._height; + } + + set height(value) // eslint-disable-line require-jsdoc + { + this._height = value; + this._refresh(); + } + + /** + * The width of the left column + * + * @member {number} + */ + get leftWidth() + { + return this._leftWidth; + } + + set leftWidth(value) // eslint-disable-line require-jsdoc + { + this._leftWidth = value; + this._refresh(); + } + + /** + * The width of the right column + * + * @member {number} + */ + get rightWidth() + { + return this._rightWidth; + } + + set rightWidth(value) // eslint-disable-line require-jsdoc + { + this._rightWidth = value; + this._refresh(); + } + + /** + * The height of the top row + * + * @member {number} + */ + get topHeight() + { + return this._topHeight; + } + + set topHeight(value) // eslint-disable-line require-jsdoc + { + this._topHeight = value; + this._refresh(); + } + + /** + * The height of the bottom row + * + * @member {number} + */ + get bottomHeight() + { + return this._bottomHeight; + } + + set bottomHeight(value) // eslint-disable-line require-jsdoc + { + this._bottomHeight = value; + this._refresh(); + } + + /** + * Refreshes NineSlicePlane coords. All of them. + */ + _refresh() + { + super._refresh(); + + const uvs = this.uvs; + const texture = this._texture; + + this._origWidth = texture.orig.width; + this._origHeight = texture.orig.height; + + const _uvw = 1.0 / this._origWidth; + const _uvh = 1.0 / this._origHeight; + + uvs[0] = uvs[8] = uvs[16] = uvs[24] = 0; + uvs[1] = uvs[3] = uvs[5] = uvs[7] = 0; + uvs[6] = uvs[14] = uvs[22] = uvs[30] = 1; + uvs[25] = uvs[27] = uvs[29] = uvs[31] = 1; + + uvs[2] = uvs[10] = uvs[18] = uvs[26] = _uvw * this._leftWidth; + uvs[4] = uvs[12] = uvs[20] = uvs[28] = 1 - (_uvw * this._rightWidth); + uvs[9] = uvs[11] = uvs[13] = uvs[15] = _uvh * this._topHeight; + uvs[17] = uvs[19] = uvs[21] = uvs[23] = 1 - (_uvh * this._bottomHeight); + + this.updateHorizontalVertices(); + this.updateVerticalVertices(); + + this.geometry.buffers[1].update(); + + this.multiplyUvs(); + } +} diff --git a/packages/mesh-extras/src/Plane.js b/packages/mesh-extras/src/Plane.js new file mode 100644 index 0000000..1c240c4 --- /dev/null +++ b/packages/mesh-extras/src/Plane.js @@ -0,0 +1,100 @@ +import Mesh2d from './Mesh2d'; + +/** + * The Plane allows you to draw a texture across several points and them manipulate these points + * + *```js + * for (let i = 0; i < 20; i++) { + * points.push(new PIXI.Point(i * 50, 0)); + * }; + * let Plane = new PIXI.Plane(PIXI.Texture.from("snake.png"), points); + * ``` + * + * @class + * @extends PIXI.Mesh + * @memberof PIXI + * + */ +export default class Plane extends Mesh2d +{ + /** + * @param {PIXI.Texture} texture - The texture to use on the Plane. + * @param {number} verticesX - The number of vertices in the x-axis + * @param {number} verticesY - The number of vertices in the y-axis + * @param {object} [opts] - an options object - add meshWidth and meshHeight, temporary object for PixiJS v5 alpha + */ + constructor(texture, verticesX, verticesY, opts = {}) + { + super(texture, new Float32Array(1), new Float32Array(1), new Uint16Array(1), 4); + + this.verticesX = verticesX || 10; + this.verticesY = verticesY || 10; + + this.meshWidth = opts.meshWidth || 0; + this.meshHeight = opts.meshHeight || 0; + + this.refresh(); + } + + /** + * Refreshes plane coordinates + * @private + */ + _refresh() + { + const texture = this._texture; + const total = this.verticesX * this.verticesY; + const verts = []; + const uvs = []; + const indices = []; + + const segmentsX = this.verticesX - 1; + const segmentsY = this.verticesY - 1; + + const sizeX = (this.meshWidth || texture.width) / segmentsX; + const sizeY = (this.meshHeight || texture.height) / segmentsY; + + for (let i = 0; i < total; i++) + { + const x = (i % this.verticesX); + const y = ((i / this.verticesX) | 0); + + verts.push(x * sizeX, y * sizeY); + + uvs.push(x / segmentsX, y / segmentsY); + } + + // cons + + const totalSub = segmentsX * segmentsY; + + for (let i = 0; i < totalSub; i++) + { + const xpos = i % segmentsX; + const ypos = (i / segmentsX) | 0; + + const value = (ypos * this.verticesX) + xpos; + const value2 = (ypos * this.verticesX) + xpos + 1; + const value3 = ((ypos + 1) * this.verticesX) + xpos; + const value4 = ((ypos + 1) * this.verticesX) + xpos + 1; + + indices.push(value, value2, value3); + indices.push(value2, value4, value3); + } + + this.vertices = new Float32Array(verts); + this.uvs = new Float32Array(uvs); + this.indices = new Uint16Array(indices); + + this.geometry.buffers[0].data = this.vertices; + this.geometry.buffers[1].data = this.uvs; + this.geometry.indexBuffer.data = this.indices; + + // ensure that the changes are uploaded + this.geometry.buffers[0].update(); + this.geometry.buffers[1].update(); + this.geometry.indexBuffer.update(); + + this.multiplyUvs(); + } +} diff --git a/packages/mesh-extras/src/Rope.js b/packages/mesh-extras/src/Rope.js new file mode 100644 index 0000000..9cfde38 --- /dev/null +++ b/packages/mesh-extras/src/Rope.js @@ -0,0 +1,182 @@ +import Mesh2d from './Mesh2d'; + +/** + * The rope allows you to draw a texture across several points and them manipulate these points + * + *```js + * for (let i = 0; i < 20; i++) { + * points.push(new PIXI.Point(i * 50, 0)); + * }; + * let rope = new PIXI.Rope(PIXI.Texture.from("snake.png"), points); + * ``` + * + * @class + * @extends PIXI.Mesh + * @memberof PIXI + * + */ +export default class Rope extends Mesh2d +{ + /** + * @param {PIXI.Texture} texture - The texture to use on the rope. + * @param {PIXI.Point[]} points - An array of {@link PIXI.Point} objects to construct this rope. + */ + constructor(texture, points) + { + super(texture, new Float32Array(points.length * 4), + new Float32Array(points.length * 4), + new Uint16Array(points.length * 2), + 5); + + /* + * @member {PIXI.Point[]} An array of points that determine the rope + */ + this.points = points; + this.refresh(); + } + /** + * Refreshes Rope indices and uvs + * @private + */ + _refresh() + { + const points = this.points; + + if (!points) return; + + const vertexBuffer = this.geometry.getAttribute('aVertexPosition'); + const uvBuffer = this.geometry.getAttribute('aTextureCoord'); + const indexBuffer = this.geometry.getIndex(); + + // if too little points, or texture hasn't got UVs set yet just move on. + if (points.length < 1 || !this.texture._uvs) + { + return; + } + + // if the number of points has changed we will need to recreate the arraybuffers + if (vertexBuffer.data.length / 4 !== points.length) + { + vertexBuffer.data = new Float32Array(points.length * 4); + uvBuffer.data = new Float32Array(points.length * 4); + indexBuffer.data = new Uint16Array(points.length * 2); + } + + const uvs = uvBuffer.data; + const indices = indexBuffer.data; + + uvs[0] = 0; + uvs[1] = 0; + uvs[2] = 0; + uvs[3] = 1; + + indices[0] = 0; + indices[1] = 1; + + const total = points.length; + + for (let i = 1; i < total; i++) + { + // time to do some smart drawing! + let index = i * 4; + const amount = i / (total - 1); + + uvs[index] = amount; + uvs[index + 1] = 0; + + uvs[index + 2] = amount; + uvs[index + 3] = 1; + + index = i * 2; + indices[index] = index; + indices[index + 1] = index + 1; + } + + // ensure that the changes are uploaded + uvBuffer.update(); + indexBuffer.update(); + + this.multiplyUvs(); + this.refreshVertices(); + } + + /** + * refreshes vertices of Rope mesh + */ + refreshVertices() + { + const points = this.points; + + if (points.length < 1) + { + return; + } + + let lastPoint = points[0]; + let nextPoint; + let perpX = 0; + let perpY = 0; + + // this.count -= 0.2; + + const vertices = this.vertices; + const total = points.length; + + for (let i = 0; i < total; i++) + { + const point = points[i]; + const index = i * 4; + + if (i < points.length - 1) + { + nextPoint = points[i + 1]; + } + else + { + nextPoint = point; + } + + perpY = -(nextPoint.x - lastPoint.x); + perpX = nextPoint.y - lastPoint.y; + + let ratio = (1 - (i / (total - 1))) * 10; + + if (ratio > 1) + { + ratio = 1; + } + + const perpLength = Math.sqrt((perpX * perpX) + (perpY * perpY)); + const num = this._texture.height / 2; // (20 + Math.abs(Math.sin((i + this.count) * 0.3) * 50) )* ratio; + + perpX /= perpLength; + perpY /= perpLength; + + perpX *= num; + perpY *= num; + + vertices[index] = point.x + perpX; + vertices[index + 1] = point.y + perpY; + vertices[index + 2] = point.x - perpX; + vertices[index + 3] = point.y - perpY; + + lastPoint = point; + } + + this.geometry.buffers[0].update(); + } + + /** + * Updates the object transform for rendering + * + * @private + */ + updateTransform() + { + if (this.autoUpdate) + { + this.refreshVertices(); + } + this.containerUpdateTransform(); + } +} diff --git a/packages/mesh-extras/src/index.js b/packages/mesh-extras/src/index.js new file mode 100644 index 0000000..decf454 --- /dev/null +++ b/packages/mesh-extras/src/index.js @@ -0,0 +1,4 @@ +export { default as Mesh2d } from './Mesh2d'; +export { default as Plane } from './Plane'; +export { default as NineSlicePlane } from './NineSlicePlane'; +export { default as Rope } from './Rope'; diff --git a/bundles/pixi.js/package.json b/bundles/pixi.js/package.json index 49c7276..177e059 100644 --- a/bundles/pixi.js/package.json +++ b/bundles/pixi.js/package.json @@ -49,6 +49,7 @@ "@pixi/loaders": "^5.0.0-alpha.2", "@pixi/math": "^5.0.0-alpha.2", "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/mesh-extras": "^5.0.0-alpha.2", "@pixi/mixin-cache-as-bitmap": "^5.0.0-alpha.2", "@pixi/mixin-get-child-by-name": "^5.0.0-alpha.2", "@pixi/mixin-get-global-position": "^5.0.0-alpha.2", diff --git a/bundles/pixi.js/src/deprecated.js b/bundles/pixi.js/src/deprecated.js index 147617c..dbebeb0 100644 --- a/bundles/pixi.js/src/deprecated.js +++ b/bundles/pixi.js/src/deprecated.js @@ -263,15 +263,15 @@ Object.defineProperties(PIXI.mesh, { /** * @class PIXI.mesh.Mesh - * @see PIXI.Mesh + * @see PIXI.Mesh2d * @deprecated since 5.0.0 */ Mesh: { get() { - warn('PIXI.mesh.Mesh has moved to PIXI.Mesh'); + warn('PIXI.mesh.Mesh has moved to PIXI.Mesh2d'); - return PIXI.Mesh; + return PIXI.Mesh2d; }, }, /** @@ -315,15 +315,15 @@ }, /** * @class PIXI.mesh.RawMesh - * @see PIXI.RawMesh + * @see PIXI.Mesh * @deprecated since 5.0.0 */ RawMesh: { get() { - warn('PIXI.mesh.RawMesh has moved to PIXI.RawMesh'); + warn('PIXI.mesh.RawMesh has moved to PIXI.Mesh'); - return PIXI.RawMesh; + return PIXI.Mesh; }, }, /** diff --git a/bundles/pixi.js/src/index.js b/bundles/pixi.js/src/index.js index a3a0d1b..6fdabf0 100644 --- a/bundles/pixi.js/src/index.js +++ b/bundles/pixi.js/src/index.js @@ -9,6 +9,7 @@ import * as loaders from '@pixi/loaders'; import * as math from '@pixi/math'; import * as mesh from '@pixi/mesh'; +import * as meshExtras from '@pixi/mesh-extras'; import * as particles from '@pixi/particles'; import * as prepare from '@pixi/prepare'; import * as sprite from '@pixi/sprite'; @@ -128,6 +129,7 @@ loaders, math, mesh, + meshExtras, particles, sprite, spriteAnimated, @@ -152,6 +154,7 @@ export * from '@pixi/loaders'; export * from '@pixi/math'; export * from '@pixi/mesh'; +export * from '@pixi/mesh-extras'; export * from '@pixi/particles'; export * from '@pixi/sprite'; export * from '@pixi/spritesheet'; diff --git a/package-lock.json b/package-lock.json index 7fe6db7..0814729 100644 --- a/package-lock.json +++ b/package-lock.json @@ -209,7 +209,7 @@ "argparse": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", - "integrity": "sha1-vNZ5HqWuCXJeF+WtmIE0zUCz2RE=", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", "dev": true, "requires": { "sprintf-js": "1.0.3" @@ -228,7 +228,7 @@ "arr-flatten": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz", - "integrity": "sha1-NgSLv/TntH4TZkQxbJlmnqWukfE=", + "integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==", "dev": true }, "arr-union": { @@ -297,7 +297,7 @@ "assertion-error": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", - "integrity": "sha1-5gtrDo8wG9l+U3UhW9pAbIURjAs=", + "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", "dev": true }, "async": { @@ -396,7 +396,7 @@ "brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha1-PH/L9SnYcibz0vUrlm/1Jx60Qd0=", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, "requires": { "balanced-match": "1.0.0", @@ -568,7 +568,7 @@ "circular-json": { "version": "0.3.3", "resolved": "https://registry.npmjs.org/circular-json/-/circular-json-0.3.3.tgz", - "integrity": "sha1-gVyZ6oT2gJUp0vRXkb34JxE1LWY=", + "integrity": "sha512-UZK3NBx2Mca+b5LsG7bY183pHWt5Y1xts4P3Pz7ENTwGVnJOUWbRb3ocjvX7hx9tq/yTAdclXm9sZ38gNuem4A==", "dev": true }, "cli-cursor": { @@ -638,7 +638,7 @@ "color-convert": { "version": "1.9.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.1.tgz", - "integrity": "sha1-wSYRB66y8pTr/+ye2eytUppgl+0=", + "integrity": "sha512-mjGanIiwQJskCC18rPR6OmrZ6fm2Lc7PeGFYwCmy5J34wC6F1PzdGL6xeMfmgicfYcNLGuVFA3WzXtIDCQSZxQ==", "dev": true, "requires": { "color-name": "1.1.3" @@ -1427,7 +1427,7 @@ "boom": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/boom/-/boom-5.2.0.tgz", - "integrity": "sha1-XdnabuOl8wIHdDYpDLcX0/SlTgI=", + "integrity": "sha512-Z5BTk6ZRe4tXXQlkqftmsAUANpXmuwlsF5Oov8ThoMbQRzdGTA1ngYRW160GexgOgjsFOKJz0LYhoNi+2AMBUw==", "dev": true, "requires": { "hoek": "4.2.1" @@ -1471,7 +1471,7 @@ "debug": { "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha1-XRKFFd8TT/Mn6QpMk/Tgd6U2NB8=", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", "dev": true, "requires": { "ms": "2.0.0" @@ -1585,7 +1585,7 @@ "doctrine": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", - "integrity": "sha1-XNAfwQFiG0LEzX9dGmYkNxbT850=", + "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", "dev": true, "requires": { "esutils": "2.0.2" @@ -1662,7 +1662,7 @@ "es6-promise": { "version": "4.2.4", "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.4.tgz", - "integrity": "sha1-3EIhwrFlGHYL2MOaUtjzVvwA7Sk=", + "integrity": "sha512-/NdNZVJg+uZgtm9eS3O6lrOLYmQag2DjdEXuPaHlZ6RuVqgqaVZfgYCepEIKsLqwdQArOPtC3XzRLqGGfT8KQQ==", "dev": true }, "escape-string-regexp": { @@ -1788,7 +1788,7 @@ "espree": { "version": "3.5.4", "resolved": "https://registry.npmjs.org/espree/-/espree-3.5.4.tgz", - "integrity": "sha1-sPRHGHyKi+2US4FaZgvd9d610ac=", + "integrity": "sha512-yAcIQxtmMiB/jL32dzEp2enBeidsB7xWPLNiw3IIkpVds1P+h7qF9YwJq1yUNzp2OKXgAprs4F61ih66UsoD1A==", "dev": true, "requires": { "acorn": "5.5.0", @@ -1798,7 +1798,7 @@ "esprima": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.0.tgz", - "integrity": "sha1-RJnt3NERDgshi6zy+n9/WfVcqAQ=", + "integrity": "sha512-oftTcaMu/EGrEIu904mWteKIv8vMuOgGYo7EhVJJN00R/EED9DCua/xxHRdYnKtcECzVg7xOWhflvJMnqcFZjw==", "dev": true }, "esquery": { @@ -1813,7 +1813,7 @@ "esrecurse": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.2.1.tgz", - "integrity": "sha1-AHo7n9vCs7uH5IeeoZyS/b05Qs8=", + "integrity": "sha512-64RBB++fIOAXPw3P9cy89qfMlvZEXZkqqJkjqqXIvzP5ezRZjW+lPWjw35UX/3EhUPFYbg5ER4JYgDw4007/DQ==", "dev": true, "requires": { "estraverse": "4.2.0" @@ -2024,7 +2024,7 @@ "find-root": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/find-root/-/find-root-1.1.0.tgz", - "integrity": "sha1-q8/Iunb3CMQql7PWhbfpRQv7nOQ=", + "integrity": "sha512-NKfW6bec6GfKc0SGx1e07QZY9PE99u0Bft/0rzSD5k3sO/vwkVUpDUKVm5Gpp5Ue3YfShPFTX2070tDs5kB9Ng==", "dev": true }, "find-up": { @@ -2103,7 +2103,7 @@ "supports-color": { "version": "5.3.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.3.0.tgz", - "integrity": "sha1-WySsFduA+pJ89SJ6SjP9PEx2dsA=", + "integrity": "sha512-0aP01LLIskjKs3lq52EC0aGBAJhLq7B2Rd8HC/DR/PtNNpcLilNmHC12O+hu0usQpo7wtHNRqtrhBwtDb0+dNg==", "dev": true, "requires": { "has-flag": "3.0.0" @@ -2567,7 +2567,7 @@ "glob": { "version": "7.1.2", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", - "integrity": "sha1-wZyd+aAocC1nhhI4SmVSQExjbRU=", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", "dev": true, "requires": { "fs.realpath": "1.0.0", @@ -2672,7 +2672,7 @@ "growl": { "version": "1.10.3", "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.3.tgz", - "integrity": "sha1-GSa6kM8+3+KttJJ/WIC8IsZseQ8=", + "integrity": "sha512-hKlsbA5Vu3xsh1Cg3J7jSmX/WaW6A5oBeqzM88oNbCRQFz+zUaXm6yxS4RVytp1scBoJzSYl4YAEOQIt6O8V1Q==", "dev": true }, "handlebars": { @@ -2738,7 +2738,7 @@ "hawk": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/hawk/-/hawk-6.0.2.tgz", - "integrity": "sha1-r02RTrBl+bXOTZ0RwcshJu7MMDg=", + "integrity": "sha512-miowhl2+U7Qle4vdLqDdPt9m09K6yZhkLDTWGoUiUzrQCn+mHHSmfJgAyGaLRZbPmTqfFFjRV1QWCW0VWUJBbQ==", "dev": true, "requires": { "boom": "4.3.1", @@ -2756,7 +2756,7 @@ "hoek": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/hoek/-/hoek-4.2.1.tgz", - "integrity": "sha1-ljRQKqEsRF3Vp8VzS1cruHOKrLs=", + "integrity": "sha512-QLg82fGkfnJ/4iy1xZ81/9SIJiq1NGFUMGs6ParyjBZr6jW2Ufj/snDqTHixNlHdPNwN2RLVD0Pi3igeK9+JfA==", "dev": true }, "home-path": { @@ -2791,7 +2791,7 @@ "ignore": { "version": "3.3.7", "resolved": "https://registry.npmjs.org/ignore/-/ignore-3.3.7.tgz", - "integrity": "sha1-YSKJv7PCIOGGpYEYYY1b6MG6sCE=", + "integrity": "sha512-YGG3ejvBNHRqu0559EOxxNFihD0AjpvHlC/pdGKd3X3ofe+CoJkYazwNJYTNebqpPKN+VVQbh4ZFn1DivMNuHA==", "dev": true }, "imurmurhash": { @@ -2828,7 +2828,7 @@ "ini": { "version": "1.3.5", "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", - "integrity": "sha1-7uJfVtscnsYIXgwid4CD9Zar+Sc=", + "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==", "dev": true }, "inquirer": { @@ -2901,7 +2901,7 @@ "is-buffer": { "version": "1.1.6", "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", - "integrity": "sha1-76ouqdqg16suoTqXsritUf776L4=", + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", "dev": true }, "is-builtin-module": { @@ -3054,7 +3054,7 @@ "is-resolvable": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/is-resolvable/-/is-resolvable-1.1.0.tgz", - "integrity": "sha1-+xj4fOH+uSUWnJpAfBkxijIG7Yg=", + "integrity": "sha512-qgDYXFSR5WvEfuS5dMj6oTMEbrrSaM0CrFk2Yiq/gXnBvD9pMa2jGXxyhGLfvhZpuMZe18CJpFxAt3CRs42NMg==", "dev": true }, "is-retry-allowed": { @@ -3204,7 +3204,7 @@ "js-yaml": { "version": "3.11.0", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.11.0.tgz", - "integrity": "sha1-WXwai9VxUvJtYizkEXhRpR9euu8=", + "integrity": "sha512-saJstZWv7oNeOyBh3+Dx1qWzhW0+e6/8eDzo7p5rDFqxntSztloLtuKu+Ejhtq82jsilwOIZYsCz+lIjthg1Hw==", "dev": true, "requires": { "argparse": "1.0.10", @@ -3324,7 +3324,7 @@ "just-extend": { "version": "1.1.27", "resolved": "https://registry.npmjs.org/just-extend/-/just-extend-1.1.27.tgz", - "integrity": "sha1-7G55QQ/5FORyZSq/oOYDwD1g6QU=", + "integrity": "sha512-mJVp13Ix6gFo3SBAy9U/kL+oeZqzlYYYLQBwXVBlVzIsZwBqGREnOro24oC/8s8aox+rJhtZ2DiQof++IrkA+g==", "dev": true }, "kind-of": { @@ -3703,7 +3703,7 @@ "lodash": { "version": "4.17.5", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.5.tgz", - "integrity": "sha1-maktZcAnLevoyWtgV7yPv6O+1RE=", + "integrity": "sha512-svL3uiZf1RwhH+cWrfZn3A4+U58wbP0tGVTLQPbjplZxZ8ROD9VLuNgsRniTlLe7OlSqR79RUehXgpBW/s0IQw==", "dev": true }, "lodash._reinterpolate": { @@ -3740,7 +3740,7 @@ "lolex": { "version": "2.3.2", "resolved": "https://registry.npmjs.org/lolex/-/lolex-2.3.2.tgz", - "integrity": "sha1-hflFBCUQO/nnpgZo6iXcQydMqAc=", + "integrity": "sha512-A5pN2tkFj7H0dGIAM6MFvHKMJcPnjZsOMvR7ujCjfgW5TbV6H9vb1PgxLtHvjqNZTHsUolz+6/WEO0N1xNx2ng==", "dev": true }, "longest": { @@ -3816,7 +3816,7 @@ "marked": { "version": "0.3.17", "resolved": "https://registry.npmjs.org/marked/-/marked-0.3.17.tgz", - "integrity": "sha1-YH8GZos8axJGso8T2nYRasGqLSs=", + "integrity": "sha512-+AKbNsjZl6jFfLPwHhWmGTqE009wTKn3RTmn9K8oUKHrX/abPJjtcRtXpYB/FFrwPJRUA86LX/de3T0knkPCmQ==", "dev": true }, "mem": { @@ -3896,13 +3896,13 @@ "mime-db": { "version": "1.33.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.33.0.tgz", - "integrity": "sha1-o0kgUKXLm2NFBUHjnZeI0icng9s=", + "integrity": "sha512-BHJ/EKruNIqJf/QahvxwQZXKygOQ256myeN/Ew+THcAa5q+PjyTTMMeNQC4DZw5AwfvelsUrA6B67NKMqXDbzQ==", "dev": true }, "mime-types": { "version": "2.1.18", "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.18.tgz", - "integrity": "sha1-bzI/YKg9ERRvgx/xH9ZuL+VQO7g=", + "integrity": "sha512-lc/aahn+t4/SWV/qcmumYjymLsWfN3ELhpmVuUFjgsORruuZPVSwAQryq+HHGvO/SI2KVX26bx+En+zhM8g8hQ==", "dev": true, "requires": { "mime-db": "1.33.0" @@ -3917,7 +3917,7 @@ "minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha1-UWbihkV/AzBgZL5Ul+jbsMPTIIM=", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "dev": true, "requires": { "brace-expansion": "1.1.11" @@ -4071,7 +4071,7 @@ "normalize-package-data": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.4.0.tgz", - "integrity": "sha1-EvlaMH1YNSB1oEkHuErIvpisAS8=", + "integrity": "sha512-9jjUFbTPfEy3R/ad/2oNbKtW9Hgovl5O1FvFWKkKblNXoN/Oou6+9+KKohPK13Yc3/TyunyWhJp6gvRNR/PPAw==", "dev": true, "requires": { "hosted-git-info": "2.5.0", @@ -4511,7 +4511,7 @@ "process-nextick-args": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", - "integrity": "sha1-o31zL0JxtKsa0HDTVQjoKQeI/6o=", + "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==", "dev": true }, "progress": { @@ -4584,7 +4584,7 @@ "qs": { "version": "6.5.1", "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.1.tgz", - "integrity": "sha1-NJzfbu+J7EXBLX1es/wMhwNDptg=", + "integrity": "sha512-eRzhrN1WSINYCDCbrz796z37LOe3m5tmW7RQf6oBntukAG1nmovJvhnwHHRMAfeoItc1m2Hk02WER2aQ/iqs+A==", "dev": true }, "quick-lru": { @@ -4596,7 +4596,7 @@ "randomatic": { "version": "1.1.7", "resolved": "https://registry.npmjs.org/randomatic/-/randomatic-1.1.7.tgz", - "integrity": "sha1-x6vpzIuHwLqodrGf3oP9RkeX44w=", + "integrity": "sha512-D5JUjPyJbaJDkuAazpVnSfVkLlpeO3wDlPROTMLGKG1zMFNFRgrciKo1ltz/AzNTkqE0HzDx655QOL51N06how==", "dev": true, "requires": { "is-number": "3.0.0", @@ -4701,7 +4701,7 @@ "regex-cache": { "version": "0.4.4", "resolved": "https://registry.npmjs.org/regex-cache/-/regex-cache-0.4.4.tgz", - "integrity": "sha1-db3FiioUls7EihKDW8VMjVYjNt0=", + "integrity": "sha512-nVIZwtCjkC9YgvWkpM55B5rBhBYRZhAaJbgcFYXXsHnbZ9UZI9nnVWYZpBlCqv9ho2eZryPnWrZGsOdPwVWXWQ==", "dev": true, "requires": { "is-equal-shallow": "0.1.3" @@ -4729,7 +4729,7 @@ "remap-istanbul": { "version": "0.10.1", "resolved": "https://registry.npmjs.org/remap-istanbul/-/remap-istanbul-0.10.1.tgz", - "integrity": "sha1-OqWN1QIdSZ8zbTulvzu7kcG4jjc=", + "integrity": "sha512-gsNQXs5kJLhErICSyYhzVZ++C8LBW8dgwr874Y2QvzAUS75zBlD/juZgXs39nbYJ09fZDlX2AVLVJAY2jbFJoQ==", "dev": true, "requires": { "amdefine": "1.0.1", @@ -4769,7 +4769,7 @@ "source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha1-dHIq8y6WFOnCh6jQu95IteLxomM=", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", "dev": true }, "through2": { @@ -4883,7 +4883,7 @@ "resolve": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.5.0.tgz", - "integrity": "sha1-HwmsznlsmnYlefMbLBzEw83fnzY=", + "integrity": "sha512-hgoSGrc3pjzAPHNBg+KnFcK2HwlHTs/YrAGUr6qgTVUZmXv1UEXXl0bZNBKMA9fud6lRYFdPGz0xXxycPzmmiw==", "dev": true, "requires": { "path-parse": "1.0.5" @@ -4924,7 +4924,7 @@ "rimraf": { "version": "2.6.2", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", - "integrity": "sha1-LtgVDSShbqhlHm1u8PR8QVjOejY=", + "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", "dev": true, "requires": { "glob": "7.1.2" @@ -5063,19 +5063,19 @@ "safe-buffer": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", - "integrity": "sha1-iTMSr2myEj3vcfV4iQAWce6yyFM=", + "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", "dev": true }, "samsam": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/samsam/-/samsam-1.3.0.tgz", - "integrity": "sha1-jR2TUOJWItow3j5EumkrUiGrfFA=", + "integrity": "sha512-1HwIYD/8UlOtFS3QO3w7ey+SdSDFE4HRNLZoZRYVQefrOY3l17epswImeB1ijgJFQJodIaHcwkp3r/myBjFVbg==", "dev": true }, "semver": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz", - "integrity": "sha1-3Eu8emyp2Rbe5dQ1FvAJK1j3uKs=", + "integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==", "dev": true }, "set-blocking": { @@ -5117,7 +5117,7 @@ "sinon-chai": { "version": "2.14.0", "resolved": "https://registry.npmjs.org/sinon-chai/-/sinon-chai-2.14.0.tgz", - "integrity": "sha1-2n3UzIPNaiYLZ8yg96n9riahIF0=", + "integrity": "sha512-9stIF1utB0ywNHNT7RgiXbdmen8QDCRsrTjw+G9TgKt1Yexjiv8TOWZ6WHsTPz57Yky3DIswZvEqX8fpuHNDtQ==", "dev": true }, "slash": { @@ -5146,7 +5146,7 @@ "sntp": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/sntp/-/sntp-2.1.0.tgz", - "integrity": "sha1-LGzsFP7cIiJznK+bXD2F0cxaLMg=", + "integrity": "sha512-FL1b58BDrqS3A11lJ0zEdnJ3UOKqVxawAkF3k7F0CVN7VQ34aZrV+G8BZ1WC9ZL7NyrwsW0oviwsWDgRuVYtJg==", "dev": true, "requires": { "hoek": "4.2.1" @@ -5203,7 +5203,7 @@ "spdx-correct": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.0.0.tgz", - "integrity": "sha1-BaW01xU6GVvJLDxCW2nzsqlSTII=", + "integrity": "sha512-N19o9z5cEyc8yQQPukRCZ9EUmb4HUpnrmaL/fxS2pBo2jbfcFRVuFZ/oFC+vZz0MNNk0h80iMn5/S6qGZOL5+g==", "dev": true, "requires": { "spdx-expression-parse": "3.0.0", @@ -5213,13 +5213,13 @@ "spdx-exceptions": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.1.0.tgz", - "integrity": "sha1-LHrmEFbHFKW5ubKyr30xHvXHj+k=", + "integrity": "sha512-4K1NsmrlCU1JJgUrtgEeTVyfx8VaYea9J9LvARxhbHtVtohPs/gFGG5yy49beySjlIMhhXZ4QqujIZEfS4l6Cg==", "dev": true }, "spdx-expression-parse": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.0.tgz", - "integrity": "sha1-meEZt6XaAOBUkcn6M4t5BII7QdA=", + "integrity": "sha512-Yg6D3XpRD4kkOmTpdgbUiEJFKghJH03fiC1OPll5h/0sO6neh2jqRDVHOQ4o/LMea0tgCkbMgea5ip/e+MkWyg==", "dev": true, "requires": { "spdx-exceptions": "2.1.0", @@ -5229,7 +5229,7 @@ "spdx-license-ids": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.0.tgz", - "integrity": "sha1-enzShHDMbToc/m1miG9rxDDTrIc=", + "integrity": "sha512-2+EPwgbnmOIl8HjGBXXMd9NAu02vLjOO1nWw4kmeRDFyHn+M/ETfHxQUK0oXg8ctgVnl9t3rosNVsZ1jG61nDA==", "dev": true }, "speedometer": { @@ -5566,7 +5566,7 @@ "tough-cookie": { "version": "2.3.4", "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.4.tgz", - "integrity": "sha1-7GDO44rGdQY//JelwYlwV47oNlU=", + "integrity": "sha512-TZ6TTfI5NtZnuyy/Kecv+CnoROnyXn2DN97LontgQpCwsX2XyLYCC0ENhYkehSOwAp8rTQKc/NUIF7BkQ5rKLA==", "dev": true, "requires": { "punycode": "1.4.1" @@ -5708,13 +5708,13 @@ "uuid": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.2.1.tgz", - "integrity": "sha1-EsUou51Y0LkmXZovbw/ovhf/HxQ=", + "integrity": "sha512-jZnMwlb9Iku/O3smGWvZhauCf6cvvpKi4BKRiliS3cxnI+Gz9j5MEpTz2UFuXiKPJocb7gnsLHwiS05ige5BEA==", "dev": true }, "validate-npm-package-license": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.3.tgz", - "integrity": "sha1-gWQ7y+8b3+zUYjeT3EZIlIupgzg=", + "integrity": "sha512-63ZOUnL4SIXj4L0NixR3L1lcjO38crAbgrTpl28t8jjrfuiOBL5Iygm+60qPs/KsZGzPNg6Smnc/oY16QTjF0g==", "dev": true, "requires": { "spdx-correct": "3.0.0", @@ -5750,7 +5750,7 @@ "which": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/which/-/which-1.3.0.tgz", - "integrity": "sha1-/wS9/AEO5UfXgL7DjhrBwnd9JTo=", + "integrity": "sha512-xcJpopdamTuY5duC/KnTTNBraPK54YwpenP4lzxU8H91GudWpFv38u0CKjclE1Wi2EH2EDz5LRcHcKbCIzqGyg==", "dev": true, "requires": { "isexe": "2.0.0" diff --git a/packages/canvas/canvas-mesh/package.json b/packages/canvas/canvas-mesh/package.json index 691cd2c..6744a17 100644 --- a/packages/canvas/canvas-mesh/package.json +++ b/packages/canvas/canvas-mesh/package.json @@ -24,6 +24,7 @@ "dependencies": { "@pixi/constants": "^5.0.0-alpha.2", "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/mesh-extras": "^5.0.0-alpha.2", "@pixi/settings": "^5.0.0-alpha.2" }, "devDependencies": { diff --git a/packages/canvas/canvas-mesh/src/Mesh.js b/packages/canvas/canvas-mesh/src/Mesh.js index 900a872..c43a74b 100644 --- a/packages/canvas/canvas-mesh/src/Mesh.js +++ b/packages/canvas/canvas-mesh/src/Mesh.js @@ -1,36 +1,14 @@ import { Mesh } from '@pixi/mesh'; -import { settings } from './settings'; - -// IMPORTANT: Please do NOT use this as a precedent to use `settings` after the object is created -// this was merely created to completely decouple canvas from the base Mesh class and we are -// unable to add `canvasPadding` in the constructor anymore, as the case was for PixiJS v4. /** - * Internal variable for `canvasPadding`. + * Renders the object using the Canvas renderer * * @private - * @memberof PIXI.Mesh - * @member {number} - * @default null - */ -Mesh.prototype._canvasPadding = null; - -/** - * Triangles in canvas mode are automatically antialiased, use this value to force triangles - * to overlap a bit with each other. To set the global default, set {@link PIXI.settings.MESH_CANVAS_PADDING} - * - * @see PIXI.settings.MESH_CANVAS_PADDING - * @member {number} canvasPadding + * @method _renderCanvas * @memberof PIXI.Mesh# - * @default 0 + * @param {PIXI.CanvasRenderer} renderer - The canvas renderer. */ -Object.defineProperty(Mesh.prototype, 'canvasPadding', { - get() - { - return this._canvasPadding !== null ? this._canvasPadding : settings.MESH_CANVAS_PADDING; - }, - set(value) - { - this._canvasPadding = value; - }, -}); +Mesh.prototype._renderCanvas = function _renderCanvas(renderer) +{ + renderer.plugins[this.pluginName].render(this); +}; diff --git a/packages/canvas/canvas-mesh/src/Mesh2d.js b/packages/canvas/canvas-mesh/src/Mesh2d.js new file mode 100644 index 0000000..d0bd80f --- /dev/null +++ b/packages/canvas/canvas-mesh/src/Mesh2d.js @@ -0,0 +1,36 @@ +import { Mesh2d } from '@pixi/mesh-extras'; +import { settings } from './settings'; + +// IMPORTANT: Please do NOT use this as a precedent to use `settings` after the object is created +// this was merely created to completely decouple canvas from the base Mesh class and we are +// unable to add `canvasPadding` in the constructor anymore, as the case was for PixiJS v4. + +/** + * Internal variable for `canvasPadding`. + * + * @private + * @memberof PIXI.Mesh2d + * @member {number} + * @default null + */ +Mesh2d.prototype._canvasPadding = null; + +/** + * Triangles in canvas mode are automatically antialiased, use this value to force triangles + * to overlap a bit with each other. To set the global default, set {@link PIXI.settings.MESH_CANVAS_PADDING} + * + * @see PIXI.settings.MESH_CANVAS_PADDING + * @member {number} canvasPadding + * @memberof PIXI.Mesh2d# + * @default 0 + */ +Object.defineProperty(Mesh2d.prototype, 'canvasPadding', { + get() + { + return this._canvasPadding !== null ? this._canvasPadding : settings.MESH_CANVAS_PADDING; + }, + set(value) + { + this._canvasPadding = value; + }, +}); diff --git a/packages/canvas/canvas-mesh/src/NineSlicePlane.js b/packages/canvas/canvas-mesh/src/NineSlicePlane.js index 09eaf9c..2fd5acc 100644 --- a/packages/canvas/canvas-mesh/src/NineSlicePlane.js +++ b/packages/canvas/canvas-mesh/src/NineSlicePlane.js @@ -1,4 +1,4 @@ -import { NineSlicePlane } from '@pixi/mesh'; +import { NineSlicePlane } from '@pixi/mesh-extras'; /** * Renders the object using the Canvas renderer diff --git a/packages/canvas/canvas-mesh/src/RawMesh.js b/packages/canvas/canvas-mesh/src/RawMesh.js deleted file mode 100644 index bf40184..0000000 --- a/packages/canvas/canvas-mesh/src/RawMesh.js +++ /dev/null @@ -1,14 +0,0 @@ -import { RawMesh } from '@pixi/mesh'; - -/** - * Renders the object using the Canvas renderer - * - * @private - * @method _renderCanvas - * @memberof PIXI.RawMesh# - * @param {PIXI.CanvasRenderer} renderer - The canvas renderer. - */ -RawMesh.prototype._renderCanvas = function _renderCanvas(renderer) -{ - renderer.plugins[this.pluginName].render(this); -}; diff --git a/packages/canvas/canvas-mesh/src/index.js b/packages/canvas/canvas-mesh/src/index.js index 2295016..f4fa31d 100644 --- a/packages/canvas/canvas-mesh/src/index.js +++ b/packages/canvas/canvas-mesh/src/index.js @@ -1,6 +1,6 @@ export { default as CanvasMeshRenderer } from './CanvasMeshRenderer'; import './settings'; -import './Mesh'; +import './Mesh2d'; import './NineSlicePlane'; -import './RawMesh'; +import './Mesh'; diff --git a/packages/canvas/canvas-mesh/src/settings.js b/packages/canvas/canvas-mesh/src/settings.js index 4cefb4c..e81b8e0 100644 --- a/packages/canvas/canvas-mesh/src/settings.js +++ b/packages/canvas/canvas-mesh/src/settings.js @@ -3,7 +3,7 @@ /** * Default `canvasPadding` for canvas-based Mesh rendering. * - * @see PIXI.Mesh#canvasPadding + * @see PIXI.Mesh2d#canvasPadding * @static * @constant * @memberof PIXI.settings diff --git a/packages/mesh-extras/LICENSE b/packages/mesh-extras/LICENSE new file mode 100644 index 0000000..148e3eb --- /dev/null +++ b/packages/mesh-extras/LICENSE @@ -0,0 +1,21 @@ +The MIT License + +Copyright (c) 2013-2018 Mathew Groves, Chad Engler + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/packages/mesh-extras/README.md b/packages/mesh-extras/README.md new file mode 100644 index 0000000..1d9b0e1 --- /dev/null +++ b/packages/mesh-extras/README.md @@ -0,0 +1,19 @@ +# @pixi/mesh-extras + +## Installation + +```bash +npm install @pixi/mesh-extras +``` + +## Usage + +```js +import { MeshRenderer } from '@pixi/mesh'; +import { Renderer } from '@pixi/core'; +import { Rope } from '@pixi/mesh-extras'; + +Renderer.registerPlugin('mesh', MeshRenderer); + +const rope = new Rope(); +``` \ No newline at end of file diff --git a/packages/mesh-extras/package.json b/packages/mesh-extras/package.json new file mode 100644 index 0000000..d134f64 --- /dev/null +++ b/packages/mesh-extras/package.json @@ -0,0 +1,38 @@ +{ + "name": "@pixi/mesh-extras", + "version": "5.0.0-alpha.2", + "main": "lib/mesh-extras.js", + "module": "lib/mesh-extras.es.js", + "description": "Custom Mesh display objects, like Rope and Plane", + "author": "Mat Groves", + "contributors": [ + "Matt Karl " + ], + "homepage": "http://pixijs.com/", + "bugs": "https://github.com/pixijs/pixi.js/issues", + "license": "MIT", + "repository": { + "type": "git", + "url": "https://github.com/pixijs/pixi.js.git" + }, + "publishConfig": { + "access": "public" + }, + "scripts": { + "test": "floss --path test" + }, + "files": [ + "lib" + ], + "dependencies": { + "@pixi/constants": "^5.0.0-alpha.2", + "@pixi/core": "^5.0.0-alpha.2", + "@pixi/math": "^5.0.0-alpha.2", + "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/utils": "^5.0.0-alpha.2" + }, + "devDependencies": { + "@pixi/loaders": "^5.0.0-alpha.2", + "floss": "^2.1.3" + } +} diff --git a/packages/mesh-extras/src/Mesh2d.js b/packages/mesh-extras/src/Mesh2d.js new file mode 100644 index 0000000..d113a5e --- /dev/null +++ b/packages/mesh-extras/src/Mesh2d.js @@ -0,0 +1,263 @@ +import { Mesh } from '@pixi/mesh'; +import { Geometry, Program, Shader, Texture, TextureMatrix } from '@pixi/core'; +import { Matrix } from '@pixi/math'; +import { BLEND_MODES } from '@pixi/constants'; +import { hex2rgb, premultiplyRgba } from '@pixi/utils'; +import vertex from './mesh.vert'; +import fragment from './mesh.frag'; + +let meshProgram; + +/** + * Base mesh class + * @class + * @extends PIXI.Container + * @memberof PIXI + */ +export default class Mesh2d extends Mesh +{ + /** + * @param {PIXI.Texture} [texture=Texture.EMPTY] - The texture to use + * @param {Float32Array} [vertices] - if you want to specify the vertices + * @param {Float32Array} [uvs] - if you want to specify the uvs + * @param {Uint16Array} [indices] - if you want to specify the indices + * @param {number} [drawMode] - the drawMode, can be any of the Mesh.DRAW_MODES consts + */ + constructor(texture = Texture.EMPTY, vertices, uvs, indices, drawMode) + { + const geometry = new Geometry(); + + if (!meshProgram) + { + meshProgram = new Program(vertex, fragment); + } + + geometry.addAttribute('aVertexPosition', vertices) + .addAttribute('aTextureCoord', uvs) + .addIndex(indices); + + geometry.getAttribute('aVertexPosition').static = false; + + const uniforms = { + uSampler: texture, + uTextureMatrix: Matrix.IDENTITY, + alpha: 1, + uColor: new Float32Array([1, 1, 1, 1]), + }; + + super(geometry, new Shader(meshProgram, uniforms), null, drawMode); + + /** + * The Uvs of the Mesh + * + * @member {Float32Array} + */ + this.uvs = geometry.getAttribute('aTextureCoord').data; + + /** + * An array of vertices + * + * @member {Float32Array} + */ + this.vertices = geometry.getAttribute('aVertexPosition').data; + + this.uniforms = uniforms; + + /** + * The texture of the Mesh + * + * @member {PIXI.Texture} + * @default PIXI.Texture.EMPTY + * @private + */ + this.texture = texture; + + /** + * The tint applied to the mesh. This is a [r,g,b] value. A value of [1,1,1] will remove any + * tint effect. + * + * @member {number} + * @private + */ + this._tintRGB = new Float32Array([1, 1, 1]); + + // Set default tint + this.tint = 0xFFFFFF; + + this.blendMode = BLEND_MODES.NORMAL; + + /** + * TextureMatrix instance for this Mesh, used to track Texture changes + * + * @member {PIXI.TextureMatrix} + * @readonly + */ + this.uvMatrix = new TextureMatrix(this._texture); + + /** + * whether or not upload uvMatrix to shader + * if its false, then uvs should be pre-multiplied + * if you change it for generated mesh, please call 'refresh(true)' + * @member {boolean} + * @default false + */ + this.uploadUvMatrix = false; + + /** + * Uploads vertices buffer every frame, like in PixiJS V3 and V4. + * + * @member {boolean} + * @default true + */ + this.autoUpdate = true; + } + + /** + * The tint applied to the Rope. This is a hex value. A value of + * 0xFFFFFF will remove any tint effect. + * + * @member {number} + * @memberof PIXI.Sprite# + * @default 0xFFFFFF + */ + get tint() + { + return this._tint; + } + + /** + * Sets the tint of the rope. + * + * @param {number} value - The value to set to. + */ + set tint(value) + { + this._tint = value; + + hex2rgb(this._tint, this._tintRGB); + } + + /** + * The blend mode to be applied to the sprite. Set to `PIXI.BLEND_MODES.NORMAL` to remove any blend mode. + * + * @member {number} + * @default PIXI.BLEND_MODES.NORMAL + * @see PIXI.BLEND_MODES + */ + get blendMode() + { + return this.state.blendMode; + } + + set blendMode(value) // eslint-disable-line require-jsdoc + { + this.state.blendMode = value; + } + + /** + * The texture that the mesh uses. + * + * @member {PIXI.Texture} + */ + get texture() + { + return this._texture; + } + + set texture(value) // eslint-disable-line require-jsdoc + { + if (this._texture === value) + { + return; + } + + this._texture = value; + this.uniforms.uSampler = this.texture; + + if (value) + { + // wait for the texture to load + if (value.baseTexture.valid) + { + this._onTextureUpdate(); + } + else + { + value.once('update', this._onTextureUpdate, this); + } + } + } + + _render(renderer) + { + const baseTex = this._texture.baseTexture; + + premultiplyRgba(this._tintRGB, this.worldAlpha, this.uniforms.uColor, baseTex.premultiplyAlpha); + super._render(renderer); + } + /** + * When the texture is updated, this event will fire to update the scale and frame + * + * @private + */ + _onTextureUpdate() + { + // constructor texture update stop + if (!this.uvMatrix) + { + return; + } + this.uvMatrix.texture = this._texture; + this.refresh(); + } + + /** + * multiplies uvs only if uploadUvMatrix is false + * call it after you change uvs manually + * make sure that texture is valid + */ + multiplyUvs() + { + if (!this.uploadUvMatrix) + { + this.uvMatrix.multiplyUvs(this.uvs); + } + } + + /** + * Refreshes uvs for generated meshes (rope, plane) + * sometimes refreshes vertices too + * + * @param {boolean} [forceUpdate=false] if true, matrices will be updated any case + */ + refresh(forceUpdate) + { + if (this.uvMatrix.update(forceUpdate)) + { + this._refresh(); + } + } + + /** + * Updates the object transform for rendering + * + * @private + */ + updateTransform() + { + if (this.autoUpdate) + { + this.geometry.buffers[0].update(); + } + this.containerUpdateTransform(); + } + + /** + * re-calculates mesh coords + * @private + */ + _refresh() + { + /* empty */ + } +} diff --git a/packages/mesh-extras/src/NineSlicePlane.js b/packages/mesh-extras/src/NineSlicePlane.js new file mode 100644 index 0000000..0bae92c --- /dev/null +++ b/packages/mesh-extras/src/NineSlicePlane.js @@ -0,0 +1,270 @@ +import Plane from './Plane'; + +const DEFAULT_BORDER_SIZE = 10; + +/** + * The NineSlicePlane allows you to stretch a texture using 9-slice scaling. The corners will remain unscaled (useful + * for buttons with rounded corners for example) and the other areas will be scaled horizontally and or vertically + * + *```js + * let Plane9 = new PIXI.NineSlicePlane(PIXI.Texture.from('BoxWithRoundedCorners.png'), 15, 15, 15, 15); + * ``` + *
+ *      A                          B
+ *    +---+----------------------+---+
+ *  C | 1 |          2           | 3 |
+ *    +---+----------------------+---+
+ *    |   |                      |   |
+ *    | 4 |          5           | 6 |
+ *    |   |                      |   |
+ *    +---+----------------------+---+
+ *  D | 7 |          8           | 9 |
+ *    +---+----------------------+---+
+
+ *  When changing this objects width and/or height:
+ *     areas 1 3 7 and 9 will remain unscaled.
+ *     areas 2 and 8 will be stretched horizontally
+ *     areas 4 and 6 will be stretched vertically
+ *     area 5 will be stretched both horizontally and vertically
+ * 
+ * + * @class + * @extends PIXI.Plane + * @memberof PIXI + * + */ +export default class NineSlicePlane extends Plane +{ + /** + * @param {PIXI.Texture} texture - The texture to use on the NineSlicePlane. + * @param {int} [leftWidth=10] size of the left vertical bar (A) + * @param {int} [topHeight=10] size of the top horizontal bar (C) + * @param {int} [rightWidth=10] size of the right vertical bar (B) + * @param {int} [bottomHeight=10] size of the bottom horizontal bar (D) + */ + constructor(texture, leftWidth, topHeight, rightWidth, bottomHeight) + { + super(texture, 4, 4); + + this._origWidth = texture.orig.width; + this._origHeight = texture.orig.height; + + /** + * The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._width = this._origWidth; + + /** + * The height of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._height = this._origHeight; + + /** + * The width of the left column (a) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._leftWidth = typeof leftWidth !== 'undefined' ? leftWidth : DEFAULT_BORDER_SIZE; + + /** + * The width of the right column (b) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._rightWidth = typeof rightWidth !== 'undefined' ? rightWidth : DEFAULT_BORDER_SIZE; + + /** + * The height of the top row (c) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._topHeight = typeof topHeight !== 'undefined' ? topHeight : DEFAULT_BORDER_SIZE; + + /** + * The height of the bottom row (d) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._bottomHeight = typeof bottomHeight !== 'undefined' ? bottomHeight : DEFAULT_BORDER_SIZE; + + this.refresh(true); + } + + /** + * Updates the horizontal vertices. + * + */ + updateHorizontalVertices() + { + const vertices = this.vertices; + + const h = this._topHeight + this._bottomHeight; + const scale = this._height > h ? 1.0 : this._height / h; + + vertices[9] = vertices[11] = vertices[13] = vertices[15] = this._topHeight * scale; + vertices[17] = vertices[19] = vertices[21] = vertices[23] = this._height - (this._bottomHeight * scale); + vertices[25] = vertices[27] = vertices[29] = vertices[31] = this._height; + } + + /** + * Updates the vertical vertices. + * + */ + updateVerticalVertices() + { + const vertices = this.vertices; + + const w = this._leftWidth + this._rightWidth; + const scale = this._width > w ? 1.0 : this._width / w; + + vertices[2] = vertices[10] = vertices[18] = vertices[26] = this._leftWidth * scale; + vertices[4] = vertices[12] = vertices[20] = vertices[28] = this._width - (this._rightWidth * scale); + vertices[6] = vertices[14] = vertices[22] = vertices[30] = this._width; + } + + /** + * The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + */ + get width() + { + return this._width; + } + + set width(value) // eslint-disable-line require-jsdoc + { + this._width = value; + this._refresh(); + } + + /** + * The height of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + */ + get height() + { + return this._height; + } + + set height(value) // eslint-disable-line require-jsdoc + { + this._height = value; + this._refresh(); + } + + /** + * The width of the left column + * + * @member {number} + */ + get leftWidth() + { + return this._leftWidth; + } + + set leftWidth(value) // eslint-disable-line require-jsdoc + { + this._leftWidth = value; + this._refresh(); + } + + /** + * The width of the right column + * + * @member {number} + */ + get rightWidth() + { + return this._rightWidth; + } + + set rightWidth(value) // eslint-disable-line require-jsdoc + { + this._rightWidth = value; + this._refresh(); + } + + /** + * The height of the top row + * + * @member {number} + */ + get topHeight() + { + return this._topHeight; + } + + set topHeight(value) // eslint-disable-line require-jsdoc + { + this._topHeight = value; + this._refresh(); + } + + /** + * The height of the bottom row + * + * @member {number} + */ + get bottomHeight() + { + return this._bottomHeight; + } + + set bottomHeight(value) // eslint-disable-line require-jsdoc + { + this._bottomHeight = value; + this._refresh(); + } + + /** + * Refreshes NineSlicePlane coords. All of them. + */ + _refresh() + { + super._refresh(); + + const uvs = this.uvs; + const texture = this._texture; + + this._origWidth = texture.orig.width; + this._origHeight = texture.orig.height; + + const _uvw = 1.0 / this._origWidth; + const _uvh = 1.0 / this._origHeight; + + uvs[0] = uvs[8] = uvs[16] = uvs[24] = 0; + uvs[1] = uvs[3] = uvs[5] = uvs[7] = 0; + uvs[6] = uvs[14] = uvs[22] = uvs[30] = 1; + uvs[25] = uvs[27] = uvs[29] = uvs[31] = 1; + + uvs[2] = uvs[10] = uvs[18] = uvs[26] = _uvw * this._leftWidth; + uvs[4] = uvs[12] = uvs[20] = uvs[28] = 1 - (_uvw * this._rightWidth); + uvs[9] = uvs[11] = uvs[13] = uvs[15] = _uvh * this._topHeight; + uvs[17] = uvs[19] = uvs[21] = uvs[23] = 1 - (_uvh * this._bottomHeight); + + this.updateHorizontalVertices(); + this.updateVerticalVertices(); + + this.geometry.buffers[1].update(); + + this.multiplyUvs(); + } +} diff --git a/packages/mesh-extras/src/Plane.js b/packages/mesh-extras/src/Plane.js new file mode 100644 index 0000000..1c240c4 --- /dev/null +++ b/packages/mesh-extras/src/Plane.js @@ -0,0 +1,100 @@ +import Mesh2d from './Mesh2d'; + +/** + * The Plane allows you to draw a texture across several points and them manipulate these points + * + *```js + * for (let i = 0; i < 20; i++) { + * points.push(new PIXI.Point(i * 50, 0)); + * }; + * let Plane = new PIXI.Plane(PIXI.Texture.from("snake.png"), points); + * ``` + * + * @class + * @extends PIXI.Mesh + * @memberof PIXI + * + */ +export default class Plane extends Mesh2d +{ + /** + * @param {PIXI.Texture} texture - The texture to use on the Plane. + * @param {number} verticesX - The number of vertices in the x-axis + * @param {number} verticesY - The number of vertices in the y-axis + * @param {object} [opts] - an options object - add meshWidth and meshHeight, temporary object for PixiJS v5 alpha + */ + constructor(texture, verticesX, verticesY, opts = {}) + { + super(texture, new Float32Array(1), new Float32Array(1), new Uint16Array(1), 4); + + this.verticesX = verticesX || 10; + this.verticesY = verticesY || 10; + + this.meshWidth = opts.meshWidth || 0; + this.meshHeight = opts.meshHeight || 0; + + this.refresh(); + } + + /** + * Refreshes plane coordinates + * @private + */ + _refresh() + { + const texture = this._texture; + const total = this.verticesX * this.verticesY; + const verts = []; + const uvs = []; + const indices = []; + + const segmentsX = this.verticesX - 1; + const segmentsY = this.verticesY - 1; + + const sizeX = (this.meshWidth || texture.width) / segmentsX; + const sizeY = (this.meshHeight || texture.height) / segmentsY; + + for (let i = 0; i < total; i++) + { + const x = (i % this.verticesX); + const y = ((i / this.verticesX) | 0); + + verts.push(x * sizeX, y * sizeY); + + uvs.push(x / segmentsX, y / segmentsY); + } + + // cons + + const totalSub = segmentsX * segmentsY; + + for (let i = 0; i < totalSub; i++) + { + const xpos = i % segmentsX; + const ypos = (i / segmentsX) | 0; + + const value = (ypos * this.verticesX) + xpos; + const value2 = (ypos * this.verticesX) + xpos + 1; + const value3 = ((ypos + 1) * this.verticesX) + xpos; + const value4 = ((ypos + 1) * this.verticesX) + xpos + 1; + + indices.push(value, value2, value3); + indices.push(value2, value4, value3); + } + + this.vertices = new Float32Array(verts); + this.uvs = new Float32Array(uvs); + this.indices = new Uint16Array(indices); + + this.geometry.buffers[0].data = this.vertices; + this.geometry.buffers[1].data = this.uvs; + this.geometry.indexBuffer.data = this.indices; + + // ensure that the changes are uploaded + this.geometry.buffers[0].update(); + this.geometry.buffers[1].update(); + this.geometry.indexBuffer.update(); + + this.multiplyUvs(); + } +} diff --git a/packages/mesh-extras/src/Rope.js b/packages/mesh-extras/src/Rope.js new file mode 100644 index 0000000..9cfde38 --- /dev/null +++ b/packages/mesh-extras/src/Rope.js @@ -0,0 +1,182 @@ +import Mesh2d from './Mesh2d'; + +/** + * The rope allows you to draw a texture across several points and them manipulate these points + * + *```js + * for (let i = 0; i < 20; i++) { + * points.push(new PIXI.Point(i * 50, 0)); + * }; + * let rope = new PIXI.Rope(PIXI.Texture.from("snake.png"), points); + * ``` + * + * @class + * @extends PIXI.Mesh + * @memberof PIXI + * + */ +export default class Rope extends Mesh2d +{ + /** + * @param {PIXI.Texture} texture - The texture to use on the rope. + * @param {PIXI.Point[]} points - An array of {@link PIXI.Point} objects to construct this rope. + */ + constructor(texture, points) + { + super(texture, new Float32Array(points.length * 4), + new Float32Array(points.length * 4), + new Uint16Array(points.length * 2), + 5); + + /* + * @member {PIXI.Point[]} An array of points that determine the rope + */ + this.points = points; + this.refresh(); + } + /** + * Refreshes Rope indices and uvs + * @private + */ + _refresh() + { + const points = this.points; + + if (!points) return; + + const vertexBuffer = this.geometry.getAttribute('aVertexPosition'); + const uvBuffer = this.geometry.getAttribute('aTextureCoord'); + const indexBuffer = this.geometry.getIndex(); + + // if too little points, or texture hasn't got UVs set yet just move on. + if (points.length < 1 || !this.texture._uvs) + { + return; + } + + // if the number of points has changed we will need to recreate the arraybuffers + if (vertexBuffer.data.length / 4 !== points.length) + { + vertexBuffer.data = new Float32Array(points.length * 4); + uvBuffer.data = new Float32Array(points.length * 4); + indexBuffer.data = new Uint16Array(points.length * 2); + } + + const uvs = uvBuffer.data; + const indices = indexBuffer.data; + + uvs[0] = 0; + uvs[1] = 0; + uvs[2] = 0; + uvs[3] = 1; + + indices[0] = 0; + indices[1] = 1; + + const total = points.length; + + for (let i = 1; i < total; i++) + { + // time to do some smart drawing! + let index = i * 4; + const amount = i / (total - 1); + + uvs[index] = amount; + uvs[index + 1] = 0; + + uvs[index + 2] = amount; + uvs[index + 3] = 1; + + index = i * 2; + indices[index] = index; + indices[index + 1] = index + 1; + } + + // ensure that the changes are uploaded + uvBuffer.update(); + indexBuffer.update(); + + this.multiplyUvs(); + this.refreshVertices(); + } + + /** + * refreshes vertices of Rope mesh + */ + refreshVertices() + { + const points = this.points; + + if (points.length < 1) + { + return; + } + + let lastPoint = points[0]; + let nextPoint; + let perpX = 0; + let perpY = 0; + + // this.count -= 0.2; + + const vertices = this.vertices; + const total = points.length; + + for (let i = 0; i < total; i++) + { + const point = points[i]; + const index = i * 4; + + if (i < points.length - 1) + { + nextPoint = points[i + 1]; + } + else + { + nextPoint = point; + } + + perpY = -(nextPoint.x - lastPoint.x); + perpX = nextPoint.y - lastPoint.y; + + let ratio = (1 - (i / (total - 1))) * 10; + + if (ratio > 1) + { + ratio = 1; + } + + const perpLength = Math.sqrt((perpX * perpX) + (perpY * perpY)); + const num = this._texture.height / 2; // (20 + Math.abs(Math.sin((i + this.count) * 0.3) * 50) )* ratio; + + perpX /= perpLength; + perpY /= perpLength; + + perpX *= num; + perpY *= num; + + vertices[index] = point.x + perpX; + vertices[index + 1] = point.y + perpY; + vertices[index + 2] = point.x - perpX; + vertices[index + 3] = point.y - perpY; + + lastPoint = point; + } + + this.geometry.buffers[0].update(); + } + + /** + * Updates the object transform for rendering + * + * @private + */ + updateTransform() + { + if (this.autoUpdate) + { + this.refreshVertices(); + } + this.containerUpdateTransform(); + } +} diff --git a/packages/mesh-extras/src/index.js b/packages/mesh-extras/src/index.js new file mode 100644 index 0000000..decf454 --- /dev/null +++ b/packages/mesh-extras/src/index.js @@ -0,0 +1,4 @@ +export { default as Mesh2d } from './Mesh2d'; +export { default as Plane } from './Plane'; +export { default as NineSlicePlane } from './NineSlicePlane'; +export { default as Rope } from './Rope'; diff --git a/packages/mesh-extras/src/mesh.frag b/packages/mesh-extras/src/mesh.frag new file mode 100644 index 0000000..6096983 --- /dev/null +++ b/packages/mesh-extras/src/mesh.frag @@ -0,0 +1,9 @@ +varying vec2 vTextureCoord; +uniform vec4 uColor; + +uniform sampler2D uSampler; + +void main(void) +{ + gl_FragColor = texture2D(uSampler, vTextureCoord) * uColor; +} diff --git a/bundles/pixi.js/package.json b/bundles/pixi.js/package.json index 49c7276..177e059 100644 --- a/bundles/pixi.js/package.json +++ b/bundles/pixi.js/package.json @@ -49,6 +49,7 @@ "@pixi/loaders": "^5.0.0-alpha.2", "@pixi/math": "^5.0.0-alpha.2", "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/mesh-extras": "^5.0.0-alpha.2", "@pixi/mixin-cache-as-bitmap": "^5.0.0-alpha.2", "@pixi/mixin-get-child-by-name": "^5.0.0-alpha.2", "@pixi/mixin-get-global-position": "^5.0.0-alpha.2", diff --git a/bundles/pixi.js/src/deprecated.js b/bundles/pixi.js/src/deprecated.js index 147617c..dbebeb0 100644 --- a/bundles/pixi.js/src/deprecated.js +++ b/bundles/pixi.js/src/deprecated.js @@ -263,15 +263,15 @@ Object.defineProperties(PIXI.mesh, { /** * @class PIXI.mesh.Mesh - * @see PIXI.Mesh + * @see PIXI.Mesh2d * @deprecated since 5.0.0 */ Mesh: { get() { - warn('PIXI.mesh.Mesh has moved to PIXI.Mesh'); + warn('PIXI.mesh.Mesh has moved to PIXI.Mesh2d'); - return PIXI.Mesh; + return PIXI.Mesh2d; }, }, /** @@ -315,15 +315,15 @@ }, /** * @class PIXI.mesh.RawMesh - * @see PIXI.RawMesh + * @see PIXI.Mesh * @deprecated since 5.0.0 */ RawMesh: { get() { - warn('PIXI.mesh.RawMesh has moved to PIXI.RawMesh'); + warn('PIXI.mesh.RawMesh has moved to PIXI.Mesh'); - return PIXI.RawMesh; + return PIXI.Mesh; }, }, /** diff --git a/bundles/pixi.js/src/index.js b/bundles/pixi.js/src/index.js index a3a0d1b..6fdabf0 100644 --- a/bundles/pixi.js/src/index.js +++ b/bundles/pixi.js/src/index.js @@ -9,6 +9,7 @@ import * as loaders from '@pixi/loaders'; import * as math from '@pixi/math'; import * as mesh from '@pixi/mesh'; +import * as meshExtras from '@pixi/mesh-extras'; import * as particles from '@pixi/particles'; import * as prepare from '@pixi/prepare'; import * as sprite from '@pixi/sprite'; @@ -128,6 +129,7 @@ loaders, math, mesh, + meshExtras, particles, sprite, spriteAnimated, @@ -152,6 +154,7 @@ export * from '@pixi/loaders'; export * from '@pixi/math'; export * from '@pixi/mesh'; +export * from '@pixi/mesh-extras'; export * from '@pixi/particles'; export * from '@pixi/sprite'; export * from '@pixi/spritesheet'; diff --git a/package-lock.json b/package-lock.json index 7fe6db7..0814729 100644 --- a/package-lock.json +++ b/package-lock.json @@ -209,7 +209,7 @@ "argparse": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", - "integrity": "sha1-vNZ5HqWuCXJeF+WtmIE0zUCz2RE=", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", "dev": true, "requires": { "sprintf-js": "1.0.3" @@ -228,7 +228,7 @@ "arr-flatten": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz", - "integrity": "sha1-NgSLv/TntH4TZkQxbJlmnqWukfE=", + "integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==", "dev": true }, "arr-union": { @@ -297,7 +297,7 @@ "assertion-error": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", - "integrity": "sha1-5gtrDo8wG9l+U3UhW9pAbIURjAs=", + "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", "dev": true }, "async": { @@ -396,7 +396,7 @@ "brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha1-PH/L9SnYcibz0vUrlm/1Jx60Qd0=", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, "requires": { "balanced-match": "1.0.0", @@ -568,7 +568,7 @@ "circular-json": { "version": "0.3.3", "resolved": "https://registry.npmjs.org/circular-json/-/circular-json-0.3.3.tgz", - "integrity": "sha1-gVyZ6oT2gJUp0vRXkb34JxE1LWY=", + "integrity": "sha512-UZK3NBx2Mca+b5LsG7bY183pHWt5Y1xts4P3Pz7ENTwGVnJOUWbRb3ocjvX7hx9tq/yTAdclXm9sZ38gNuem4A==", "dev": true }, "cli-cursor": { @@ -638,7 +638,7 @@ "color-convert": { "version": "1.9.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.1.tgz", - "integrity": "sha1-wSYRB66y8pTr/+ye2eytUppgl+0=", + "integrity": "sha512-mjGanIiwQJskCC18rPR6OmrZ6fm2Lc7PeGFYwCmy5J34wC6F1PzdGL6xeMfmgicfYcNLGuVFA3WzXtIDCQSZxQ==", "dev": true, "requires": { "color-name": "1.1.3" @@ -1427,7 +1427,7 @@ "boom": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/boom/-/boom-5.2.0.tgz", - "integrity": "sha1-XdnabuOl8wIHdDYpDLcX0/SlTgI=", + "integrity": "sha512-Z5BTk6ZRe4tXXQlkqftmsAUANpXmuwlsF5Oov8ThoMbQRzdGTA1ngYRW160GexgOgjsFOKJz0LYhoNi+2AMBUw==", "dev": true, "requires": { "hoek": "4.2.1" @@ -1471,7 +1471,7 @@ "debug": { "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha1-XRKFFd8TT/Mn6QpMk/Tgd6U2NB8=", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", "dev": true, "requires": { "ms": "2.0.0" @@ -1585,7 +1585,7 @@ "doctrine": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", - "integrity": "sha1-XNAfwQFiG0LEzX9dGmYkNxbT850=", + "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", "dev": true, "requires": { "esutils": "2.0.2" @@ -1662,7 +1662,7 @@ "es6-promise": { "version": "4.2.4", "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.4.tgz", - "integrity": "sha1-3EIhwrFlGHYL2MOaUtjzVvwA7Sk=", + "integrity": "sha512-/NdNZVJg+uZgtm9eS3O6lrOLYmQag2DjdEXuPaHlZ6RuVqgqaVZfgYCepEIKsLqwdQArOPtC3XzRLqGGfT8KQQ==", "dev": true }, "escape-string-regexp": { @@ -1788,7 +1788,7 @@ "espree": { "version": "3.5.4", "resolved": "https://registry.npmjs.org/espree/-/espree-3.5.4.tgz", - "integrity": "sha1-sPRHGHyKi+2US4FaZgvd9d610ac=", + "integrity": "sha512-yAcIQxtmMiB/jL32dzEp2enBeidsB7xWPLNiw3IIkpVds1P+h7qF9YwJq1yUNzp2OKXgAprs4F61ih66UsoD1A==", "dev": true, "requires": { "acorn": "5.5.0", @@ -1798,7 +1798,7 @@ "esprima": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.0.tgz", - "integrity": "sha1-RJnt3NERDgshi6zy+n9/WfVcqAQ=", + "integrity": "sha512-oftTcaMu/EGrEIu904mWteKIv8vMuOgGYo7EhVJJN00R/EED9DCua/xxHRdYnKtcECzVg7xOWhflvJMnqcFZjw==", "dev": true }, "esquery": { @@ -1813,7 +1813,7 @@ "esrecurse": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.2.1.tgz", - "integrity": "sha1-AHo7n9vCs7uH5IeeoZyS/b05Qs8=", + "integrity": "sha512-64RBB++fIOAXPw3P9cy89qfMlvZEXZkqqJkjqqXIvzP5ezRZjW+lPWjw35UX/3EhUPFYbg5ER4JYgDw4007/DQ==", "dev": true, "requires": { "estraverse": "4.2.0" @@ -2024,7 +2024,7 @@ "find-root": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/find-root/-/find-root-1.1.0.tgz", - "integrity": "sha1-q8/Iunb3CMQql7PWhbfpRQv7nOQ=", + "integrity": "sha512-NKfW6bec6GfKc0SGx1e07QZY9PE99u0Bft/0rzSD5k3sO/vwkVUpDUKVm5Gpp5Ue3YfShPFTX2070tDs5kB9Ng==", "dev": true }, "find-up": { @@ -2103,7 +2103,7 @@ "supports-color": { "version": "5.3.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.3.0.tgz", - "integrity": "sha1-WySsFduA+pJ89SJ6SjP9PEx2dsA=", + "integrity": "sha512-0aP01LLIskjKs3lq52EC0aGBAJhLq7B2Rd8HC/DR/PtNNpcLilNmHC12O+hu0usQpo7wtHNRqtrhBwtDb0+dNg==", "dev": true, "requires": { "has-flag": "3.0.0" @@ -2567,7 +2567,7 @@ "glob": { "version": "7.1.2", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", - "integrity": "sha1-wZyd+aAocC1nhhI4SmVSQExjbRU=", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", "dev": true, "requires": { "fs.realpath": "1.0.0", @@ -2672,7 +2672,7 @@ "growl": { "version": "1.10.3", "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.3.tgz", - "integrity": "sha1-GSa6kM8+3+KttJJ/WIC8IsZseQ8=", + "integrity": "sha512-hKlsbA5Vu3xsh1Cg3J7jSmX/WaW6A5oBeqzM88oNbCRQFz+zUaXm6yxS4RVytp1scBoJzSYl4YAEOQIt6O8V1Q==", "dev": true }, "handlebars": { @@ -2738,7 +2738,7 @@ "hawk": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/hawk/-/hawk-6.0.2.tgz", - "integrity": "sha1-r02RTrBl+bXOTZ0RwcshJu7MMDg=", + "integrity": "sha512-miowhl2+U7Qle4vdLqDdPt9m09K6yZhkLDTWGoUiUzrQCn+mHHSmfJgAyGaLRZbPmTqfFFjRV1QWCW0VWUJBbQ==", "dev": true, "requires": { "boom": "4.3.1", @@ -2756,7 +2756,7 @@ "hoek": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/hoek/-/hoek-4.2.1.tgz", - "integrity": "sha1-ljRQKqEsRF3Vp8VzS1cruHOKrLs=", + "integrity": "sha512-QLg82fGkfnJ/4iy1xZ81/9SIJiq1NGFUMGs6ParyjBZr6jW2Ufj/snDqTHixNlHdPNwN2RLVD0Pi3igeK9+JfA==", "dev": true }, "home-path": { @@ -2791,7 +2791,7 @@ "ignore": { "version": "3.3.7", "resolved": "https://registry.npmjs.org/ignore/-/ignore-3.3.7.tgz", - "integrity": "sha1-YSKJv7PCIOGGpYEYYY1b6MG6sCE=", + "integrity": "sha512-YGG3ejvBNHRqu0559EOxxNFihD0AjpvHlC/pdGKd3X3ofe+CoJkYazwNJYTNebqpPKN+VVQbh4ZFn1DivMNuHA==", "dev": true }, "imurmurhash": { @@ -2828,7 +2828,7 @@ "ini": { "version": "1.3.5", "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", - "integrity": "sha1-7uJfVtscnsYIXgwid4CD9Zar+Sc=", + "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==", "dev": true }, "inquirer": { @@ -2901,7 +2901,7 @@ "is-buffer": { "version": "1.1.6", "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", - "integrity": "sha1-76ouqdqg16suoTqXsritUf776L4=", + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", "dev": true }, "is-builtin-module": { @@ -3054,7 +3054,7 @@ "is-resolvable": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/is-resolvable/-/is-resolvable-1.1.0.tgz", - "integrity": "sha1-+xj4fOH+uSUWnJpAfBkxijIG7Yg=", + "integrity": "sha512-qgDYXFSR5WvEfuS5dMj6oTMEbrrSaM0CrFk2Yiq/gXnBvD9pMa2jGXxyhGLfvhZpuMZe18CJpFxAt3CRs42NMg==", "dev": true }, "is-retry-allowed": { @@ -3204,7 +3204,7 @@ "js-yaml": { "version": "3.11.0", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.11.0.tgz", - "integrity": "sha1-WXwai9VxUvJtYizkEXhRpR9euu8=", + "integrity": "sha512-saJstZWv7oNeOyBh3+Dx1qWzhW0+e6/8eDzo7p5rDFqxntSztloLtuKu+Ejhtq82jsilwOIZYsCz+lIjthg1Hw==", "dev": true, "requires": { "argparse": "1.0.10", @@ -3324,7 +3324,7 @@ "just-extend": { "version": "1.1.27", "resolved": "https://registry.npmjs.org/just-extend/-/just-extend-1.1.27.tgz", - "integrity": "sha1-7G55QQ/5FORyZSq/oOYDwD1g6QU=", + "integrity": "sha512-mJVp13Ix6gFo3SBAy9U/kL+oeZqzlYYYLQBwXVBlVzIsZwBqGREnOro24oC/8s8aox+rJhtZ2DiQof++IrkA+g==", "dev": true }, "kind-of": { @@ -3703,7 +3703,7 @@ "lodash": { "version": "4.17.5", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.5.tgz", - "integrity": "sha1-maktZcAnLevoyWtgV7yPv6O+1RE=", + "integrity": "sha512-svL3uiZf1RwhH+cWrfZn3A4+U58wbP0tGVTLQPbjplZxZ8ROD9VLuNgsRniTlLe7OlSqR79RUehXgpBW/s0IQw==", "dev": true }, "lodash._reinterpolate": { @@ -3740,7 +3740,7 @@ "lolex": { "version": "2.3.2", "resolved": "https://registry.npmjs.org/lolex/-/lolex-2.3.2.tgz", - "integrity": "sha1-hflFBCUQO/nnpgZo6iXcQydMqAc=", + "integrity": "sha512-A5pN2tkFj7H0dGIAM6MFvHKMJcPnjZsOMvR7ujCjfgW5TbV6H9vb1PgxLtHvjqNZTHsUolz+6/WEO0N1xNx2ng==", "dev": true }, "longest": { @@ -3816,7 +3816,7 @@ "marked": { "version": "0.3.17", "resolved": "https://registry.npmjs.org/marked/-/marked-0.3.17.tgz", - "integrity": "sha1-YH8GZos8axJGso8T2nYRasGqLSs=", + "integrity": "sha512-+AKbNsjZl6jFfLPwHhWmGTqE009wTKn3RTmn9K8oUKHrX/abPJjtcRtXpYB/FFrwPJRUA86LX/de3T0knkPCmQ==", "dev": true }, "mem": { @@ -3896,13 +3896,13 @@ "mime-db": { "version": "1.33.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.33.0.tgz", - "integrity": "sha1-o0kgUKXLm2NFBUHjnZeI0icng9s=", + "integrity": "sha512-BHJ/EKruNIqJf/QahvxwQZXKygOQ256myeN/Ew+THcAa5q+PjyTTMMeNQC4DZw5AwfvelsUrA6B67NKMqXDbzQ==", "dev": true }, "mime-types": { "version": "2.1.18", "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.18.tgz", - "integrity": "sha1-bzI/YKg9ERRvgx/xH9ZuL+VQO7g=", + "integrity": "sha512-lc/aahn+t4/SWV/qcmumYjymLsWfN3ELhpmVuUFjgsORruuZPVSwAQryq+HHGvO/SI2KVX26bx+En+zhM8g8hQ==", "dev": true, "requires": { "mime-db": "1.33.0" @@ -3917,7 +3917,7 @@ "minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha1-UWbihkV/AzBgZL5Ul+jbsMPTIIM=", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "dev": true, "requires": { "brace-expansion": "1.1.11" @@ -4071,7 +4071,7 @@ "normalize-package-data": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.4.0.tgz", - "integrity": "sha1-EvlaMH1YNSB1oEkHuErIvpisAS8=", + "integrity": "sha512-9jjUFbTPfEy3R/ad/2oNbKtW9Hgovl5O1FvFWKkKblNXoN/Oou6+9+KKohPK13Yc3/TyunyWhJp6gvRNR/PPAw==", "dev": true, "requires": { "hosted-git-info": "2.5.0", @@ -4511,7 +4511,7 @@ "process-nextick-args": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", - "integrity": "sha1-o31zL0JxtKsa0HDTVQjoKQeI/6o=", + "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==", "dev": true }, "progress": { @@ -4584,7 +4584,7 @@ "qs": { "version": "6.5.1", "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.1.tgz", - "integrity": "sha1-NJzfbu+J7EXBLX1es/wMhwNDptg=", + "integrity": "sha512-eRzhrN1WSINYCDCbrz796z37LOe3m5tmW7RQf6oBntukAG1nmovJvhnwHHRMAfeoItc1m2Hk02WER2aQ/iqs+A==", "dev": true }, "quick-lru": { @@ -4596,7 +4596,7 @@ "randomatic": { "version": "1.1.7", "resolved": "https://registry.npmjs.org/randomatic/-/randomatic-1.1.7.tgz", - "integrity": "sha1-x6vpzIuHwLqodrGf3oP9RkeX44w=", + "integrity": "sha512-D5JUjPyJbaJDkuAazpVnSfVkLlpeO3wDlPROTMLGKG1zMFNFRgrciKo1ltz/AzNTkqE0HzDx655QOL51N06how==", "dev": true, "requires": { "is-number": "3.0.0", @@ -4701,7 +4701,7 @@ "regex-cache": { "version": "0.4.4", "resolved": "https://registry.npmjs.org/regex-cache/-/regex-cache-0.4.4.tgz", - "integrity": "sha1-db3FiioUls7EihKDW8VMjVYjNt0=", + "integrity": "sha512-nVIZwtCjkC9YgvWkpM55B5rBhBYRZhAaJbgcFYXXsHnbZ9UZI9nnVWYZpBlCqv9ho2eZryPnWrZGsOdPwVWXWQ==", "dev": true, "requires": { "is-equal-shallow": "0.1.3" @@ -4729,7 +4729,7 @@ "remap-istanbul": { "version": "0.10.1", "resolved": "https://registry.npmjs.org/remap-istanbul/-/remap-istanbul-0.10.1.tgz", - "integrity": "sha1-OqWN1QIdSZ8zbTulvzu7kcG4jjc=", + "integrity": "sha512-gsNQXs5kJLhErICSyYhzVZ++C8LBW8dgwr874Y2QvzAUS75zBlD/juZgXs39nbYJ09fZDlX2AVLVJAY2jbFJoQ==", "dev": true, "requires": { "amdefine": "1.0.1", @@ -4769,7 +4769,7 @@ "source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha1-dHIq8y6WFOnCh6jQu95IteLxomM=", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", "dev": true }, "through2": { @@ -4883,7 +4883,7 @@ "resolve": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.5.0.tgz", - "integrity": "sha1-HwmsznlsmnYlefMbLBzEw83fnzY=", + "integrity": "sha512-hgoSGrc3pjzAPHNBg+KnFcK2HwlHTs/YrAGUr6qgTVUZmXv1UEXXl0bZNBKMA9fud6lRYFdPGz0xXxycPzmmiw==", "dev": true, "requires": { "path-parse": "1.0.5" @@ -4924,7 +4924,7 @@ "rimraf": { "version": "2.6.2", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", - "integrity": "sha1-LtgVDSShbqhlHm1u8PR8QVjOejY=", + "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", "dev": true, "requires": { "glob": "7.1.2" @@ -5063,19 +5063,19 @@ "safe-buffer": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", - "integrity": "sha1-iTMSr2myEj3vcfV4iQAWce6yyFM=", + "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", "dev": true }, "samsam": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/samsam/-/samsam-1.3.0.tgz", - "integrity": "sha1-jR2TUOJWItow3j5EumkrUiGrfFA=", + "integrity": "sha512-1HwIYD/8UlOtFS3QO3w7ey+SdSDFE4HRNLZoZRYVQefrOY3l17epswImeB1ijgJFQJodIaHcwkp3r/myBjFVbg==", "dev": true }, "semver": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz", - "integrity": "sha1-3Eu8emyp2Rbe5dQ1FvAJK1j3uKs=", + "integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==", "dev": true }, "set-blocking": { @@ -5117,7 +5117,7 @@ "sinon-chai": { "version": "2.14.0", "resolved": "https://registry.npmjs.org/sinon-chai/-/sinon-chai-2.14.0.tgz", - "integrity": "sha1-2n3UzIPNaiYLZ8yg96n9riahIF0=", + "integrity": "sha512-9stIF1utB0ywNHNT7RgiXbdmen8QDCRsrTjw+G9TgKt1Yexjiv8TOWZ6WHsTPz57Yky3DIswZvEqX8fpuHNDtQ==", "dev": true }, "slash": { @@ -5146,7 +5146,7 @@ "sntp": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/sntp/-/sntp-2.1.0.tgz", - "integrity": "sha1-LGzsFP7cIiJznK+bXD2F0cxaLMg=", + "integrity": "sha512-FL1b58BDrqS3A11lJ0zEdnJ3UOKqVxawAkF3k7F0CVN7VQ34aZrV+G8BZ1WC9ZL7NyrwsW0oviwsWDgRuVYtJg==", "dev": true, "requires": { "hoek": "4.2.1" @@ -5203,7 +5203,7 @@ "spdx-correct": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.0.0.tgz", - "integrity": "sha1-BaW01xU6GVvJLDxCW2nzsqlSTII=", + "integrity": "sha512-N19o9z5cEyc8yQQPukRCZ9EUmb4HUpnrmaL/fxS2pBo2jbfcFRVuFZ/oFC+vZz0MNNk0h80iMn5/S6qGZOL5+g==", "dev": true, "requires": { "spdx-expression-parse": "3.0.0", @@ -5213,13 +5213,13 @@ "spdx-exceptions": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.1.0.tgz", - "integrity": "sha1-LHrmEFbHFKW5ubKyr30xHvXHj+k=", + "integrity": "sha512-4K1NsmrlCU1JJgUrtgEeTVyfx8VaYea9J9LvARxhbHtVtohPs/gFGG5yy49beySjlIMhhXZ4QqujIZEfS4l6Cg==", "dev": true }, "spdx-expression-parse": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.0.tgz", - "integrity": "sha1-meEZt6XaAOBUkcn6M4t5BII7QdA=", + "integrity": "sha512-Yg6D3XpRD4kkOmTpdgbUiEJFKghJH03fiC1OPll5h/0sO6neh2jqRDVHOQ4o/LMea0tgCkbMgea5ip/e+MkWyg==", "dev": true, "requires": { "spdx-exceptions": "2.1.0", @@ -5229,7 +5229,7 @@ "spdx-license-ids": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.0.tgz", - "integrity": "sha1-enzShHDMbToc/m1miG9rxDDTrIc=", + "integrity": "sha512-2+EPwgbnmOIl8HjGBXXMd9NAu02vLjOO1nWw4kmeRDFyHn+M/ETfHxQUK0oXg8ctgVnl9t3rosNVsZ1jG61nDA==", "dev": true }, "speedometer": { @@ -5566,7 +5566,7 @@ "tough-cookie": { "version": "2.3.4", "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.4.tgz", - "integrity": "sha1-7GDO44rGdQY//JelwYlwV47oNlU=", + "integrity": "sha512-TZ6TTfI5NtZnuyy/Kecv+CnoROnyXn2DN97LontgQpCwsX2XyLYCC0ENhYkehSOwAp8rTQKc/NUIF7BkQ5rKLA==", "dev": true, "requires": { "punycode": "1.4.1" @@ -5708,13 +5708,13 @@ "uuid": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.2.1.tgz", - "integrity": "sha1-EsUou51Y0LkmXZovbw/ovhf/HxQ=", + "integrity": "sha512-jZnMwlb9Iku/O3smGWvZhauCf6cvvpKi4BKRiliS3cxnI+Gz9j5MEpTz2UFuXiKPJocb7gnsLHwiS05ige5BEA==", "dev": true }, "validate-npm-package-license": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.3.tgz", - "integrity": "sha1-gWQ7y+8b3+zUYjeT3EZIlIupgzg=", + "integrity": "sha512-63ZOUnL4SIXj4L0NixR3L1lcjO38crAbgrTpl28t8jjrfuiOBL5Iygm+60qPs/KsZGzPNg6Smnc/oY16QTjF0g==", "dev": true, "requires": { "spdx-correct": "3.0.0", @@ -5750,7 +5750,7 @@ "which": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/which/-/which-1.3.0.tgz", - "integrity": "sha1-/wS9/AEO5UfXgL7DjhrBwnd9JTo=", + "integrity": "sha512-xcJpopdamTuY5duC/KnTTNBraPK54YwpenP4lzxU8H91GudWpFv38u0CKjclE1Wi2EH2EDz5LRcHcKbCIzqGyg==", "dev": true, "requires": { "isexe": "2.0.0" diff --git a/packages/canvas/canvas-mesh/package.json b/packages/canvas/canvas-mesh/package.json index 691cd2c..6744a17 100644 --- a/packages/canvas/canvas-mesh/package.json +++ b/packages/canvas/canvas-mesh/package.json @@ -24,6 +24,7 @@ "dependencies": { "@pixi/constants": "^5.0.0-alpha.2", "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/mesh-extras": "^5.0.0-alpha.2", "@pixi/settings": "^5.0.0-alpha.2" }, "devDependencies": { diff --git a/packages/canvas/canvas-mesh/src/Mesh.js b/packages/canvas/canvas-mesh/src/Mesh.js index 900a872..c43a74b 100644 --- a/packages/canvas/canvas-mesh/src/Mesh.js +++ b/packages/canvas/canvas-mesh/src/Mesh.js @@ -1,36 +1,14 @@ import { Mesh } from '@pixi/mesh'; -import { settings } from './settings'; - -// IMPORTANT: Please do NOT use this as a precedent to use `settings` after the object is created -// this was merely created to completely decouple canvas from the base Mesh class and we are -// unable to add `canvasPadding` in the constructor anymore, as the case was for PixiJS v4. /** - * Internal variable for `canvasPadding`. + * Renders the object using the Canvas renderer * * @private - * @memberof PIXI.Mesh - * @member {number} - * @default null - */ -Mesh.prototype._canvasPadding = null; - -/** - * Triangles in canvas mode are automatically antialiased, use this value to force triangles - * to overlap a bit with each other. To set the global default, set {@link PIXI.settings.MESH_CANVAS_PADDING} - * - * @see PIXI.settings.MESH_CANVAS_PADDING - * @member {number} canvasPadding + * @method _renderCanvas * @memberof PIXI.Mesh# - * @default 0 + * @param {PIXI.CanvasRenderer} renderer - The canvas renderer. */ -Object.defineProperty(Mesh.prototype, 'canvasPadding', { - get() - { - return this._canvasPadding !== null ? this._canvasPadding : settings.MESH_CANVAS_PADDING; - }, - set(value) - { - this._canvasPadding = value; - }, -}); +Mesh.prototype._renderCanvas = function _renderCanvas(renderer) +{ + renderer.plugins[this.pluginName].render(this); +}; diff --git a/packages/canvas/canvas-mesh/src/Mesh2d.js b/packages/canvas/canvas-mesh/src/Mesh2d.js new file mode 100644 index 0000000..d0bd80f --- /dev/null +++ b/packages/canvas/canvas-mesh/src/Mesh2d.js @@ -0,0 +1,36 @@ +import { Mesh2d } from '@pixi/mesh-extras'; +import { settings } from './settings'; + +// IMPORTANT: Please do NOT use this as a precedent to use `settings` after the object is created +// this was merely created to completely decouple canvas from the base Mesh class and we are +// unable to add `canvasPadding` in the constructor anymore, as the case was for PixiJS v4. + +/** + * Internal variable for `canvasPadding`. + * + * @private + * @memberof PIXI.Mesh2d + * @member {number} + * @default null + */ +Mesh2d.prototype._canvasPadding = null; + +/** + * Triangles in canvas mode are automatically antialiased, use this value to force triangles + * to overlap a bit with each other. To set the global default, set {@link PIXI.settings.MESH_CANVAS_PADDING} + * + * @see PIXI.settings.MESH_CANVAS_PADDING + * @member {number} canvasPadding + * @memberof PIXI.Mesh2d# + * @default 0 + */ +Object.defineProperty(Mesh2d.prototype, 'canvasPadding', { + get() + { + return this._canvasPadding !== null ? this._canvasPadding : settings.MESH_CANVAS_PADDING; + }, + set(value) + { + this._canvasPadding = value; + }, +}); diff --git a/packages/canvas/canvas-mesh/src/NineSlicePlane.js b/packages/canvas/canvas-mesh/src/NineSlicePlane.js index 09eaf9c..2fd5acc 100644 --- a/packages/canvas/canvas-mesh/src/NineSlicePlane.js +++ b/packages/canvas/canvas-mesh/src/NineSlicePlane.js @@ -1,4 +1,4 @@ -import { NineSlicePlane } from '@pixi/mesh'; +import { NineSlicePlane } from '@pixi/mesh-extras'; /** * Renders the object using the Canvas renderer diff --git a/packages/canvas/canvas-mesh/src/RawMesh.js b/packages/canvas/canvas-mesh/src/RawMesh.js deleted file mode 100644 index bf40184..0000000 --- a/packages/canvas/canvas-mesh/src/RawMesh.js +++ /dev/null @@ -1,14 +0,0 @@ -import { RawMesh } from '@pixi/mesh'; - -/** - * Renders the object using the Canvas renderer - * - * @private - * @method _renderCanvas - * @memberof PIXI.RawMesh# - * @param {PIXI.CanvasRenderer} renderer - The canvas renderer. - */ -RawMesh.prototype._renderCanvas = function _renderCanvas(renderer) -{ - renderer.plugins[this.pluginName].render(this); -}; diff --git a/packages/canvas/canvas-mesh/src/index.js b/packages/canvas/canvas-mesh/src/index.js index 2295016..f4fa31d 100644 --- a/packages/canvas/canvas-mesh/src/index.js +++ b/packages/canvas/canvas-mesh/src/index.js @@ -1,6 +1,6 @@ export { default as CanvasMeshRenderer } from './CanvasMeshRenderer'; import './settings'; -import './Mesh'; +import './Mesh2d'; import './NineSlicePlane'; -import './RawMesh'; +import './Mesh'; diff --git a/packages/canvas/canvas-mesh/src/settings.js b/packages/canvas/canvas-mesh/src/settings.js index 4cefb4c..e81b8e0 100644 --- a/packages/canvas/canvas-mesh/src/settings.js +++ b/packages/canvas/canvas-mesh/src/settings.js @@ -3,7 +3,7 @@ /** * Default `canvasPadding` for canvas-based Mesh rendering. * - * @see PIXI.Mesh#canvasPadding + * @see PIXI.Mesh2d#canvasPadding * @static * @constant * @memberof PIXI.settings diff --git a/packages/mesh-extras/LICENSE b/packages/mesh-extras/LICENSE new file mode 100644 index 0000000..148e3eb --- /dev/null +++ b/packages/mesh-extras/LICENSE @@ -0,0 +1,21 @@ +The MIT License + +Copyright (c) 2013-2018 Mathew Groves, Chad Engler + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/packages/mesh-extras/README.md b/packages/mesh-extras/README.md new file mode 100644 index 0000000..1d9b0e1 --- /dev/null +++ b/packages/mesh-extras/README.md @@ -0,0 +1,19 @@ +# @pixi/mesh-extras + +## Installation + +```bash +npm install @pixi/mesh-extras +``` + +## Usage + +```js +import { MeshRenderer } from '@pixi/mesh'; +import { Renderer } from '@pixi/core'; +import { Rope } from '@pixi/mesh-extras'; + +Renderer.registerPlugin('mesh', MeshRenderer); + +const rope = new Rope(); +``` \ No newline at end of file diff --git a/packages/mesh-extras/package.json b/packages/mesh-extras/package.json new file mode 100644 index 0000000..d134f64 --- /dev/null +++ b/packages/mesh-extras/package.json @@ -0,0 +1,38 @@ +{ + "name": "@pixi/mesh-extras", + "version": "5.0.0-alpha.2", + "main": "lib/mesh-extras.js", + "module": "lib/mesh-extras.es.js", + "description": "Custom Mesh display objects, like Rope and Plane", + "author": "Mat Groves", + "contributors": [ + "Matt Karl " + ], + "homepage": "http://pixijs.com/", + "bugs": "https://github.com/pixijs/pixi.js/issues", + "license": "MIT", + "repository": { + "type": "git", + "url": "https://github.com/pixijs/pixi.js.git" + }, + "publishConfig": { + "access": "public" + }, + "scripts": { + "test": "floss --path test" + }, + "files": [ + "lib" + ], + "dependencies": { + "@pixi/constants": "^5.0.0-alpha.2", + "@pixi/core": "^5.0.0-alpha.2", + "@pixi/math": "^5.0.0-alpha.2", + "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/utils": "^5.0.0-alpha.2" + }, + "devDependencies": { + "@pixi/loaders": "^5.0.0-alpha.2", + "floss": "^2.1.3" + } +} diff --git a/packages/mesh-extras/src/Mesh2d.js b/packages/mesh-extras/src/Mesh2d.js new file mode 100644 index 0000000..d113a5e --- /dev/null +++ b/packages/mesh-extras/src/Mesh2d.js @@ -0,0 +1,263 @@ +import { Mesh } from '@pixi/mesh'; +import { Geometry, Program, Shader, Texture, TextureMatrix } from '@pixi/core'; +import { Matrix } from '@pixi/math'; +import { BLEND_MODES } from '@pixi/constants'; +import { hex2rgb, premultiplyRgba } from '@pixi/utils'; +import vertex from './mesh.vert'; +import fragment from './mesh.frag'; + +let meshProgram; + +/** + * Base mesh class + * @class + * @extends PIXI.Container + * @memberof PIXI + */ +export default class Mesh2d extends Mesh +{ + /** + * @param {PIXI.Texture} [texture=Texture.EMPTY] - The texture to use + * @param {Float32Array} [vertices] - if you want to specify the vertices + * @param {Float32Array} [uvs] - if you want to specify the uvs + * @param {Uint16Array} [indices] - if you want to specify the indices + * @param {number} [drawMode] - the drawMode, can be any of the Mesh.DRAW_MODES consts + */ + constructor(texture = Texture.EMPTY, vertices, uvs, indices, drawMode) + { + const geometry = new Geometry(); + + if (!meshProgram) + { + meshProgram = new Program(vertex, fragment); + } + + geometry.addAttribute('aVertexPosition', vertices) + .addAttribute('aTextureCoord', uvs) + .addIndex(indices); + + geometry.getAttribute('aVertexPosition').static = false; + + const uniforms = { + uSampler: texture, + uTextureMatrix: Matrix.IDENTITY, + alpha: 1, + uColor: new Float32Array([1, 1, 1, 1]), + }; + + super(geometry, new Shader(meshProgram, uniforms), null, drawMode); + + /** + * The Uvs of the Mesh + * + * @member {Float32Array} + */ + this.uvs = geometry.getAttribute('aTextureCoord').data; + + /** + * An array of vertices + * + * @member {Float32Array} + */ + this.vertices = geometry.getAttribute('aVertexPosition').data; + + this.uniforms = uniforms; + + /** + * The texture of the Mesh + * + * @member {PIXI.Texture} + * @default PIXI.Texture.EMPTY + * @private + */ + this.texture = texture; + + /** + * The tint applied to the mesh. This is a [r,g,b] value. A value of [1,1,1] will remove any + * tint effect. + * + * @member {number} + * @private + */ + this._tintRGB = new Float32Array([1, 1, 1]); + + // Set default tint + this.tint = 0xFFFFFF; + + this.blendMode = BLEND_MODES.NORMAL; + + /** + * TextureMatrix instance for this Mesh, used to track Texture changes + * + * @member {PIXI.TextureMatrix} + * @readonly + */ + this.uvMatrix = new TextureMatrix(this._texture); + + /** + * whether or not upload uvMatrix to shader + * if its false, then uvs should be pre-multiplied + * if you change it for generated mesh, please call 'refresh(true)' + * @member {boolean} + * @default false + */ + this.uploadUvMatrix = false; + + /** + * Uploads vertices buffer every frame, like in PixiJS V3 and V4. + * + * @member {boolean} + * @default true + */ + this.autoUpdate = true; + } + + /** + * The tint applied to the Rope. This is a hex value. A value of + * 0xFFFFFF will remove any tint effect. + * + * @member {number} + * @memberof PIXI.Sprite# + * @default 0xFFFFFF + */ + get tint() + { + return this._tint; + } + + /** + * Sets the tint of the rope. + * + * @param {number} value - The value to set to. + */ + set tint(value) + { + this._tint = value; + + hex2rgb(this._tint, this._tintRGB); + } + + /** + * The blend mode to be applied to the sprite. Set to `PIXI.BLEND_MODES.NORMAL` to remove any blend mode. + * + * @member {number} + * @default PIXI.BLEND_MODES.NORMAL + * @see PIXI.BLEND_MODES + */ + get blendMode() + { + return this.state.blendMode; + } + + set blendMode(value) // eslint-disable-line require-jsdoc + { + this.state.blendMode = value; + } + + /** + * The texture that the mesh uses. + * + * @member {PIXI.Texture} + */ + get texture() + { + return this._texture; + } + + set texture(value) // eslint-disable-line require-jsdoc + { + if (this._texture === value) + { + return; + } + + this._texture = value; + this.uniforms.uSampler = this.texture; + + if (value) + { + // wait for the texture to load + if (value.baseTexture.valid) + { + this._onTextureUpdate(); + } + else + { + value.once('update', this._onTextureUpdate, this); + } + } + } + + _render(renderer) + { + const baseTex = this._texture.baseTexture; + + premultiplyRgba(this._tintRGB, this.worldAlpha, this.uniforms.uColor, baseTex.premultiplyAlpha); + super._render(renderer); + } + /** + * When the texture is updated, this event will fire to update the scale and frame + * + * @private + */ + _onTextureUpdate() + { + // constructor texture update stop + if (!this.uvMatrix) + { + return; + } + this.uvMatrix.texture = this._texture; + this.refresh(); + } + + /** + * multiplies uvs only if uploadUvMatrix is false + * call it after you change uvs manually + * make sure that texture is valid + */ + multiplyUvs() + { + if (!this.uploadUvMatrix) + { + this.uvMatrix.multiplyUvs(this.uvs); + } + } + + /** + * Refreshes uvs for generated meshes (rope, plane) + * sometimes refreshes vertices too + * + * @param {boolean} [forceUpdate=false] if true, matrices will be updated any case + */ + refresh(forceUpdate) + { + if (this.uvMatrix.update(forceUpdate)) + { + this._refresh(); + } + } + + /** + * Updates the object transform for rendering + * + * @private + */ + updateTransform() + { + if (this.autoUpdate) + { + this.geometry.buffers[0].update(); + } + this.containerUpdateTransform(); + } + + /** + * re-calculates mesh coords + * @private + */ + _refresh() + { + /* empty */ + } +} diff --git a/packages/mesh-extras/src/NineSlicePlane.js b/packages/mesh-extras/src/NineSlicePlane.js new file mode 100644 index 0000000..0bae92c --- /dev/null +++ b/packages/mesh-extras/src/NineSlicePlane.js @@ -0,0 +1,270 @@ +import Plane from './Plane'; + +const DEFAULT_BORDER_SIZE = 10; + +/** + * The NineSlicePlane allows you to stretch a texture using 9-slice scaling. The corners will remain unscaled (useful + * for buttons with rounded corners for example) and the other areas will be scaled horizontally and or vertically + * + *```js + * let Plane9 = new PIXI.NineSlicePlane(PIXI.Texture.from('BoxWithRoundedCorners.png'), 15, 15, 15, 15); + * ``` + *
+ *      A                          B
+ *    +---+----------------------+---+
+ *  C | 1 |          2           | 3 |
+ *    +---+----------------------+---+
+ *    |   |                      |   |
+ *    | 4 |          5           | 6 |
+ *    |   |                      |   |
+ *    +---+----------------------+---+
+ *  D | 7 |          8           | 9 |
+ *    +---+----------------------+---+
+
+ *  When changing this objects width and/or height:
+ *     areas 1 3 7 and 9 will remain unscaled.
+ *     areas 2 and 8 will be stretched horizontally
+ *     areas 4 and 6 will be stretched vertically
+ *     area 5 will be stretched both horizontally and vertically
+ * 
+ * + * @class + * @extends PIXI.Plane + * @memberof PIXI + * + */ +export default class NineSlicePlane extends Plane +{ + /** + * @param {PIXI.Texture} texture - The texture to use on the NineSlicePlane. + * @param {int} [leftWidth=10] size of the left vertical bar (A) + * @param {int} [topHeight=10] size of the top horizontal bar (C) + * @param {int} [rightWidth=10] size of the right vertical bar (B) + * @param {int} [bottomHeight=10] size of the bottom horizontal bar (D) + */ + constructor(texture, leftWidth, topHeight, rightWidth, bottomHeight) + { + super(texture, 4, 4); + + this._origWidth = texture.orig.width; + this._origHeight = texture.orig.height; + + /** + * The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._width = this._origWidth; + + /** + * The height of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._height = this._origHeight; + + /** + * The width of the left column (a) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._leftWidth = typeof leftWidth !== 'undefined' ? leftWidth : DEFAULT_BORDER_SIZE; + + /** + * The width of the right column (b) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._rightWidth = typeof rightWidth !== 'undefined' ? rightWidth : DEFAULT_BORDER_SIZE; + + /** + * The height of the top row (c) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._topHeight = typeof topHeight !== 'undefined' ? topHeight : DEFAULT_BORDER_SIZE; + + /** + * The height of the bottom row (d) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._bottomHeight = typeof bottomHeight !== 'undefined' ? bottomHeight : DEFAULT_BORDER_SIZE; + + this.refresh(true); + } + + /** + * Updates the horizontal vertices. + * + */ + updateHorizontalVertices() + { + const vertices = this.vertices; + + const h = this._topHeight + this._bottomHeight; + const scale = this._height > h ? 1.0 : this._height / h; + + vertices[9] = vertices[11] = vertices[13] = vertices[15] = this._topHeight * scale; + vertices[17] = vertices[19] = vertices[21] = vertices[23] = this._height - (this._bottomHeight * scale); + vertices[25] = vertices[27] = vertices[29] = vertices[31] = this._height; + } + + /** + * Updates the vertical vertices. + * + */ + updateVerticalVertices() + { + const vertices = this.vertices; + + const w = this._leftWidth + this._rightWidth; + const scale = this._width > w ? 1.0 : this._width / w; + + vertices[2] = vertices[10] = vertices[18] = vertices[26] = this._leftWidth * scale; + vertices[4] = vertices[12] = vertices[20] = vertices[28] = this._width - (this._rightWidth * scale); + vertices[6] = vertices[14] = vertices[22] = vertices[30] = this._width; + } + + /** + * The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + */ + get width() + { + return this._width; + } + + set width(value) // eslint-disable-line require-jsdoc + { + this._width = value; + this._refresh(); + } + + /** + * The height of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + */ + get height() + { + return this._height; + } + + set height(value) // eslint-disable-line require-jsdoc + { + this._height = value; + this._refresh(); + } + + /** + * The width of the left column + * + * @member {number} + */ + get leftWidth() + { + return this._leftWidth; + } + + set leftWidth(value) // eslint-disable-line require-jsdoc + { + this._leftWidth = value; + this._refresh(); + } + + /** + * The width of the right column + * + * @member {number} + */ + get rightWidth() + { + return this._rightWidth; + } + + set rightWidth(value) // eslint-disable-line require-jsdoc + { + this._rightWidth = value; + this._refresh(); + } + + /** + * The height of the top row + * + * @member {number} + */ + get topHeight() + { + return this._topHeight; + } + + set topHeight(value) // eslint-disable-line require-jsdoc + { + this._topHeight = value; + this._refresh(); + } + + /** + * The height of the bottom row + * + * @member {number} + */ + get bottomHeight() + { + return this._bottomHeight; + } + + set bottomHeight(value) // eslint-disable-line require-jsdoc + { + this._bottomHeight = value; + this._refresh(); + } + + /** + * Refreshes NineSlicePlane coords. All of them. + */ + _refresh() + { + super._refresh(); + + const uvs = this.uvs; + const texture = this._texture; + + this._origWidth = texture.orig.width; + this._origHeight = texture.orig.height; + + const _uvw = 1.0 / this._origWidth; + const _uvh = 1.0 / this._origHeight; + + uvs[0] = uvs[8] = uvs[16] = uvs[24] = 0; + uvs[1] = uvs[3] = uvs[5] = uvs[7] = 0; + uvs[6] = uvs[14] = uvs[22] = uvs[30] = 1; + uvs[25] = uvs[27] = uvs[29] = uvs[31] = 1; + + uvs[2] = uvs[10] = uvs[18] = uvs[26] = _uvw * this._leftWidth; + uvs[4] = uvs[12] = uvs[20] = uvs[28] = 1 - (_uvw * this._rightWidth); + uvs[9] = uvs[11] = uvs[13] = uvs[15] = _uvh * this._topHeight; + uvs[17] = uvs[19] = uvs[21] = uvs[23] = 1 - (_uvh * this._bottomHeight); + + this.updateHorizontalVertices(); + this.updateVerticalVertices(); + + this.geometry.buffers[1].update(); + + this.multiplyUvs(); + } +} diff --git a/packages/mesh-extras/src/Plane.js b/packages/mesh-extras/src/Plane.js new file mode 100644 index 0000000..1c240c4 --- /dev/null +++ b/packages/mesh-extras/src/Plane.js @@ -0,0 +1,100 @@ +import Mesh2d from './Mesh2d'; + +/** + * The Plane allows you to draw a texture across several points and them manipulate these points + * + *```js + * for (let i = 0; i < 20; i++) { + * points.push(new PIXI.Point(i * 50, 0)); + * }; + * let Plane = new PIXI.Plane(PIXI.Texture.from("snake.png"), points); + * ``` + * + * @class + * @extends PIXI.Mesh + * @memberof PIXI + * + */ +export default class Plane extends Mesh2d +{ + /** + * @param {PIXI.Texture} texture - The texture to use on the Plane. + * @param {number} verticesX - The number of vertices in the x-axis + * @param {number} verticesY - The number of vertices in the y-axis + * @param {object} [opts] - an options object - add meshWidth and meshHeight, temporary object for PixiJS v5 alpha + */ + constructor(texture, verticesX, verticesY, opts = {}) + { + super(texture, new Float32Array(1), new Float32Array(1), new Uint16Array(1), 4); + + this.verticesX = verticesX || 10; + this.verticesY = verticesY || 10; + + this.meshWidth = opts.meshWidth || 0; + this.meshHeight = opts.meshHeight || 0; + + this.refresh(); + } + + /** + * Refreshes plane coordinates + * @private + */ + _refresh() + { + const texture = this._texture; + const total = this.verticesX * this.verticesY; + const verts = []; + const uvs = []; + const indices = []; + + const segmentsX = this.verticesX - 1; + const segmentsY = this.verticesY - 1; + + const sizeX = (this.meshWidth || texture.width) / segmentsX; + const sizeY = (this.meshHeight || texture.height) / segmentsY; + + for (let i = 0; i < total; i++) + { + const x = (i % this.verticesX); + const y = ((i / this.verticesX) | 0); + + verts.push(x * sizeX, y * sizeY); + + uvs.push(x / segmentsX, y / segmentsY); + } + + // cons + + const totalSub = segmentsX * segmentsY; + + for (let i = 0; i < totalSub; i++) + { + const xpos = i % segmentsX; + const ypos = (i / segmentsX) | 0; + + const value = (ypos * this.verticesX) + xpos; + const value2 = (ypos * this.verticesX) + xpos + 1; + const value3 = ((ypos + 1) * this.verticesX) + xpos; + const value4 = ((ypos + 1) * this.verticesX) + xpos + 1; + + indices.push(value, value2, value3); + indices.push(value2, value4, value3); + } + + this.vertices = new Float32Array(verts); + this.uvs = new Float32Array(uvs); + this.indices = new Uint16Array(indices); + + this.geometry.buffers[0].data = this.vertices; + this.geometry.buffers[1].data = this.uvs; + this.geometry.indexBuffer.data = this.indices; + + // ensure that the changes are uploaded + this.geometry.buffers[0].update(); + this.geometry.buffers[1].update(); + this.geometry.indexBuffer.update(); + + this.multiplyUvs(); + } +} diff --git a/packages/mesh-extras/src/Rope.js b/packages/mesh-extras/src/Rope.js new file mode 100644 index 0000000..9cfde38 --- /dev/null +++ b/packages/mesh-extras/src/Rope.js @@ -0,0 +1,182 @@ +import Mesh2d from './Mesh2d'; + +/** + * The rope allows you to draw a texture across several points and them manipulate these points + * + *```js + * for (let i = 0; i < 20; i++) { + * points.push(new PIXI.Point(i * 50, 0)); + * }; + * let rope = new PIXI.Rope(PIXI.Texture.from("snake.png"), points); + * ``` + * + * @class + * @extends PIXI.Mesh + * @memberof PIXI + * + */ +export default class Rope extends Mesh2d +{ + /** + * @param {PIXI.Texture} texture - The texture to use on the rope. + * @param {PIXI.Point[]} points - An array of {@link PIXI.Point} objects to construct this rope. + */ + constructor(texture, points) + { + super(texture, new Float32Array(points.length * 4), + new Float32Array(points.length * 4), + new Uint16Array(points.length * 2), + 5); + + /* + * @member {PIXI.Point[]} An array of points that determine the rope + */ + this.points = points; + this.refresh(); + } + /** + * Refreshes Rope indices and uvs + * @private + */ + _refresh() + { + const points = this.points; + + if (!points) return; + + const vertexBuffer = this.geometry.getAttribute('aVertexPosition'); + const uvBuffer = this.geometry.getAttribute('aTextureCoord'); + const indexBuffer = this.geometry.getIndex(); + + // if too little points, or texture hasn't got UVs set yet just move on. + if (points.length < 1 || !this.texture._uvs) + { + return; + } + + // if the number of points has changed we will need to recreate the arraybuffers + if (vertexBuffer.data.length / 4 !== points.length) + { + vertexBuffer.data = new Float32Array(points.length * 4); + uvBuffer.data = new Float32Array(points.length * 4); + indexBuffer.data = new Uint16Array(points.length * 2); + } + + const uvs = uvBuffer.data; + const indices = indexBuffer.data; + + uvs[0] = 0; + uvs[1] = 0; + uvs[2] = 0; + uvs[3] = 1; + + indices[0] = 0; + indices[1] = 1; + + const total = points.length; + + for (let i = 1; i < total; i++) + { + // time to do some smart drawing! + let index = i * 4; + const amount = i / (total - 1); + + uvs[index] = amount; + uvs[index + 1] = 0; + + uvs[index + 2] = amount; + uvs[index + 3] = 1; + + index = i * 2; + indices[index] = index; + indices[index + 1] = index + 1; + } + + // ensure that the changes are uploaded + uvBuffer.update(); + indexBuffer.update(); + + this.multiplyUvs(); + this.refreshVertices(); + } + + /** + * refreshes vertices of Rope mesh + */ + refreshVertices() + { + const points = this.points; + + if (points.length < 1) + { + return; + } + + let lastPoint = points[0]; + let nextPoint; + let perpX = 0; + let perpY = 0; + + // this.count -= 0.2; + + const vertices = this.vertices; + const total = points.length; + + for (let i = 0; i < total; i++) + { + const point = points[i]; + const index = i * 4; + + if (i < points.length - 1) + { + nextPoint = points[i + 1]; + } + else + { + nextPoint = point; + } + + perpY = -(nextPoint.x - lastPoint.x); + perpX = nextPoint.y - lastPoint.y; + + let ratio = (1 - (i / (total - 1))) * 10; + + if (ratio > 1) + { + ratio = 1; + } + + const perpLength = Math.sqrt((perpX * perpX) + (perpY * perpY)); + const num = this._texture.height / 2; // (20 + Math.abs(Math.sin((i + this.count) * 0.3) * 50) )* ratio; + + perpX /= perpLength; + perpY /= perpLength; + + perpX *= num; + perpY *= num; + + vertices[index] = point.x + perpX; + vertices[index + 1] = point.y + perpY; + vertices[index + 2] = point.x - perpX; + vertices[index + 3] = point.y - perpY; + + lastPoint = point; + } + + this.geometry.buffers[0].update(); + } + + /** + * Updates the object transform for rendering + * + * @private + */ + updateTransform() + { + if (this.autoUpdate) + { + this.refreshVertices(); + } + this.containerUpdateTransform(); + } +} diff --git a/packages/mesh-extras/src/index.js b/packages/mesh-extras/src/index.js new file mode 100644 index 0000000..decf454 --- /dev/null +++ b/packages/mesh-extras/src/index.js @@ -0,0 +1,4 @@ +export { default as Mesh2d } from './Mesh2d'; +export { default as Plane } from './Plane'; +export { default as NineSlicePlane } from './NineSlicePlane'; +export { default as Rope } from './Rope'; diff --git a/packages/mesh-extras/src/mesh.frag b/packages/mesh-extras/src/mesh.frag new file mode 100644 index 0000000..6096983 --- /dev/null +++ b/packages/mesh-extras/src/mesh.frag @@ -0,0 +1,9 @@ +varying vec2 vTextureCoord; +uniform vec4 uColor; + +uniform sampler2D uSampler; + +void main(void) +{ + gl_FragColor = texture2D(uSampler, vTextureCoord) * uColor; +} diff --git a/packages/mesh-extras/src/mesh.vert b/packages/mesh-extras/src/mesh.vert new file mode 100644 index 0000000..0526df9 --- /dev/null +++ b/packages/mesh-extras/src/mesh.vert @@ -0,0 +1,15 @@ +attribute vec2 aVertexPosition; +attribute vec2 aTextureCoord; + +uniform mat3 projectionMatrix; +uniform mat3 translationMatrix; +uniform mat3 uTextureMatrix; + +varying vec2 vTextureCoord; + +void main(void) +{ + gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); + + vTextureCoord = (uTextureMatrix * vec3(aTextureCoord, 1.0)).xy; +} diff --git a/bundles/pixi.js/package.json b/bundles/pixi.js/package.json index 49c7276..177e059 100644 --- a/bundles/pixi.js/package.json +++ b/bundles/pixi.js/package.json @@ -49,6 +49,7 @@ "@pixi/loaders": "^5.0.0-alpha.2", "@pixi/math": "^5.0.0-alpha.2", "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/mesh-extras": "^5.0.0-alpha.2", "@pixi/mixin-cache-as-bitmap": "^5.0.0-alpha.2", "@pixi/mixin-get-child-by-name": "^5.0.0-alpha.2", "@pixi/mixin-get-global-position": "^5.0.0-alpha.2", diff --git a/bundles/pixi.js/src/deprecated.js b/bundles/pixi.js/src/deprecated.js index 147617c..dbebeb0 100644 --- a/bundles/pixi.js/src/deprecated.js +++ b/bundles/pixi.js/src/deprecated.js @@ -263,15 +263,15 @@ Object.defineProperties(PIXI.mesh, { /** * @class PIXI.mesh.Mesh - * @see PIXI.Mesh + * @see PIXI.Mesh2d * @deprecated since 5.0.0 */ Mesh: { get() { - warn('PIXI.mesh.Mesh has moved to PIXI.Mesh'); + warn('PIXI.mesh.Mesh has moved to PIXI.Mesh2d'); - return PIXI.Mesh; + return PIXI.Mesh2d; }, }, /** @@ -315,15 +315,15 @@ }, /** * @class PIXI.mesh.RawMesh - * @see PIXI.RawMesh + * @see PIXI.Mesh * @deprecated since 5.0.0 */ RawMesh: { get() { - warn('PIXI.mesh.RawMesh has moved to PIXI.RawMesh'); + warn('PIXI.mesh.RawMesh has moved to PIXI.Mesh'); - return PIXI.RawMesh; + return PIXI.Mesh; }, }, /** diff --git a/bundles/pixi.js/src/index.js b/bundles/pixi.js/src/index.js index a3a0d1b..6fdabf0 100644 --- a/bundles/pixi.js/src/index.js +++ b/bundles/pixi.js/src/index.js @@ -9,6 +9,7 @@ import * as loaders from '@pixi/loaders'; import * as math from '@pixi/math'; import * as mesh from '@pixi/mesh'; +import * as meshExtras from '@pixi/mesh-extras'; import * as particles from '@pixi/particles'; import * as prepare from '@pixi/prepare'; import * as sprite from '@pixi/sprite'; @@ -128,6 +129,7 @@ loaders, math, mesh, + meshExtras, particles, sprite, spriteAnimated, @@ -152,6 +154,7 @@ export * from '@pixi/loaders'; export * from '@pixi/math'; export * from '@pixi/mesh'; +export * from '@pixi/mesh-extras'; export * from '@pixi/particles'; export * from '@pixi/sprite'; export * from '@pixi/spritesheet'; diff --git a/package-lock.json b/package-lock.json index 7fe6db7..0814729 100644 --- a/package-lock.json +++ b/package-lock.json @@ -209,7 +209,7 @@ "argparse": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", - "integrity": "sha1-vNZ5HqWuCXJeF+WtmIE0zUCz2RE=", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", "dev": true, "requires": { "sprintf-js": "1.0.3" @@ -228,7 +228,7 @@ "arr-flatten": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz", - "integrity": "sha1-NgSLv/TntH4TZkQxbJlmnqWukfE=", + "integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==", "dev": true }, "arr-union": { @@ -297,7 +297,7 @@ "assertion-error": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", - "integrity": "sha1-5gtrDo8wG9l+U3UhW9pAbIURjAs=", + "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", "dev": true }, "async": { @@ -396,7 +396,7 @@ "brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha1-PH/L9SnYcibz0vUrlm/1Jx60Qd0=", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, "requires": { "balanced-match": "1.0.0", @@ -568,7 +568,7 @@ "circular-json": { "version": "0.3.3", "resolved": "https://registry.npmjs.org/circular-json/-/circular-json-0.3.3.tgz", - "integrity": "sha1-gVyZ6oT2gJUp0vRXkb34JxE1LWY=", + "integrity": "sha512-UZK3NBx2Mca+b5LsG7bY183pHWt5Y1xts4P3Pz7ENTwGVnJOUWbRb3ocjvX7hx9tq/yTAdclXm9sZ38gNuem4A==", "dev": true }, "cli-cursor": { @@ -638,7 +638,7 @@ "color-convert": { "version": "1.9.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.1.tgz", - "integrity": "sha1-wSYRB66y8pTr/+ye2eytUppgl+0=", + "integrity": "sha512-mjGanIiwQJskCC18rPR6OmrZ6fm2Lc7PeGFYwCmy5J34wC6F1PzdGL6xeMfmgicfYcNLGuVFA3WzXtIDCQSZxQ==", "dev": true, "requires": { "color-name": "1.1.3" @@ -1427,7 +1427,7 @@ "boom": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/boom/-/boom-5.2.0.tgz", - "integrity": "sha1-XdnabuOl8wIHdDYpDLcX0/SlTgI=", + "integrity": "sha512-Z5BTk6ZRe4tXXQlkqftmsAUANpXmuwlsF5Oov8ThoMbQRzdGTA1ngYRW160GexgOgjsFOKJz0LYhoNi+2AMBUw==", "dev": true, "requires": { "hoek": "4.2.1" @@ -1471,7 +1471,7 @@ "debug": { "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha1-XRKFFd8TT/Mn6QpMk/Tgd6U2NB8=", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", "dev": true, "requires": { "ms": "2.0.0" @@ -1585,7 +1585,7 @@ "doctrine": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", - "integrity": "sha1-XNAfwQFiG0LEzX9dGmYkNxbT850=", + "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", "dev": true, "requires": { "esutils": "2.0.2" @@ -1662,7 +1662,7 @@ "es6-promise": { "version": "4.2.4", "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.4.tgz", - "integrity": "sha1-3EIhwrFlGHYL2MOaUtjzVvwA7Sk=", + "integrity": "sha512-/NdNZVJg+uZgtm9eS3O6lrOLYmQag2DjdEXuPaHlZ6RuVqgqaVZfgYCepEIKsLqwdQArOPtC3XzRLqGGfT8KQQ==", "dev": true }, "escape-string-regexp": { @@ -1788,7 +1788,7 @@ "espree": { "version": "3.5.4", "resolved": "https://registry.npmjs.org/espree/-/espree-3.5.4.tgz", - "integrity": "sha1-sPRHGHyKi+2US4FaZgvd9d610ac=", + "integrity": "sha512-yAcIQxtmMiB/jL32dzEp2enBeidsB7xWPLNiw3IIkpVds1P+h7qF9YwJq1yUNzp2OKXgAprs4F61ih66UsoD1A==", "dev": true, "requires": { "acorn": "5.5.0", @@ -1798,7 +1798,7 @@ "esprima": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.0.tgz", - "integrity": "sha1-RJnt3NERDgshi6zy+n9/WfVcqAQ=", + "integrity": "sha512-oftTcaMu/EGrEIu904mWteKIv8vMuOgGYo7EhVJJN00R/EED9DCua/xxHRdYnKtcECzVg7xOWhflvJMnqcFZjw==", "dev": true }, "esquery": { @@ -1813,7 +1813,7 @@ "esrecurse": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.2.1.tgz", - "integrity": "sha1-AHo7n9vCs7uH5IeeoZyS/b05Qs8=", + "integrity": "sha512-64RBB++fIOAXPw3P9cy89qfMlvZEXZkqqJkjqqXIvzP5ezRZjW+lPWjw35UX/3EhUPFYbg5ER4JYgDw4007/DQ==", "dev": true, "requires": { "estraverse": "4.2.0" @@ -2024,7 +2024,7 @@ "find-root": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/find-root/-/find-root-1.1.0.tgz", - "integrity": "sha1-q8/Iunb3CMQql7PWhbfpRQv7nOQ=", + "integrity": "sha512-NKfW6bec6GfKc0SGx1e07QZY9PE99u0Bft/0rzSD5k3sO/vwkVUpDUKVm5Gpp5Ue3YfShPFTX2070tDs5kB9Ng==", "dev": true }, "find-up": { @@ -2103,7 +2103,7 @@ "supports-color": { "version": "5.3.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.3.0.tgz", - "integrity": "sha1-WySsFduA+pJ89SJ6SjP9PEx2dsA=", + "integrity": "sha512-0aP01LLIskjKs3lq52EC0aGBAJhLq7B2Rd8HC/DR/PtNNpcLilNmHC12O+hu0usQpo7wtHNRqtrhBwtDb0+dNg==", "dev": true, "requires": { "has-flag": "3.0.0" @@ -2567,7 +2567,7 @@ "glob": { "version": "7.1.2", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", - "integrity": "sha1-wZyd+aAocC1nhhI4SmVSQExjbRU=", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", "dev": true, "requires": { "fs.realpath": "1.0.0", @@ -2672,7 +2672,7 @@ "growl": { "version": "1.10.3", "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.3.tgz", - "integrity": "sha1-GSa6kM8+3+KttJJ/WIC8IsZseQ8=", + "integrity": "sha512-hKlsbA5Vu3xsh1Cg3J7jSmX/WaW6A5oBeqzM88oNbCRQFz+zUaXm6yxS4RVytp1scBoJzSYl4YAEOQIt6O8V1Q==", "dev": true }, "handlebars": { @@ -2738,7 +2738,7 @@ "hawk": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/hawk/-/hawk-6.0.2.tgz", - "integrity": "sha1-r02RTrBl+bXOTZ0RwcshJu7MMDg=", + "integrity": "sha512-miowhl2+U7Qle4vdLqDdPt9m09K6yZhkLDTWGoUiUzrQCn+mHHSmfJgAyGaLRZbPmTqfFFjRV1QWCW0VWUJBbQ==", "dev": true, "requires": { "boom": "4.3.1", @@ -2756,7 +2756,7 @@ "hoek": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/hoek/-/hoek-4.2.1.tgz", - "integrity": "sha1-ljRQKqEsRF3Vp8VzS1cruHOKrLs=", + "integrity": "sha512-QLg82fGkfnJ/4iy1xZ81/9SIJiq1NGFUMGs6ParyjBZr6jW2Ufj/snDqTHixNlHdPNwN2RLVD0Pi3igeK9+JfA==", "dev": true }, "home-path": { @@ -2791,7 +2791,7 @@ "ignore": { "version": "3.3.7", "resolved": "https://registry.npmjs.org/ignore/-/ignore-3.3.7.tgz", - "integrity": "sha1-YSKJv7PCIOGGpYEYYY1b6MG6sCE=", + "integrity": "sha512-YGG3ejvBNHRqu0559EOxxNFihD0AjpvHlC/pdGKd3X3ofe+CoJkYazwNJYTNebqpPKN+VVQbh4ZFn1DivMNuHA==", "dev": true }, "imurmurhash": { @@ -2828,7 +2828,7 @@ "ini": { "version": "1.3.5", "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", - "integrity": "sha1-7uJfVtscnsYIXgwid4CD9Zar+Sc=", + "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==", "dev": true }, "inquirer": { @@ -2901,7 +2901,7 @@ "is-buffer": { "version": "1.1.6", "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", - "integrity": "sha1-76ouqdqg16suoTqXsritUf776L4=", + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", "dev": true }, "is-builtin-module": { @@ -3054,7 +3054,7 @@ "is-resolvable": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/is-resolvable/-/is-resolvable-1.1.0.tgz", - "integrity": "sha1-+xj4fOH+uSUWnJpAfBkxijIG7Yg=", + "integrity": "sha512-qgDYXFSR5WvEfuS5dMj6oTMEbrrSaM0CrFk2Yiq/gXnBvD9pMa2jGXxyhGLfvhZpuMZe18CJpFxAt3CRs42NMg==", "dev": true }, "is-retry-allowed": { @@ -3204,7 +3204,7 @@ "js-yaml": { "version": "3.11.0", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.11.0.tgz", - "integrity": "sha1-WXwai9VxUvJtYizkEXhRpR9euu8=", + "integrity": "sha512-saJstZWv7oNeOyBh3+Dx1qWzhW0+e6/8eDzo7p5rDFqxntSztloLtuKu+Ejhtq82jsilwOIZYsCz+lIjthg1Hw==", "dev": true, "requires": { "argparse": "1.0.10", @@ -3324,7 +3324,7 @@ "just-extend": { "version": "1.1.27", "resolved": "https://registry.npmjs.org/just-extend/-/just-extend-1.1.27.tgz", - "integrity": "sha1-7G55QQ/5FORyZSq/oOYDwD1g6QU=", + "integrity": "sha512-mJVp13Ix6gFo3SBAy9U/kL+oeZqzlYYYLQBwXVBlVzIsZwBqGREnOro24oC/8s8aox+rJhtZ2DiQof++IrkA+g==", "dev": true }, "kind-of": { @@ -3703,7 +3703,7 @@ "lodash": { "version": "4.17.5", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.5.tgz", - "integrity": "sha1-maktZcAnLevoyWtgV7yPv6O+1RE=", + "integrity": "sha512-svL3uiZf1RwhH+cWrfZn3A4+U58wbP0tGVTLQPbjplZxZ8ROD9VLuNgsRniTlLe7OlSqR79RUehXgpBW/s0IQw==", "dev": true }, "lodash._reinterpolate": { @@ -3740,7 +3740,7 @@ "lolex": { "version": "2.3.2", "resolved": "https://registry.npmjs.org/lolex/-/lolex-2.3.2.tgz", - "integrity": "sha1-hflFBCUQO/nnpgZo6iXcQydMqAc=", + "integrity": "sha512-A5pN2tkFj7H0dGIAM6MFvHKMJcPnjZsOMvR7ujCjfgW5TbV6H9vb1PgxLtHvjqNZTHsUolz+6/WEO0N1xNx2ng==", "dev": true }, "longest": { @@ -3816,7 +3816,7 @@ "marked": { "version": "0.3.17", "resolved": "https://registry.npmjs.org/marked/-/marked-0.3.17.tgz", - "integrity": "sha1-YH8GZos8axJGso8T2nYRasGqLSs=", + "integrity": "sha512-+AKbNsjZl6jFfLPwHhWmGTqE009wTKn3RTmn9K8oUKHrX/abPJjtcRtXpYB/FFrwPJRUA86LX/de3T0knkPCmQ==", "dev": true }, "mem": { @@ -3896,13 +3896,13 @@ "mime-db": { "version": "1.33.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.33.0.tgz", - "integrity": "sha1-o0kgUKXLm2NFBUHjnZeI0icng9s=", + "integrity": "sha512-BHJ/EKruNIqJf/QahvxwQZXKygOQ256myeN/Ew+THcAa5q+PjyTTMMeNQC4DZw5AwfvelsUrA6B67NKMqXDbzQ==", "dev": true }, "mime-types": { "version": "2.1.18", "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.18.tgz", - "integrity": "sha1-bzI/YKg9ERRvgx/xH9ZuL+VQO7g=", + "integrity": "sha512-lc/aahn+t4/SWV/qcmumYjymLsWfN3ELhpmVuUFjgsORruuZPVSwAQryq+HHGvO/SI2KVX26bx+En+zhM8g8hQ==", "dev": true, "requires": { "mime-db": "1.33.0" @@ -3917,7 +3917,7 @@ "minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha1-UWbihkV/AzBgZL5Ul+jbsMPTIIM=", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "dev": true, "requires": { "brace-expansion": "1.1.11" @@ -4071,7 +4071,7 @@ "normalize-package-data": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.4.0.tgz", - "integrity": "sha1-EvlaMH1YNSB1oEkHuErIvpisAS8=", + "integrity": "sha512-9jjUFbTPfEy3R/ad/2oNbKtW9Hgovl5O1FvFWKkKblNXoN/Oou6+9+KKohPK13Yc3/TyunyWhJp6gvRNR/PPAw==", "dev": true, "requires": { "hosted-git-info": "2.5.0", @@ -4511,7 +4511,7 @@ "process-nextick-args": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", - "integrity": "sha1-o31zL0JxtKsa0HDTVQjoKQeI/6o=", + "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==", "dev": true }, "progress": { @@ -4584,7 +4584,7 @@ "qs": { "version": "6.5.1", "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.1.tgz", - "integrity": "sha1-NJzfbu+J7EXBLX1es/wMhwNDptg=", + "integrity": "sha512-eRzhrN1WSINYCDCbrz796z37LOe3m5tmW7RQf6oBntukAG1nmovJvhnwHHRMAfeoItc1m2Hk02WER2aQ/iqs+A==", "dev": true }, "quick-lru": { @@ -4596,7 +4596,7 @@ "randomatic": { "version": "1.1.7", "resolved": "https://registry.npmjs.org/randomatic/-/randomatic-1.1.7.tgz", - "integrity": "sha1-x6vpzIuHwLqodrGf3oP9RkeX44w=", + "integrity": "sha512-D5JUjPyJbaJDkuAazpVnSfVkLlpeO3wDlPROTMLGKG1zMFNFRgrciKo1ltz/AzNTkqE0HzDx655QOL51N06how==", "dev": true, "requires": { "is-number": "3.0.0", @@ -4701,7 +4701,7 @@ "regex-cache": { "version": "0.4.4", "resolved": "https://registry.npmjs.org/regex-cache/-/regex-cache-0.4.4.tgz", - "integrity": "sha1-db3FiioUls7EihKDW8VMjVYjNt0=", + "integrity": "sha512-nVIZwtCjkC9YgvWkpM55B5rBhBYRZhAaJbgcFYXXsHnbZ9UZI9nnVWYZpBlCqv9ho2eZryPnWrZGsOdPwVWXWQ==", "dev": true, "requires": { "is-equal-shallow": "0.1.3" @@ -4729,7 +4729,7 @@ "remap-istanbul": { "version": "0.10.1", "resolved": "https://registry.npmjs.org/remap-istanbul/-/remap-istanbul-0.10.1.tgz", - "integrity": "sha1-OqWN1QIdSZ8zbTulvzu7kcG4jjc=", + "integrity": "sha512-gsNQXs5kJLhErICSyYhzVZ++C8LBW8dgwr874Y2QvzAUS75zBlD/juZgXs39nbYJ09fZDlX2AVLVJAY2jbFJoQ==", "dev": true, "requires": { "amdefine": "1.0.1", @@ -4769,7 +4769,7 @@ "source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha1-dHIq8y6WFOnCh6jQu95IteLxomM=", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", "dev": true }, "through2": { @@ -4883,7 +4883,7 @@ "resolve": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.5.0.tgz", - "integrity": "sha1-HwmsznlsmnYlefMbLBzEw83fnzY=", + "integrity": "sha512-hgoSGrc3pjzAPHNBg+KnFcK2HwlHTs/YrAGUr6qgTVUZmXv1UEXXl0bZNBKMA9fud6lRYFdPGz0xXxycPzmmiw==", "dev": true, "requires": { "path-parse": "1.0.5" @@ -4924,7 +4924,7 @@ "rimraf": { "version": "2.6.2", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", - "integrity": "sha1-LtgVDSShbqhlHm1u8PR8QVjOejY=", + "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", "dev": true, "requires": { "glob": "7.1.2" @@ -5063,19 +5063,19 @@ "safe-buffer": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", - "integrity": "sha1-iTMSr2myEj3vcfV4iQAWce6yyFM=", + "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", "dev": true }, "samsam": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/samsam/-/samsam-1.3.0.tgz", - "integrity": "sha1-jR2TUOJWItow3j5EumkrUiGrfFA=", + "integrity": "sha512-1HwIYD/8UlOtFS3QO3w7ey+SdSDFE4HRNLZoZRYVQefrOY3l17epswImeB1ijgJFQJodIaHcwkp3r/myBjFVbg==", "dev": true }, "semver": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz", - "integrity": "sha1-3Eu8emyp2Rbe5dQ1FvAJK1j3uKs=", + "integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==", "dev": true }, "set-blocking": { @@ -5117,7 +5117,7 @@ "sinon-chai": { "version": "2.14.0", "resolved": "https://registry.npmjs.org/sinon-chai/-/sinon-chai-2.14.0.tgz", - "integrity": "sha1-2n3UzIPNaiYLZ8yg96n9riahIF0=", + "integrity": "sha512-9stIF1utB0ywNHNT7RgiXbdmen8QDCRsrTjw+G9TgKt1Yexjiv8TOWZ6WHsTPz57Yky3DIswZvEqX8fpuHNDtQ==", "dev": true }, "slash": { @@ -5146,7 +5146,7 @@ "sntp": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/sntp/-/sntp-2.1.0.tgz", - "integrity": "sha1-LGzsFP7cIiJznK+bXD2F0cxaLMg=", + "integrity": "sha512-FL1b58BDrqS3A11lJ0zEdnJ3UOKqVxawAkF3k7F0CVN7VQ34aZrV+G8BZ1WC9ZL7NyrwsW0oviwsWDgRuVYtJg==", "dev": true, "requires": { "hoek": "4.2.1" @@ -5203,7 +5203,7 @@ "spdx-correct": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.0.0.tgz", - "integrity": "sha1-BaW01xU6GVvJLDxCW2nzsqlSTII=", + "integrity": "sha512-N19o9z5cEyc8yQQPukRCZ9EUmb4HUpnrmaL/fxS2pBo2jbfcFRVuFZ/oFC+vZz0MNNk0h80iMn5/S6qGZOL5+g==", "dev": true, "requires": { "spdx-expression-parse": "3.0.0", @@ -5213,13 +5213,13 @@ "spdx-exceptions": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.1.0.tgz", - "integrity": "sha1-LHrmEFbHFKW5ubKyr30xHvXHj+k=", + "integrity": "sha512-4K1NsmrlCU1JJgUrtgEeTVyfx8VaYea9J9LvARxhbHtVtohPs/gFGG5yy49beySjlIMhhXZ4QqujIZEfS4l6Cg==", "dev": true }, "spdx-expression-parse": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.0.tgz", - "integrity": "sha1-meEZt6XaAOBUkcn6M4t5BII7QdA=", + "integrity": "sha512-Yg6D3XpRD4kkOmTpdgbUiEJFKghJH03fiC1OPll5h/0sO6neh2jqRDVHOQ4o/LMea0tgCkbMgea5ip/e+MkWyg==", "dev": true, "requires": { "spdx-exceptions": "2.1.0", @@ -5229,7 +5229,7 @@ "spdx-license-ids": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.0.tgz", - "integrity": "sha1-enzShHDMbToc/m1miG9rxDDTrIc=", + "integrity": "sha512-2+EPwgbnmOIl8HjGBXXMd9NAu02vLjOO1nWw4kmeRDFyHn+M/ETfHxQUK0oXg8ctgVnl9t3rosNVsZ1jG61nDA==", "dev": true }, "speedometer": { @@ -5566,7 +5566,7 @@ "tough-cookie": { "version": "2.3.4", "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.4.tgz", - "integrity": "sha1-7GDO44rGdQY//JelwYlwV47oNlU=", + "integrity": "sha512-TZ6TTfI5NtZnuyy/Kecv+CnoROnyXn2DN97LontgQpCwsX2XyLYCC0ENhYkehSOwAp8rTQKc/NUIF7BkQ5rKLA==", "dev": true, "requires": { "punycode": "1.4.1" @@ -5708,13 +5708,13 @@ "uuid": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.2.1.tgz", - "integrity": "sha1-EsUou51Y0LkmXZovbw/ovhf/HxQ=", + "integrity": "sha512-jZnMwlb9Iku/O3smGWvZhauCf6cvvpKi4BKRiliS3cxnI+Gz9j5MEpTz2UFuXiKPJocb7gnsLHwiS05ige5BEA==", "dev": true }, "validate-npm-package-license": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.3.tgz", - "integrity": "sha1-gWQ7y+8b3+zUYjeT3EZIlIupgzg=", + "integrity": "sha512-63ZOUnL4SIXj4L0NixR3L1lcjO38crAbgrTpl28t8jjrfuiOBL5Iygm+60qPs/KsZGzPNg6Smnc/oY16QTjF0g==", "dev": true, "requires": { "spdx-correct": "3.0.0", @@ -5750,7 +5750,7 @@ "which": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/which/-/which-1.3.0.tgz", - "integrity": "sha1-/wS9/AEO5UfXgL7DjhrBwnd9JTo=", + "integrity": "sha512-xcJpopdamTuY5duC/KnTTNBraPK54YwpenP4lzxU8H91GudWpFv38u0CKjclE1Wi2EH2EDz5LRcHcKbCIzqGyg==", "dev": true, "requires": { "isexe": "2.0.0" diff --git a/packages/canvas/canvas-mesh/package.json b/packages/canvas/canvas-mesh/package.json index 691cd2c..6744a17 100644 --- a/packages/canvas/canvas-mesh/package.json +++ b/packages/canvas/canvas-mesh/package.json @@ -24,6 +24,7 @@ "dependencies": { "@pixi/constants": "^5.0.0-alpha.2", "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/mesh-extras": "^5.0.0-alpha.2", "@pixi/settings": "^5.0.0-alpha.2" }, "devDependencies": { diff --git a/packages/canvas/canvas-mesh/src/Mesh.js b/packages/canvas/canvas-mesh/src/Mesh.js index 900a872..c43a74b 100644 --- a/packages/canvas/canvas-mesh/src/Mesh.js +++ b/packages/canvas/canvas-mesh/src/Mesh.js @@ -1,36 +1,14 @@ import { Mesh } from '@pixi/mesh'; -import { settings } from './settings'; - -// IMPORTANT: Please do NOT use this as a precedent to use `settings` after the object is created -// this was merely created to completely decouple canvas from the base Mesh class and we are -// unable to add `canvasPadding` in the constructor anymore, as the case was for PixiJS v4. /** - * Internal variable for `canvasPadding`. + * Renders the object using the Canvas renderer * * @private - * @memberof PIXI.Mesh - * @member {number} - * @default null - */ -Mesh.prototype._canvasPadding = null; - -/** - * Triangles in canvas mode are automatically antialiased, use this value to force triangles - * to overlap a bit with each other. To set the global default, set {@link PIXI.settings.MESH_CANVAS_PADDING} - * - * @see PIXI.settings.MESH_CANVAS_PADDING - * @member {number} canvasPadding + * @method _renderCanvas * @memberof PIXI.Mesh# - * @default 0 + * @param {PIXI.CanvasRenderer} renderer - The canvas renderer. */ -Object.defineProperty(Mesh.prototype, 'canvasPadding', { - get() - { - return this._canvasPadding !== null ? this._canvasPadding : settings.MESH_CANVAS_PADDING; - }, - set(value) - { - this._canvasPadding = value; - }, -}); +Mesh.prototype._renderCanvas = function _renderCanvas(renderer) +{ + renderer.plugins[this.pluginName].render(this); +}; diff --git a/packages/canvas/canvas-mesh/src/Mesh2d.js b/packages/canvas/canvas-mesh/src/Mesh2d.js new file mode 100644 index 0000000..d0bd80f --- /dev/null +++ b/packages/canvas/canvas-mesh/src/Mesh2d.js @@ -0,0 +1,36 @@ +import { Mesh2d } from '@pixi/mesh-extras'; +import { settings } from './settings'; + +// IMPORTANT: Please do NOT use this as a precedent to use `settings` after the object is created +// this was merely created to completely decouple canvas from the base Mesh class and we are +// unable to add `canvasPadding` in the constructor anymore, as the case was for PixiJS v4. + +/** + * Internal variable for `canvasPadding`. + * + * @private + * @memberof PIXI.Mesh2d + * @member {number} + * @default null + */ +Mesh2d.prototype._canvasPadding = null; + +/** + * Triangles in canvas mode are automatically antialiased, use this value to force triangles + * to overlap a bit with each other. To set the global default, set {@link PIXI.settings.MESH_CANVAS_PADDING} + * + * @see PIXI.settings.MESH_CANVAS_PADDING + * @member {number} canvasPadding + * @memberof PIXI.Mesh2d# + * @default 0 + */ +Object.defineProperty(Mesh2d.prototype, 'canvasPadding', { + get() + { + return this._canvasPadding !== null ? this._canvasPadding : settings.MESH_CANVAS_PADDING; + }, + set(value) + { + this._canvasPadding = value; + }, +}); diff --git a/packages/canvas/canvas-mesh/src/NineSlicePlane.js b/packages/canvas/canvas-mesh/src/NineSlicePlane.js index 09eaf9c..2fd5acc 100644 --- a/packages/canvas/canvas-mesh/src/NineSlicePlane.js +++ b/packages/canvas/canvas-mesh/src/NineSlicePlane.js @@ -1,4 +1,4 @@ -import { NineSlicePlane } from '@pixi/mesh'; +import { NineSlicePlane } from '@pixi/mesh-extras'; /** * Renders the object using the Canvas renderer diff --git a/packages/canvas/canvas-mesh/src/RawMesh.js b/packages/canvas/canvas-mesh/src/RawMesh.js deleted file mode 100644 index bf40184..0000000 --- a/packages/canvas/canvas-mesh/src/RawMesh.js +++ /dev/null @@ -1,14 +0,0 @@ -import { RawMesh } from '@pixi/mesh'; - -/** - * Renders the object using the Canvas renderer - * - * @private - * @method _renderCanvas - * @memberof PIXI.RawMesh# - * @param {PIXI.CanvasRenderer} renderer - The canvas renderer. - */ -RawMesh.prototype._renderCanvas = function _renderCanvas(renderer) -{ - renderer.plugins[this.pluginName].render(this); -}; diff --git a/packages/canvas/canvas-mesh/src/index.js b/packages/canvas/canvas-mesh/src/index.js index 2295016..f4fa31d 100644 --- a/packages/canvas/canvas-mesh/src/index.js +++ b/packages/canvas/canvas-mesh/src/index.js @@ -1,6 +1,6 @@ export { default as CanvasMeshRenderer } from './CanvasMeshRenderer'; import './settings'; -import './Mesh'; +import './Mesh2d'; import './NineSlicePlane'; -import './RawMesh'; +import './Mesh'; diff --git a/packages/canvas/canvas-mesh/src/settings.js b/packages/canvas/canvas-mesh/src/settings.js index 4cefb4c..e81b8e0 100644 --- a/packages/canvas/canvas-mesh/src/settings.js +++ b/packages/canvas/canvas-mesh/src/settings.js @@ -3,7 +3,7 @@ /** * Default `canvasPadding` for canvas-based Mesh rendering. * - * @see PIXI.Mesh#canvasPadding + * @see PIXI.Mesh2d#canvasPadding * @static * @constant * @memberof PIXI.settings diff --git a/packages/mesh-extras/LICENSE b/packages/mesh-extras/LICENSE new file mode 100644 index 0000000..148e3eb --- /dev/null +++ b/packages/mesh-extras/LICENSE @@ -0,0 +1,21 @@ +The MIT License + +Copyright (c) 2013-2018 Mathew Groves, Chad Engler + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/packages/mesh-extras/README.md b/packages/mesh-extras/README.md new file mode 100644 index 0000000..1d9b0e1 --- /dev/null +++ b/packages/mesh-extras/README.md @@ -0,0 +1,19 @@ +# @pixi/mesh-extras + +## Installation + +```bash +npm install @pixi/mesh-extras +``` + +## Usage + +```js +import { MeshRenderer } from '@pixi/mesh'; +import { Renderer } from '@pixi/core'; +import { Rope } from '@pixi/mesh-extras'; + +Renderer.registerPlugin('mesh', MeshRenderer); + +const rope = new Rope(); +``` \ No newline at end of file diff --git a/packages/mesh-extras/package.json b/packages/mesh-extras/package.json new file mode 100644 index 0000000..d134f64 --- /dev/null +++ b/packages/mesh-extras/package.json @@ -0,0 +1,38 @@ +{ + "name": "@pixi/mesh-extras", + "version": "5.0.0-alpha.2", + "main": "lib/mesh-extras.js", + "module": "lib/mesh-extras.es.js", + "description": "Custom Mesh display objects, like Rope and Plane", + "author": "Mat Groves", + "contributors": [ + "Matt Karl " + ], + "homepage": "http://pixijs.com/", + "bugs": "https://github.com/pixijs/pixi.js/issues", + "license": "MIT", + "repository": { + "type": "git", + "url": "https://github.com/pixijs/pixi.js.git" + }, + "publishConfig": { + "access": "public" + }, + "scripts": { + "test": "floss --path test" + }, + "files": [ + "lib" + ], + "dependencies": { + "@pixi/constants": "^5.0.0-alpha.2", + "@pixi/core": "^5.0.0-alpha.2", + "@pixi/math": "^5.0.0-alpha.2", + "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/utils": "^5.0.0-alpha.2" + }, + "devDependencies": { + "@pixi/loaders": "^5.0.0-alpha.2", + "floss": "^2.1.3" + } +} diff --git a/packages/mesh-extras/src/Mesh2d.js b/packages/mesh-extras/src/Mesh2d.js new file mode 100644 index 0000000..d113a5e --- /dev/null +++ b/packages/mesh-extras/src/Mesh2d.js @@ -0,0 +1,263 @@ +import { Mesh } from '@pixi/mesh'; +import { Geometry, Program, Shader, Texture, TextureMatrix } from '@pixi/core'; +import { Matrix } from '@pixi/math'; +import { BLEND_MODES } from '@pixi/constants'; +import { hex2rgb, premultiplyRgba } from '@pixi/utils'; +import vertex from './mesh.vert'; +import fragment from './mesh.frag'; + +let meshProgram; + +/** + * Base mesh class + * @class + * @extends PIXI.Container + * @memberof PIXI + */ +export default class Mesh2d extends Mesh +{ + /** + * @param {PIXI.Texture} [texture=Texture.EMPTY] - The texture to use + * @param {Float32Array} [vertices] - if you want to specify the vertices + * @param {Float32Array} [uvs] - if you want to specify the uvs + * @param {Uint16Array} [indices] - if you want to specify the indices + * @param {number} [drawMode] - the drawMode, can be any of the Mesh.DRAW_MODES consts + */ + constructor(texture = Texture.EMPTY, vertices, uvs, indices, drawMode) + { + const geometry = new Geometry(); + + if (!meshProgram) + { + meshProgram = new Program(vertex, fragment); + } + + geometry.addAttribute('aVertexPosition', vertices) + .addAttribute('aTextureCoord', uvs) + .addIndex(indices); + + geometry.getAttribute('aVertexPosition').static = false; + + const uniforms = { + uSampler: texture, + uTextureMatrix: Matrix.IDENTITY, + alpha: 1, + uColor: new Float32Array([1, 1, 1, 1]), + }; + + super(geometry, new Shader(meshProgram, uniforms), null, drawMode); + + /** + * The Uvs of the Mesh + * + * @member {Float32Array} + */ + this.uvs = geometry.getAttribute('aTextureCoord').data; + + /** + * An array of vertices + * + * @member {Float32Array} + */ + this.vertices = geometry.getAttribute('aVertexPosition').data; + + this.uniforms = uniforms; + + /** + * The texture of the Mesh + * + * @member {PIXI.Texture} + * @default PIXI.Texture.EMPTY + * @private + */ + this.texture = texture; + + /** + * The tint applied to the mesh. This is a [r,g,b] value. A value of [1,1,1] will remove any + * tint effect. + * + * @member {number} + * @private + */ + this._tintRGB = new Float32Array([1, 1, 1]); + + // Set default tint + this.tint = 0xFFFFFF; + + this.blendMode = BLEND_MODES.NORMAL; + + /** + * TextureMatrix instance for this Mesh, used to track Texture changes + * + * @member {PIXI.TextureMatrix} + * @readonly + */ + this.uvMatrix = new TextureMatrix(this._texture); + + /** + * whether or not upload uvMatrix to shader + * if its false, then uvs should be pre-multiplied + * if you change it for generated mesh, please call 'refresh(true)' + * @member {boolean} + * @default false + */ + this.uploadUvMatrix = false; + + /** + * Uploads vertices buffer every frame, like in PixiJS V3 and V4. + * + * @member {boolean} + * @default true + */ + this.autoUpdate = true; + } + + /** + * The tint applied to the Rope. This is a hex value. A value of + * 0xFFFFFF will remove any tint effect. + * + * @member {number} + * @memberof PIXI.Sprite# + * @default 0xFFFFFF + */ + get tint() + { + return this._tint; + } + + /** + * Sets the tint of the rope. + * + * @param {number} value - The value to set to. + */ + set tint(value) + { + this._tint = value; + + hex2rgb(this._tint, this._tintRGB); + } + + /** + * The blend mode to be applied to the sprite. Set to `PIXI.BLEND_MODES.NORMAL` to remove any blend mode. + * + * @member {number} + * @default PIXI.BLEND_MODES.NORMAL + * @see PIXI.BLEND_MODES + */ + get blendMode() + { + return this.state.blendMode; + } + + set blendMode(value) // eslint-disable-line require-jsdoc + { + this.state.blendMode = value; + } + + /** + * The texture that the mesh uses. + * + * @member {PIXI.Texture} + */ + get texture() + { + return this._texture; + } + + set texture(value) // eslint-disable-line require-jsdoc + { + if (this._texture === value) + { + return; + } + + this._texture = value; + this.uniforms.uSampler = this.texture; + + if (value) + { + // wait for the texture to load + if (value.baseTexture.valid) + { + this._onTextureUpdate(); + } + else + { + value.once('update', this._onTextureUpdate, this); + } + } + } + + _render(renderer) + { + const baseTex = this._texture.baseTexture; + + premultiplyRgba(this._tintRGB, this.worldAlpha, this.uniforms.uColor, baseTex.premultiplyAlpha); + super._render(renderer); + } + /** + * When the texture is updated, this event will fire to update the scale and frame + * + * @private + */ + _onTextureUpdate() + { + // constructor texture update stop + if (!this.uvMatrix) + { + return; + } + this.uvMatrix.texture = this._texture; + this.refresh(); + } + + /** + * multiplies uvs only if uploadUvMatrix is false + * call it after you change uvs manually + * make sure that texture is valid + */ + multiplyUvs() + { + if (!this.uploadUvMatrix) + { + this.uvMatrix.multiplyUvs(this.uvs); + } + } + + /** + * Refreshes uvs for generated meshes (rope, plane) + * sometimes refreshes vertices too + * + * @param {boolean} [forceUpdate=false] if true, matrices will be updated any case + */ + refresh(forceUpdate) + { + if (this.uvMatrix.update(forceUpdate)) + { + this._refresh(); + } + } + + /** + * Updates the object transform for rendering + * + * @private + */ + updateTransform() + { + if (this.autoUpdate) + { + this.geometry.buffers[0].update(); + } + this.containerUpdateTransform(); + } + + /** + * re-calculates mesh coords + * @private + */ + _refresh() + { + /* empty */ + } +} diff --git a/packages/mesh-extras/src/NineSlicePlane.js b/packages/mesh-extras/src/NineSlicePlane.js new file mode 100644 index 0000000..0bae92c --- /dev/null +++ b/packages/mesh-extras/src/NineSlicePlane.js @@ -0,0 +1,270 @@ +import Plane from './Plane'; + +const DEFAULT_BORDER_SIZE = 10; + +/** + * The NineSlicePlane allows you to stretch a texture using 9-slice scaling. The corners will remain unscaled (useful + * for buttons with rounded corners for example) and the other areas will be scaled horizontally and or vertically + * + *```js + * let Plane9 = new PIXI.NineSlicePlane(PIXI.Texture.from('BoxWithRoundedCorners.png'), 15, 15, 15, 15); + * ``` + *
+ *      A                          B
+ *    +---+----------------------+---+
+ *  C | 1 |          2           | 3 |
+ *    +---+----------------------+---+
+ *    |   |                      |   |
+ *    | 4 |          5           | 6 |
+ *    |   |                      |   |
+ *    +---+----------------------+---+
+ *  D | 7 |          8           | 9 |
+ *    +---+----------------------+---+
+
+ *  When changing this objects width and/or height:
+ *     areas 1 3 7 and 9 will remain unscaled.
+ *     areas 2 and 8 will be stretched horizontally
+ *     areas 4 and 6 will be stretched vertically
+ *     area 5 will be stretched both horizontally and vertically
+ * 
+ * + * @class + * @extends PIXI.Plane + * @memberof PIXI + * + */ +export default class NineSlicePlane extends Plane +{ + /** + * @param {PIXI.Texture} texture - The texture to use on the NineSlicePlane. + * @param {int} [leftWidth=10] size of the left vertical bar (A) + * @param {int} [topHeight=10] size of the top horizontal bar (C) + * @param {int} [rightWidth=10] size of the right vertical bar (B) + * @param {int} [bottomHeight=10] size of the bottom horizontal bar (D) + */ + constructor(texture, leftWidth, topHeight, rightWidth, bottomHeight) + { + super(texture, 4, 4); + + this._origWidth = texture.orig.width; + this._origHeight = texture.orig.height; + + /** + * The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._width = this._origWidth; + + /** + * The height of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._height = this._origHeight; + + /** + * The width of the left column (a) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._leftWidth = typeof leftWidth !== 'undefined' ? leftWidth : DEFAULT_BORDER_SIZE; + + /** + * The width of the right column (b) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._rightWidth = typeof rightWidth !== 'undefined' ? rightWidth : DEFAULT_BORDER_SIZE; + + /** + * The height of the top row (c) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._topHeight = typeof topHeight !== 'undefined' ? topHeight : DEFAULT_BORDER_SIZE; + + /** + * The height of the bottom row (d) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._bottomHeight = typeof bottomHeight !== 'undefined' ? bottomHeight : DEFAULT_BORDER_SIZE; + + this.refresh(true); + } + + /** + * Updates the horizontal vertices. + * + */ + updateHorizontalVertices() + { + const vertices = this.vertices; + + const h = this._topHeight + this._bottomHeight; + const scale = this._height > h ? 1.0 : this._height / h; + + vertices[9] = vertices[11] = vertices[13] = vertices[15] = this._topHeight * scale; + vertices[17] = vertices[19] = vertices[21] = vertices[23] = this._height - (this._bottomHeight * scale); + vertices[25] = vertices[27] = vertices[29] = vertices[31] = this._height; + } + + /** + * Updates the vertical vertices. + * + */ + updateVerticalVertices() + { + const vertices = this.vertices; + + const w = this._leftWidth + this._rightWidth; + const scale = this._width > w ? 1.0 : this._width / w; + + vertices[2] = vertices[10] = vertices[18] = vertices[26] = this._leftWidth * scale; + vertices[4] = vertices[12] = vertices[20] = vertices[28] = this._width - (this._rightWidth * scale); + vertices[6] = vertices[14] = vertices[22] = vertices[30] = this._width; + } + + /** + * The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + */ + get width() + { + return this._width; + } + + set width(value) // eslint-disable-line require-jsdoc + { + this._width = value; + this._refresh(); + } + + /** + * The height of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + */ + get height() + { + return this._height; + } + + set height(value) // eslint-disable-line require-jsdoc + { + this._height = value; + this._refresh(); + } + + /** + * The width of the left column + * + * @member {number} + */ + get leftWidth() + { + return this._leftWidth; + } + + set leftWidth(value) // eslint-disable-line require-jsdoc + { + this._leftWidth = value; + this._refresh(); + } + + /** + * The width of the right column + * + * @member {number} + */ + get rightWidth() + { + return this._rightWidth; + } + + set rightWidth(value) // eslint-disable-line require-jsdoc + { + this._rightWidth = value; + this._refresh(); + } + + /** + * The height of the top row + * + * @member {number} + */ + get topHeight() + { + return this._topHeight; + } + + set topHeight(value) // eslint-disable-line require-jsdoc + { + this._topHeight = value; + this._refresh(); + } + + /** + * The height of the bottom row + * + * @member {number} + */ + get bottomHeight() + { + return this._bottomHeight; + } + + set bottomHeight(value) // eslint-disable-line require-jsdoc + { + this._bottomHeight = value; + this._refresh(); + } + + /** + * Refreshes NineSlicePlane coords. All of them. + */ + _refresh() + { + super._refresh(); + + const uvs = this.uvs; + const texture = this._texture; + + this._origWidth = texture.orig.width; + this._origHeight = texture.orig.height; + + const _uvw = 1.0 / this._origWidth; + const _uvh = 1.0 / this._origHeight; + + uvs[0] = uvs[8] = uvs[16] = uvs[24] = 0; + uvs[1] = uvs[3] = uvs[5] = uvs[7] = 0; + uvs[6] = uvs[14] = uvs[22] = uvs[30] = 1; + uvs[25] = uvs[27] = uvs[29] = uvs[31] = 1; + + uvs[2] = uvs[10] = uvs[18] = uvs[26] = _uvw * this._leftWidth; + uvs[4] = uvs[12] = uvs[20] = uvs[28] = 1 - (_uvw * this._rightWidth); + uvs[9] = uvs[11] = uvs[13] = uvs[15] = _uvh * this._topHeight; + uvs[17] = uvs[19] = uvs[21] = uvs[23] = 1 - (_uvh * this._bottomHeight); + + this.updateHorizontalVertices(); + this.updateVerticalVertices(); + + this.geometry.buffers[1].update(); + + this.multiplyUvs(); + } +} diff --git a/packages/mesh-extras/src/Plane.js b/packages/mesh-extras/src/Plane.js new file mode 100644 index 0000000..1c240c4 --- /dev/null +++ b/packages/mesh-extras/src/Plane.js @@ -0,0 +1,100 @@ +import Mesh2d from './Mesh2d'; + +/** + * The Plane allows you to draw a texture across several points and them manipulate these points + * + *```js + * for (let i = 0; i < 20; i++) { + * points.push(new PIXI.Point(i * 50, 0)); + * }; + * let Plane = new PIXI.Plane(PIXI.Texture.from("snake.png"), points); + * ``` + * + * @class + * @extends PIXI.Mesh + * @memberof PIXI + * + */ +export default class Plane extends Mesh2d +{ + /** + * @param {PIXI.Texture} texture - The texture to use on the Plane. + * @param {number} verticesX - The number of vertices in the x-axis + * @param {number} verticesY - The number of vertices in the y-axis + * @param {object} [opts] - an options object - add meshWidth and meshHeight, temporary object for PixiJS v5 alpha + */ + constructor(texture, verticesX, verticesY, opts = {}) + { + super(texture, new Float32Array(1), new Float32Array(1), new Uint16Array(1), 4); + + this.verticesX = verticesX || 10; + this.verticesY = verticesY || 10; + + this.meshWidth = opts.meshWidth || 0; + this.meshHeight = opts.meshHeight || 0; + + this.refresh(); + } + + /** + * Refreshes plane coordinates + * @private + */ + _refresh() + { + const texture = this._texture; + const total = this.verticesX * this.verticesY; + const verts = []; + const uvs = []; + const indices = []; + + const segmentsX = this.verticesX - 1; + const segmentsY = this.verticesY - 1; + + const sizeX = (this.meshWidth || texture.width) / segmentsX; + const sizeY = (this.meshHeight || texture.height) / segmentsY; + + for (let i = 0; i < total; i++) + { + const x = (i % this.verticesX); + const y = ((i / this.verticesX) | 0); + + verts.push(x * sizeX, y * sizeY); + + uvs.push(x / segmentsX, y / segmentsY); + } + + // cons + + const totalSub = segmentsX * segmentsY; + + for (let i = 0; i < totalSub; i++) + { + const xpos = i % segmentsX; + const ypos = (i / segmentsX) | 0; + + const value = (ypos * this.verticesX) + xpos; + const value2 = (ypos * this.verticesX) + xpos + 1; + const value3 = ((ypos + 1) * this.verticesX) + xpos; + const value4 = ((ypos + 1) * this.verticesX) + xpos + 1; + + indices.push(value, value2, value3); + indices.push(value2, value4, value3); + } + + this.vertices = new Float32Array(verts); + this.uvs = new Float32Array(uvs); + this.indices = new Uint16Array(indices); + + this.geometry.buffers[0].data = this.vertices; + this.geometry.buffers[1].data = this.uvs; + this.geometry.indexBuffer.data = this.indices; + + // ensure that the changes are uploaded + this.geometry.buffers[0].update(); + this.geometry.buffers[1].update(); + this.geometry.indexBuffer.update(); + + this.multiplyUvs(); + } +} diff --git a/packages/mesh-extras/src/Rope.js b/packages/mesh-extras/src/Rope.js new file mode 100644 index 0000000..9cfde38 --- /dev/null +++ b/packages/mesh-extras/src/Rope.js @@ -0,0 +1,182 @@ +import Mesh2d from './Mesh2d'; + +/** + * The rope allows you to draw a texture across several points and them manipulate these points + * + *```js + * for (let i = 0; i < 20; i++) { + * points.push(new PIXI.Point(i * 50, 0)); + * }; + * let rope = new PIXI.Rope(PIXI.Texture.from("snake.png"), points); + * ``` + * + * @class + * @extends PIXI.Mesh + * @memberof PIXI + * + */ +export default class Rope extends Mesh2d +{ + /** + * @param {PIXI.Texture} texture - The texture to use on the rope. + * @param {PIXI.Point[]} points - An array of {@link PIXI.Point} objects to construct this rope. + */ + constructor(texture, points) + { + super(texture, new Float32Array(points.length * 4), + new Float32Array(points.length * 4), + new Uint16Array(points.length * 2), + 5); + + /* + * @member {PIXI.Point[]} An array of points that determine the rope + */ + this.points = points; + this.refresh(); + } + /** + * Refreshes Rope indices and uvs + * @private + */ + _refresh() + { + const points = this.points; + + if (!points) return; + + const vertexBuffer = this.geometry.getAttribute('aVertexPosition'); + const uvBuffer = this.geometry.getAttribute('aTextureCoord'); + const indexBuffer = this.geometry.getIndex(); + + // if too little points, or texture hasn't got UVs set yet just move on. + if (points.length < 1 || !this.texture._uvs) + { + return; + } + + // if the number of points has changed we will need to recreate the arraybuffers + if (vertexBuffer.data.length / 4 !== points.length) + { + vertexBuffer.data = new Float32Array(points.length * 4); + uvBuffer.data = new Float32Array(points.length * 4); + indexBuffer.data = new Uint16Array(points.length * 2); + } + + const uvs = uvBuffer.data; + const indices = indexBuffer.data; + + uvs[0] = 0; + uvs[1] = 0; + uvs[2] = 0; + uvs[3] = 1; + + indices[0] = 0; + indices[1] = 1; + + const total = points.length; + + for (let i = 1; i < total; i++) + { + // time to do some smart drawing! + let index = i * 4; + const amount = i / (total - 1); + + uvs[index] = amount; + uvs[index + 1] = 0; + + uvs[index + 2] = amount; + uvs[index + 3] = 1; + + index = i * 2; + indices[index] = index; + indices[index + 1] = index + 1; + } + + // ensure that the changes are uploaded + uvBuffer.update(); + indexBuffer.update(); + + this.multiplyUvs(); + this.refreshVertices(); + } + + /** + * refreshes vertices of Rope mesh + */ + refreshVertices() + { + const points = this.points; + + if (points.length < 1) + { + return; + } + + let lastPoint = points[0]; + let nextPoint; + let perpX = 0; + let perpY = 0; + + // this.count -= 0.2; + + const vertices = this.vertices; + const total = points.length; + + for (let i = 0; i < total; i++) + { + const point = points[i]; + const index = i * 4; + + if (i < points.length - 1) + { + nextPoint = points[i + 1]; + } + else + { + nextPoint = point; + } + + perpY = -(nextPoint.x - lastPoint.x); + perpX = nextPoint.y - lastPoint.y; + + let ratio = (1 - (i / (total - 1))) * 10; + + if (ratio > 1) + { + ratio = 1; + } + + const perpLength = Math.sqrt((perpX * perpX) + (perpY * perpY)); + const num = this._texture.height / 2; // (20 + Math.abs(Math.sin((i + this.count) * 0.3) * 50) )* ratio; + + perpX /= perpLength; + perpY /= perpLength; + + perpX *= num; + perpY *= num; + + vertices[index] = point.x + perpX; + vertices[index + 1] = point.y + perpY; + vertices[index + 2] = point.x - perpX; + vertices[index + 3] = point.y - perpY; + + lastPoint = point; + } + + this.geometry.buffers[0].update(); + } + + /** + * Updates the object transform for rendering + * + * @private + */ + updateTransform() + { + if (this.autoUpdate) + { + this.refreshVertices(); + } + this.containerUpdateTransform(); + } +} diff --git a/packages/mesh-extras/src/index.js b/packages/mesh-extras/src/index.js new file mode 100644 index 0000000..decf454 --- /dev/null +++ b/packages/mesh-extras/src/index.js @@ -0,0 +1,4 @@ +export { default as Mesh2d } from './Mesh2d'; +export { default as Plane } from './Plane'; +export { default as NineSlicePlane } from './NineSlicePlane'; +export { default as Rope } from './Rope'; diff --git a/packages/mesh-extras/src/mesh.frag b/packages/mesh-extras/src/mesh.frag new file mode 100644 index 0000000..6096983 --- /dev/null +++ b/packages/mesh-extras/src/mesh.frag @@ -0,0 +1,9 @@ +varying vec2 vTextureCoord; +uniform vec4 uColor; + +uniform sampler2D uSampler; + +void main(void) +{ + gl_FragColor = texture2D(uSampler, vTextureCoord) * uColor; +} diff --git a/packages/mesh-extras/src/mesh.vert b/packages/mesh-extras/src/mesh.vert new file mode 100644 index 0000000..0526df9 --- /dev/null +++ b/packages/mesh-extras/src/mesh.vert @@ -0,0 +1,15 @@ +attribute vec2 aVertexPosition; +attribute vec2 aTextureCoord; + +uniform mat3 projectionMatrix; +uniform mat3 translationMatrix; +uniform mat3 uTextureMatrix; + +varying vec2 vTextureCoord; + +void main(void) +{ + gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); + + vTextureCoord = (uTextureMatrix * vec3(aTextureCoord, 1.0)).xy; +} diff --git a/packages/mesh-extras/test/.eslintrc.json b/packages/mesh-extras/test/.eslintrc.json new file mode 100644 index 0000000..2ad8efb --- /dev/null +++ b/packages/mesh-extras/test/.eslintrc.json @@ -0,0 +1,12 @@ +{ + "globals": { + "expect": false, + "assert": false, + "sinon": false, + "PIXI": false + }, + "rules": { + "func-names": 0, + "no-unused-expressions": 0 + } +} \ No newline at end of file diff --git a/bundles/pixi.js/package.json b/bundles/pixi.js/package.json index 49c7276..177e059 100644 --- a/bundles/pixi.js/package.json +++ b/bundles/pixi.js/package.json @@ -49,6 +49,7 @@ "@pixi/loaders": "^5.0.0-alpha.2", "@pixi/math": "^5.0.0-alpha.2", "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/mesh-extras": "^5.0.0-alpha.2", "@pixi/mixin-cache-as-bitmap": "^5.0.0-alpha.2", "@pixi/mixin-get-child-by-name": "^5.0.0-alpha.2", "@pixi/mixin-get-global-position": "^5.0.0-alpha.2", diff --git a/bundles/pixi.js/src/deprecated.js b/bundles/pixi.js/src/deprecated.js index 147617c..dbebeb0 100644 --- a/bundles/pixi.js/src/deprecated.js +++ b/bundles/pixi.js/src/deprecated.js @@ -263,15 +263,15 @@ Object.defineProperties(PIXI.mesh, { /** * @class PIXI.mesh.Mesh - * @see PIXI.Mesh + * @see PIXI.Mesh2d * @deprecated since 5.0.0 */ Mesh: { get() { - warn('PIXI.mesh.Mesh has moved to PIXI.Mesh'); + warn('PIXI.mesh.Mesh has moved to PIXI.Mesh2d'); - return PIXI.Mesh; + return PIXI.Mesh2d; }, }, /** @@ -315,15 +315,15 @@ }, /** * @class PIXI.mesh.RawMesh - * @see PIXI.RawMesh + * @see PIXI.Mesh * @deprecated since 5.0.0 */ RawMesh: { get() { - warn('PIXI.mesh.RawMesh has moved to PIXI.RawMesh'); + warn('PIXI.mesh.RawMesh has moved to PIXI.Mesh'); - return PIXI.RawMesh; + return PIXI.Mesh; }, }, /** diff --git a/bundles/pixi.js/src/index.js b/bundles/pixi.js/src/index.js index a3a0d1b..6fdabf0 100644 --- a/bundles/pixi.js/src/index.js +++ b/bundles/pixi.js/src/index.js @@ -9,6 +9,7 @@ import * as loaders from '@pixi/loaders'; import * as math from '@pixi/math'; import * as mesh from '@pixi/mesh'; +import * as meshExtras from '@pixi/mesh-extras'; import * as particles from '@pixi/particles'; import * as prepare from '@pixi/prepare'; import * as sprite from '@pixi/sprite'; @@ -128,6 +129,7 @@ loaders, math, mesh, + meshExtras, particles, sprite, spriteAnimated, @@ -152,6 +154,7 @@ export * from '@pixi/loaders'; export * from '@pixi/math'; export * from '@pixi/mesh'; +export * from '@pixi/mesh-extras'; export * from '@pixi/particles'; export * from '@pixi/sprite'; export * from '@pixi/spritesheet'; diff --git a/package-lock.json b/package-lock.json index 7fe6db7..0814729 100644 --- a/package-lock.json +++ b/package-lock.json @@ -209,7 +209,7 @@ "argparse": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", - "integrity": "sha1-vNZ5HqWuCXJeF+WtmIE0zUCz2RE=", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", "dev": true, "requires": { "sprintf-js": "1.0.3" @@ -228,7 +228,7 @@ "arr-flatten": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz", - "integrity": "sha1-NgSLv/TntH4TZkQxbJlmnqWukfE=", + "integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==", "dev": true }, "arr-union": { @@ -297,7 +297,7 @@ "assertion-error": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", - "integrity": "sha1-5gtrDo8wG9l+U3UhW9pAbIURjAs=", + "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", "dev": true }, "async": { @@ -396,7 +396,7 @@ "brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha1-PH/L9SnYcibz0vUrlm/1Jx60Qd0=", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, "requires": { "balanced-match": "1.0.0", @@ -568,7 +568,7 @@ "circular-json": { "version": "0.3.3", "resolved": "https://registry.npmjs.org/circular-json/-/circular-json-0.3.3.tgz", - "integrity": "sha1-gVyZ6oT2gJUp0vRXkb34JxE1LWY=", + "integrity": "sha512-UZK3NBx2Mca+b5LsG7bY183pHWt5Y1xts4P3Pz7ENTwGVnJOUWbRb3ocjvX7hx9tq/yTAdclXm9sZ38gNuem4A==", "dev": true }, "cli-cursor": { @@ -638,7 +638,7 @@ "color-convert": { "version": "1.9.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.1.tgz", - "integrity": "sha1-wSYRB66y8pTr/+ye2eytUppgl+0=", + "integrity": "sha512-mjGanIiwQJskCC18rPR6OmrZ6fm2Lc7PeGFYwCmy5J34wC6F1PzdGL6xeMfmgicfYcNLGuVFA3WzXtIDCQSZxQ==", "dev": true, "requires": { "color-name": "1.1.3" @@ -1427,7 +1427,7 @@ "boom": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/boom/-/boom-5.2.0.tgz", - "integrity": "sha1-XdnabuOl8wIHdDYpDLcX0/SlTgI=", + "integrity": "sha512-Z5BTk6ZRe4tXXQlkqftmsAUANpXmuwlsF5Oov8ThoMbQRzdGTA1ngYRW160GexgOgjsFOKJz0LYhoNi+2AMBUw==", "dev": true, "requires": { "hoek": "4.2.1" @@ -1471,7 +1471,7 @@ "debug": { "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha1-XRKFFd8TT/Mn6QpMk/Tgd6U2NB8=", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", "dev": true, "requires": { "ms": "2.0.0" @@ -1585,7 +1585,7 @@ "doctrine": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", - "integrity": "sha1-XNAfwQFiG0LEzX9dGmYkNxbT850=", + "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", "dev": true, "requires": { "esutils": "2.0.2" @@ -1662,7 +1662,7 @@ "es6-promise": { "version": "4.2.4", "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.4.tgz", - "integrity": "sha1-3EIhwrFlGHYL2MOaUtjzVvwA7Sk=", + "integrity": "sha512-/NdNZVJg+uZgtm9eS3O6lrOLYmQag2DjdEXuPaHlZ6RuVqgqaVZfgYCepEIKsLqwdQArOPtC3XzRLqGGfT8KQQ==", "dev": true }, "escape-string-regexp": { @@ -1788,7 +1788,7 @@ "espree": { "version": "3.5.4", "resolved": "https://registry.npmjs.org/espree/-/espree-3.5.4.tgz", - "integrity": "sha1-sPRHGHyKi+2US4FaZgvd9d610ac=", + "integrity": "sha512-yAcIQxtmMiB/jL32dzEp2enBeidsB7xWPLNiw3IIkpVds1P+h7qF9YwJq1yUNzp2OKXgAprs4F61ih66UsoD1A==", "dev": true, "requires": { "acorn": "5.5.0", @@ -1798,7 +1798,7 @@ "esprima": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.0.tgz", - "integrity": "sha1-RJnt3NERDgshi6zy+n9/WfVcqAQ=", + "integrity": "sha512-oftTcaMu/EGrEIu904mWteKIv8vMuOgGYo7EhVJJN00R/EED9DCua/xxHRdYnKtcECzVg7xOWhflvJMnqcFZjw==", "dev": true }, "esquery": { @@ -1813,7 +1813,7 @@ "esrecurse": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.2.1.tgz", - "integrity": "sha1-AHo7n9vCs7uH5IeeoZyS/b05Qs8=", + "integrity": "sha512-64RBB++fIOAXPw3P9cy89qfMlvZEXZkqqJkjqqXIvzP5ezRZjW+lPWjw35UX/3EhUPFYbg5ER4JYgDw4007/DQ==", "dev": true, "requires": { "estraverse": "4.2.0" @@ -2024,7 +2024,7 @@ "find-root": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/find-root/-/find-root-1.1.0.tgz", - "integrity": "sha1-q8/Iunb3CMQql7PWhbfpRQv7nOQ=", + "integrity": "sha512-NKfW6bec6GfKc0SGx1e07QZY9PE99u0Bft/0rzSD5k3sO/vwkVUpDUKVm5Gpp5Ue3YfShPFTX2070tDs5kB9Ng==", "dev": true }, "find-up": { @@ -2103,7 +2103,7 @@ "supports-color": { "version": "5.3.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.3.0.tgz", - "integrity": "sha1-WySsFduA+pJ89SJ6SjP9PEx2dsA=", + "integrity": "sha512-0aP01LLIskjKs3lq52EC0aGBAJhLq7B2Rd8HC/DR/PtNNpcLilNmHC12O+hu0usQpo7wtHNRqtrhBwtDb0+dNg==", "dev": true, "requires": { "has-flag": "3.0.0" @@ -2567,7 +2567,7 @@ "glob": { "version": "7.1.2", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", - "integrity": "sha1-wZyd+aAocC1nhhI4SmVSQExjbRU=", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", "dev": true, "requires": { "fs.realpath": "1.0.0", @@ -2672,7 +2672,7 @@ "growl": { "version": "1.10.3", "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.3.tgz", - "integrity": "sha1-GSa6kM8+3+KttJJ/WIC8IsZseQ8=", + "integrity": "sha512-hKlsbA5Vu3xsh1Cg3J7jSmX/WaW6A5oBeqzM88oNbCRQFz+zUaXm6yxS4RVytp1scBoJzSYl4YAEOQIt6O8V1Q==", "dev": true }, "handlebars": { @@ -2738,7 +2738,7 @@ "hawk": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/hawk/-/hawk-6.0.2.tgz", - "integrity": "sha1-r02RTrBl+bXOTZ0RwcshJu7MMDg=", + "integrity": "sha512-miowhl2+U7Qle4vdLqDdPt9m09K6yZhkLDTWGoUiUzrQCn+mHHSmfJgAyGaLRZbPmTqfFFjRV1QWCW0VWUJBbQ==", "dev": true, "requires": { "boom": "4.3.1", @@ -2756,7 +2756,7 @@ "hoek": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/hoek/-/hoek-4.2.1.tgz", - "integrity": "sha1-ljRQKqEsRF3Vp8VzS1cruHOKrLs=", + "integrity": "sha512-QLg82fGkfnJ/4iy1xZ81/9SIJiq1NGFUMGs6ParyjBZr6jW2Ufj/snDqTHixNlHdPNwN2RLVD0Pi3igeK9+JfA==", "dev": true }, "home-path": { @@ -2791,7 +2791,7 @@ "ignore": { "version": "3.3.7", "resolved": "https://registry.npmjs.org/ignore/-/ignore-3.3.7.tgz", - "integrity": "sha1-YSKJv7PCIOGGpYEYYY1b6MG6sCE=", + "integrity": "sha512-YGG3ejvBNHRqu0559EOxxNFihD0AjpvHlC/pdGKd3X3ofe+CoJkYazwNJYTNebqpPKN+VVQbh4ZFn1DivMNuHA==", "dev": true }, "imurmurhash": { @@ -2828,7 +2828,7 @@ "ini": { "version": "1.3.5", "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", - "integrity": "sha1-7uJfVtscnsYIXgwid4CD9Zar+Sc=", + "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==", "dev": true }, "inquirer": { @@ -2901,7 +2901,7 @@ "is-buffer": { "version": "1.1.6", "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", - "integrity": "sha1-76ouqdqg16suoTqXsritUf776L4=", + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", "dev": true }, "is-builtin-module": { @@ -3054,7 +3054,7 @@ "is-resolvable": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/is-resolvable/-/is-resolvable-1.1.0.tgz", - "integrity": "sha1-+xj4fOH+uSUWnJpAfBkxijIG7Yg=", + "integrity": "sha512-qgDYXFSR5WvEfuS5dMj6oTMEbrrSaM0CrFk2Yiq/gXnBvD9pMa2jGXxyhGLfvhZpuMZe18CJpFxAt3CRs42NMg==", "dev": true }, "is-retry-allowed": { @@ -3204,7 +3204,7 @@ "js-yaml": { "version": "3.11.0", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.11.0.tgz", - "integrity": "sha1-WXwai9VxUvJtYizkEXhRpR9euu8=", + "integrity": "sha512-saJstZWv7oNeOyBh3+Dx1qWzhW0+e6/8eDzo7p5rDFqxntSztloLtuKu+Ejhtq82jsilwOIZYsCz+lIjthg1Hw==", "dev": true, "requires": { "argparse": "1.0.10", @@ -3324,7 +3324,7 @@ "just-extend": { "version": "1.1.27", "resolved": "https://registry.npmjs.org/just-extend/-/just-extend-1.1.27.tgz", - "integrity": "sha1-7G55QQ/5FORyZSq/oOYDwD1g6QU=", + "integrity": "sha512-mJVp13Ix6gFo3SBAy9U/kL+oeZqzlYYYLQBwXVBlVzIsZwBqGREnOro24oC/8s8aox+rJhtZ2DiQof++IrkA+g==", "dev": true }, "kind-of": { @@ -3703,7 +3703,7 @@ "lodash": { "version": "4.17.5", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.5.tgz", - "integrity": "sha1-maktZcAnLevoyWtgV7yPv6O+1RE=", + "integrity": "sha512-svL3uiZf1RwhH+cWrfZn3A4+U58wbP0tGVTLQPbjplZxZ8ROD9VLuNgsRniTlLe7OlSqR79RUehXgpBW/s0IQw==", "dev": true }, "lodash._reinterpolate": { @@ -3740,7 +3740,7 @@ "lolex": { "version": "2.3.2", "resolved": "https://registry.npmjs.org/lolex/-/lolex-2.3.2.tgz", - "integrity": "sha1-hflFBCUQO/nnpgZo6iXcQydMqAc=", + "integrity": "sha512-A5pN2tkFj7H0dGIAM6MFvHKMJcPnjZsOMvR7ujCjfgW5TbV6H9vb1PgxLtHvjqNZTHsUolz+6/WEO0N1xNx2ng==", "dev": true }, "longest": { @@ -3816,7 +3816,7 @@ "marked": { "version": "0.3.17", "resolved": "https://registry.npmjs.org/marked/-/marked-0.3.17.tgz", - "integrity": "sha1-YH8GZos8axJGso8T2nYRasGqLSs=", + "integrity": "sha512-+AKbNsjZl6jFfLPwHhWmGTqE009wTKn3RTmn9K8oUKHrX/abPJjtcRtXpYB/FFrwPJRUA86LX/de3T0knkPCmQ==", "dev": true }, "mem": { @@ -3896,13 +3896,13 @@ "mime-db": { "version": "1.33.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.33.0.tgz", - "integrity": "sha1-o0kgUKXLm2NFBUHjnZeI0icng9s=", + "integrity": "sha512-BHJ/EKruNIqJf/QahvxwQZXKygOQ256myeN/Ew+THcAa5q+PjyTTMMeNQC4DZw5AwfvelsUrA6B67NKMqXDbzQ==", "dev": true }, "mime-types": { "version": "2.1.18", "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.18.tgz", - "integrity": "sha1-bzI/YKg9ERRvgx/xH9ZuL+VQO7g=", + "integrity": "sha512-lc/aahn+t4/SWV/qcmumYjymLsWfN3ELhpmVuUFjgsORruuZPVSwAQryq+HHGvO/SI2KVX26bx+En+zhM8g8hQ==", "dev": true, "requires": { "mime-db": "1.33.0" @@ -3917,7 +3917,7 @@ "minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha1-UWbihkV/AzBgZL5Ul+jbsMPTIIM=", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "dev": true, "requires": { "brace-expansion": "1.1.11" @@ -4071,7 +4071,7 @@ "normalize-package-data": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.4.0.tgz", - "integrity": "sha1-EvlaMH1YNSB1oEkHuErIvpisAS8=", + "integrity": "sha512-9jjUFbTPfEy3R/ad/2oNbKtW9Hgovl5O1FvFWKkKblNXoN/Oou6+9+KKohPK13Yc3/TyunyWhJp6gvRNR/PPAw==", "dev": true, "requires": { "hosted-git-info": "2.5.0", @@ -4511,7 +4511,7 @@ "process-nextick-args": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", - "integrity": "sha1-o31zL0JxtKsa0HDTVQjoKQeI/6o=", + "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==", "dev": true }, "progress": { @@ -4584,7 +4584,7 @@ "qs": { "version": "6.5.1", "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.1.tgz", - "integrity": "sha1-NJzfbu+J7EXBLX1es/wMhwNDptg=", + "integrity": "sha512-eRzhrN1WSINYCDCbrz796z37LOe3m5tmW7RQf6oBntukAG1nmovJvhnwHHRMAfeoItc1m2Hk02WER2aQ/iqs+A==", "dev": true }, "quick-lru": { @@ -4596,7 +4596,7 @@ "randomatic": { "version": "1.1.7", "resolved": "https://registry.npmjs.org/randomatic/-/randomatic-1.1.7.tgz", - "integrity": "sha1-x6vpzIuHwLqodrGf3oP9RkeX44w=", + "integrity": "sha512-D5JUjPyJbaJDkuAazpVnSfVkLlpeO3wDlPROTMLGKG1zMFNFRgrciKo1ltz/AzNTkqE0HzDx655QOL51N06how==", "dev": true, "requires": { "is-number": "3.0.0", @@ -4701,7 +4701,7 @@ "regex-cache": { "version": "0.4.4", "resolved": "https://registry.npmjs.org/regex-cache/-/regex-cache-0.4.4.tgz", - "integrity": "sha1-db3FiioUls7EihKDW8VMjVYjNt0=", + "integrity": "sha512-nVIZwtCjkC9YgvWkpM55B5rBhBYRZhAaJbgcFYXXsHnbZ9UZI9nnVWYZpBlCqv9ho2eZryPnWrZGsOdPwVWXWQ==", "dev": true, "requires": { "is-equal-shallow": "0.1.3" @@ -4729,7 +4729,7 @@ "remap-istanbul": { "version": "0.10.1", "resolved": "https://registry.npmjs.org/remap-istanbul/-/remap-istanbul-0.10.1.tgz", - "integrity": "sha1-OqWN1QIdSZ8zbTulvzu7kcG4jjc=", + "integrity": "sha512-gsNQXs5kJLhErICSyYhzVZ++C8LBW8dgwr874Y2QvzAUS75zBlD/juZgXs39nbYJ09fZDlX2AVLVJAY2jbFJoQ==", "dev": true, "requires": { "amdefine": "1.0.1", @@ -4769,7 +4769,7 @@ "source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha1-dHIq8y6WFOnCh6jQu95IteLxomM=", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", "dev": true }, "through2": { @@ -4883,7 +4883,7 @@ "resolve": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.5.0.tgz", - "integrity": "sha1-HwmsznlsmnYlefMbLBzEw83fnzY=", + "integrity": "sha512-hgoSGrc3pjzAPHNBg+KnFcK2HwlHTs/YrAGUr6qgTVUZmXv1UEXXl0bZNBKMA9fud6lRYFdPGz0xXxycPzmmiw==", "dev": true, "requires": { "path-parse": "1.0.5" @@ -4924,7 +4924,7 @@ "rimraf": { "version": "2.6.2", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", - "integrity": "sha1-LtgVDSShbqhlHm1u8PR8QVjOejY=", + "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", "dev": true, "requires": { "glob": "7.1.2" @@ -5063,19 +5063,19 @@ "safe-buffer": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", - "integrity": "sha1-iTMSr2myEj3vcfV4iQAWce6yyFM=", + "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", "dev": true }, "samsam": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/samsam/-/samsam-1.3.0.tgz", - "integrity": "sha1-jR2TUOJWItow3j5EumkrUiGrfFA=", + "integrity": "sha512-1HwIYD/8UlOtFS3QO3w7ey+SdSDFE4HRNLZoZRYVQefrOY3l17epswImeB1ijgJFQJodIaHcwkp3r/myBjFVbg==", "dev": true }, "semver": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz", - "integrity": "sha1-3Eu8emyp2Rbe5dQ1FvAJK1j3uKs=", + "integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==", "dev": true }, "set-blocking": { @@ -5117,7 +5117,7 @@ "sinon-chai": { "version": "2.14.0", "resolved": "https://registry.npmjs.org/sinon-chai/-/sinon-chai-2.14.0.tgz", - "integrity": "sha1-2n3UzIPNaiYLZ8yg96n9riahIF0=", + "integrity": "sha512-9stIF1utB0ywNHNT7RgiXbdmen8QDCRsrTjw+G9TgKt1Yexjiv8TOWZ6WHsTPz57Yky3DIswZvEqX8fpuHNDtQ==", "dev": true }, "slash": { @@ -5146,7 +5146,7 @@ "sntp": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/sntp/-/sntp-2.1.0.tgz", - "integrity": "sha1-LGzsFP7cIiJznK+bXD2F0cxaLMg=", + "integrity": "sha512-FL1b58BDrqS3A11lJ0zEdnJ3UOKqVxawAkF3k7F0CVN7VQ34aZrV+G8BZ1WC9ZL7NyrwsW0oviwsWDgRuVYtJg==", "dev": true, "requires": { "hoek": "4.2.1" @@ -5203,7 +5203,7 @@ "spdx-correct": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.0.0.tgz", - "integrity": "sha1-BaW01xU6GVvJLDxCW2nzsqlSTII=", + "integrity": "sha512-N19o9z5cEyc8yQQPukRCZ9EUmb4HUpnrmaL/fxS2pBo2jbfcFRVuFZ/oFC+vZz0MNNk0h80iMn5/S6qGZOL5+g==", "dev": true, "requires": { "spdx-expression-parse": "3.0.0", @@ -5213,13 +5213,13 @@ "spdx-exceptions": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.1.0.tgz", - "integrity": "sha1-LHrmEFbHFKW5ubKyr30xHvXHj+k=", + "integrity": "sha512-4K1NsmrlCU1JJgUrtgEeTVyfx8VaYea9J9LvARxhbHtVtohPs/gFGG5yy49beySjlIMhhXZ4QqujIZEfS4l6Cg==", "dev": true }, "spdx-expression-parse": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.0.tgz", - "integrity": "sha1-meEZt6XaAOBUkcn6M4t5BII7QdA=", + "integrity": "sha512-Yg6D3XpRD4kkOmTpdgbUiEJFKghJH03fiC1OPll5h/0sO6neh2jqRDVHOQ4o/LMea0tgCkbMgea5ip/e+MkWyg==", "dev": true, "requires": { "spdx-exceptions": "2.1.0", @@ -5229,7 +5229,7 @@ "spdx-license-ids": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.0.tgz", - "integrity": "sha1-enzShHDMbToc/m1miG9rxDDTrIc=", + "integrity": "sha512-2+EPwgbnmOIl8HjGBXXMd9NAu02vLjOO1nWw4kmeRDFyHn+M/ETfHxQUK0oXg8ctgVnl9t3rosNVsZ1jG61nDA==", "dev": true }, "speedometer": { @@ -5566,7 +5566,7 @@ "tough-cookie": { "version": "2.3.4", "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.4.tgz", - "integrity": "sha1-7GDO44rGdQY//JelwYlwV47oNlU=", + "integrity": "sha512-TZ6TTfI5NtZnuyy/Kecv+CnoROnyXn2DN97LontgQpCwsX2XyLYCC0ENhYkehSOwAp8rTQKc/NUIF7BkQ5rKLA==", "dev": true, "requires": { "punycode": "1.4.1" @@ -5708,13 +5708,13 @@ "uuid": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.2.1.tgz", - "integrity": "sha1-EsUou51Y0LkmXZovbw/ovhf/HxQ=", + "integrity": "sha512-jZnMwlb9Iku/O3smGWvZhauCf6cvvpKi4BKRiliS3cxnI+Gz9j5MEpTz2UFuXiKPJocb7gnsLHwiS05ige5BEA==", "dev": true }, "validate-npm-package-license": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.3.tgz", - "integrity": "sha1-gWQ7y+8b3+zUYjeT3EZIlIupgzg=", + "integrity": "sha512-63ZOUnL4SIXj4L0NixR3L1lcjO38crAbgrTpl28t8jjrfuiOBL5Iygm+60qPs/KsZGzPNg6Smnc/oY16QTjF0g==", "dev": true, "requires": { "spdx-correct": "3.0.0", @@ -5750,7 +5750,7 @@ "which": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/which/-/which-1.3.0.tgz", - "integrity": "sha1-/wS9/AEO5UfXgL7DjhrBwnd9JTo=", + "integrity": "sha512-xcJpopdamTuY5duC/KnTTNBraPK54YwpenP4lzxU8H91GudWpFv38u0CKjclE1Wi2EH2EDz5LRcHcKbCIzqGyg==", "dev": true, "requires": { "isexe": "2.0.0" diff --git a/packages/canvas/canvas-mesh/package.json b/packages/canvas/canvas-mesh/package.json index 691cd2c..6744a17 100644 --- a/packages/canvas/canvas-mesh/package.json +++ b/packages/canvas/canvas-mesh/package.json @@ -24,6 +24,7 @@ "dependencies": { "@pixi/constants": "^5.0.0-alpha.2", "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/mesh-extras": "^5.0.0-alpha.2", "@pixi/settings": "^5.0.0-alpha.2" }, "devDependencies": { diff --git a/packages/canvas/canvas-mesh/src/Mesh.js b/packages/canvas/canvas-mesh/src/Mesh.js index 900a872..c43a74b 100644 --- a/packages/canvas/canvas-mesh/src/Mesh.js +++ b/packages/canvas/canvas-mesh/src/Mesh.js @@ -1,36 +1,14 @@ import { Mesh } from '@pixi/mesh'; -import { settings } from './settings'; - -// IMPORTANT: Please do NOT use this as a precedent to use `settings` after the object is created -// this was merely created to completely decouple canvas from the base Mesh class and we are -// unable to add `canvasPadding` in the constructor anymore, as the case was for PixiJS v4. /** - * Internal variable for `canvasPadding`. + * Renders the object using the Canvas renderer * * @private - * @memberof PIXI.Mesh - * @member {number} - * @default null - */ -Mesh.prototype._canvasPadding = null; - -/** - * Triangles in canvas mode are automatically antialiased, use this value to force triangles - * to overlap a bit with each other. To set the global default, set {@link PIXI.settings.MESH_CANVAS_PADDING} - * - * @see PIXI.settings.MESH_CANVAS_PADDING - * @member {number} canvasPadding + * @method _renderCanvas * @memberof PIXI.Mesh# - * @default 0 + * @param {PIXI.CanvasRenderer} renderer - The canvas renderer. */ -Object.defineProperty(Mesh.prototype, 'canvasPadding', { - get() - { - return this._canvasPadding !== null ? this._canvasPadding : settings.MESH_CANVAS_PADDING; - }, - set(value) - { - this._canvasPadding = value; - }, -}); +Mesh.prototype._renderCanvas = function _renderCanvas(renderer) +{ + renderer.plugins[this.pluginName].render(this); +}; diff --git a/packages/canvas/canvas-mesh/src/Mesh2d.js b/packages/canvas/canvas-mesh/src/Mesh2d.js new file mode 100644 index 0000000..d0bd80f --- /dev/null +++ b/packages/canvas/canvas-mesh/src/Mesh2d.js @@ -0,0 +1,36 @@ +import { Mesh2d } from '@pixi/mesh-extras'; +import { settings } from './settings'; + +// IMPORTANT: Please do NOT use this as a precedent to use `settings` after the object is created +// this was merely created to completely decouple canvas from the base Mesh class and we are +// unable to add `canvasPadding` in the constructor anymore, as the case was for PixiJS v4. + +/** + * Internal variable for `canvasPadding`. + * + * @private + * @memberof PIXI.Mesh2d + * @member {number} + * @default null + */ +Mesh2d.prototype._canvasPadding = null; + +/** + * Triangles in canvas mode are automatically antialiased, use this value to force triangles + * to overlap a bit with each other. To set the global default, set {@link PIXI.settings.MESH_CANVAS_PADDING} + * + * @see PIXI.settings.MESH_CANVAS_PADDING + * @member {number} canvasPadding + * @memberof PIXI.Mesh2d# + * @default 0 + */ +Object.defineProperty(Mesh2d.prototype, 'canvasPadding', { + get() + { + return this._canvasPadding !== null ? this._canvasPadding : settings.MESH_CANVAS_PADDING; + }, + set(value) + { + this._canvasPadding = value; + }, +}); diff --git a/packages/canvas/canvas-mesh/src/NineSlicePlane.js b/packages/canvas/canvas-mesh/src/NineSlicePlane.js index 09eaf9c..2fd5acc 100644 --- a/packages/canvas/canvas-mesh/src/NineSlicePlane.js +++ b/packages/canvas/canvas-mesh/src/NineSlicePlane.js @@ -1,4 +1,4 @@ -import { NineSlicePlane } from '@pixi/mesh'; +import { NineSlicePlane } from '@pixi/mesh-extras'; /** * Renders the object using the Canvas renderer diff --git a/packages/canvas/canvas-mesh/src/RawMesh.js b/packages/canvas/canvas-mesh/src/RawMesh.js deleted file mode 100644 index bf40184..0000000 --- a/packages/canvas/canvas-mesh/src/RawMesh.js +++ /dev/null @@ -1,14 +0,0 @@ -import { RawMesh } from '@pixi/mesh'; - -/** - * Renders the object using the Canvas renderer - * - * @private - * @method _renderCanvas - * @memberof PIXI.RawMesh# - * @param {PIXI.CanvasRenderer} renderer - The canvas renderer. - */ -RawMesh.prototype._renderCanvas = function _renderCanvas(renderer) -{ - renderer.plugins[this.pluginName].render(this); -}; diff --git a/packages/canvas/canvas-mesh/src/index.js b/packages/canvas/canvas-mesh/src/index.js index 2295016..f4fa31d 100644 --- a/packages/canvas/canvas-mesh/src/index.js +++ b/packages/canvas/canvas-mesh/src/index.js @@ -1,6 +1,6 @@ export { default as CanvasMeshRenderer } from './CanvasMeshRenderer'; import './settings'; -import './Mesh'; +import './Mesh2d'; import './NineSlicePlane'; -import './RawMesh'; +import './Mesh'; diff --git a/packages/canvas/canvas-mesh/src/settings.js b/packages/canvas/canvas-mesh/src/settings.js index 4cefb4c..e81b8e0 100644 --- a/packages/canvas/canvas-mesh/src/settings.js +++ b/packages/canvas/canvas-mesh/src/settings.js @@ -3,7 +3,7 @@ /** * Default `canvasPadding` for canvas-based Mesh rendering. * - * @see PIXI.Mesh#canvasPadding + * @see PIXI.Mesh2d#canvasPadding * @static * @constant * @memberof PIXI.settings diff --git a/packages/mesh-extras/LICENSE b/packages/mesh-extras/LICENSE new file mode 100644 index 0000000..148e3eb --- /dev/null +++ b/packages/mesh-extras/LICENSE @@ -0,0 +1,21 @@ +The MIT License + +Copyright (c) 2013-2018 Mathew Groves, Chad Engler + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/packages/mesh-extras/README.md b/packages/mesh-extras/README.md new file mode 100644 index 0000000..1d9b0e1 --- /dev/null +++ b/packages/mesh-extras/README.md @@ -0,0 +1,19 @@ +# @pixi/mesh-extras + +## Installation + +```bash +npm install @pixi/mesh-extras +``` + +## Usage + +```js +import { MeshRenderer } from '@pixi/mesh'; +import { Renderer } from '@pixi/core'; +import { Rope } from '@pixi/mesh-extras'; + +Renderer.registerPlugin('mesh', MeshRenderer); + +const rope = new Rope(); +``` \ No newline at end of file diff --git a/packages/mesh-extras/package.json b/packages/mesh-extras/package.json new file mode 100644 index 0000000..d134f64 --- /dev/null +++ b/packages/mesh-extras/package.json @@ -0,0 +1,38 @@ +{ + "name": "@pixi/mesh-extras", + "version": "5.0.0-alpha.2", + "main": "lib/mesh-extras.js", + "module": "lib/mesh-extras.es.js", + "description": "Custom Mesh display objects, like Rope and Plane", + "author": "Mat Groves", + "contributors": [ + "Matt Karl " + ], + "homepage": "http://pixijs.com/", + "bugs": "https://github.com/pixijs/pixi.js/issues", + "license": "MIT", + "repository": { + "type": "git", + "url": "https://github.com/pixijs/pixi.js.git" + }, + "publishConfig": { + "access": "public" + }, + "scripts": { + "test": "floss --path test" + }, + "files": [ + "lib" + ], + "dependencies": { + "@pixi/constants": "^5.0.0-alpha.2", + "@pixi/core": "^5.0.0-alpha.2", + "@pixi/math": "^5.0.0-alpha.2", + "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/utils": "^5.0.0-alpha.2" + }, + "devDependencies": { + "@pixi/loaders": "^5.0.0-alpha.2", + "floss": "^2.1.3" + } +} diff --git a/packages/mesh-extras/src/Mesh2d.js b/packages/mesh-extras/src/Mesh2d.js new file mode 100644 index 0000000..d113a5e --- /dev/null +++ b/packages/mesh-extras/src/Mesh2d.js @@ -0,0 +1,263 @@ +import { Mesh } from '@pixi/mesh'; +import { Geometry, Program, Shader, Texture, TextureMatrix } from '@pixi/core'; +import { Matrix } from '@pixi/math'; +import { BLEND_MODES } from '@pixi/constants'; +import { hex2rgb, premultiplyRgba } from '@pixi/utils'; +import vertex from './mesh.vert'; +import fragment from './mesh.frag'; + +let meshProgram; + +/** + * Base mesh class + * @class + * @extends PIXI.Container + * @memberof PIXI + */ +export default class Mesh2d extends Mesh +{ + /** + * @param {PIXI.Texture} [texture=Texture.EMPTY] - The texture to use + * @param {Float32Array} [vertices] - if you want to specify the vertices + * @param {Float32Array} [uvs] - if you want to specify the uvs + * @param {Uint16Array} [indices] - if you want to specify the indices + * @param {number} [drawMode] - the drawMode, can be any of the Mesh.DRAW_MODES consts + */ + constructor(texture = Texture.EMPTY, vertices, uvs, indices, drawMode) + { + const geometry = new Geometry(); + + if (!meshProgram) + { + meshProgram = new Program(vertex, fragment); + } + + geometry.addAttribute('aVertexPosition', vertices) + .addAttribute('aTextureCoord', uvs) + .addIndex(indices); + + geometry.getAttribute('aVertexPosition').static = false; + + const uniforms = { + uSampler: texture, + uTextureMatrix: Matrix.IDENTITY, + alpha: 1, + uColor: new Float32Array([1, 1, 1, 1]), + }; + + super(geometry, new Shader(meshProgram, uniforms), null, drawMode); + + /** + * The Uvs of the Mesh + * + * @member {Float32Array} + */ + this.uvs = geometry.getAttribute('aTextureCoord').data; + + /** + * An array of vertices + * + * @member {Float32Array} + */ + this.vertices = geometry.getAttribute('aVertexPosition').data; + + this.uniforms = uniforms; + + /** + * The texture of the Mesh + * + * @member {PIXI.Texture} + * @default PIXI.Texture.EMPTY + * @private + */ + this.texture = texture; + + /** + * The tint applied to the mesh. This is a [r,g,b] value. A value of [1,1,1] will remove any + * tint effect. + * + * @member {number} + * @private + */ + this._tintRGB = new Float32Array([1, 1, 1]); + + // Set default tint + this.tint = 0xFFFFFF; + + this.blendMode = BLEND_MODES.NORMAL; + + /** + * TextureMatrix instance for this Mesh, used to track Texture changes + * + * @member {PIXI.TextureMatrix} + * @readonly + */ + this.uvMatrix = new TextureMatrix(this._texture); + + /** + * whether or not upload uvMatrix to shader + * if its false, then uvs should be pre-multiplied + * if you change it for generated mesh, please call 'refresh(true)' + * @member {boolean} + * @default false + */ + this.uploadUvMatrix = false; + + /** + * Uploads vertices buffer every frame, like in PixiJS V3 and V4. + * + * @member {boolean} + * @default true + */ + this.autoUpdate = true; + } + + /** + * The tint applied to the Rope. This is a hex value. A value of + * 0xFFFFFF will remove any tint effect. + * + * @member {number} + * @memberof PIXI.Sprite# + * @default 0xFFFFFF + */ + get tint() + { + return this._tint; + } + + /** + * Sets the tint of the rope. + * + * @param {number} value - The value to set to. + */ + set tint(value) + { + this._tint = value; + + hex2rgb(this._tint, this._tintRGB); + } + + /** + * The blend mode to be applied to the sprite. Set to `PIXI.BLEND_MODES.NORMAL` to remove any blend mode. + * + * @member {number} + * @default PIXI.BLEND_MODES.NORMAL + * @see PIXI.BLEND_MODES + */ + get blendMode() + { + return this.state.blendMode; + } + + set blendMode(value) // eslint-disable-line require-jsdoc + { + this.state.blendMode = value; + } + + /** + * The texture that the mesh uses. + * + * @member {PIXI.Texture} + */ + get texture() + { + return this._texture; + } + + set texture(value) // eslint-disable-line require-jsdoc + { + if (this._texture === value) + { + return; + } + + this._texture = value; + this.uniforms.uSampler = this.texture; + + if (value) + { + // wait for the texture to load + if (value.baseTexture.valid) + { + this._onTextureUpdate(); + } + else + { + value.once('update', this._onTextureUpdate, this); + } + } + } + + _render(renderer) + { + const baseTex = this._texture.baseTexture; + + premultiplyRgba(this._tintRGB, this.worldAlpha, this.uniforms.uColor, baseTex.premultiplyAlpha); + super._render(renderer); + } + /** + * When the texture is updated, this event will fire to update the scale and frame + * + * @private + */ + _onTextureUpdate() + { + // constructor texture update stop + if (!this.uvMatrix) + { + return; + } + this.uvMatrix.texture = this._texture; + this.refresh(); + } + + /** + * multiplies uvs only if uploadUvMatrix is false + * call it after you change uvs manually + * make sure that texture is valid + */ + multiplyUvs() + { + if (!this.uploadUvMatrix) + { + this.uvMatrix.multiplyUvs(this.uvs); + } + } + + /** + * Refreshes uvs for generated meshes (rope, plane) + * sometimes refreshes vertices too + * + * @param {boolean} [forceUpdate=false] if true, matrices will be updated any case + */ + refresh(forceUpdate) + { + if (this.uvMatrix.update(forceUpdate)) + { + this._refresh(); + } + } + + /** + * Updates the object transform for rendering + * + * @private + */ + updateTransform() + { + if (this.autoUpdate) + { + this.geometry.buffers[0].update(); + } + this.containerUpdateTransform(); + } + + /** + * re-calculates mesh coords + * @private + */ + _refresh() + { + /* empty */ + } +} diff --git a/packages/mesh-extras/src/NineSlicePlane.js b/packages/mesh-extras/src/NineSlicePlane.js new file mode 100644 index 0000000..0bae92c --- /dev/null +++ b/packages/mesh-extras/src/NineSlicePlane.js @@ -0,0 +1,270 @@ +import Plane from './Plane'; + +const DEFAULT_BORDER_SIZE = 10; + +/** + * The NineSlicePlane allows you to stretch a texture using 9-slice scaling. The corners will remain unscaled (useful + * for buttons with rounded corners for example) and the other areas will be scaled horizontally and or vertically + * + *```js + * let Plane9 = new PIXI.NineSlicePlane(PIXI.Texture.from('BoxWithRoundedCorners.png'), 15, 15, 15, 15); + * ``` + *
+ *      A                          B
+ *    +---+----------------------+---+
+ *  C | 1 |          2           | 3 |
+ *    +---+----------------------+---+
+ *    |   |                      |   |
+ *    | 4 |          5           | 6 |
+ *    |   |                      |   |
+ *    +---+----------------------+---+
+ *  D | 7 |          8           | 9 |
+ *    +---+----------------------+---+
+
+ *  When changing this objects width and/or height:
+ *     areas 1 3 7 and 9 will remain unscaled.
+ *     areas 2 and 8 will be stretched horizontally
+ *     areas 4 and 6 will be stretched vertically
+ *     area 5 will be stretched both horizontally and vertically
+ * 
+ * + * @class + * @extends PIXI.Plane + * @memberof PIXI + * + */ +export default class NineSlicePlane extends Plane +{ + /** + * @param {PIXI.Texture} texture - The texture to use on the NineSlicePlane. + * @param {int} [leftWidth=10] size of the left vertical bar (A) + * @param {int} [topHeight=10] size of the top horizontal bar (C) + * @param {int} [rightWidth=10] size of the right vertical bar (B) + * @param {int} [bottomHeight=10] size of the bottom horizontal bar (D) + */ + constructor(texture, leftWidth, topHeight, rightWidth, bottomHeight) + { + super(texture, 4, 4); + + this._origWidth = texture.orig.width; + this._origHeight = texture.orig.height; + + /** + * The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._width = this._origWidth; + + /** + * The height of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._height = this._origHeight; + + /** + * The width of the left column (a) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._leftWidth = typeof leftWidth !== 'undefined' ? leftWidth : DEFAULT_BORDER_SIZE; + + /** + * The width of the right column (b) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._rightWidth = typeof rightWidth !== 'undefined' ? rightWidth : DEFAULT_BORDER_SIZE; + + /** + * The height of the top row (c) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._topHeight = typeof topHeight !== 'undefined' ? topHeight : DEFAULT_BORDER_SIZE; + + /** + * The height of the bottom row (d) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._bottomHeight = typeof bottomHeight !== 'undefined' ? bottomHeight : DEFAULT_BORDER_SIZE; + + this.refresh(true); + } + + /** + * Updates the horizontal vertices. + * + */ + updateHorizontalVertices() + { + const vertices = this.vertices; + + const h = this._topHeight + this._bottomHeight; + const scale = this._height > h ? 1.0 : this._height / h; + + vertices[9] = vertices[11] = vertices[13] = vertices[15] = this._topHeight * scale; + vertices[17] = vertices[19] = vertices[21] = vertices[23] = this._height - (this._bottomHeight * scale); + vertices[25] = vertices[27] = vertices[29] = vertices[31] = this._height; + } + + /** + * Updates the vertical vertices. + * + */ + updateVerticalVertices() + { + const vertices = this.vertices; + + const w = this._leftWidth + this._rightWidth; + const scale = this._width > w ? 1.0 : this._width / w; + + vertices[2] = vertices[10] = vertices[18] = vertices[26] = this._leftWidth * scale; + vertices[4] = vertices[12] = vertices[20] = vertices[28] = this._width - (this._rightWidth * scale); + vertices[6] = vertices[14] = vertices[22] = vertices[30] = this._width; + } + + /** + * The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + */ + get width() + { + return this._width; + } + + set width(value) // eslint-disable-line require-jsdoc + { + this._width = value; + this._refresh(); + } + + /** + * The height of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + */ + get height() + { + return this._height; + } + + set height(value) // eslint-disable-line require-jsdoc + { + this._height = value; + this._refresh(); + } + + /** + * The width of the left column + * + * @member {number} + */ + get leftWidth() + { + return this._leftWidth; + } + + set leftWidth(value) // eslint-disable-line require-jsdoc + { + this._leftWidth = value; + this._refresh(); + } + + /** + * The width of the right column + * + * @member {number} + */ + get rightWidth() + { + return this._rightWidth; + } + + set rightWidth(value) // eslint-disable-line require-jsdoc + { + this._rightWidth = value; + this._refresh(); + } + + /** + * The height of the top row + * + * @member {number} + */ + get topHeight() + { + return this._topHeight; + } + + set topHeight(value) // eslint-disable-line require-jsdoc + { + this._topHeight = value; + this._refresh(); + } + + /** + * The height of the bottom row + * + * @member {number} + */ + get bottomHeight() + { + return this._bottomHeight; + } + + set bottomHeight(value) // eslint-disable-line require-jsdoc + { + this._bottomHeight = value; + this._refresh(); + } + + /** + * Refreshes NineSlicePlane coords. All of them. + */ + _refresh() + { + super._refresh(); + + const uvs = this.uvs; + const texture = this._texture; + + this._origWidth = texture.orig.width; + this._origHeight = texture.orig.height; + + const _uvw = 1.0 / this._origWidth; + const _uvh = 1.0 / this._origHeight; + + uvs[0] = uvs[8] = uvs[16] = uvs[24] = 0; + uvs[1] = uvs[3] = uvs[5] = uvs[7] = 0; + uvs[6] = uvs[14] = uvs[22] = uvs[30] = 1; + uvs[25] = uvs[27] = uvs[29] = uvs[31] = 1; + + uvs[2] = uvs[10] = uvs[18] = uvs[26] = _uvw * this._leftWidth; + uvs[4] = uvs[12] = uvs[20] = uvs[28] = 1 - (_uvw * this._rightWidth); + uvs[9] = uvs[11] = uvs[13] = uvs[15] = _uvh * this._topHeight; + uvs[17] = uvs[19] = uvs[21] = uvs[23] = 1 - (_uvh * this._bottomHeight); + + this.updateHorizontalVertices(); + this.updateVerticalVertices(); + + this.geometry.buffers[1].update(); + + this.multiplyUvs(); + } +} diff --git a/packages/mesh-extras/src/Plane.js b/packages/mesh-extras/src/Plane.js new file mode 100644 index 0000000..1c240c4 --- /dev/null +++ b/packages/mesh-extras/src/Plane.js @@ -0,0 +1,100 @@ +import Mesh2d from './Mesh2d'; + +/** + * The Plane allows you to draw a texture across several points and them manipulate these points + * + *```js + * for (let i = 0; i < 20; i++) { + * points.push(new PIXI.Point(i * 50, 0)); + * }; + * let Plane = new PIXI.Plane(PIXI.Texture.from("snake.png"), points); + * ``` + * + * @class + * @extends PIXI.Mesh + * @memberof PIXI + * + */ +export default class Plane extends Mesh2d +{ + /** + * @param {PIXI.Texture} texture - The texture to use on the Plane. + * @param {number} verticesX - The number of vertices in the x-axis + * @param {number} verticesY - The number of vertices in the y-axis + * @param {object} [opts] - an options object - add meshWidth and meshHeight, temporary object for PixiJS v5 alpha + */ + constructor(texture, verticesX, verticesY, opts = {}) + { + super(texture, new Float32Array(1), new Float32Array(1), new Uint16Array(1), 4); + + this.verticesX = verticesX || 10; + this.verticesY = verticesY || 10; + + this.meshWidth = opts.meshWidth || 0; + this.meshHeight = opts.meshHeight || 0; + + this.refresh(); + } + + /** + * Refreshes plane coordinates + * @private + */ + _refresh() + { + const texture = this._texture; + const total = this.verticesX * this.verticesY; + const verts = []; + const uvs = []; + const indices = []; + + const segmentsX = this.verticesX - 1; + const segmentsY = this.verticesY - 1; + + const sizeX = (this.meshWidth || texture.width) / segmentsX; + const sizeY = (this.meshHeight || texture.height) / segmentsY; + + for (let i = 0; i < total; i++) + { + const x = (i % this.verticesX); + const y = ((i / this.verticesX) | 0); + + verts.push(x * sizeX, y * sizeY); + + uvs.push(x / segmentsX, y / segmentsY); + } + + // cons + + const totalSub = segmentsX * segmentsY; + + for (let i = 0; i < totalSub; i++) + { + const xpos = i % segmentsX; + const ypos = (i / segmentsX) | 0; + + const value = (ypos * this.verticesX) + xpos; + const value2 = (ypos * this.verticesX) + xpos + 1; + const value3 = ((ypos + 1) * this.verticesX) + xpos; + const value4 = ((ypos + 1) * this.verticesX) + xpos + 1; + + indices.push(value, value2, value3); + indices.push(value2, value4, value3); + } + + this.vertices = new Float32Array(verts); + this.uvs = new Float32Array(uvs); + this.indices = new Uint16Array(indices); + + this.geometry.buffers[0].data = this.vertices; + this.geometry.buffers[1].data = this.uvs; + this.geometry.indexBuffer.data = this.indices; + + // ensure that the changes are uploaded + this.geometry.buffers[0].update(); + this.geometry.buffers[1].update(); + this.geometry.indexBuffer.update(); + + this.multiplyUvs(); + } +} diff --git a/packages/mesh-extras/src/Rope.js b/packages/mesh-extras/src/Rope.js new file mode 100644 index 0000000..9cfde38 --- /dev/null +++ b/packages/mesh-extras/src/Rope.js @@ -0,0 +1,182 @@ +import Mesh2d from './Mesh2d'; + +/** + * The rope allows you to draw a texture across several points and them manipulate these points + * + *```js + * for (let i = 0; i < 20; i++) { + * points.push(new PIXI.Point(i * 50, 0)); + * }; + * let rope = new PIXI.Rope(PIXI.Texture.from("snake.png"), points); + * ``` + * + * @class + * @extends PIXI.Mesh + * @memberof PIXI + * + */ +export default class Rope extends Mesh2d +{ + /** + * @param {PIXI.Texture} texture - The texture to use on the rope. + * @param {PIXI.Point[]} points - An array of {@link PIXI.Point} objects to construct this rope. + */ + constructor(texture, points) + { + super(texture, new Float32Array(points.length * 4), + new Float32Array(points.length * 4), + new Uint16Array(points.length * 2), + 5); + + /* + * @member {PIXI.Point[]} An array of points that determine the rope + */ + this.points = points; + this.refresh(); + } + /** + * Refreshes Rope indices and uvs + * @private + */ + _refresh() + { + const points = this.points; + + if (!points) return; + + const vertexBuffer = this.geometry.getAttribute('aVertexPosition'); + const uvBuffer = this.geometry.getAttribute('aTextureCoord'); + const indexBuffer = this.geometry.getIndex(); + + // if too little points, or texture hasn't got UVs set yet just move on. + if (points.length < 1 || !this.texture._uvs) + { + return; + } + + // if the number of points has changed we will need to recreate the arraybuffers + if (vertexBuffer.data.length / 4 !== points.length) + { + vertexBuffer.data = new Float32Array(points.length * 4); + uvBuffer.data = new Float32Array(points.length * 4); + indexBuffer.data = new Uint16Array(points.length * 2); + } + + const uvs = uvBuffer.data; + const indices = indexBuffer.data; + + uvs[0] = 0; + uvs[1] = 0; + uvs[2] = 0; + uvs[3] = 1; + + indices[0] = 0; + indices[1] = 1; + + const total = points.length; + + for (let i = 1; i < total; i++) + { + // time to do some smart drawing! + let index = i * 4; + const amount = i / (total - 1); + + uvs[index] = amount; + uvs[index + 1] = 0; + + uvs[index + 2] = amount; + uvs[index + 3] = 1; + + index = i * 2; + indices[index] = index; + indices[index + 1] = index + 1; + } + + // ensure that the changes are uploaded + uvBuffer.update(); + indexBuffer.update(); + + this.multiplyUvs(); + this.refreshVertices(); + } + + /** + * refreshes vertices of Rope mesh + */ + refreshVertices() + { + const points = this.points; + + if (points.length < 1) + { + return; + } + + let lastPoint = points[0]; + let nextPoint; + let perpX = 0; + let perpY = 0; + + // this.count -= 0.2; + + const vertices = this.vertices; + const total = points.length; + + for (let i = 0; i < total; i++) + { + const point = points[i]; + const index = i * 4; + + if (i < points.length - 1) + { + nextPoint = points[i + 1]; + } + else + { + nextPoint = point; + } + + perpY = -(nextPoint.x - lastPoint.x); + perpX = nextPoint.y - lastPoint.y; + + let ratio = (1 - (i / (total - 1))) * 10; + + if (ratio > 1) + { + ratio = 1; + } + + const perpLength = Math.sqrt((perpX * perpX) + (perpY * perpY)); + const num = this._texture.height / 2; // (20 + Math.abs(Math.sin((i + this.count) * 0.3) * 50) )* ratio; + + perpX /= perpLength; + perpY /= perpLength; + + perpX *= num; + perpY *= num; + + vertices[index] = point.x + perpX; + vertices[index + 1] = point.y + perpY; + vertices[index + 2] = point.x - perpX; + vertices[index + 3] = point.y - perpY; + + lastPoint = point; + } + + this.geometry.buffers[0].update(); + } + + /** + * Updates the object transform for rendering + * + * @private + */ + updateTransform() + { + if (this.autoUpdate) + { + this.refreshVertices(); + } + this.containerUpdateTransform(); + } +} diff --git a/packages/mesh-extras/src/index.js b/packages/mesh-extras/src/index.js new file mode 100644 index 0000000..decf454 --- /dev/null +++ b/packages/mesh-extras/src/index.js @@ -0,0 +1,4 @@ +export { default as Mesh2d } from './Mesh2d'; +export { default as Plane } from './Plane'; +export { default as NineSlicePlane } from './NineSlicePlane'; +export { default as Rope } from './Rope'; diff --git a/packages/mesh-extras/src/mesh.frag b/packages/mesh-extras/src/mesh.frag new file mode 100644 index 0000000..6096983 --- /dev/null +++ b/packages/mesh-extras/src/mesh.frag @@ -0,0 +1,9 @@ +varying vec2 vTextureCoord; +uniform vec4 uColor; + +uniform sampler2D uSampler; + +void main(void) +{ + gl_FragColor = texture2D(uSampler, vTextureCoord) * uColor; +} diff --git a/packages/mesh-extras/src/mesh.vert b/packages/mesh-extras/src/mesh.vert new file mode 100644 index 0000000..0526df9 --- /dev/null +++ b/packages/mesh-extras/src/mesh.vert @@ -0,0 +1,15 @@ +attribute vec2 aVertexPosition; +attribute vec2 aTextureCoord; + +uniform mat3 projectionMatrix; +uniform mat3 translationMatrix; +uniform mat3 uTextureMatrix; + +varying vec2 vTextureCoord; + +void main(void) +{ + gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); + + vTextureCoord = (uTextureMatrix * vec3(aTextureCoord, 1.0)).xy; +} diff --git a/packages/mesh-extras/test/.eslintrc.json b/packages/mesh-extras/test/.eslintrc.json new file mode 100644 index 0000000..2ad8efb --- /dev/null +++ b/packages/mesh-extras/test/.eslintrc.json @@ -0,0 +1,12 @@ +{ + "globals": { + "expect": false, + "assert": false, + "sinon": false, + "PIXI": false + }, + "rules": { + "func-names": 0, + "no-unused-expressions": 0 + } +} \ No newline at end of file diff --git a/packages/mesh-extras/test/Plane.js b/packages/mesh-extras/test/Plane.js new file mode 100644 index 0000000..f9b1c25 --- /dev/null +++ b/packages/mesh-extras/test/Plane.js @@ -0,0 +1,60 @@ +const { Plane } = require('../'); +const { isWebGLSupported, skipHello } = require('@pixi/utils'); +const { Loader } = require('@pixi/loaders'); +const { Point } = require('@pixi/math'); +const { RenderTexture, Texture } = require('@pixi/core'); + +skipHello(); + +function withGL(fn) +{ + return isWebGLSupported() ? fn : undefined; +} + +// TODO: fix with webglrenderer +describe('PIXI.mesh.Plane', function () +{ + it.skip('should create a plane from an external image', withGL(function (done) + { + const loader = new Loader(); + + loader.add('testBitmap', `file://${__dirname}/resources/bitmap-1.png`) + .load(function (loader, resources) + { + const plane = new Plane(resources.testBitmap.texture, 100, 100); + + expect(plane.verticesX).to.equal(100); + expect(plane.verticesY).to.equal(100); + done(); + }); + })); + + it.skip('should create a new empty textured Plane', withGL(function () + { + const plane = new Plane(Texture.EMPTY, 100, 100); + + expect(plane.verticesX).to.equal(100); + expect(plane.verticesY).to.equal(100); + })); + + describe('containsPoint', function () + { + it.skip('should return true when point inside', withGL(function () + { + const point = new Point(10, 10); + const texture = new RenderTexture.create(20, 30); + const plane = new Plane(texture, 100, 100); + + expect(plane.containsPoint(point)).to.be.true; + })); + + it.skip('should return false when point outside', withGL(function () + { + const point = new Point(100, 100); + const texture = new RenderTexture.create(20, 30); + const plane = new Plane(texture, 100, 100); + + expect(plane.containsPoint(point)).to.be.false; + })); + }); +}); diff --git a/bundles/pixi.js/package.json b/bundles/pixi.js/package.json index 49c7276..177e059 100644 --- a/bundles/pixi.js/package.json +++ b/bundles/pixi.js/package.json @@ -49,6 +49,7 @@ "@pixi/loaders": "^5.0.0-alpha.2", "@pixi/math": "^5.0.0-alpha.2", "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/mesh-extras": "^5.0.0-alpha.2", "@pixi/mixin-cache-as-bitmap": "^5.0.0-alpha.2", "@pixi/mixin-get-child-by-name": "^5.0.0-alpha.2", "@pixi/mixin-get-global-position": "^5.0.0-alpha.2", diff --git a/bundles/pixi.js/src/deprecated.js b/bundles/pixi.js/src/deprecated.js index 147617c..dbebeb0 100644 --- a/bundles/pixi.js/src/deprecated.js +++ b/bundles/pixi.js/src/deprecated.js @@ -263,15 +263,15 @@ Object.defineProperties(PIXI.mesh, { /** * @class PIXI.mesh.Mesh - * @see PIXI.Mesh + * @see PIXI.Mesh2d * @deprecated since 5.0.0 */ Mesh: { get() { - warn('PIXI.mesh.Mesh has moved to PIXI.Mesh'); + warn('PIXI.mesh.Mesh has moved to PIXI.Mesh2d'); - return PIXI.Mesh; + return PIXI.Mesh2d; }, }, /** @@ -315,15 +315,15 @@ }, /** * @class PIXI.mesh.RawMesh - * @see PIXI.RawMesh + * @see PIXI.Mesh * @deprecated since 5.0.0 */ RawMesh: { get() { - warn('PIXI.mesh.RawMesh has moved to PIXI.RawMesh'); + warn('PIXI.mesh.RawMesh has moved to PIXI.Mesh'); - return PIXI.RawMesh; + return PIXI.Mesh; }, }, /** diff --git a/bundles/pixi.js/src/index.js b/bundles/pixi.js/src/index.js index a3a0d1b..6fdabf0 100644 --- a/bundles/pixi.js/src/index.js +++ b/bundles/pixi.js/src/index.js @@ -9,6 +9,7 @@ import * as loaders from '@pixi/loaders'; import * as math from '@pixi/math'; import * as mesh from '@pixi/mesh'; +import * as meshExtras from '@pixi/mesh-extras'; import * as particles from '@pixi/particles'; import * as prepare from '@pixi/prepare'; import * as sprite from '@pixi/sprite'; @@ -128,6 +129,7 @@ loaders, math, mesh, + meshExtras, particles, sprite, spriteAnimated, @@ -152,6 +154,7 @@ export * from '@pixi/loaders'; export * from '@pixi/math'; export * from '@pixi/mesh'; +export * from '@pixi/mesh-extras'; export * from '@pixi/particles'; export * from '@pixi/sprite'; export * from '@pixi/spritesheet'; diff --git a/package-lock.json b/package-lock.json index 7fe6db7..0814729 100644 --- a/package-lock.json +++ b/package-lock.json @@ -209,7 +209,7 @@ "argparse": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", - "integrity": "sha1-vNZ5HqWuCXJeF+WtmIE0zUCz2RE=", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", "dev": true, "requires": { "sprintf-js": "1.0.3" @@ -228,7 +228,7 @@ "arr-flatten": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz", - "integrity": "sha1-NgSLv/TntH4TZkQxbJlmnqWukfE=", + "integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==", "dev": true }, "arr-union": { @@ -297,7 +297,7 @@ "assertion-error": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", - "integrity": "sha1-5gtrDo8wG9l+U3UhW9pAbIURjAs=", + "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", "dev": true }, "async": { @@ -396,7 +396,7 @@ "brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha1-PH/L9SnYcibz0vUrlm/1Jx60Qd0=", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, "requires": { "balanced-match": "1.0.0", @@ -568,7 +568,7 @@ "circular-json": { "version": "0.3.3", "resolved": "https://registry.npmjs.org/circular-json/-/circular-json-0.3.3.tgz", - "integrity": "sha1-gVyZ6oT2gJUp0vRXkb34JxE1LWY=", + "integrity": "sha512-UZK3NBx2Mca+b5LsG7bY183pHWt5Y1xts4P3Pz7ENTwGVnJOUWbRb3ocjvX7hx9tq/yTAdclXm9sZ38gNuem4A==", "dev": true }, "cli-cursor": { @@ -638,7 +638,7 @@ "color-convert": { "version": "1.9.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.1.tgz", - "integrity": "sha1-wSYRB66y8pTr/+ye2eytUppgl+0=", + "integrity": "sha512-mjGanIiwQJskCC18rPR6OmrZ6fm2Lc7PeGFYwCmy5J34wC6F1PzdGL6xeMfmgicfYcNLGuVFA3WzXtIDCQSZxQ==", "dev": true, "requires": { "color-name": "1.1.3" @@ -1427,7 +1427,7 @@ "boom": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/boom/-/boom-5.2.0.tgz", - "integrity": "sha1-XdnabuOl8wIHdDYpDLcX0/SlTgI=", + "integrity": "sha512-Z5BTk6ZRe4tXXQlkqftmsAUANpXmuwlsF5Oov8ThoMbQRzdGTA1ngYRW160GexgOgjsFOKJz0LYhoNi+2AMBUw==", "dev": true, "requires": { "hoek": "4.2.1" @@ -1471,7 +1471,7 @@ "debug": { "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha1-XRKFFd8TT/Mn6QpMk/Tgd6U2NB8=", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", "dev": true, "requires": { "ms": "2.0.0" @@ -1585,7 +1585,7 @@ "doctrine": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", - "integrity": "sha1-XNAfwQFiG0LEzX9dGmYkNxbT850=", + "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", "dev": true, "requires": { "esutils": "2.0.2" @@ -1662,7 +1662,7 @@ "es6-promise": { "version": "4.2.4", "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.4.tgz", - "integrity": "sha1-3EIhwrFlGHYL2MOaUtjzVvwA7Sk=", + "integrity": "sha512-/NdNZVJg+uZgtm9eS3O6lrOLYmQag2DjdEXuPaHlZ6RuVqgqaVZfgYCepEIKsLqwdQArOPtC3XzRLqGGfT8KQQ==", "dev": true }, "escape-string-regexp": { @@ -1788,7 +1788,7 @@ "espree": { "version": "3.5.4", "resolved": "https://registry.npmjs.org/espree/-/espree-3.5.4.tgz", - "integrity": "sha1-sPRHGHyKi+2US4FaZgvd9d610ac=", + "integrity": "sha512-yAcIQxtmMiB/jL32dzEp2enBeidsB7xWPLNiw3IIkpVds1P+h7qF9YwJq1yUNzp2OKXgAprs4F61ih66UsoD1A==", "dev": true, "requires": { "acorn": "5.5.0", @@ -1798,7 +1798,7 @@ "esprima": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.0.tgz", - "integrity": "sha1-RJnt3NERDgshi6zy+n9/WfVcqAQ=", + "integrity": "sha512-oftTcaMu/EGrEIu904mWteKIv8vMuOgGYo7EhVJJN00R/EED9DCua/xxHRdYnKtcECzVg7xOWhflvJMnqcFZjw==", "dev": true }, "esquery": { @@ -1813,7 +1813,7 @@ "esrecurse": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.2.1.tgz", - "integrity": "sha1-AHo7n9vCs7uH5IeeoZyS/b05Qs8=", + "integrity": "sha512-64RBB++fIOAXPw3P9cy89qfMlvZEXZkqqJkjqqXIvzP5ezRZjW+lPWjw35UX/3EhUPFYbg5ER4JYgDw4007/DQ==", "dev": true, "requires": { "estraverse": "4.2.0" @@ -2024,7 +2024,7 @@ "find-root": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/find-root/-/find-root-1.1.0.tgz", - "integrity": "sha1-q8/Iunb3CMQql7PWhbfpRQv7nOQ=", + "integrity": "sha512-NKfW6bec6GfKc0SGx1e07QZY9PE99u0Bft/0rzSD5k3sO/vwkVUpDUKVm5Gpp5Ue3YfShPFTX2070tDs5kB9Ng==", "dev": true }, "find-up": { @@ -2103,7 +2103,7 @@ "supports-color": { "version": "5.3.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.3.0.tgz", - "integrity": "sha1-WySsFduA+pJ89SJ6SjP9PEx2dsA=", + "integrity": "sha512-0aP01LLIskjKs3lq52EC0aGBAJhLq7B2Rd8HC/DR/PtNNpcLilNmHC12O+hu0usQpo7wtHNRqtrhBwtDb0+dNg==", "dev": true, "requires": { "has-flag": "3.0.0" @@ -2567,7 +2567,7 @@ "glob": { "version": "7.1.2", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", - "integrity": "sha1-wZyd+aAocC1nhhI4SmVSQExjbRU=", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", "dev": true, "requires": { "fs.realpath": "1.0.0", @@ -2672,7 +2672,7 @@ "growl": { "version": "1.10.3", "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.3.tgz", - "integrity": "sha1-GSa6kM8+3+KttJJ/WIC8IsZseQ8=", + "integrity": "sha512-hKlsbA5Vu3xsh1Cg3J7jSmX/WaW6A5oBeqzM88oNbCRQFz+zUaXm6yxS4RVytp1scBoJzSYl4YAEOQIt6O8V1Q==", "dev": true }, "handlebars": { @@ -2738,7 +2738,7 @@ "hawk": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/hawk/-/hawk-6.0.2.tgz", - "integrity": "sha1-r02RTrBl+bXOTZ0RwcshJu7MMDg=", + "integrity": "sha512-miowhl2+U7Qle4vdLqDdPt9m09K6yZhkLDTWGoUiUzrQCn+mHHSmfJgAyGaLRZbPmTqfFFjRV1QWCW0VWUJBbQ==", "dev": true, "requires": { "boom": "4.3.1", @@ -2756,7 +2756,7 @@ "hoek": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/hoek/-/hoek-4.2.1.tgz", - "integrity": "sha1-ljRQKqEsRF3Vp8VzS1cruHOKrLs=", + "integrity": "sha512-QLg82fGkfnJ/4iy1xZ81/9SIJiq1NGFUMGs6ParyjBZr6jW2Ufj/snDqTHixNlHdPNwN2RLVD0Pi3igeK9+JfA==", "dev": true }, "home-path": { @@ -2791,7 +2791,7 @@ "ignore": { "version": "3.3.7", "resolved": "https://registry.npmjs.org/ignore/-/ignore-3.3.7.tgz", - "integrity": "sha1-YSKJv7PCIOGGpYEYYY1b6MG6sCE=", + "integrity": "sha512-YGG3ejvBNHRqu0559EOxxNFihD0AjpvHlC/pdGKd3X3ofe+CoJkYazwNJYTNebqpPKN+VVQbh4ZFn1DivMNuHA==", "dev": true }, "imurmurhash": { @@ -2828,7 +2828,7 @@ "ini": { "version": "1.3.5", "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", - "integrity": "sha1-7uJfVtscnsYIXgwid4CD9Zar+Sc=", + "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==", "dev": true }, "inquirer": { @@ -2901,7 +2901,7 @@ "is-buffer": { "version": "1.1.6", "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", - "integrity": "sha1-76ouqdqg16suoTqXsritUf776L4=", + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", "dev": true }, "is-builtin-module": { @@ -3054,7 +3054,7 @@ "is-resolvable": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/is-resolvable/-/is-resolvable-1.1.0.tgz", - "integrity": "sha1-+xj4fOH+uSUWnJpAfBkxijIG7Yg=", + "integrity": "sha512-qgDYXFSR5WvEfuS5dMj6oTMEbrrSaM0CrFk2Yiq/gXnBvD9pMa2jGXxyhGLfvhZpuMZe18CJpFxAt3CRs42NMg==", "dev": true }, "is-retry-allowed": { @@ -3204,7 +3204,7 @@ "js-yaml": { "version": "3.11.0", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.11.0.tgz", - "integrity": "sha1-WXwai9VxUvJtYizkEXhRpR9euu8=", + "integrity": "sha512-saJstZWv7oNeOyBh3+Dx1qWzhW0+e6/8eDzo7p5rDFqxntSztloLtuKu+Ejhtq82jsilwOIZYsCz+lIjthg1Hw==", "dev": true, "requires": { "argparse": "1.0.10", @@ -3324,7 +3324,7 @@ "just-extend": { "version": "1.1.27", "resolved": "https://registry.npmjs.org/just-extend/-/just-extend-1.1.27.tgz", - "integrity": "sha1-7G55QQ/5FORyZSq/oOYDwD1g6QU=", + "integrity": "sha512-mJVp13Ix6gFo3SBAy9U/kL+oeZqzlYYYLQBwXVBlVzIsZwBqGREnOro24oC/8s8aox+rJhtZ2DiQof++IrkA+g==", "dev": true }, "kind-of": { @@ -3703,7 +3703,7 @@ "lodash": { "version": "4.17.5", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.5.tgz", - "integrity": "sha1-maktZcAnLevoyWtgV7yPv6O+1RE=", + "integrity": "sha512-svL3uiZf1RwhH+cWrfZn3A4+U58wbP0tGVTLQPbjplZxZ8ROD9VLuNgsRniTlLe7OlSqR79RUehXgpBW/s0IQw==", "dev": true }, "lodash._reinterpolate": { @@ -3740,7 +3740,7 @@ "lolex": { "version": "2.3.2", "resolved": "https://registry.npmjs.org/lolex/-/lolex-2.3.2.tgz", - "integrity": "sha1-hflFBCUQO/nnpgZo6iXcQydMqAc=", + "integrity": "sha512-A5pN2tkFj7H0dGIAM6MFvHKMJcPnjZsOMvR7ujCjfgW5TbV6H9vb1PgxLtHvjqNZTHsUolz+6/WEO0N1xNx2ng==", "dev": true }, "longest": { @@ -3816,7 +3816,7 @@ "marked": { "version": "0.3.17", "resolved": "https://registry.npmjs.org/marked/-/marked-0.3.17.tgz", - "integrity": "sha1-YH8GZos8axJGso8T2nYRasGqLSs=", + "integrity": "sha512-+AKbNsjZl6jFfLPwHhWmGTqE009wTKn3RTmn9K8oUKHrX/abPJjtcRtXpYB/FFrwPJRUA86LX/de3T0knkPCmQ==", "dev": true }, "mem": { @@ -3896,13 +3896,13 @@ "mime-db": { "version": "1.33.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.33.0.tgz", - "integrity": "sha1-o0kgUKXLm2NFBUHjnZeI0icng9s=", + "integrity": "sha512-BHJ/EKruNIqJf/QahvxwQZXKygOQ256myeN/Ew+THcAa5q+PjyTTMMeNQC4DZw5AwfvelsUrA6B67NKMqXDbzQ==", "dev": true }, "mime-types": { "version": "2.1.18", "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.18.tgz", - "integrity": "sha1-bzI/YKg9ERRvgx/xH9ZuL+VQO7g=", + "integrity": "sha512-lc/aahn+t4/SWV/qcmumYjymLsWfN3ELhpmVuUFjgsORruuZPVSwAQryq+HHGvO/SI2KVX26bx+En+zhM8g8hQ==", "dev": true, "requires": { "mime-db": "1.33.0" @@ -3917,7 +3917,7 @@ "minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha1-UWbihkV/AzBgZL5Ul+jbsMPTIIM=", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "dev": true, "requires": { "brace-expansion": "1.1.11" @@ -4071,7 +4071,7 @@ "normalize-package-data": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.4.0.tgz", - "integrity": "sha1-EvlaMH1YNSB1oEkHuErIvpisAS8=", + "integrity": "sha512-9jjUFbTPfEy3R/ad/2oNbKtW9Hgovl5O1FvFWKkKblNXoN/Oou6+9+KKohPK13Yc3/TyunyWhJp6gvRNR/PPAw==", "dev": true, "requires": { "hosted-git-info": "2.5.0", @@ -4511,7 +4511,7 @@ "process-nextick-args": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", - "integrity": "sha1-o31zL0JxtKsa0HDTVQjoKQeI/6o=", + "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==", "dev": true }, "progress": { @@ -4584,7 +4584,7 @@ "qs": { "version": "6.5.1", "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.1.tgz", - "integrity": "sha1-NJzfbu+J7EXBLX1es/wMhwNDptg=", + "integrity": "sha512-eRzhrN1WSINYCDCbrz796z37LOe3m5tmW7RQf6oBntukAG1nmovJvhnwHHRMAfeoItc1m2Hk02WER2aQ/iqs+A==", "dev": true }, "quick-lru": { @@ -4596,7 +4596,7 @@ "randomatic": { "version": "1.1.7", "resolved": "https://registry.npmjs.org/randomatic/-/randomatic-1.1.7.tgz", - "integrity": "sha1-x6vpzIuHwLqodrGf3oP9RkeX44w=", + "integrity": "sha512-D5JUjPyJbaJDkuAazpVnSfVkLlpeO3wDlPROTMLGKG1zMFNFRgrciKo1ltz/AzNTkqE0HzDx655QOL51N06how==", "dev": true, "requires": { "is-number": "3.0.0", @@ -4701,7 +4701,7 @@ "regex-cache": { "version": "0.4.4", "resolved": "https://registry.npmjs.org/regex-cache/-/regex-cache-0.4.4.tgz", - "integrity": "sha1-db3FiioUls7EihKDW8VMjVYjNt0=", + "integrity": "sha512-nVIZwtCjkC9YgvWkpM55B5rBhBYRZhAaJbgcFYXXsHnbZ9UZI9nnVWYZpBlCqv9ho2eZryPnWrZGsOdPwVWXWQ==", "dev": true, "requires": { "is-equal-shallow": "0.1.3" @@ -4729,7 +4729,7 @@ "remap-istanbul": { "version": "0.10.1", "resolved": "https://registry.npmjs.org/remap-istanbul/-/remap-istanbul-0.10.1.tgz", - "integrity": "sha1-OqWN1QIdSZ8zbTulvzu7kcG4jjc=", + "integrity": "sha512-gsNQXs5kJLhErICSyYhzVZ++C8LBW8dgwr874Y2QvzAUS75zBlD/juZgXs39nbYJ09fZDlX2AVLVJAY2jbFJoQ==", "dev": true, "requires": { "amdefine": "1.0.1", @@ -4769,7 +4769,7 @@ "source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha1-dHIq8y6WFOnCh6jQu95IteLxomM=", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", "dev": true }, "through2": { @@ -4883,7 +4883,7 @@ "resolve": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.5.0.tgz", - "integrity": "sha1-HwmsznlsmnYlefMbLBzEw83fnzY=", + "integrity": "sha512-hgoSGrc3pjzAPHNBg+KnFcK2HwlHTs/YrAGUr6qgTVUZmXv1UEXXl0bZNBKMA9fud6lRYFdPGz0xXxycPzmmiw==", "dev": true, "requires": { "path-parse": "1.0.5" @@ -4924,7 +4924,7 @@ "rimraf": { "version": "2.6.2", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", - "integrity": "sha1-LtgVDSShbqhlHm1u8PR8QVjOejY=", + "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", "dev": true, "requires": { "glob": "7.1.2" @@ -5063,19 +5063,19 @@ "safe-buffer": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", - "integrity": "sha1-iTMSr2myEj3vcfV4iQAWce6yyFM=", + "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", "dev": true }, "samsam": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/samsam/-/samsam-1.3.0.tgz", - "integrity": "sha1-jR2TUOJWItow3j5EumkrUiGrfFA=", + "integrity": "sha512-1HwIYD/8UlOtFS3QO3w7ey+SdSDFE4HRNLZoZRYVQefrOY3l17epswImeB1ijgJFQJodIaHcwkp3r/myBjFVbg==", "dev": true }, "semver": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz", - "integrity": "sha1-3Eu8emyp2Rbe5dQ1FvAJK1j3uKs=", + "integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==", "dev": true }, "set-blocking": { @@ -5117,7 +5117,7 @@ "sinon-chai": { "version": "2.14.0", "resolved": "https://registry.npmjs.org/sinon-chai/-/sinon-chai-2.14.0.tgz", - "integrity": "sha1-2n3UzIPNaiYLZ8yg96n9riahIF0=", + "integrity": "sha512-9stIF1utB0ywNHNT7RgiXbdmen8QDCRsrTjw+G9TgKt1Yexjiv8TOWZ6WHsTPz57Yky3DIswZvEqX8fpuHNDtQ==", "dev": true }, "slash": { @@ -5146,7 +5146,7 @@ "sntp": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/sntp/-/sntp-2.1.0.tgz", - "integrity": "sha1-LGzsFP7cIiJznK+bXD2F0cxaLMg=", + "integrity": "sha512-FL1b58BDrqS3A11lJ0zEdnJ3UOKqVxawAkF3k7F0CVN7VQ34aZrV+G8BZ1WC9ZL7NyrwsW0oviwsWDgRuVYtJg==", "dev": true, "requires": { "hoek": "4.2.1" @@ -5203,7 +5203,7 @@ "spdx-correct": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.0.0.tgz", - "integrity": "sha1-BaW01xU6GVvJLDxCW2nzsqlSTII=", + "integrity": "sha512-N19o9z5cEyc8yQQPukRCZ9EUmb4HUpnrmaL/fxS2pBo2jbfcFRVuFZ/oFC+vZz0MNNk0h80iMn5/S6qGZOL5+g==", "dev": true, "requires": { "spdx-expression-parse": "3.0.0", @@ -5213,13 +5213,13 @@ "spdx-exceptions": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.1.0.tgz", - "integrity": "sha1-LHrmEFbHFKW5ubKyr30xHvXHj+k=", + "integrity": "sha512-4K1NsmrlCU1JJgUrtgEeTVyfx8VaYea9J9LvARxhbHtVtohPs/gFGG5yy49beySjlIMhhXZ4QqujIZEfS4l6Cg==", "dev": true }, "spdx-expression-parse": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.0.tgz", - "integrity": "sha1-meEZt6XaAOBUkcn6M4t5BII7QdA=", + "integrity": "sha512-Yg6D3XpRD4kkOmTpdgbUiEJFKghJH03fiC1OPll5h/0sO6neh2jqRDVHOQ4o/LMea0tgCkbMgea5ip/e+MkWyg==", "dev": true, "requires": { "spdx-exceptions": "2.1.0", @@ -5229,7 +5229,7 @@ "spdx-license-ids": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.0.tgz", - "integrity": "sha1-enzShHDMbToc/m1miG9rxDDTrIc=", + "integrity": "sha512-2+EPwgbnmOIl8HjGBXXMd9NAu02vLjOO1nWw4kmeRDFyHn+M/ETfHxQUK0oXg8ctgVnl9t3rosNVsZ1jG61nDA==", "dev": true }, "speedometer": { @@ -5566,7 +5566,7 @@ "tough-cookie": { "version": "2.3.4", "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.4.tgz", - "integrity": "sha1-7GDO44rGdQY//JelwYlwV47oNlU=", + "integrity": "sha512-TZ6TTfI5NtZnuyy/Kecv+CnoROnyXn2DN97LontgQpCwsX2XyLYCC0ENhYkehSOwAp8rTQKc/NUIF7BkQ5rKLA==", "dev": true, "requires": { "punycode": "1.4.1" @@ -5708,13 +5708,13 @@ "uuid": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.2.1.tgz", - "integrity": "sha1-EsUou51Y0LkmXZovbw/ovhf/HxQ=", + "integrity": "sha512-jZnMwlb9Iku/O3smGWvZhauCf6cvvpKi4BKRiliS3cxnI+Gz9j5MEpTz2UFuXiKPJocb7gnsLHwiS05ige5BEA==", "dev": true }, "validate-npm-package-license": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.3.tgz", - "integrity": "sha1-gWQ7y+8b3+zUYjeT3EZIlIupgzg=", + "integrity": "sha512-63ZOUnL4SIXj4L0NixR3L1lcjO38crAbgrTpl28t8jjrfuiOBL5Iygm+60qPs/KsZGzPNg6Smnc/oY16QTjF0g==", "dev": true, "requires": { "spdx-correct": "3.0.0", @@ -5750,7 +5750,7 @@ "which": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/which/-/which-1.3.0.tgz", - "integrity": "sha1-/wS9/AEO5UfXgL7DjhrBwnd9JTo=", + "integrity": "sha512-xcJpopdamTuY5duC/KnTTNBraPK54YwpenP4lzxU8H91GudWpFv38u0CKjclE1Wi2EH2EDz5LRcHcKbCIzqGyg==", "dev": true, "requires": { "isexe": "2.0.0" diff --git a/packages/canvas/canvas-mesh/package.json b/packages/canvas/canvas-mesh/package.json index 691cd2c..6744a17 100644 --- a/packages/canvas/canvas-mesh/package.json +++ b/packages/canvas/canvas-mesh/package.json @@ -24,6 +24,7 @@ "dependencies": { "@pixi/constants": "^5.0.0-alpha.2", "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/mesh-extras": "^5.0.0-alpha.2", "@pixi/settings": "^5.0.0-alpha.2" }, "devDependencies": { diff --git a/packages/canvas/canvas-mesh/src/Mesh.js b/packages/canvas/canvas-mesh/src/Mesh.js index 900a872..c43a74b 100644 --- a/packages/canvas/canvas-mesh/src/Mesh.js +++ b/packages/canvas/canvas-mesh/src/Mesh.js @@ -1,36 +1,14 @@ import { Mesh } from '@pixi/mesh'; -import { settings } from './settings'; - -// IMPORTANT: Please do NOT use this as a precedent to use `settings` after the object is created -// this was merely created to completely decouple canvas from the base Mesh class and we are -// unable to add `canvasPadding` in the constructor anymore, as the case was for PixiJS v4. /** - * Internal variable for `canvasPadding`. + * Renders the object using the Canvas renderer * * @private - * @memberof PIXI.Mesh - * @member {number} - * @default null - */ -Mesh.prototype._canvasPadding = null; - -/** - * Triangles in canvas mode are automatically antialiased, use this value to force triangles - * to overlap a bit with each other. To set the global default, set {@link PIXI.settings.MESH_CANVAS_PADDING} - * - * @see PIXI.settings.MESH_CANVAS_PADDING - * @member {number} canvasPadding + * @method _renderCanvas * @memberof PIXI.Mesh# - * @default 0 + * @param {PIXI.CanvasRenderer} renderer - The canvas renderer. */ -Object.defineProperty(Mesh.prototype, 'canvasPadding', { - get() - { - return this._canvasPadding !== null ? this._canvasPadding : settings.MESH_CANVAS_PADDING; - }, - set(value) - { - this._canvasPadding = value; - }, -}); +Mesh.prototype._renderCanvas = function _renderCanvas(renderer) +{ + renderer.plugins[this.pluginName].render(this); +}; diff --git a/packages/canvas/canvas-mesh/src/Mesh2d.js b/packages/canvas/canvas-mesh/src/Mesh2d.js new file mode 100644 index 0000000..d0bd80f --- /dev/null +++ b/packages/canvas/canvas-mesh/src/Mesh2d.js @@ -0,0 +1,36 @@ +import { Mesh2d } from '@pixi/mesh-extras'; +import { settings } from './settings'; + +// IMPORTANT: Please do NOT use this as a precedent to use `settings` after the object is created +// this was merely created to completely decouple canvas from the base Mesh class and we are +// unable to add `canvasPadding` in the constructor anymore, as the case was for PixiJS v4. + +/** + * Internal variable for `canvasPadding`. + * + * @private + * @memberof PIXI.Mesh2d + * @member {number} + * @default null + */ +Mesh2d.prototype._canvasPadding = null; + +/** + * Triangles in canvas mode are automatically antialiased, use this value to force triangles + * to overlap a bit with each other. To set the global default, set {@link PIXI.settings.MESH_CANVAS_PADDING} + * + * @see PIXI.settings.MESH_CANVAS_PADDING + * @member {number} canvasPadding + * @memberof PIXI.Mesh2d# + * @default 0 + */ +Object.defineProperty(Mesh2d.prototype, 'canvasPadding', { + get() + { + return this._canvasPadding !== null ? this._canvasPadding : settings.MESH_CANVAS_PADDING; + }, + set(value) + { + this._canvasPadding = value; + }, +}); diff --git a/packages/canvas/canvas-mesh/src/NineSlicePlane.js b/packages/canvas/canvas-mesh/src/NineSlicePlane.js index 09eaf9c..2fd5acc 100644 --- a/packages/canvas/canvas-mesh/src/NineSlicePlane.js +++ b/packages/canvas/canvas-mesh/src/NineSlicePlane.js @@ -1,4 +1,4 @@ -import { NineSlicePlane } from '@pixi/mesh'; +import { NineSlicePlane } from '@pixi/mesh-extras'; /** * Renders the object using the Canvas renderer diff --git a/packages/canvas/canvas-mesh/src/RawMesh.js b/packages/canvas/canvas-mesh/src/RawMesh.js deleted file mode 100644 index bf40184..0000000 --- a/packages/canvas/canvas-mesh/src/RawMesh.js +++ /dev/null @@ -1,14 +0,0 @@ -import { RawMesh } from '@pixi/mesh'; - -/** - * Renders the object using the Canvas renderer - * - * @private - * @method _renderCanvas - * @memberof PIXI.RawMesh# - * @param {PIXI.CanvasRenderer} renderer - The canvas renderer. - */ -RawMesh.prototype._renderCanvas = function _renderCanvas(renderer) -{ - renderer.plugins[this.pluginName].render(this); -}; diff --git a/packages/canvas/canvas-mesh/src/index.js b/packages/canvas/canvas-mesh/src/index.js index 2295016..f4fa31d 100644 --- a/packages/canvas/canvas-mesh/src/index.js +++ b/packages/canvas/canvas-mesh/src/index.js @@ -1,6 +1,6 @@ export { default as CanvasMeshRenderer } from './CanvasMeshRenderer'; import './settings'; -import './Mesh'; +import './Mesh2d'; import './NineSlicePlane'; -import './RawMesh'; +import './Mesh'; diff --git a/packages/canvas/canvas-mesh/src/settings.js b/packages/canvas/canvas-mesh/src/settings.js index 4cefb4c..e81b8e0 100644 --- a/packages/canvas/canvas-mesh/src/settings.js +++ b/packages/canvas/canvas-mesh/src/settings.js @@ -3,7 +3,7 @@ /** * Default `canvasPadding` for canvas-based Mesh rendering. * - * @see PIXI.Mesh#canvasPadding + * @see PIXI.Mesh2d#canvasPadding * @static * @constant * @memberof PIXI.settings diff --git a/packages/mesh-extras/LICENSE b/packages/mesh-extras/LICENSE new file mode 100644 index 0000000..148e3eb --- /dev/null +++ b/packages/mesh-extras/LICENSE @@ -0,0 +1,21 @@ +The MIT License + +Copyright (c) 2013-2018 Mathew Groves, Chad Engler + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/packages/mesh-extras/README.md b/packages/mesh-extras/README.md new file mode 100644 index 0000000..1d9b0e1 --- /dev/null +++ b/packages/mesh-extras/README.md @@ -0,0 +1,19 @@ +# @pixi/mesh-extras + +## Installation + +```bash +npm install @pixi/mesh-extras +``` + +## Usage + +```js +import { MeshRenderer } from '@pixi/mesh'; +import { Renderer } from '@pixi/core'; +import { Rope } from '@pixi/mesh-extras'; + +Renderer.registerPlugin('mesh', MeshRenderer); + +const rope = new Rope(); +``` \ No newline at end of file diff --git a/packages/mesh-extras/package.json b/packages/mesh-extras/package.json new file mode 100644 index 0000000..d134f64 --- /dev/null +++ b/packages/mesh-extras/package.json @@ -0,0 +1,38 @@ +{ + "name": "@pixi/mesh-extras", + "version": "5.0.0-alpha.2", + "main": "lib/mesh-extras.js", + "module": "lib/mesh-extras.es.js", + "description": "Custom Mesh display objects, like Rope and Plane", + "author": "Mat Groves", + "contributors": [ + "Matt Karl " + ], + "homepage": "http://pixijs.com/", + "bugs": "https://github.com/pixijs/pixi.js/issues", + "license": "MIT", + "repository": { + "type": "git", + "url": "https://github.com/pixijs/pixi.js.git" + }, + "publishConfig": { + "access": "public" + }, + "scripts": { + "test": "floss --path test" + }, + "files": [ + "lib" + ], + "dependencies": { + "@pixi/constants": "^5.0.0-alpha.2", + "@pixi/core": "^5.0.0-alpha.2", + "@pixi/math": "^5.0.0-alpha.2", + "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/utils": "^5.0.0-alpha.2" + }, + "devDependencies": { + "@pixi/loaders": "^5.0.0-alpha.2", + "floss": "^2.1.3" + } +} diff --git a/packages/mesh-extras/src/Mesh2d.js b/packages/mesh-extras/src/Mesh2d.js new file mode 100644 index 0000000..d113a5e --- /dev/null +++ b/packages/mesh-extras/src/Mesh2d.js @@ -0,0 +1,263 @@ +import { Mesh } from '@pixi/mesh'; +import { Geometry, Program, Shader, Texture, TextureMatrix } from '@pixi/core'; +import { Matrix } from '@pixi/math'; +import { BLEND_MODES } from '@pixi/constants'; +import { hex2rgb, premultiplyRgba } from '@pixi/utils'; +import vertex from './mesh.vert'; +import fragment from './mesh.frag'; + +let meshProgram; + +/** + * Base mesh class + * @class + * @extends PIXI.Container + * @memberof PIXI + */ +export default class Mesh2d extends Mesh +{ + /** + * @param {PIXI.Texture} [texture=Texture.EMPTY] - The texture to use + * @param {Float32Array} [vertices] - if you want to specify the vertices + * @param {Float32Array} [uvs] - if you want to specify the uvs + * @param {Uint16Array} [indices] - if you want to specify the indices + * @param {number} [drawMode] - the drawMode, can be any of the Mesh.DRAW_MODES consts + */ + constructor(texture = Texture.EMPTY, vertices, uvs, indices, drawMode) + { + const geometry = new Geometry(); + + if (!meshProgram) + { + meshProgram = new Program(vertex, fragment); + } + + geometry.addAttribute('aVertexPosition', vertices) + .addAttribute('aTextureCoord', uvs) + .addIndex(indices); + + geometry.getAttribute('aVertexPosition').static = false; + + const uniforms = { + uSampler: texture, + uTextureMatrix: Matrix.IDENTITY, + alpha: 1, + uColor: new Float32Array([1, 1, 1, 1]), + }; + + super(geometry, new Shader(meshProgram, uniforms), null, drawMode); + + /** + * The Uvs of the Mesh + * + * @member {Float32Array} + */ + this.uvs = geometry.getAttribute('aTextureCoord').data; + + /** + * An array of vertices + * + * @member {Float32Array} + */ + this.vertices = geometry.getAttribute('aVertexPosition').data; + + this.uniforms = uniforms; + + /** + * The texture of the Mesh + * + * @member {PIXI.Texture} + * @default PIXI.Texture.EMPTY + * @private + */ + this.texture = texture; + + /** + * The tint applied to the mesh. This is a [r,g,b] value. A value of [1,1,1] will remove any + * tint effect. + * + * @member {number} + * @private + */ + this._tintRGB = new Float32Array([1, 1, 1]); + + // Set default tint + this.tint = 0xFFFFFF; + + this.blendMode = BLEND_MODES.NORMAL; + + /** + * TextureMatrix instance for this Mesh, used to track Texture changes + * + * @member {PIXI.TextureMatrix} + * @readonly + */ + this.uvMatrix = new TextureMatrix(this._texture); + + /** + * whether or not upload uvMatrix to shader + * if its false, then uvs should be pre-multiplied + * if you change it for generated mesh, please call 'refresh(true)' + * @member {boolean} + * @default false + */ + this.uploadUvMatrix = false; + + /** + * Uploads vertices buffer every frame, like in PixiJS V3 and V4. + * + * @member {boolean} + * @default true + */ + this.autoUpdate = true; + } + + /** + * The tint applied to the Rope. This is a hex value. A value of + * 0xFFFFFF will remove any tint effect. + * + * @member {number} + * @memberof PIXI.Sprite# + * @default 0xFFFFFF + */ + get tint() + { + return this._tint; + } + + /** + * Sets the tint of the rope. + * + * @param {number} value - The value to set to. + */ + set tint(value) + { + this._tint = value; + + hex2rgb(this._tint, this._tintRGB); + } + + /** + * The blend mode to be applied to the sprite. Set to `PIXI.BLEND_MODES.NORMAL` to remove any blend mode. + * + * @member {number} + * @default PIXI.BLEND_MODES.NORMAL + * @see PIXI.BLEND_MODES + */ + get blendMode() + { + return this.state.blendMode; + } + + set blendMode(value) // eslint-disable-line require-jsdoc + { + this.state.blendMode = value; + } + + /** + * The texture that the mesh uses. + * + * @member {PIXI.Texture} + */ + get texture() + { + return this._texture; + } + + set texture(value) // eslint-disable-line require-jsdoc + { + if (this._texture === value) + { + return; + } + + this._texture = value; + this.uniforms.uSampler = this.texture; + + if (value) + { + // wait for the texture to load + if (value.baseTexture.valid) + { + this._onTextureUpdate(); + } + else + { + value.once('update', this._onTextureUpdate, this); + } + } + } + + _render(renderer) + { + const baseTex = this._texture.baseTexture; + + premultiplyRgba(this._tintRGB, this.worldAlpha, this.uniforms.uColor, baseTex.premultiplyAlpha); + super._render(renderer); + } + /** + * When the texture is updated, this event will fire to update the scale and frame + * + * @private + */ + _onTextureUpdate() + { + // constructor texture update stop + if (!this.uvMatrix) + { + return; + } + this.uvMatrix.texture = this._texture; + this.refresh(); + } + + /** + * multiplies uvs only if uploadUvMatrix is false + * call it after you change uvs manually + * make sure that texture is valid + */ + multiplyUvs() + { + if (!this.uploadUvMatrix) + { + this.uvMatrix.multiplyUvs(this.uvs); + } + } + + /** + * Refreshes uvs for generated meshes (rope, plane) + * sometimes refreshes vertices too + * + * @param {boolean} [forceUpdate=false] if true, matrices will be updated any case + */ + refresh(forceUpdate) + { + if (this.uvMatrix.update(forceUpdate)) + { + this._refresh(); + } + } + + /** + * Updates the object transform for rendering + * + * @private + */ + updateTransform() + { + if (this.autoUpdate) + { + this.geometry.buffers[0].update(); + } + this.containerUpdateTransform(); + } + + /** + * re-calculates mesh coords + * @private + */ + _refresh() + { + /* empty */ + } +} diff --git a/packages/mesh-extras/src/NineSlicePlane.js b/packages/mesh-extras/src/NineSlicePlane.js new file mode 100644 index 0000000..0bae92c --- /dev/null +++ b/packages/mesh-extras/src/NineSlicePlane.js @@ -0,0 +1,270 @@ +import Plane from './Plane'; + +const DEFAULT_BORDER_SIZE = 10; + +/** + * The NineSlicePlane allows you to stretch a texture using 9-slice scaling. The corners will remain unscaled (useful + * for buttons with rounded corners for example) and the other areas will be scaled horizontally and or vertically + * + *```js + * let Plane9 = new PIXI.NineSlicePlane(PIXI.Texture.from('BoxWithRoundedCorners.png'), 15, 15, 15, 15); + * ``` + *
+ *      A                          B
+ *    +---+----------------------+---+
+ *  C | 1 |          2           | 3 |
+ *    +---+----------------------+---+
+ *    |   |                      |   |
+ *    | 4 |          5           | 6 |
+ *    |   |                      |   |
+ *    +---+----------------------+---+
+ *  D | 7 |          8           | 9 |
+ *    +---+----------------------+---+
+
+ *  When changing this objects width and/or height:
+ *     areas 1 3 7 and 9 will remain unscaled.
+ *     areas 2 and 8 will be stretched horizontally
+ *     areas 4 and 6 will be stretched vertically
+ *     area 5 will be stretched both horizontally and vertically
+ * 
+ * + * @class + * @extends PIXI.Plane + * @memberof PIXI + * + */ +export default class NineSlicePlane extends Plane +{ + /** + * @param {PIXI.Texture} texture - The texture to use on the NineSlicePlane. + * @param {int} [leftWidth=10] size of the left vertical bar (A) + * @param {int} [topHeight=10] size of the top horizontal bar (C) + * @param {int} [rightWidth=10] size of the right vertical bar (B) + * @param {int} [bottomHeight=10] size of the bottom horizontal bar (D) + */ + constructor(texture, leftWidth, topHeight, rightWidth, bottomHeight) + { + super(texture, 4, 4); + + this._origWidth = texture.orig.width; + this._origHeight = texture.orig.height; + + /** + * The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._width = this._origWidth; + + /** + * The height of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._height = this._origHeight; + + /** + * The width of the left column (a) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._leftWidth = typeof leftWidth !== 'undefined' ? leftWidth : DEFAULT_BORDER_SIZE; + + /** + * The width of the right column (b) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._rightWidth = typeof rightWidth !== 'undefined' ? rightWidth : DEFAULT_BORDER_SIZE; + + /** + * The height of the top row (c) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._topHeight = typeof topHeight !== 'undefined' ? topHeight : DEFAULT_BORDER_SIZE; + + /** + * The height of the bottom row (d) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._bottomHeight = typeof bottomHeight !== 'undefined' ? bottomHeight : DEFAULT_BORDER_SIZE; + + this.refresh(true); + } + + /** + * Updates the horizontal vertices. + * + */ + updateHorizontalVertices() + { + const vertices = this.vertices; + + const h = this._topHeight + this._bottomHeight; + const scale = this._height > h ? 1.0 : this._height / h; + + vertices[9] = vertices[11] = vertices[13] = vertices[15] = this._topHeight * scale; + vertices[17] = vertices[19] = vertices[21] = vertices[23] = this._height - (this._bottomHeight * scale); + vertices[25] = vertices[27] = vertices[29] = vertices[31] = this._height; + } + + /** + * Updates the vertical vertices. + * + */ + updateVerticalVertices() + { + const vertices = this.vertices; + + const w = this._leftWidth + this._rightWidth; + const scale = this._width > w ? 1.0 : this._width / w; + + vertices[2] = vertices[10] = vertices[18] = vertices[26] = this._leftWidth * scale; + vertices[4] = vertices[12] = vertices[20] = vertices[28] = this._width - (this._rightWidth * scale); + vertices[6] = vertices[14] = vertices[22] = vertices[30] = this._width; + } + + /** + * The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + */ + get width() + { + return this._width; + } + + set width(value) // eslint-disable-line require-jsdoc + { + this._width = value; + this._refresh(); + } + + /** + * The height of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + */ + get height() + { + return this._height; + } + + set height(value) // eslint-disable-line require-jsdoc + { + this._height = value; + this._refresh(); + } + + /** + * The width of the left column + * + * @member {number} + */ + get leftWidth() + { + return this._leftWidth; + } + + set leftWidth(value) // eslint-disable-line require-jsdoc + { + this._leftWidth = value; + this._refresh(); + } + + /** + * The width of the right column + * + * @member {number} + */ + get rightWidth() + { + return this._rightWidth; + } + + set rightWidth(value) // eslint-disable-line require-jsdoc + { + this._rightWidth = value; + this._refresh(); + } + + /** + * The height of the top row + * + * @member {number} + */ + get topHeight() + { + return this._topHeight; + } + + set topHeight(value) // eslint-disable-line require-jsdoc + { + this._topHeight = value; + this._refresh(); + } + + /** + * The height of the bottom row + * + * @member {number} + */ + get bottomHeight() + { + return this._bottomHeight; + } + + set bottomHeight(value) // eslint-disable-line require-jsdoc + { + this._bottomHeight = value; + this._refresh(); + } + + /** + * Refreshes NineSlicePlane coords. All of them. + */ + _refresh() + { + super._refresh(); + + const uvs = this.uvs; + const texture = this._texture; + + this._origWidth = texture.orig.width; + this._origHeight = texture.orig.height; + + const _uvw = 1.0 / this._origWidth; + const _uvh = 1.0 / this._origHeight; + + uvs[0] = uvs[8] = uvs[16] = uvs[24] = 0; + uvs[1] = uvs[3] = uvs[5] = uvs[7] = 0; + uvs[6] = uvs[14] = uvs[22] = uvs[30] = 1; + uvs[25] = uvs[27] = uvs[29] = uvs[31] = 1; + + uvs[2] = uvs[10] = uvs[18] = uvs[26] = _uvw * this._leftWidth; + uvs[4] = uvs[12] = uvs[20] = uvs[28] = 1 - (_uvw * this._rightWidth); + uvs[9] = uvs[11] = uvs[13] = uvs[15] = _uvh * this._topHeight; + uvs[17] = uvs[19] = uvs[21] = uvs[23] = 1 - (_uvh * this._bottomHeight); + + this.updateHorizontalVertices(); + this.updateVerticalVertices(); + + this.geometry.buffers[1].update(); + + this.multiplyUvs(); + } +} diff --git a/packages/mesh-extras/src/Plane.js b/packages/mesh-extras/src/Plane.js new file mode 100644 index 0000000..1c240c4 --- /dev/null +++ b/packages/mesh-extras/src/Plane.js @@ -0,0 +1,100 @@ +import Mesh2d from './Mesh2d'; + +/** + * The Plane allows you to draw a texture across several points and them manipulate these points + * + *```js + * for (let i = 0; i < 20; i++) { + * points.push(new PIXI.Point(i * 50, 0)); + * }; + * let Plane = new PIXI.Plane(PIXI.Texture.from("snake.png"), points); + * ``` + * + * @class + * @extends PIXI.Mesh + * @memberof PIXI + * + */ +export default class Plane extends Mesh2d +{ + /** + * @param {PIXI.Texture} texture - The texture to use on the Plane. + * @param {number} verticesX - The number of vertices in the x-axis + * @param {number} verticesY - The number of vertices in the y-axis + * @param {object} [opts] - an options object - add meshWidth and meshHeight, temporary object for PixiJS v5 alpha + */ + constructor(texture, verticesX, verticesY, opts = {}) + { + super(texture, new Float32Array(1), new Float32Array(1), new Uint16Array(1), 4); + + this.verticesX = verticesX || 10; + this.verticesY = verticesY || 10; + + this.meshWidth = opts.meshWidth || 0; + this.meshHeight = opts.meshHeight || 0; + + this.refresh(); + } + + /** + * Refreshes plane coordinates + * @private + */ + _refresh() + { + const texture = this._texture; + const total = this.verticesX * this.verticesY; + const verts = []; + const uvs = []; + const indices = []; + + const segmentsX = this.verticesX - 1; + const segmentsY = this.verticesY - 1; + + const sizeX = (this.meshWidth || texture.width) / segmentsX; + const sizeY = (this.meshHeight || texture.height) / segmentsY; + + for (let i = 0; i < total; i++) + { + const x = (i % this.verticesX); + const y = ((i / this.verticesX) | 0); + + verts.push(x * sizeX, y * sizeY); + + uvs.push(x / segmentsX, y / segmentsY); + } + + // cons + + const totalSub = segmentsX * segmentsY; + + for (let i = 0; i < totalSub; i++) + { + const xpos = i % segmentsX; + const ypos = (i / segmentsX) | 0; + + const value = (ypos * this.verticesX) + xpos; + const value2 = (ypos * this.verticesX) + xpos + 1; + const value3 = ((ypos + 1) * this.verticesX) + xpos; + const value4 = ((ypos + 1) * this.verticesX) + xpos + 1; + + indices.push(value, value2, value3); + indices.push(value2, value4, value3); + } + + this.vertices = new Float32Array(verts); + this.uvs = new Float32Array(uvs); + this.indices = new Uint16Array(indices); + + this.geometry.buffers[0].data = this.vertices; + this.geometry.buffers[1].data = this.uvs; + this.geometry.indexBuffer.data = this.indices; + + // ensure that the changes are uploaded + this.geometry.buffers[0].update(); + this.geometry.buffers[1].update(); + this.geometry.indexBuffer.update(); + + this.multiplyUvs(); + } +} diff --git a/packages/mesh-extras/src/Rope.js b/packages/mesh-extras/src/Rope.js new file mode 100644 index 0000000..9cfde38 --- /dev/null +++ b/packages/mesh-extras/src/Rope.js @@ -0,0 +1,182 @@ +import Mesh2d from './Mesh2d'; + +/** + * The rope allows you to draw a texture across several points and them manipulate these points + * + *```js + * for (let i = 0; i < 20; i++) { + * points.push(new PIXI.Point(i * 50, 0)); + * }; + * let rope = new PIXI.Rope(PIXI.Texture.from("snake.png"), points); + * ``` + * + * @class + * @extends PIXI.Mesh + * @memberof PIXI + * + */ +export default class Rope extends Mesh2d +{ + /** + * @param {PIXI.Texture} texture - The texture to use on the rope. + * @param {PIXI.Point[]} points - An array of {@link PIXI.Point} objects to construct this rope. + */ + constructor(texture, points) + { + super(texture, new Float32Array(points.length * 4), + new Float32Array(points.length * 4), + new Uint16Array(points.length * 2), + 5); + + /* + * @member {PIXI.Point[]} An array of points that determine the rope + */ + this.points = points; + this.refresh(); + } + /** + * Refreshes Rope indices and uvs + * @private + */ + _refresh() + { + const points = this.points; + + if (!points) return; + + const vertexBuffer = this.geometry.getAttribute('aVertexPosition'); + const uvBuffer = this.geometry.getAttribute('aTextureCoord'); + const indexBuffer = this.geometry.getIndex(); + + // if too little points, or texture hasn't got UVs set yet just move on. + if (points.length < 1 || !this.texture._uvs) + { + return; + } + + // if the number of points has changed we will need to recreate the arraybuffers + if (vertexBuffer.data.length / 4 !== points.length) + { + vertexBuffer.data = new Float32Array(points.length * 4); + uvBuffer.data = new Float32Array(points.length * 4); + indexBuffer.data = new Uint16Array(points.length * 2); + } + + const uvs = uvBuffer.data; + const indices = indexBuffer.data; + + uvs[0] = 0; + uvs[1] = 0; + uvs[2] = 0; + uvs[3] = 1; + + indices[0] = 0; + indices[1] = 1; + + const total = points.length; + + for (let i = 1; i < total; i++) + { + // time to do some smart drawing! + let index = i * 4; + const amount = i / (total - 1); + + uvs[index] = amount; + uvs[index + 1] = 0; + + uvs[index + 2] = amount; + uvs[index + 3] = 1; + + index = i * 2; + indices[index] = index; + indices[index + 1] = index + 1; + } + + // ensure that the changes are uploaded + uvBuffer.update(); + indexBuffer.update(); + + this.multiplyUvs(); + this.refreshVertices(); + } + + /** + * refreshes vertices of Rope mesh + */ + refreshVertices() + { + const points = this.points; + + if (points.length < 1) + { + return; + } + + let lastPoint = points[0]; + let nextPoint; + let perpX = 0; + let perpY = 0; + + // this.count -= 0.2; + + const vertices = this.vertices; + const total = points.length; + + for (let i = 0; i < total; i++) + { + const point = points[i]; + const index = i * 4; + + if (i < points.length - 1) + { + nextPoint = points[i + 1]; + } + else + { + nextPoint = point; + } + + perpY = -(nextPoint.x - lastPoint.x); + perpX = nextPoint.y - lastPoint.y; + + let ratio = (1 - (i / (total - 1))) * 10; + + if (ratio > 1) + { + ratio = 1; + } + + const perpLength = Math.sqrt((perpX * perpX) + (perpY * perpY)); + const num = this._texture.height / 2; // (20 + Math.abs(Math.sin((i + this.count) * 0.3) * 50) )* ratio; + + perpX /= perpLength; + perpY /= perpLength; + + perpX *= num; + perpY *= num; + + vertices[index] = point.x + perpX; + vertices[index + 1] = point.y + perpY; + vertices[index + 2] = point.x - perpX; + vertices[index + 3] = point.y - perpY; + + lastPoint = point; + } + + this.geometry.buffers[0].update(); + } + + /** + * Updates the object transform for rendering + * + * @private + */ + updateTransform() + { + if (this.autoUpdate) + { + this.refreshVertices(); + } + this.containerUpdateTransform(); + } +} diff --git a/packages/mesh-extras/src/index.js b/packages/mesh-extras/src/index.js new file mode 100644 index 0000000..decf454 --- /dev/null +++ b/packages/mesh-extras/src/index.js @@ -0,0 +1,4 @@ +export { default as Mesh2d } from './Mesh2d'; +export { default as Plane } from './Plane'; +export { default as NineSlicePlane } from './NineSlicePlane'; +export { default as Rope } from './Rope'; diff --git a/packages/mesh-extras/src/mesh.frag b/packages/mesh-extras/src/mesh.frag new file mode 100644 index 0000000..6096983 --- /dev/null +++ b/packages/mesh-extras/src/mesh.frag @@ -0,0 +1,9 @@ +varying vec2 vTextureCoord; +uniform vec4 uColor; + +uniform sampler2D uSampler; + +void main(void) +{ + gl_FragColor = texture2D(uSampler, vTextureCoord) * uColor; +} diff --git a/packages/mesh-extras/src/mesh.vert b/packages/mesh-extras/src/mesh.vert new file mode 100644 index 0000000..0526df9 --- /dev/null +++ b/packages/mesh-extras/src/mesh.vert @@ -0,0 +1,15 @@ +attribute vec2 aVertexPosition; +attribute vec2 aTextureCoord; + +uniform mat3 projectionMatrix; +uniform mat3 translationMatrix; +uniform mat3 uTextureMatrix; + +varying vec2 vTextureCoord; + +void main(void) +{ + gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); + + vTextureCoord = (uTextureMatrix * vec3(aTextureCoord, 1.0)).xy; +} diff --git a/packages/mesh-extras/test/.eslintrc.json b/packages/mesh-extras/test/.eslintrc.json new file mode 100644 index 0000000..2ad8efb --- /dev/null +++ b/packages/mesh-extras/test/.eslintrc.json @@ -0,0 +1,12 @@ +{ + "globals": { + "expect": false, + "assert": false, + "sinon": false, + "PIXI": false + }, + "rules": { + "func-names": 0, + "no-unused-expressions": 0 + } +} \ No newline at end of file diff --git a/packages/mesh-extras/test/Plane.js b/packages/mesh-extras/test/Plane.js new file mode 100644 index 0000000..f9b1c25 --- /dev/null +++ b/packages/mesh-extras/test/Plane.js @@ -0,0 +1,60 @@ +const { Plane } = require('../'); +const { isWebGLSupported, skipHello } = require('@pixi/utils'); +const { Loader } = require('@pixi/loaders'); +const { Point } = require('@pixi/math'); +const { RenderTexture, Texture } = require('@pixi/core'); + +skipHello(); + +function withGL(fn) +{ + return isWebGLSupported() ? fn : undefined; +} + +// TODO: fix with webglrenderer +describe('PIXI.mesh.Plane', function () +{ + it.skip('should create a plane from an external image', withGL(function (done) + { + const loader = new Loader(); + + loader.add('testBitmap', `file://${__dirname}/resources/bitmap-1.png`) + .load(function (loader, resources) + { + const plane = new Plane(resources.testBitmap.texture, 100, 100); + + expect(plane.verticesX).to.equal(100); + expect(plane.verticesY).to.equal(100); + done(); + }); + })); + + it.skip('should create a new empty textured Plane', withGL(function () + { + const plane = new Plane(Texture.EMPTY, 100, 100); + + expect(plane.verticesX).to.equal(100); + expect(plane.verticesY).to.equal(100); + })); + + describe('containsPoint', function () + { + it.skip('should return true when point inside', withGL(function () + { + const point = new Point(10, 10); + const texture = new RenderTexture.create(20, 30); + const plane = new Plane(texture, 100, 100); + + expect(plane.containsPoint(point)).to.be.true; + })); + + it.skip('should return false when point outside', withGL(function () + { + const point = new Point(100, 100); + const texture = new RenderTexture.create(20, 30); + const plane = new Plane(texture, 100, 100); + + expect(plane.containsPoint(point)).to.be.false; + })); + }); +}); diff --git a/packages/mesh-extras/test/index.js b/packages/mesh-extras/test/index.js new file mode 100644 index 0000000..d767624 --- /dev/null +++ b/packages/mesh-extras/test/index.js @@ -0,0 +1 @@ +require('./Plane'); diff --git a/bundles/pixi.js/package.json b/bundles/pixi.js/package.json index 49c7276..177e059 100644 --- a/bundles/pixi.js/package.json +++ b/bundles/pixi.js/package.json @@ -49,6 +49,7 @@ "@pixi/loaders": "^5.0.0-alpha.2", "@pixi/math": "^5.0.0-alpha.2", "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/mesh-extras": "^5.0.0-alpha.2", "@pixi/mixin-cache-as-bitmap": "^5.0.0-alpha.2", "@pixi/mixin-get-child-by-name": "^5.0.0-alpha.2", "@pixi/mixin-get-global-position": "^5.0.0-alpha.2", diff --git a/bundles/pixi.js/src/deprecated.js b/bundles/pixi.js/src/deprecated.js index 147617c..dbebeb0 100644 --- a/bundles/pixi.js/src/deprecated.js +++ b/bundles/pixi.js/src/deprecated.js @@ -263,15 +263,15 @@ Object.defineProperties(PIXI.mesh, { /** * @class PIXI.mesh.Mesh - * @see PIXI.Mesh + * @see PIXI.Mesh2d * @deprecated since 5.0.0 */ Mesh: { get() { - warn('PIXI.mesh.Mesh has moved to PIXI.Mesh'); + warn('PIXI.mesh.Mesh has moved to PIXI.Mesh2d'); - return PIXI.Mesh; + return PIXI.Mesh2d; }, }, /** @@ -315,15 +315,15 @@ }, /** * @class PIXI.mesh.RawMesh - * @see PIXI.RawMesh + * @see PIXI.Mesh * @deprecated since 5.0.0 */ RawMesh: { get() { - warn('PIXI.mesh.RawMesh has moved to PIXI.RawMesh'); + warn('PIXI.mesh.RawMesh has moved to PIXI.Mesh'); - return PIXI.RawMesh; + return PIXI.Mesh; }, }, /** diff --git a/bundles/pixi.js/src/index.js b/bundles/pixi.js/src/index.js index a3a0d1b..6fdabf0 100644 --- a/bundles/pixi.js/src/index.js +++ b/bundles/pixi.js/src/index.js @@ -9,6 +9,7 @@ import * as loaders from '@pixi/loaders'; import * as math from '@pixi/math'; import * as mesh from '@pixi/mesh'; +import * as meshExtras from '@pixi/mesh-extras'; import * as particles from '@pixi/particles'; import * as prepare from '@pixi/prepare'; import * as sprite from '@pixi/sprite'; @@ -128,6 +129,7 @@ loaders, math, mesh, + meshExtras, particles, sprite, spriteAnimated, @@ -152,6 +154,7 @@ export * from '@pixi/loaders'; export * from '@pixi/math'; export * from '@pixi/mesh'; +export * from '@pixi/mesh-extras'; export * from '@pixi/particles'; export * from '@pixi/sprite'; export * from '@pixi/spritesheet'; diff --git a/package-lock.json b/package-lock.json index 7fe6db7..0814729 100644 --- a/package-lock.json +++ b/package-lock.json @@ -209,7 +209,7 @@ "argparse": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", - "integrity": "sha1-vNZ5HqWuCXJeF+WtmIE0zUCz2RE=", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", "dev": true, "requires": { "sprintf-js": "1.0.3" @@ -228,7 +228,7 @@ "arr-flatten": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz", - "integrity": "sha1-NgSLv/TntH4TZkQxbJlmnqWukfE=", + "integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==", "dev": true }, "arr-union": { @@ -297,7 +297,7 @@ "assertion-error": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", - "integrity": "sha1-5gtrDo8wG9l+U3UhW9pAbIURjAs=", + "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", "dev": true }, "async": { @@ -396,7 +396,7 @@ "brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha1-PH/L9SnYcibz0vUrlm/1Jx60Qd0=", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, "requires": { "balanced-match": "1.0.0", @@ -568,7 +568,7 @@ "circular-json": { "version": "0.3.3", "resolved": "https://registry.npmjs.org/circular-json/-/circular-json-0.3.3.tgz", - "integrity": "sha1-gVyZ6oT2gJUp0vRXkb34JxE1LWY=", + "integrity": "sha512-UZK3NBx2Mca+b5LsG7bY183pHWt5Y1xts4P3Pz7ENTwGVnJOUWbRb3ocjvX7hx9tq/yTAdclXm9sZ38gNuem4A==", "dev": true }, "cli-cursor": { @@ -638,7 +638,7 @@ "color-convert": { "version": "1.9.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.1.tgz", - "integrity": "sha1-wSYRB66y8pTr/+ye2eytUppgl+0=", + "integrity": "sha512-mjGanIiwQJskCC18rPR6OmrZ6fm2Lc7PeGFYwCmy5J34wC6F1PzdGL6xeMfmgicfYcNLGuVFA3WzXtIDCQSZxQ==", "dev": true, "requires": { "color-name": "1.1.3" @@ -1427,7 +1427,7 @@ "boom": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/boom/-/boom-5.2.0.tgz", - "integrity": "sha1-XdnabuOl8wIHdDYpDLcX0/SlTgI=", + "integrity": "sha512-Z5BTk6ZRe4tXXQlkqftmsAUANpXmuwlsF5Oov8ThoMbQRzdGTA1ngYRW160GexgOgjsFOKJz0LYhoNi+2AMBUw==", "dev": true, "requires": { "hoek": "4.2.1" @@ -1471,7 +1471,7 @@ "debug": { "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha1-XRKFFd8TT/Mn6QpMk/Tgd6U2NB8=", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", "dev": true, "requires": { "ms": "2.0.0" @@ -1585,7 +1585,7 @@ "doctrine": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", - "integrity": "sha1-XNAfwQFiG0LEzX9dGmYkNxbT850=", + "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", "dev": true, "requires": { "esutils": "2.0.2" @@ -1662,7 +1662,7 @@ "es6-promise": { "version": "4.2.4", "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.4.tgz", - "integrity": "sha1-3EIhwrFlGHYL2MOaUtjzVvwA7Sk=", + "integrity": "sha512-/NdNZVJg+uZgtm9eS3O6lrOLYmQag2DjdEXuPaHlZ6RuVqgqaVZfgYCepEIKsLqwdQArOPtC3XzRLqGGfT8KQQ==", "dev": true }, "escape-string-regexp": { @@ -1788,7 +1788,7 @@ "espree": { "version": "3.5.4", "resolved": "https://registry.npmjs.org/espree/-/espree-3.5.4.tgz", - "integrity": "sha1-sPRHGHyKi+2US4FaZgvd9d610ac=", + "integrity": "sha512-yAcIQxtmMiB/jL32dzEp2enBeidsB7xWPLNiw3IIkpVds1P+h7qF9YwJq1yUNzp2OKXgAprs4F61ih66UsoD1A==", "dev": true, "requires": { "acorn": "5.5.0", @@ -1798,7 +1798,7 @@ "esprima": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.0.tgz", - "integrity": "sha1-RJnt3NERDgshi6zy+n9/WfVcqAQ=", + "integrity": "sha512-oftTcaMu/EGrEIu904mWteKIv8vMuOgGYo7EhVJJN00R/EED9DCua/xxHRdYnKtcECzVg7xOWhflvJMnqcFZjw==", "dev": true }, "esquery": { @@ -1813,7 +1813,7 @@ "esrecurse": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.2.1.tgz", - "integrity": "sha1-AHo7n9vCs7uH5IeeoZyS/b05Qs8=", + "integrity": "sha512-64RBB++fIOAXPw3P9cy89qfMlvZEXZkqqJkjqqXIvzP5ezRZjW+lPWjw35UX/3EhUPFYbg5ER4JYgDw4007/DQ==", "dev": true, "requires": { "estraverse": "4.2.0" @@ -2024,7 +2024,7 @@ "find-root": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/find-root/-/find-root-1.1.0.tgz", - "integrity": "sha1-q8/Iunb3CMQql7PWhbfpRQv7nOQ=", + "integrity": "sha512-NKfW6bec6GfKc0SGx1e07QZY9PE99u0Bft/0rzSD5k3sO/vwkVUpDUKVm5Gpp5Ue3YfShPFTX2070tDs5kB9Ng==", "dev": true }, "find-up": { @@ -2103,7 +2103,7 @@ "supports-color": { "version": "5.3.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.3.0.tgz", - "integrity": "sha1-WySsFduA+pJ89SJ6SjP9PEx2dsA=", + "integrity": "sha512-0aP01LLIskjKs3lq52EC0aGBAJhLq7B2Rd8HC/DR/PtNNpcLilNmHC12O+hu0usQpo7wtHNRqtrhBwtDb0+dNg==", "dev": true, "requires": { "has-flag": "3.0.0" @@ -2567,7 +2567,7 @@ "glob": { "version": "7.1.2", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", - "integrity": "sha1-wZyd+aAocC1nhhI4SmVSQExjbRU=", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", "dev": true, "requires": { "fs.realpath": "1.0.0", @@ -2672,7 +2672,7 @@ "growl": { "version": "1.10.3", "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.3.tgz", - "integrity": "sha1-GSa6kM8+3+KttJJ/WIC8IsZseQ8=", + "integrity": "sha512-hKlsbA5Vu3xsh1Cg3J7jSmX/WaW6A5oBeqzM88oNbCRQFz+zUaXm6yxS4RVytp1scBoJzSYl4YAEOQIt6O8V1Q==", "dev": true }, "handlebars": { @@ -2738,7 +2738,7 @@ "hawk": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/hawk/-/hawk-6.0.2.tgz", - "integrity": "sha1-r02RTrBl+bXOTZ0RwcshJu7MMDg=", + "integrity": "sha512-miowhl2+U7Qle4vdLqDdPt9m09K6yZhkLDTWGoUiUzrQCn+mHHSmfJgAyGaLRZbPmTqfFFjRV1QWCW0VWUJBbQ==", "dev": true, "requires": { "boom": "4.3.1", @@ -2756,7 +2756,7 @@ "hoek": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/hoek/-/hoek-4.2.1.tgz", - "integrity": "sha1-ljRQKqEsRF3Vp8VzS1cruHOKrLs=", + "integrity": "sha512-QLg82fGkfnJ/4iy1xZ81/9SIJiq1NGFUMGs6ParyjBZr6jW2Ufj/snDqTHixNlHdPNwN2RLVD0Pi3igeK9+JfA==", "dev": true }, "home-path": { @@ -2791,7 +2791,7 @@ "ignore": { "version": "3.3.7", "resolved": "https://registry.npmjs.org/ignore/-/ignore-3.3.7.tgz", - "integrity": "sha1-YSKJv7PCIOGGpYEYYY1b6MG6sCE=", + "integrity": "sha512-YGG3ejvBNHRqu0559EOxxNFihD0AjpvHlC/pdGKd3X3ofe+CoJkYazwNJYTNebqpPKN+VVQbh4ZFn1DivMNuHA==", "dev": true }, "imurmurhash": { @@ -2828,7 +2828,7 @@ "ini": { "version": "1.3.5", "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", - "integrity": "sha1-7uJfVtscnsYIXgwid4CD9Zar+Sc=", + "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==", "dev": true }, "inquirer": { @@ -2901,7 +2901,7 @@ "is-buffer": { "version": "1.1.6", "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", - "integrity": "sha1-76ouqdqg16suoTqXsritUf776L4=", + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", "dev": true }, "is-builtin-module": { @@ -3054,7 +3054,7 @@ "is-resolvable": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/is-resolvable/-/is-resolvable-1.1.0.tgz", - "integrity": "sha1-+xj4fOH+uSUWnJpAfBkxijIG7Yg=", + "integrity": "sha512-qgDYXFSR5WvEfuS5dMj6oTMEbrrSaM0CrFk2Yiq/gXnBvD9pMa2jGXxyhGLfvhZpuMZe18CJpFxAt3CRs42NMg==", "dev": true }, "is-retry-allowed": { @@ -3204,7 +3204,7 @@ "js-yaml": { "version": "3.11.0", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.11.0.tgz", - "integrity": "sha1-WXwai9VxUvJtYizkEXhRpR9euu8=", + "integrity": "sha512-saJstZWv7oNeOyBh3+Dx1qWzhW0+e6/8eDzo7p5rDFqxntSztloLtuKu+Ejhtq82jsilwOIZYsCz+lIjthg1Hw==", "dev": true, "requires": { "argparse": "1.0.10", @@ -3324,7 +3324,7 @@ "just-extend": { "version": "1.1.27", "resolved": "https://registry.npmjs.org/just-extend/-/just-extend-1.1.27.tgz", - "integrity": "sha1-7G55QQ/5FORyZSq/oOYDwD1g6QU=", + "integrity": "sha512-mJVp13Ix6gFo3SBAy9U/kL+oeZqzlYYYLQBwXVBlVzIsZwBqGREnOro24oC/8s8aox+rJhtZ2DiQof++IrkA+g==", "dev": true }, "kind-of": { @@ -3703,7 +3703,7 @@ "lodash": { "version": "4.17.5", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.5.tgz", - "integrity": "sha1-maktZcAnLevoyWtgV7yPv6O+1RE=", + "integrity": "sha512-svL3uiZf1RwhH+cWrfZn3A4+U58wbP0tGVTLQPbjplZxZ8ROD9VLuNgsRniTlLe7OlSqR79RUehXgpBW/s0IQw==", "dev": true }, "lodash._reinterpolate": { @@ -3740,7 +3740,7 @@ "lolex": { "version": "2.3.2", "resolved": "https://registry.npmjs.org/lolex/-/lolex-2.3.2.tgz", - "integrity": "sha1-hflFBCUQO/nnpgZo6iXcQydMqAc=", + "integrity": "sha512-A5pN2tkFj7H0dGIAM6MFvHKMJcPnjZsOMvR7ujCjfgW5TbV6H9vb1PgxLtHvjqNZTHsUolz+6/WEO0N1xNx2ng==", "dev": true }, "longest": { @@ -3816,7 +3816,7 @@ "marked": { "version": "0.3.17", "resolved": "https://registry.npmjs.org/marked/-/marked-0.3.17.tgz", - "integrity": "sha1-YH8GZos8axJGso8T2nYRasGqLSs=", + "integrity": "sha512-+AKbNsjZl6jFfLPwHhWmGTqE009wTKn3RTmn9K8oUKHrX/abPJjtcRtXpYB/FFrwPJRUA86LX/de3T0knkPCmQ==", "dev": true }, "mem": { @@ -3896,13 +3896,13 @@ "mime-db": { "version": "1.33.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.33.0.tgz", - "integrity": "sha1-o0kgUKXLm2NFBUHjnZeI0icng9s=", + "integrity": "sha512-BHJ/EKruNIqJf/QahvxwQZXKygOQ256myeN/Ew+THcAa5q+PjyTTMMeNQC4DZw5AwfvelsUrA6B67NKMqXDbzQ==", "dev": true }, "mime-types": { "version": "2.1.18", "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.18.tgz", - "integrity": "sha1-bzI/YKg9ERRvgx/xH9ZuL+VQO7g=", + "integrity": "sha512-lc/aahn+t4/SWV/qcmumYjymLsWfN3ELhpmVuUFjgsORruuZPVSwAQryq+HHGvO/SI2KVX26bx+En+zhM8g8hQ==", "dev": true, "requires": { "mime-db": "1.33.0" @@ -3917,7 +3917,7 @@ "minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha1-UWbihkV/AzBgZL5Ul+jbsMPTIIM=", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "dev": true, "requires": { "brace-expansion": "1.1.11" @@ -4071,7 +4071,7 @@ "normalize-package-data": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.4.0.tgz", - "integrity": "sha1-EvlaMH1YNSB1oEkHuErIvpisAS8=", + "integrity": "sha512-9jjUFbTPfEy3R/ad/2oNbKtW9Hgovl5O1FvFWKkKblNXoN/Oou6+9+KKohPK13Yc3/TyunyWhJp6gvRNR/PPAw==", "dev": true, "requires": { "hosted-git-info": "2.5.0", @@ -4511,7 +4511,7 @@ "process-nextick-args": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", - "integrity": "sha1-o31zL0JxtKsa0HDTVQjoKQeI/6o=", + "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==", "dev": true }, "progress": { @@ -4584,7 +4584,7 @@ "qs": { "version": "6.5.1", "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.1.tgz", - "integrity": "sha1-NJzfbu+J7EXBLX1es/wMhwNDptg=", + "integrity": "sha512-eRzhrN1WSINYCDCbrz796z37LOe3m5tmW7RQf6oBntukAG1nmovJvhnwHHRMAfeoItc1m2Hk02WER2aQ/iqs+A==", "dev": true }, "quick-lru": { @@ -4596,7 +4596,7 @@ "randomatic": { "version": "1.1.7", "resolved": "https://registry.npmjs.org/randomatic/-/randomatic-1.1.7.tgz", - "integrity": "sha1-x6vpzIuHwLqodrGf3oP9RkeX44w=", + "integrity": "sha512-D5JUjPyJbaJDkuAazpVnSfVkLlpeO3wDlPROTMLGKG1zMFNFRgrciKo1ltz/AzNTkqE0HzDx655QOL51N06how==", "dev": true, "requires": { "is-number": "3.0.0", @@ -4701,7 +4701,7 @@ "regex-cache": { "version": "0.4.4", "resolved": "https://registry.npmjs.org/regex-cache/-/regex-cache-0.4.4.tgz", - "integrity": "sha1-db3FiioUls7EihKDW8VMjVYjNt0=", + "integrity": "sha512-nVIZwtCjkC9YgvWkpM55B5rBhBYRZhAaJbgcFYXXsHnbZ9UZI9nnVWYZpBlCqv9ho2eZryPnWrZGsOdPwVWXWQ==", "dev": true, "requires": { "is-equal-shallow": "0.1.3" @@ -4729,7 +4729,7 @@ "remap-istanbul": { "version": "0.10.1", "resolved": "https://registry.npmjs.org/remap-istanbul/-/remap-istanbul-0.10.1.tgz", - "integrity": "sha1-OqWN1QIdSZ8zbTulvzu7kcG4jjc=", + "integrity": "sha512-gsNQXs5kJLhErICSyYhzVZ++C8LBW8dgwr874Y2QvzAUS75zBlD/juZgXs39nbYJ09fZDlX2AVLVJAY2jbFJoQ==", "dev": true, "requires": { "amdefine": "1.0.1", @@ -4769,7 +4769,7 @@ "source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha1-dHIq8y6WFOnCh6jQu95IteLxomM=", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", "dev": true }, "through2": { @@ -4883,7 +4883,7 @@ "resolve": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.5.0.tgz", - "integrity": "sha1-HwmsznlsmnYlefMbLBzEw83fnzY=", + "integrity": "sha512-hgoSGrc3pjzAPHNBg+KnFcK2HwlHTs/YrAGUr6qgTVUZmXv1UEXXl0bZNBKMA9fud6lRYFdPGz0xXxycPzmmiw==", "dev": true, "requires": { "path-parse": "1.0.5" @@ -4924,7 +4924,7 @@ "rimraf": { "version": "2.6.2", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", - "integrity": "sha1-LtgVDSShbqhlHm1u8PR8QVjOejY=", + "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", "dev": true, "requires": { "glob": "7.1.2" @@ -5063,19 +5063,19 @@ "safe-buffer": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", - "integrity": "sha1-iTMSr2myEj3vcfV4iQAWce6yyFM=", + "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", "dev": true }, "samsam": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/samsam/-/samsam-1.3.0.tgz", - "integrity": "sha1-jR2TUOJWItow3j5EumkrUiGrfFA=", + "integrity": "sha512-1HwIYD/8UlOtFS3QO3w7ey+SdSDFE4HRNLZoZRYVQefrOY3l17epswImeB1ijgJFQJodIaHcwkp3r/myBjFVbg==", "dev": true }, "semver": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz", - "integrity": "sha1-3Eu8emyp2Rbe5dQ1FvAJK1j3uKs=", + "integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==", "dev": true }, "set-blocking": { @@ -5117,7 +5117,7 @@ "sinon-chai": { "version": "2.14.0", "resolved": "https://registry.npmjs.org/sinon-chai/-/sinon-chai-2.14.0.tgz", - "integrity": "sha1-2n3UzIPNaiYLZ8yg96n9riahIF0=", + "integrity": "sha512-9stIF1utB0ywNHNT7RgiXbdmen8QDCRsrTjw+G9TgKt1Yexjiv8TOWZ6WHsTPz57Yky3DIswZvEqX8fpuHNDtQ==", "dev": true }, "slash": { @@ -5146,7 +5146,7 @@ "sntp": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/sntp/-/sntp-2.1.0.tgz", - "integrity": "sha1-LGzsFP7cIiJznK+bXD2F0cxaLMg=", + "integrity": "sha512-FL1b58BDrqS3A11lJ0zEdnJ3UOKqVxawAkF3k7F0CVN7VQ34aZrV+G8BZ1WC9ZL7NyrwsW0oviwsWDgRuVYtJg==", "dev": true, "requires": { "hoek": "4.2.1" @@ -5203,7 +5203,7 @@ "spdx-correct": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.0.0.tgz", - "integrity": "sha1-BaW01xU6GVvJLDxCW2nzsqlSTII=", + "integrity": "sha512-N19o9z5cEyc8yQQPukRCZ9EUmb4HUpnrmaL/fxS2pBo2jbfcFRVuFZ/oFC+vZz0MNNk0h80iMn5/S6qGZOL5+g==", "dev": true, "requires": { "spdx-expression-parse": "3.0.0", @@ -5213,13 +5213,13 @@ "spdx-exceptions": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.1.0.tgz", - "integrity": "sha1-LHrmEFbHFKW5ubKyr30xHvXHj+k=", + "integrity": "sha512-4K1NsmrlCU1JJgUrtgEeTVyfx8VaYea9J9LvARxhbHtVtohPs/gFGG5yy49beySjlIMhhXZ4QqujIZEfS4l6Cg==", "dev": true }, "spdx-expression-parse": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.0.tgz", - "integrity": "sha1-meEZt6XaAOBUkcn6M4t5BII7QdA=", + "integrity": "sha512-Yg6D3XpRD4kkOmTpdgbUiEJFKghJH03fiC1OPll5h/0sO6neh2jqRDVHOQ4o/LMea0tgCkbMgea5ip/e+MkWyg==", "dev": true, "requires": { "spdx-exceptions": "2.1.0", @@ -5229,7 +5229,7 @@ "spdx-license-ids": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.0.tgz", - "integrity": "sha1-enzShHDMbToc/m1miG9rxDDTrIc=", + "integrity": "sha512-2+EPwgbnmOIl8HjGBXXMd9NAu02vLjOO1nWw4kmeRDFyHn+M/ETfHxQUK0oXg8ctgVnl9t3rosNVsZ1jG61nDA==", "dev": true }, "speedometer": { @@ -5566,7 +5566,7 @@ "tough-cookie": { "version": "2.3.4", "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.4.tgz", - "integrity": "sha1-7GDO44rGdQY//JelwYlwV47oNlU=", + "integrity": "sha512-TZ6TTfI5NtZnuyy/Kecv+CnoROnyXn2DN97LontgQpCwsX2XyLYCC0ENhYkehSOwAp8rTQKc/NUIF7BkQ5rKLA==", "dev": true, "requires": { "punycode": "1.4.1" @@ -5708,13 +5708,13 @@ "uuid": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.2.1.tgz", - "integrity": "sha1-EsUou51Y0LkmXZovbw/ovhf/HxQ=", + "integrity": "sha512-jZnMwlb9Iku/O3smGWvZhauCf6cvvpKi4BKRiliS3cxnI+Gz9j5MEpTz2UFuXiKPJocb7gnsLHwiS05ige5BEA==", "dev": true }, "validate-npm-package-license": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.3.tgz", - "integrity": "sha1-gWQ7y+8b3+zUYjeT3EZIlIupgzg=", + "integrity": "sha512-63ZOUnL4SIXj4L0NixR3L1lcjO38crAbgrTpl28t8jjrfuiOBL5Iygm+60qPs/KsZGzPNg6Smnc/oY16QTjF0g==", "dev": true, "requires": { "spdx-correct": "3.0.0", @@ -5750,7 +5750,7 @@ "which": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/which/-/which-1.3.0.tgz", - "integrity": "sha1-/wS9/AEO5UfXgL7DjhrBwnd9JTo=", + "integrity": "sha512-xcJpopdamTuY5duC/KnTTNBraPK54YwpenP4lzxU8H91GudWpFv38u0CKjclE1Wi2EH2EDz5LRcHcKbCIzqGyg==", "dev": true, "requires": { "isexe": "2.0.0" diff --git a/packages/canvas/canvas-mesh/package.json b/packages/canvas/canvas-mesh/package.json index 691cd2c..6744a17 100644 --- a/packages/canvas/canvas-mesh/package.json +++ b/packages/canvas/canvas-mesh/package.json @@ -24,6 +24,7 @@ "dependencies": { "@pixi/constants": "^5.0.0-alpha.2", "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/mesh-extras": "^5.0.0-alpha.2", "@pixi/settings": "^5.0.0-alpha.2" }, "devDependencies": { diff --git a/packages/canvas/canvas-mesh/src/Mesh.js b/packages/canvas/canvas-mesh/src/Mesh.js index 900a872..c43a74b 100644 --- a/packages/canvas/canvas-mesh/src/Mesh.js +++ b/packages/canvas/canvas-mesh/src/Mesh.js @@ -1,36 +1,14 @@ import { Mesh } from '@pixi/mesh'; -import { settings } from './settings'; - -// IMPORTANT: Please do NOT use this as a precedent to use `settings` after the object is created -// this was merely created to completely decouple canvas from the base Mesh class and we are -// unable to add `canvasPadding` in the constructor anymore, as the case was for PixiJS v4. /** - * Internal variable for `canvasPadding`. + * Renders the object using the Canvas renderer * * @private - * @memberof PIXI.Mesh - * @member {number} - * @default null - */ -Mesh.prototype._canvasPadding = null; - -/** - * Triangles in canvas mode are automatically antialiased, use this value to force triangles - * to overlap a bit with each other. To set the global default, set {@link PIXI.settings.MESH_CANVAS_PADDING} - * - * @see PIXI.settings.MESH_CANVAS_PADDING - * @member {number} canvasPadding + * @method _renderCanvas * @memberof PIXI.Mesh# - * @default 0 + * @param {PIXI.CanvasRenderer} renderer - The canvas renderer. */ -Object.defineProperty(Mesh.prototype, 'canvasPadding', { - get() - { - return this._canvasPadding !== null ? this._canvasPadding : settings.MESH_CANVAS_PADDING; - }, - set(value) - { - this._canvasPadding = value; - }, -}); +Mesh.prototype._renderCanvas = function _renderCanvas(renderer) +{ + renderer.plugins[this.pluginName].render(this); +}; diff --git a/packages/canvas/canvas-mesh/src/Mesh2d.js b/packages/canvas/canvas-mesh/src/Mesh2d.js new file mode 100644 index 0000000..d0bd80f --- /dev/null +++ b/packages/canvas/canvas-mesh/src/Mesh2d.js @@ -0,0 +1,36 @@ +import { Mesh2d } from '@pixi/mesh-extras'; +import { settings } from './settings'; + +// IMPORTANT: Please do NOT use this as a precedent to use `settings` after the object is created +// this was merely created to completely decouple canvas from the base Mesh class and we are +// unable to add `canvasPadding` in the constructor anymore, as the case was for PixiJS v4. + +/** + * Internal variable for `canvasPadding`. + * + * @private + * @memberof PIXI.Mesh2d + * @member {number} + * @default null + */ +Mesh2d.prototype._canvasPadding = null; + +/** + * Triangles in canvas mode are automatically antialiased, use this value to force triangles + * to overlap a bit with each other. To set the global default, set {@link PIXI.settings.MESH_CANVAS_PADDING} + * + * @see PIXI.settings.MESH_CANVAS_PADDING + * @member {number} canvasPadding + * @memberof PIXI.Mesh2d# + * @default 0 + */ +Object.defineProperty(Mesh2d.prototype, 'canvasPadding', { + get() + { + return this._canvasPadding !== null ? this._canvasPadding : settings.MESH_CANVAS_PADDING; + }, + set(value) + { + this._canvasPadding = value; + }, +}); diff --git a/packages/canvas/canvas-mesh/src/NineSlicePlane.js b/packages/canvas/canvas-mesh/src/NineSlicePlane.js index 09eaf9c..2fd5acc 100644 --- a/packages/canvas/canvas-mesh/src/NineSlicePlane.js +++ b/packages/canvas/canvas-mesh/src/NineSlicePlane.js @@ -1,4 +1,4 @@ -import { NineSlicePlane } from '@pixi/mesh'; +import { NineSlicePlane } from '@pixi/mesh-extras'; /** * Renders the object using the Canvas renderer diff --git a/packages/canvas/canvas-mesh/src/RawMesh.js b/packages/canvas/canvas-mesh/src/RawMesh.js deleted file mode 100644 index bf40184..0000000 --- a/packages/canvas/canvas-mesh/src/RawMesh.js +++ /dev/null @@ -1,14 +0,0 @@ -import { RawMesh } from '@pixi/mesh'; - -/** - * Renders the object using the Canvas renderer - * - * @private - * @method _renderCanvas - * @memberof PIXI.RawMesh# - * @param {PIXI.CanvasRenderer} renderer - The canvas renderer. - */ -RawMesh.prototype._renderCanvas = function _renderCanvas(renderer) -{ - renderer.plugins[this.pluginName].render(this); -}; diff --git a/packages/canvas/canvas-mesh/src/index.js b/packages/canvas/canvas-mesh/src/index.js index 2295016..f4fa31d 100644 --- a/packages/canvas/canvas-mesh/src/index.js +++ b/packages/canvas/canvas-mesh/src/index.js @@ -1,6 +1,6 @@ export { default as CanvasMeshRenderer } from './CanvasMeshRenderer'; import './settings'; -import './Mesh'; +import './Mesh2d'; import './NineSlicePlane'; -import './RawMesh'; +import './Mesh'; diff --git a/packages/canvas/canvas-mesh/src/settings.js b/packages/canvas/canvas-mesh/src/settings.js index 4cefb4c..e81b8e0 100644 --- a/packages/canvas/canvas-mesh/src/settings.js +++ b/packages/canvas/canvas-mesh/src/settings.js @@ -3,7 +3,7 @@ /** * Default `canvasPadding` for canvas-based Mesh rendering. * - * @see PIXI.Mesh#canvasPadding + * @see PIXI.Mesh2d#canvasPadding * @static * @constant * @memberof PIXI.settings diff --git a/packages/mesh-extras/LICENSE b/packages/mesh-extras/LICENSE new file mode 100644 index 0000000..148e3eb --- /dev/null +++ b/packages/mesh-extras/LICENSE @@ -0,0 +1,21 @@ +The MIT License + +Copyright (c) 2013-2018 Mathew Groves, Chad Engler + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/packages/mesh-extras/README.md b/packages/mesh-extras/README.md new file mode 100644 index 0000000..1d9b0e1 --- /dev/null +++ b/packages/mesh-extras/README.md @@ -0,0 +1,19 @@ +# @pixi/mesh-extras + +## Installation + +```bash +npm install @pixi/mesh-extras +``` + +## Usage + +```js +import { MeshRenderer } from '@pixi/mesh'; +import { Renderer } from '@pixi/core'; +import { Rope } from '@pixi/mesh-extras'; + +Renderer.registerPlugin('mesh', MeshRenderer); + +const rope = new Rope(); +``` \ No newline at end of file diff --git a/packages/mesh-extras/package.json b/packages/mesh-extras/package.json new file mode 100644 index 0000000..d134f64 --- /dev/null +++ b/packages/mesh-extras/package.json @@ -0,0 +1,38 @@ +{ + "name": "@pixi/mesh-extras", + "version": "5.0.0-alpha.2", + "main": "lib/mesh-extras.js", + "module": "lib/mesh-extras.es.js", + "description": "Custom Mesh display objects, like Rope and Plane", + "author": "Mat Groves", + "contributors": [ + "Matt Karl " + ], + "homepage": "http://pixijs.com/", + "bugs": "https://github.com/pixijs/pixi.js/issues", + "license": "MIT", + "repository": { + "type": "git", + "url": "https://github.com/pixijs/pixi.js.git" + }, + "publishConfig": { + "access": "public" + }, + "scripts": { + "test": "floss --path test" + }, + "files": [ + "lib" + ], + "dependencies": { + "@pixi/constants": "^5.0.0-alpha.2", + "@pixi/core": "^5.0.0-alpha.2", + "@pixi/math": "^5.0.0-alpha.2", + "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/utils": "^5.0.0-alpha.2" + }, + "devDependencies": { + "@pixi/loaders": "^5.0.0-alpha.2", + "floss": "^2.1.3" + } +} diff --git a/packages/mesh-extras/src/Mesh2d.js b/packages/mesh-extras/src/Mesh2d.js new file mode 100644 index 0000000..d113a5e --- /dev/null +++ b/packages/mesh-extras/src/Mesh2d.js @@ -0,0 +1,263 @@ +import { Mesh } from '@pixi/mesh'; +import { Geometry, Program, Shader, Texture, TextureMatrix } from '@pixi/core'; +import { Matrix } from '@pixi/math'; +import { BLEND_MODES } from '@pixi/constants'; +import { hex2rgb, premultiplyRgba } from '@pixi/utils'; +import vertex from './mesh.vert'; +import fragment from './mesh.frag'; + +let meshProgram; + +/** + * Base mesh class + * @class + * @extends PIXI.Container + * @memberof PIXI + */ +export default class Mesh2d extends Mesh +{ + /** + * @param {PIXI.Texture} [texture=Texture.EMPTY] - The texture to use + * @param {Float32Array} [vertices] - if you want to specify the vertices + * @param {Float32Array} [uvs] - if you want to specify the uvs + * @param {Uint16Array} [indices] - if you want to specify the indices + * @param {number} [drawMode] - the drawMode, can be any of the Mesh.DRAW_MODES consts + */ + constructor(texture = Texture.EMPTY, vertices, uvs, indices, drawMode) + { + const geometry = new Geometry(); + + if (!meshProgram) + { + meshProgram = new Program(vertex, fragment); + } + + geometry.addAttribute('aVertexPosition', vertices) + .addAttribute('aTextureCoord', uvs) + .addIndex(indices); + + geometry.getAttribute('aVertexPosition').static = false; + + const uniforms = { + uSampler: texture, + uTextureMatrix: Matrix.IDENTITY, + alpha: 1, + uColor: new Float32Array([1, 1, 1, 1]), + }; + + super(geometry, new Shader(meshProgram, uniforms), null, drawMode); + + /** + * The Uvs of the Mesh + * + * @member {Float32Array} + */ + this.uvs = geometry.getAttribute('aTextureCoord').data; + + /** + * An array of vertices + * + * @member {Float32Array} + */ + this.vertices = geometry.getAttribute('aVertexPosition').data; + + this.uniforms = uniforms; + + /** + * The texture of the Mesh + * + * @member {PIXI.Texture} + * @default PIXI.Texture.EMPTY + * @private + */ + this.texture = texture; + + /** + * The tint applied to the mesh. This is a [r,g,b] value. A value of [1,1,1] will remove any + * tint effect. + * + * @member {number} + * @private + */ + this._tintRGB = new Float32Array([1, 1, 1]); + + // Set default tint + this.tint = 0xFFFFFF; + + this.blendMode = BLEND_MODES.NORMAL; + + /** + * TextureMatrix instance for this Mesh, used to track Texture changes + * + * @member {PIXI.TextureMatrix} + * @readonly + */ + this.uvMatrix = new TextureMatrix(this._texture); + + /** + * whether or not upload uvMatrix to shader + * if its false, then uvs should be pre-multiplied + * if you change it for generated mesh, please call 'refresh(true)' + * @member {boolean} + * @default false + */ + this.uploadUvMatrix = false; + + /** + * Uploads vertices buffer every frame, like in PixiJS V3 and V4. + * + * @member {boolean} + * @default true + */ + this.autoUpdate = true; + } + + /** + * The tint applied to the Rope. This is a hex value. A value of + * 0xFFFFFF will remove any tint effect. + * + * @member {number} + * @memberof PIXI.Sprite# + * @default 0xFFFFFF + */ + get tint() + { + return this._tint; + } + + /** + * Sets the tint of the rope. + * + * @param {number} value - The value to set to. + */ + set tint(value) + { + this._tint = value; + + hex2rgb(this._tint, this._tintRGB); + } + + /** + * The blend mode to be applied to the sprite. Set to `PIXI.BLEND_MODES.NORMAL` to remove any blend mode. + * + * @member {number} + * @default PIXI.BLEND_MODES.NORMAL + * @see PIXI.BLEND_MODES + */ + get blendMode() + { + return this.state.blendMode; + } + + set blendMode(value) // eslint-disable-line require-jsdoc + { + this.state.blendMode = value; + } + + /** + * The texture that the mesh uses. + * + * @member {PIXI.Texture} + */ + get texture() + { + return this._texture; + } + + set texture(value) // eslint-disable-line require-jsdoc + { + if (this._texture === value) + { + return; + } + + this._texture = value; + this.uniforms.uSampler = this.texture; + + if (value) + { + // wait for the texture to load + if (value.baseTexture.valid) + { + this._onTextureUpdate(); + } + else + { + value.once('update', this._onTextureUpdate, this); + } + } + } + + _render(renderer) + { + const baseTex = this._texture.baseTexture; + + premultiplyRgba(this._tintRGB, this.worldAlpha, this.uniforms.uColor, baseTex.premultiplyAlpha); + super._render(renderer); + } + /** + * When the texture is updated, this event will fire to update the scale and frame + * + * @private + */ + _onTextureUpdate() + { + // constructor texture update stop + if (!this.uvMatrix) + { + return; + } + this.uvMatrix.texture = this._texture; + this.refresh(); + } + + /** + * multiplies uvs only if uploadUvMatrix is false + * call it after you change uvs manually + * make sure that texture is valid + */ + multiplyUvs() + { + if (!this.uploadUvMatrix) + { + this.uvMatrix.multiplyUvs(this.uvs); + } + } + + /** + * Refreshes uvs for generated meshes (rope, plane) + * sometimes refreshes vertices too + * + * @param {boolean} [forceUpdate=false] if true, matrices will be updated any case + */ + refresh(forceUpdate) + { + if (this.uvMatrix.update(forceUpdate)) + { + this._refresh(); + } + } + + /** + * Updates the object transform for rendering + * + * @private + */ + updateTransform() + { + if (this.autoUpdate) + { + this.geometry.buffers[0].update(); + } + this.containerUpdateTransform(); + } + + /** + * re-calculates mesh coords + * @private + */ + _refresh() + { + /* empty */ + } +} diff --git a/packages/mesh-extras/src/NineSlicePlane.js b/packages/mesh-extras/src/NineSlicePlane.js new file mode 100644 index 0000000..0bae92c --- /dev/null +++ b/packages/mesh-extras/src/NineSlicePlane.js @@ -0,0 +1,270 @@ +import Plane from './Plane'; + +const DEFAULT_BORDER_SIZE = 10; + +/** + * The NineSlicePlane allows you to stretch a texture using 9-slice scaling. The corners will remain unscaled (useful + * for buttons with rounded corners for example) and the other areas will be scaled horizontally and or vertically + * + *```js + * let Plane9 = new PIXI.NineSlicePlane(PIXI.Texture.from('BoxWithRoundedCorners.png'), 15, 15, 15, 15); + * ``` + *
+ *      A                          B
+ *    +---+----------------------+---+
+ *  C | 1 |          2           | 3 |
+ *    +---+----------------------+---+
+ *    |   |                      |   |
+ *    | 4 |          5           | 6 |
+ *    |   |                      |   |
+ *    +---+----------------------+---+
+ *  D | 7 |          8           | 9 |
+ *    +---+----------------------+---+
+
+ *  When changing this objects width and/or height:
+ *     areas 1 3 7 and 9 will remain unscaled.
+ *     areas 2 and 8 will be stretched horizontally
+ *     areas 4 and 6 will be stretched vertically
+ *     area 5 will be stretched both horizontally and vertically
+ * 
+ * + * @class + * @extends PIXI.Plane + * @memberof PIXI + * + */ +export default class NineSlicePlane extends Plane +{ + /** + * @param {PIXI.Texture} texture - The texture to use on the NineSlicePlane. + * @param {int} [leftWidth=10] size of the left vertical bar (A) + * @param {int} [topHeight=10] size of the top horizontal bar (C) + * @param {int} [rightWidth=10] size of the right vertical bar (B) + * @param {int} [bottomHeight=10] size of the bottom horizontal bar (D) + */ + constructor(texture, leftWidth, topHeight, rightWidth, bottomHeight) + { + super(texture, 4, 4); + + this._origWidth = texture.orig.width; + this._origHeight = texture.orig.height; + + /** + * The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._width = this._origWidth; + + /** + * The height of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._height = this._origHeight; + + /** + * The width of the left column (a) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._leftWidth = typeof leftWidth !== 'undefined' ? leftWidth : DEFAULT_BORDER_SIZE; + + /** + * The width of the right column (b) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._rightWidth = typeof rightWidth !== 'undefined' ? rightWidth : DEFAULT_BORDER_SIZE; + + /** + * The height of the top row (c) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._topHeight = typeof topHeight !== 'undefined' ? topHeight : DEFAULT_BORDER_SIZE; + + /** + * The height of the bottom row (d) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._bottomHeight = typeof bottomHeight !== 'undefined' ? bottomHeight : DEFAULT_BORDER_SIZE; + + this.refresh(true); + } + + /** + * Updates the horizontal vertices. + * + */ + updateHorizontalVertices() + { + const vertices = this.vertices; + + const h = this._topHeight + this._bottomHeight; + const scale = this._height > h ? 1.0 : this._height / h; + + vertices[9] = vertices[11] = vertices[13] = vertices[15] = this._topHeight * scale; + vertices[17] = vertices[19] = vertices[21] = vertices[23] = this._height - (this._bottomHeight * scale); + vertices[25] = vertices[27] = vertices[29] = vertices[31] = this._height; + } + + /** + * Updates the vertical vertices. + * + */ + updateVerticalVertices() + { + const vertices = this.vertices; + + const w = this._leftWidth + this._rightWidth; + const scale = this._width > w ? 1.0 : this._width / w; + + vertices[2] = vertices[10] = vertices[18] = vertices[26] = this._leftWidth * scale; + vertices[4] = vertices[12] = vertices[20] = vertices[28] = this._width - (this._rightWidth * scale); + vertices[6] = vertices[14] = vertices[22] = vertices[30] = this._width; + } + + /** + * The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + */ + get width() + { + return this._width; + } + + set width(value) // eslint-disable-line require-jsdoc + { + this._width = value; + this._refresh(); + } + + /** + * The height of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + */ + get height() + { + return this._height; + } + + set height(value) // eslint-disable-line require-jsdoc + { + this._height = value; + this._refresh(); + } + + /** + * The width of the left column + * + * @member {number} + */ + get leftWidth() + { + return this._leftWidth; + } + + set leftWidth(value) // eslint-disable-line require-jsdoc + { + this._leftWidth = value; + this._refresh(); + } + + /** + * The width of the right column + * + * @member {number} + */ + get rightWidth() + { + return this._rightWidth; + } + + set rightWidth(value) // eslint-disable-line require-jsdoc + { + this._rightWidth = value; + this._refresh(); + } + + /** + * The height of the top row + * + * @member {number} + */ + get topHeight() + { + return this._topHeight; + } + + set topHeight(value) // eslint-disable-line require-jsdoc + { + this._topHeight = value; + this._refresh(); + } + + /** + * The height of the bottom row + * + * @member {number} + */ + get bottomHeight() + { + return this._bottomHeight; + } + + set bottomHeight(value) // eslint-disable-line require-jsdoc + { + this._bottomHeight = value; + this._refresh(); + } + + /** + * Refreshes NineSlicePlane coords. All of them. + */ + _refresh() + { + super._refresh(); + + const uvs = this.uvs; + const texture = this._texture; + + this._origWidth = texture.orig.width; + this._origHeight = texture.orig.height; + + const _uvw = 1.0 / this._origWidth; + const _uvh = 1.0 / this._origHeight; + + uvs[0] = uvs[8] = uvs[16] = uvs[24] = 0; + uvs[1] = uvs[3] = uvs[5] = uvs[7] = 0; + uvs[6] = uvs[14] = uvs[22] = uvs[30] = 1; + uvs[25] = uvs[27] = uvs[29] = uvs[31] = 1; + + uvs[2] = uvs[10] = uvs[18] = uvs[26] = _uvw * this._leftWidth; + uvs[4] = uvs[12] = uvs[20] = uvs[28] = 1 - (_uvw * this._rightWidth); + uvs[9] = uvs[11] = uvs[13] = uvs[15] = _uvh * this._topHeight; + uvs[17] = uvs[19] = uvs[21] = uvs[23] = 1 - (_uvh * this._bottomHeight); + + this.updateHorizontalVertices(); + this.updateVerticalVertices(); + + this.geometry.buffers[1].update(); + + this.multiplyUvs(); + } +} diff --git a/packages/mesh-extras/src/Plane.js b/packages/mesh-extras/src/Plane.js new file mode 100644 index 0000000..1c240c4 --- /dev/null +++ b/packages/mesh-extras/src/Plane.js @@ -0,0 +1,100 @@ +import Mesh2d from './Mesh2d'; + +/** + * The Plane allows you to draw a texture across several points and them manipulate these points + * + *```js + * for (let i = 0; i < 20; i++) { + * points.push(new PIXI.Point(i * 50, 0)); + * }; + * let Plane = new PIXI.Plane(PIXI.Texture.from("snake.png"), points); + * ``` + * + * @class + * @extends PIXI.Mesh + * @memberof PIXI + * + */ +export default class Plane extends Mesh2d +{ + /** + * @param {PIXI.Texture} texture - The texture to use on the Plane. + * @param {number} verticesX - The number of vertices in the x-axis + * @param {number} verticesY - The number of vertices in the y-axis + * @param {object} [opts] - an options object - add meshWidth and meshHeight, temporary object for PixiJS v5 alpha + */ + constructor(texture, verticesX, verticesY, opts = {}) + { + super(texture, new Float32Array(1), new Float32Array(1), new Uint16Array(1), 4); + + this.verticesX = verticesX || 10; + this.verticesY = verticesY || 10; + + this.meshWidth = opts.meshWidth || 0; + this.meshHeight = opts.meshHeight || 0; + + this.refresh(); + } + + /** + * Refreshes plane coordinates + * @private + */ + _refresh() + { + const texture = this._texture; + const total = this.verticesX * this.verticesY; + const verts = []; + const uvs = []; + const indices = []; + + const segmentsX = this.verticesX - 1; + const segmentsY = this.verticesY - 1; + + const sizeX = (this.meshWidth || texture.width) / segmentsX; + const sizeY = (this.meshHeight || texture.height) / segmentsY; + + for (let i = 0; i < total; i++) + { + const x = (i % this.verticesX); + const y = ((i / this.verticesX) | 0); + + verts.push(x * sizeX, y * sizeY); + + uvs.push(x / segmentsX, y / segmentsY); + } + + // cons + + const totalSub = segmentsX * segmentsY; + + for (let i = 0; i < totalSub; i++) + { + const xpos = i % segmentsX; + const ypos = (i / segmentsX) | 0; + + const value = (ypos * this.verticesX) + xpos; + const value2 = (ypos * this.verticesX) + xpos + 1; + const value3 = ((ypos + 1) * this.verticesX) + xpos; + const value4 = ((ypos + 1) * this.verticesX) + xpos + 1; + + indices.push(value, value2, value3); + indices.push(value2, value4, value3); + } + + this.vertices = new Float32Array(verts); + this.uvs = new Float32Array(uvs); + this.indices = new Uint16Array(indices); + + this.geometry.buffers[0].data = this.vertices; + this.geometry.buffers[1].data = this.uvs; + this.geometry.indexBuffer.data = this.indices; + + // ensure that the changes are uploaded + this.geometry.buffers[0].update(); + this.geometry.buffers[1].update(); + this.geometry.indexBuffer.update(); + + this.multiplyUvs(); + } +} diff --git a/packages/mesh-extras/src/Rope.js b/packages/mesh-extras/src/Rope.js new file mode 100644 index 0000000..9cfde38 --- /dev/null +++ b/packages/mesh-extras/src/Rope.js @@ -0,0 +1,182 @@ +import Mesh2d from './Mesh2d'; + +/** + * The rope allows you to draw a texture across several points and them manipulate these points + * + *```js + * for (let i = 0; i < 20; i++) { + * points.push(new PIXI.Point(i * 50, 0)); + * }; + * let rope = new PIXI.Rope(PIXI.Texture.from("snake.png"), points); + * ``` + * + * @class + * @extends PIXI.Mesh + * @memberof PIXI + * + */ +export default class Rope extends Mesh2d +{ + /** + * @param {PIXI.Texture} texture - The texture to use on the rope. + * @param {PIXI.Point[]} points - An array of {@link PIXI.Point} objects to construct this rope. + */ + constructor(texture, points) + { + super(texture, new Float32Array(points.length * 4), + new Float32Array(points.length * 4), + new Uint16Array(points.length * 2), + 5); + + /* + * @member {PIXI.Point[]} An array of points that determine the rope + */ + this.points = points; + this.refresh(); + } + /** + * Refreshes Rope indices and uvs + * @private + */ + _refresh() + { + const points = this.points; + + if (!points) return; + + const vertexBuffer = this.geometry.getAttribute('aVertexPosition'); + const uvBuffer = this.geometry.getAttribute('aTextureCoord'); + const indexBuffer = this.geometry.getIndex(); + + // if too little points, or texture hasn't got UVs set yet just move on. + if (points.length < 1 || !this.texture._uvs) + { + return; + } + + // if the number of points has changed we will need to recreate the arraybuffers + if (vertexBuffer.data.length / 4 !== points.length) + { + vertexBuffer.data = new Float32Array(points.length * 4); + uvBuffer.data = new Float32Array(points.length * 4); + indexBuffer.data = new Uint16Array(points.length * 2); + } + + const uvs = uvBuffer.data; + const indices = indexBuffer.data; + + uvs[0] = 0; + uvs[1] = 0; + uvs[2] = 0; + uvs[3] = 1; + + indices[0] = 0; + indices[1] = 1; + + const total = points.length; + + for (let i = 1; i < total; i++) + { + // time to do some smart drawing! + let index = i * 4; + const amount = i / (total - 1); + + uvs[index] = amount; + uvs[index + 1] = 0; + + uvs[index + 2] = amount; + uvs[index + 3] = 1; + + index = i * 2; + indices[index] = index; + indices[index + 1] = index + 1; + } + + // ensure that the changes are uploaded + uvBuffer.update(); + indexBuffer.update(); + + this.multiplyUvs(); + this.refreshVertices(); + } + + /** + * refreshes vertices of Rope mesh + */ + refreshVertices() + { + const points = this.points; + + if (points.length < 1) + { + return; + } + + let lastPoint = points[0]; + let nextPoint; + let perpX = 0; + let perpY = 0; + + // this.count -= 0.2; + + const vertices = this.vertices; + const total = points.length; + + for (let i = 0; i < total; i++) + { + const point = points[i]; + const index = i * 4; + + if (i < points.length - 1) + { + nextPoint = points[i + 1]; + } + else + { + nextPoint = point; + } + + perpY = -(nextPoint.x - lastPoint.x); + perpX = nextPoint.y - lastPoint.y; + + let ratio = (1 - (i / (total - 1))) * 10; + + if (ratio > 1) + { + ratio = 1; + } + + const perpLength = Math.sqrt((perpX * perpX) + (perpY * perpY)); + const num = this._texture.height / 2; // (20 + Math.abs(Math.sin((i + this.count) * 0.3) * 50) )* ratio; + + perpX /= perpLength; + perpY /= perpLength; + + perpX *= num; + perpY *= num; + + vertices[index] = point.x + perpX; + vertices[index + 1] = point.y + perpY; + vertices[index + 2] = point.x - perpX; + vertices[index + 3] = point.y - perpY; + + lastPoint = point; + } + + this.geometry.buffers[0].update(); + } + + /** + * Updates the object transform for rendering + * + * @private + */ + updateTransform() + { + if (this.autoUpdate) + { + this.refreshVertices(); + } + this.containerUpdateTransform(); + } +} diff --git a/packages/mesh-extras/src/index.js b/packages/mesh-extras/src/index.js new file mode 100644 index 0000000..decf454 --- /dev/null +++ b/packages/mesh-extras/src/index.js @@ -0,0 +1,4 @@ +export { default as Mesh2d } from './Mesh2d'; +export { default as Plane } from './Plane'; +export { default as NineSlicePlane } from './NineSlicePlane'; +export { default as Rope } from './Rope'; diff --git a/packages/mesh-extras/src/mesh.frag b/packages/mesh-extras/src/mesh.frag new file mode 100644 index 0000000..6096983 --- /dev/null +++ b/packages/mesh-extras/src/mesh.frag @@ -0,0 +1,9 @@ +varying vec2 vTextureCoord; +uniform vec4 uColor; + +uniform sampler2D uSampler; + +void main(void) +{ + gl_FragColor = texture2D(uSampler, vTextureCoord) * uColor; +} diff --git a/packages/mesh-extras/src/mesh.vert b/packages/mesh-extras/src/mesh.vert new file mode 100644 index 0000000..0526df9 --- /dev/null +++ b/packages/mesh-extras/src/mesh.vert @@ -0,0 +1,15 @@ +attribute vec2 aVertexPosition; +attribute vec2 aTextureCoord; + +uniform mat3 projectionMatrix; +uniform mat3 translationMatrix; +uniform mat3 uTextureMatrix; + +varying vec2 vTextureCoord; + +void main(void) +{ + gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); + + vTextureCoord = (uTextureMatrix * vec3(aTextureCoord, 1.0)).xy; +} diff --git a/packages/mesh-extras/test/.eslintrc.json b/packages/mesh-extras/test/.eslintrc.json new file mode 100644 index 0000000..2ad8efb --- /dev/null +++ b/packages/mesh-extras/test/.eslintrc.json @@ -0,0 +1,12 @@ +{ + "globals": { + "expect": false, + "assert": false, + "sinon": false, + "PIXI": false + }, + "rules": { + "func-names": 0, + "no-unused-expressions": 0 + } +} \ No newline at end of file diff --git a/packages/mesh-extras/test/Plane.js b/packages/mesh-extras/test/Plane.js new file mode 100644 index 0000000..f9b1c25 --- /dev/null +++ b/packages/mesh-extras/test/Plane.js @@ -0,0 +1,60 @@ +const { Plane } = require('../'); +const { isWebGLSupported, skipHello } = require('@pixi/utils'); +const { Loader } = require('@pixi/loaders'); +const { Point } = require('@pixi/math'); +const { RenderTexture, Texture } = require('@pixi/core'); + +skipHello(); + +function withGL(fn) +{ + return isWebGLSupported() ? fn : undefined; +} + +// TODO: fix with webglrenderer +describe('PIXI.mesh.Plane', function () +{ + it.skip('should create a plane from an external image', withGL(function (done) + { + const loader = new Loader(); + + loader.add('testBitmap', `file://${__dirname}/resources/bitmap-1.png`) + .load(function (loader, resources) + { + const plane = new Plane(resources.testBitmap.texture, 100, 100); + + expect(plane.verticesX).to.equal(100); + expect(plane.verticesY).to.equal(100); + done(); + }); + })); + + it.skip('should create a new empty textured Plane', withGL(function () + { + const plane = new Plane(Texture.EMPTY, 100, 100); + + expect(plane.verticesX).to.equal(100); + expect(plane.verticesY).to.equal(100); + })); + + describe('containsPoint', function () + { + it.skip('should return true when point inside', withGL(function () + { + const point = new Point(10, 10); + const texture = new RenderTexture.create(20, 30); + const plane = new Plane(texture, 100, 100); + + expect(plane.containsPoint(point)).to.be.true; + })); + + it.skip('should return false when point outside', withGL(function () + { + const point = new Point(100, 100); + const texture = new RenderTexture.create(20, 30); + const plane = new Plane(texture, 100, 100); + + expect(plane.containsPoint(point)).to.be.false; + })); + }); +}); diff --git a/packages/mesh-extras/test/index.js b/packages/mesh-extras/test/index.js new file mode 100644 index 0000000..d767624 --- /dev/null +++ b/packages/mesh-extras/test/index.js @@ -0,0 +1 @@ +require('./Plane'); diff --git a/packages/mesh-extras/test/resources/bitmap-1.png b/packages/mesh-extras/test/resources/bitmap-1.png new file mode 100644 index 0000000..1284fb8 --- /dev/null +++ b/packages/mesh-extras/test/resources/bitmap-1.png Binary files differ diff --git a/bundles/pixi.js/package.json b/bundles/pixi.js/package.json index 49c7276..177e059 100644 --- a/bundles/pixi.js/package.json +++ b/bundles/pixi.js/package.json @@ -49,6 +49,7 @@ "@pixi/loaders": "^5.0.0-alpha.2", "@pixi/math": "^5.0.0-alpha.2", "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/mesh-extras": "^5.0.0-alpha.2", "@pixi/mixin-cache-as-bitmap": "^5.0.0-alpha.2", "@pixi/mixin-get-child-by-name": "^5.0.0-alpha.2", "@pixi/mixin-get-global-position": "^5.0.0-alpha.2", diff --git a/bundles/pixi.js/src/deprecated.js b/bundles/pixi.js/src/deprecated.js index 147617c..dbebeb0 100644 --- a/bundles/pixi.js/src/deprecated.js +++ b/bundles/pixi.js/src/deprecated.js @@ -263,15 +263,15 @@ Object.defineProperties(PIXI.mesh, { /** * @class PIXI.mesh.Mesh - * @see PIXI.Mesh + * @see PIXI.Mesh2d * @deprecated since 5.0.0 */ Mesh: { get() { - warn('PIXI.mesh.Mesh has moved to PIXI.Mesh'); + warn('PIXI.mesh.Mesh has moved to PIXI.Mesh2d'); - return PIXI.Mesh; + return PIXI.Mesh2d; }, }, /** @@ -315,15 +315,15 @@ }, /** * @class PIXI.mesh.RawMesh - * @see PIXI.RawMesh + * @see PIXI.Mesh * @deprecated since 5.0.0 */ RawMesh: { get() { - warn('PIXI.mesh.RawMesh has moved to PIXI.RawMesh'); + warn('PIXI.mesh.RawMesh has moved to PIXI.Mesh'); - return PIXI.RawMesh; + return PIXI.Mesh; }, }, /** diff --git a/bundles/pixi.js/src/index.js b/bundles/pixi.js/src/index.js index a3a0d1b..6fdabf0 100644 --- a/bundles/pixi.js/src/index.js +++ b/bundles/pixi.js/src/index.js @@ -9,6 +9,7 @@ import * as loaders from '@pixi/loaders'; import * as math from '@pixi/math'; import * as mesh from '@pixi/mesh'; +import * as meshExtras from '@pixi/mesh-extras'; import * as particles from '@pixi/particles'; import * as prepare from '@pixi/prepare'; import * as sprite from '@pixi/sprite'; @@ -128,6 +129,7 @@ loaders, math, mesh, + meshExtras, particles, sprite, spriteAnimated, @@ -152,6 +154,7 @@ export * from '@pixi/loaders'; export * from '@pixi/math'; export * from '@pixi/mesh'; +export * from '@pixi/mesh-extras'; export * from '@pixi/particles'; export * from '@pixi/sprite'; export * from '@pixi/spritesheet'; diff --git a/package-lock.json b/package-lock.json index 7fe6db7..0814729 100644 --- a/package-lock.json +++ b/package-lock.json @@ -209,7 +209,7 @@ "argparse": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", - "integrity": "sha1-vNZ5HqWuCXJeF+WtmIE0zUCz2RE=", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", "dev": true, "requires": { "sprintf-js": "1.0.3" @@ -228,7 +228,7 @@ "arr-flatten": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz", - "integrity": "sha1-NgSLv/TntH4TZkQxbJlmnqWukfE=", + "integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==", "dev": true }, "arr-union": { @@ -297,7 +297,7 @@ "assertion-error": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", - "integrity": "sha1-5gtrDo8wG9l+U3UhW9pAbIURjAs=", + "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", "dev": true }, "async": { @@ -396,7 +396,7 @@ "brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha1-PH/L9SnYcibz0vUrlm/1Jx60Qd0=", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, "requires": { "balanced-match": "1.0.0", @@ -568,7 +568,7 @@ "circular-json": { "version": "0.3.3", "resolved": "https://registry.npmjs.org/circular-json/-/circular-json-0.3.3.tgz", - "integrity": "sha1-gVyZ6oT2gJUp0vRXkb34JxE1LWY=", + "integrity": "sha512-UZK3NBx2Mca+b5LsG7bY183pHWt5Y1xts4P3Pz7ENTwGVnJOUWbRb3ocjvX7hx9tq/yTAdclXm9sZ38gNuem4A==", "dev": true }, "cli-cursor": { @@ -638,7 +638,7 @@ "color-convert": { "version": "1.9.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.1.tgz", - "integrity": "sha1-wSYRB66y8pTr/+ye2eytUppgl+0=", + "integrity": "sha512-mjGanIiwQJskCC18rPR6OmrZ6fm2Lc7PeGFYwCmy5J34wC6F1PzdGL6xeMfmgicfYcNLGuVFA3WzXtIDCQSZxQ==", "dev": true, "requires": { "color-name": "1.1.3" @@ -1427,7 +1427,7 @@ "boom": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/boom/-/boom-5.2.0.tgz", - "integrity": "sha1-XdnabuOl8wIHdDYpDLcX0/SlTgI=", + "integrity": "sha512-Z5BTk6ZRe4tXXQlkqftmsAUANpXmuwlsF5Oov8ThoMbQRzdGTA1ngYRW160GexgOgjsFOKJz0LYhoNi+2AMBUw==", "dev": true, "requires": { "hoek": "4.2.1" @@ -1471,7 +1471,7 @@ "debug": { "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha1-XRKFFd8TT/Mn6QpMk/Tgd6U2NB8=", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", "dev": true, "requires": { "ms": "2.0.0" @@ -1585,7 +1585,7 @@ "doctrine": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", - "integrity": "sha1-XNAfwQFiG0LEzX9dGmYkNxbT850=", + "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", "dev": true, "requires": { "esutils": "2.0.2" @@ -1662,7 +1662,7 @@ "es6-promise": { "version": "4.2.4", "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.4.tgz", - "integrity": "sha1-3EIhwrFlGHYL2MOaUtjzVvwA7Sk=", + "integrity": "sha512-/NdNZVJg+uZgtm9eS3O6lrOLYmQag2DjdEXuPaHlZ6RuVqgqaVZfgYCepEIKsLqwdQArOPtC3XzRLqGGfT8KQQ==", "dev": true }, "escape-string-regexp": { @@ -1788,7 +1788,7 @@ "espree": { "version": "3.5.4", "resolved": "https://registry.npmjs.org/espree/-/espree-3.5.4.tgz", - "integrity": "sha1-sPRHGHyKi+2US4FaZgvd9d610ac=", + "integrity": "sha512-yAcIQxtmMiB/jL32dzEp2enBeidsB7xWPLNiw3IIkpVds1P+h7qF9YwJq1yUNzp2OKXgAprs4F61ih66UsoD1A==", "dev": true, "requires": { "acorn": "5.5.0", @@ -1798,7 +1798,7 @@ "esprima": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.0.tgz", - "integrity": "sha1-RJnt3NERDgshi6zy+n9/WfVcqAQ=", + "integrity": "sha512-oftTcaMu/EGrEIu904mWteKIv8vMuOgGYo7EhVJJN00R/EED9DCua/xxHRdYnKtcECzVg7xOWhflvJMnqcFZjw==", "dev": true }, "esquery": { @@ -1813,7 +1813,7 @@ "esrecurse": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.2.1.tgz", - "integrity": "sha1-AHo7n9vCs7uH5IeeoZyS/b05Qs8=", + "integrity": "sha512-64RBB++fIOAXPw3P9cy89qfMlvZEXZkqqJkjqqXIvzP5ezRZjW+lPWjw35UX/3EhUPFYbg5ER4JYgDw4007/DQ==", "dev": true, "requires": { "estraverse": "4.2.0" @@ -2024,7 +2024,7 @@ "find-root": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/find-root/-/find-root-1.1.0.tgz", - "integrity": "sha1-q8/Iunb3CMQql7PWhbfpRQv7nOQ=", + "integrity": "sha512-NKfW6bec6GfKc0SGx1e07QZY9PE99u0Bft/0rzSD5k3sO/vwkVUpDUKVm5Gpp5Ue3YfShPFTX2070tDs5kB9Ng==", "dev": true }, "find-up": { @@ -2103,7 +2103,7 @@ "supports-color": { "version": "5.3.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.3.0.tgz", - "integrity": "sha1-WySsFduA+pJ89SJ6SjP9PEx2dsA=", + "integrity": "sha512-0aP01LLIskjKs3lq52EC0aGBAJhLq7B2Rd8HC/DR/PtNNpcLilNmHC12O+hu0usQpo7wtHNRqtrhBwtDb0+dNg==", "dev": true, "requires": { "has-flag": "3.0.0" @@ -2567,7 +2567,7 @@ "glob": { "version": "7.1.2", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", - "integrity": "sha1-wZyd+aAocC1nhhI4SmVSQExjbRU=", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", "dev": true, "requires": { "fs.realpath": "1.0.0", @@ -2672,7 +2672,7 @@ "growl": { "version": "1.10.3", "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.3.tgz", - "integrity": "sha1-GSa6kM8+3+KttJJ/WIC8IsZseQ8=", + "integrity": "sha512-hKlsbA5Vu3xsh1Cg3J7jSmX/WaW6A5oBeqzM88oNbCRQFz+zUaXm6yxS4RVytp1scBoJzSYl4YAEOQIt6O8V1Q==", "dev": true }, "handlebars": { @@ -2738,7 +2738,7 @@ "hawk": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/hawk/-/hawk-6.0.2.tgz", - "integrity": "sha1-r02RTrBl+bXOTZ0RwcshJu7MMDg=", + "integrity": "sha512-miowhl2+U7Qle4vdLqDdPt9m09K6yZhkLDTWGoUiUzrQCn+mHHSmfJgAyGaLRZbPmTqfFFjRV1QWCW0VWUJBbQ==", "dev": true, "requires": { "boom": "4.3.1", @@ -2756,7 +2756,7 @@ "hoek": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/hoek/-/hoek-4.2.1.tgz", - "integrity": "sha1-ljRQKqEsRF3Vp8VzS1cruHOKrLs=", + "integrity": "sha512-QLg82fGkfnJ/4iy1xZ81/9SIJiq1NGFUMGs6ParyjBZr6jW2Ufj/snDqTHixNlHdPNwN2RLVD0Pi3igeK9+JfA==", "dev": true }, "home-path": { @@ -2791,7 +2791,7 @@ "ignore": { "version": "3.3.7", "resolved": "https://registry.npmjs.org/ignore/-/ignore-3.3.7.tgz", - "integrity": "sha1-YSKJv7PCIOGGpYEYYY1b6MG6sCE=", + "integrity": "sha512-YGG3ejvBNHRqu0559EOxxNFihD0AjpvHlC/pdGKd3X3ofe+CoJkYazwNJYTNebqpPKN+VVQbh4ZFn1DivMNuHA==", "dev": true }, "imurmurhash": { @@ -2828,7 +2828,7 @@ "ini": { "version": "1.3.5", "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", - "integrity": "sha1-7uJfVtscnsYIXgwid4CD9Zar+Sc=", + "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==", "dev": true }, "inquirer": { @@ -2901,7 +2901,7 @@ "is-buffer": { "version": "1.1.6", "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", - "integrity": "sha1-76ouqdqg16suoTqXsritUf776L4=", + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", "dev": true }, "is-builtin-module": { @@ -3054,7 +3054,7 @@ "is-resolvable": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/is-resolvable/-/is-resolvable-1.1.0.tgz", - "integrity": "sha1-+xj4fOH+uSUWnJpAfBkxijIG7Yg=", + "integrity": "sha512-qgDYXFSR5WvEfuS5dMj6oTMEbrrSaM0CrFk2Yiq/gXnBvD9pMa2jGXxyhGLfvhZpuMZe18CJpFxAt3CRs42NMg==", "dev": true }, "is-retry-allowed": { @@ -3204,7 +3204,7 @@ "js-yaml": { "version": "3.11.0", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.11.0.tgz", - "integrity": "sha1-WXwai9VxUvJtYizkEXhRpR9euu8=", + "integrity": "sha512-saJstZWv7oNeOyBh3+Dx1qWzhW0+e6/8eDzo7p5rDFqxntSztloLtuKu+Ejhtq82jsilwOIZYsCz+lIjthg1Hw==", "dev": true, "requires": { "argparse": "1.0.10", @@ -3324,7 +3324,7 @@ "just-extend": { "version": "1.1.27", "resolved": "https://registry.npmjs.org/just-extend/-/just-extend-1.1.27.tgz", - "integrity": "sha1-7G55QQ/5FORyZSq/oOYDwD1g6QU=", + "integrity": "sha512-mJVp13Ix6gFo3SBAy9U/kL+oeZqzlYYYLQBwXVBlVzIsZwBqGREnOro24oC/8s8aox+rJhtZ2DiQof++IrkA+g==", "dev": true }, "kind-of": { @@ -3703,7 +3703,7 @@ "lodash": { "version": "4.17.5", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.5.tgz", - "integrity": "sha1-maktZcAnLevoyWtgV7yPv6O+1RE=", + "integrity": "sha512-svL3uiZf1RwhH+cWrfZn3A4+U58wbP0tGVTLQPbjplZxZ8ROD9VLuNgsRniTlLe7OlSqR79RUehXgpBW/s0IQw==", "dev": true }, "lodash._reinterpolate": { @@ -3740,7 +3740,7 @@ "lolex": { "version": "2.3.2", "resolved": "https://registry.npmjs.org/lolex/-/lolex-2.3.2.tgz", - "integrity": "sha1-hflFBCUQO/nnpgZo6iXcQydMqAc=", + "integrity": "sha512-A5pN2tkFj7H0dGIAM6MFvHKMJcPnjZsOMvR7ujCjfgW5TbV6H9vb1PgxLtHvjqNZTHsUolz+6/WEO0N1xNx2ng==", "dev": true }, "longest": { @@ -3816,7 +3816,7 @@ "marked": { "version": "0.3.17", "resolved": "https://registry.npmjs.org/marked/-/marked-0.3.17.tgz", - "integrity": "sha1-YH8GZos8axJGso8T2nYRasGqLSs=", + "integrity": "sha512-+AKbNsjZl6jFfLPwHhWmGTqE009wTKn3RTmn9K8oUKHrX/abPJjtcRtXpYB/FFrwPJRUA86LX/de3T0knkPCmQ==", "dev": true }, "mem": { @@ -3896,13 +3896,13 @@ "mime-db": { "version": "1.33.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.33.0.tgz", - "integrity": "sha1-o0kgUKXLm2NFBUHjnZeI0icng9s=", + "integrity": "sha512-BHJ/EKruNIqJf/QahvxwQZXKygOQ256myeN/Ew+THcAa5q+PjyTTMMeNQC4DZw5AwfvelsUrA6B67NKMqXDbzQ==", "dev": true }, "mime-types": { "version": "2.1.18", "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.18.tgz", - "integrity": "sha1-bzI/YKg9ERRvgx/xH9ZuL+VQO7g=", + "integrity": "sha512-lc/aahn+t4/SWV/qcmumYjymLsWfN3ELhpmVuUFjgsORruuZPVSwAQryq+HHGvO/SI2KVX26bx+En+zhM8g8hQ==", "dev": true, "requires": { "mime-db": "1.33.0" @@ -3917,7 +3917,7 @@ "minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha1-UWbihkV/AzBgZL5Ul+jbsMPTIIM=", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "dev": true, "requires": { "brace-expansion": "1.1.11" @@ -4071,7 +4071,7 @@ "normalize-package-data": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.4.0.tgz", - "integrity": "sha1-EvlaMH1YNSB1oEkHuErIvpisAS8=", + "integrity": "sha512-9jjUFbTPfEy3R/ad/2oNbKtW9Hgovl5O1FvFWKkKblNXoN/Oou6+9+KKohPK13Yc3/TyunyWhJp6gvRNR/PPAw==", "dev": true, "requires": { "hosted-git-info": "2.5.0", @@ -4511,7 +4511,7 @@ "process-nextick-args": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", - "integrity": "sha1-o31zL0JxtKsa0HDTVQjoKQeI/6o=", + "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==", "dev": true }, "progress": { @@ -4584,7 +4584,7 @@ "qs": { "version": "6.5.1", "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.1.tgz", - "integrity": "sha1-NJzfbu+J7EXBLX1es/wMhwNDptg=", + "integrity": "sha512-eRzhrN1WSINYCDCbrz796z37LOe3m5tmW7RQf6oBntukAG1nmovJvhnwHHRMAfeoItc1m2Hk02WER2aQ/iqs+A==", "dev": true }, "quick-lru": { @@ -4596,7 +4596,7 @@ "randomatic": { "version": "1.1.7", "resolved": "https://registry.npmjs.org/randomatic/-/randomatic-1.1.7.tgz", - "integrity": "sha1-x6vpzIuHwLqodrGf3oP9RkeX44w=", + "integrity": "sha512-D5JUjPyJbaJDkuAazpVnSfVkLlpeO3wDlPROTMLGKG1zMFNFRgrciKo1ltz/AzNTkqE0HzDx655QOL51N06how==", "dev": true, "requires": { "is-number": "3.0.0", @@ -4701,7 +4701,7 @@ "regex-cache": { "version": "0.4.4", "resolved": "https://registry.npmjs.org/regex-cache/-/regex-cache-0.4.4.tgz", - "integrity": "sha1-db3FiioUls7EihKDW8VMjVYjNt0=", + "integrity": "sha512-nVIZwtCjkC9YgvWkpM55B5rBhBYRZhAaJbgcFYXXsHnbZ9UZI9nnVWYZpBlCqv9ho2eZryPnWrZGsOdPwVWXWQ==", "dev": true, "requires": { "is-equal-shallow": "0.1.3" @@ -4729,7 +4729,7 @@ "remap-istanbul": { "version": "0.10.1", "resolved": "https://registry.npmjs.org/remap-istanbul/-/remap-istanbul-0.10.1.tgz", - "integrity": "sha1-OqWN1QIdSZ8zbTulvzu7kcG4jjc=", + "integrity": "sha512-gsNQXs5kJLhErICSyYhzVZ++C8LBW8dgwr874Y2QvzAUS75zBlD/juZgXs39nbYJ09fZDlX2AVLVJAY2jbFJoQ==", "dev": true, "requires": { "amdefine": "1.0.1", @@ -4769,7 +4769,7 @@ "source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha1-dHIq8y6WFOnCh6jQu95IteLxomM=", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", "dev": true }, "through2": { @@ -4883,7 +4883,7 @@ "resolve": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.5.0.tgz", - "integrity": "sha1-HwmsznlsmnYlefMbLBzEw83fnzY=", + "integrity": "sha512-hgoSGrc3pjzAPHNBg+KnFcK2HwlHTs/YrAGUr6qgTVUZmXv1UEXXl0bZNBKMA9fud6lRYFdPGz0xXxycPzmmiw==", "dev": true, "requires": { "path-parse": "1.0.5" @@ -4924,7 +4924,7 @@ "rimraf": { "version": "2.6.2", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", - "integrity": "sha1-LtgVDSShbqhlHm1u8PR8QVjOejY=", + "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", "dev": true, "requires": { "glob": "7.1.2" @@ -5063,19 +5063,19 @@ "safe-buffer": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", - "integrity": "sha1-iTMSr2myEj3vcfV4iQAWce6yyFM=", + "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", "dev": true }, "samsam": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/samsam/-/samsam-1.3.0.tgz", - "integrity": "sha1-jR2TUOJWItow3j5EumkrUiGrfFA=", + "integrity": "sha512-1HwIYD/8UlOtFS3QO3w7ey+SdSDFE4HRNLZoZRYVQefrOY3l17epswImeB1ijgJFQJodIaHcwkp3r/myBjFVbg==", "dev": true }, "semver": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz", - "integrity": "sha1-3Eu8emyp2Rbe5dQ1FvAJK1j3uKs=", + "integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==", "dev": true }, "set-blocking": { @@ -5117,7 +5117,7 @@ "sinon-chai": { "version": "2.14.0", "resolved": "https://registry.npmjs.org/sinon-chai/-/sinon-chai-2.14.0.tgz", - "integrity": "sha1-2n3UzIPNaiYLZ8yg96n9riahIF0=", + "integrity": "sha512-9stIF1utB0ywNHNT7RgiXbdmen8QDCRsrTjw+G9TgKt1Yexjiv8TOWZ6WHsTPz57Yky3DIswZvEqX8fpuHNDtQ==", "dev": true }, "slash": { @@ -5146,7 +5146,7 @@ "sntp": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/sntp/-/sntp-2.1.0.tgz", - "integrity": "sha1-LGzsFP7cIiJznK+bXD2F0cxaLMg=", + "integrity": "sha512-FL1b58BDrqS3A11lJ0zEdnJ3UOKqVxawAkF3k7F0CVN7VQ34aZrV+G8BZ1WC9ZL7NyrwsW0oviwsWDgRuVYtJg==", "dev": true, "requires": { "hoek": "4.2.1" @@ -5203,7 +5203,7 @@ "spdx-correct": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.0.0.tgz", - "integrity": "sha1-BaW01xU6GVvJLDxCW2nzsqlSTII=", + "integrity": "sha512-N19o9z5cEyc8yQQPukRCZ9EUmb4HUpnrmaL/fxS2pBo2jbfcFRVuFZ/oFC+vZz0MNNk0h80iMn5/S6qGZOL5+g==", "dev": true, "requires": { "spdx-expression-parse": "3.0.0", @@ -5213,13 +5213,13 @@ "spdx-exceptions": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.1.0.tgz", - "integrity": "sha1-LHrmEFbHFKW5ubKyr30xHvXHj+k=", + "integrity": "sha512-4K1NsmrlCU1JJgUrtgEeTVyfx8VaYea9J9LvARxhbHtVtohPs/gFGG5yy49beySjlIMhhXZ4QqujIZEfS4l6Cg==", "dev": true }, "spdx-expression-parse": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.0.tgz", - "integrity": "sha1-meEZt6XaAOBUkcn6M4t5BII7QdA=", + "integrity": "sha512-Yg6D3XpRD4kkOmTpdgbUiEJFKghJH03fiC1OPll5h/0sO6neh2jqRDVHOQ4o/LMea0tgCkbMgea5ip/e+MkWyg==", "dev": true, "requires": { "spdx-exceptions": "2.1.0", @@ -5229,7 +5229,7 @@ "spdx-license-ids": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.0.tgz", - "integrity": "sha1-enzShHDMbToc/m1miG9rxDDTrIc=", + "integrity": "sha512-2+EPwgbnmOIl8HjGBXXMd9NAu02vLjOO1nWw4kmeRDFyHn+M/ETfHxQUK0oXg8ctgVnl9t3rosNVsZ1jG61nDA==", "dev": true }, "speedometer": { @@ -5566,7 +5566,7 @@ "tough-cookie": { "version": "2.3.4", "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.4.tgz", - "integrity": "sha1-7GDO44rGdQY//JelwYlwV47oNlU=", + "integrity": "sha512-TZ6TTfI5NtZnuyy/Kecv+CnoROnyXn2DN97LontgQpCwsX2XyLYCC0ENhYkehSOwAp8rTQKc/NUIF7BkQ5rKLA==", "dev": true, "requires": { "punycode": "1.4.1" @@ -5708,13 +5708,13 @@ "uuid": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.2.1.tgz", - "integrity": "sha1-EsUou51Y0LkmXZovbw/ovhf/HxQ=", + "integrity": "sha512-jZnMwlb9Iku/O3smGWvZhauCf6cvvpKi4BKRiliS3cxnI+Gz9j5MEpTz2UFuXiKPJocb7gnsLHwiS05ige5BEA==", "dev": true }, "validate-npm-package-license": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.3.tgz", - "integrity": "sha1-gWQ7y+8b3+zUYjeT3EZIlIupgzg=", + "integrity": "sha512-63ZOUnL4SIXj4L0NixR3L1lcjO38crAbgrTpl28t8jjrfuiOBL5Iygm+60qPs/KsZGzPNg6Smnc/oY16QTjF0g==", "dev": true, "requires": { "spdx-correct": "3.0.0", @@ -5750,7 +5750,7 @@ "which": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/which/-/which-1.3.0.tgz", - "integrity": "sha1-/wS9/AEO5UfXgL7DjhrBwnd9JTo=", + "integrity": "sha512-xcJpopdamTuY5duC/KnTTNBraPK54YwpenP4lzxU8H91GudWpFv38u0CKjclE1Wi2EH2EDz5LRcHcKbCIzqGyg==", "dev": true, "requires": { "isexe": "2.0.0" diff --git a/packages/canvas/canvas-mesh/package.json b/packages/canvas/canvas-mesh/package.json index 691cd2c..6744a17 100644 --- a/packages/canvas/canvas-mesh/package.json +++ b/packages/canvas/canvas-mesh/package.json @@ -24,6 +24,7 @@ "dependencies": { "@pixi/constants": "^5.0.0-alpha.2", "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/mesh-extras": "^5.0.0-alpha.2", "@pixi/settings": "^5.0.0-alpha.2" }, "devDependencies": { diff --git a/packages/canvas/canvas-mesh/src/Mesh.js b/packages/canvas/canvas-mesh/src/Mesh.js index 900a872..c43a74b 100644 --- a/packages/canvas/canvas-mesh/src/Mesh.js +++ b/packages/canvas/canvas-mesh/src/Mesh.js @@ -1,36 +1,14 @@ import { Mesh } from '@pixi/mesh'; -import { settings } from './settings'; - -// IMPORTANT: Please do NOT use this as a precedent to use `settings` after the object is created -// this was merely created to completely decouple canvas from the base Mesh class and we are -// unable to add `canvasPadding` in the constructor anymore, as the case was for PixiJS v4. /** - * Internal variable for `canvasPadding`. + * Renders the object using the Canvas renderer * * @private - * @memberof PIXI.Mesh - * @member {number} - * @default null - */ -Mesh.prototype._canvasPadding = null; - -/** - * Triangles in canvas mode are automatically antialiased, use this value to force triangles - * to overlap a bit with each other. To set the global default, set {@link PIXI.settings.MESH_CANVAS_PADDING} - * - * @see PIXI.settings.MESH_CANVAS_PADDING - * @member {number} canvasPadding + * @method _renderCanvas * @memberof PIXI.Mesh# - * @default 0 + * @param {PIXI.CanvasRenderer} renderer - The canvas renderer. */ -Object.defineProperty(Mesh.prototype, 'canvasPadding', { - get() - { - return this._canvasPadding !== null ? this._canvasPadding : settings.MESH_CANVAS_PADDING; - }, - set(value) - { - this._canvasPadding = value; - }, -}); +Mesh.prototype._renderCanvas = function _renderCanvas(renderer) +{ + renderer.plugins[this.pluginName].render(this); +}; diff --git a/packages/canvas/canvas-mesh/src/Mesh2d.js b/packages/canvas/canvas-mesh/src/Mesh2d.js new file mode 100644 index 0000000..d0bd80f --- /dev/null +++ b/packages/canvas/canvas-mesh/src/Mesh2d.js @@ -0,0 +1,36 @@ +import { Mesh2d } from '@pixi/mesh-extras'; +import { settings } from './settings'; + +// IMPORTANT: Please do NOT use this as a precedent to use `settings` after the object is created +// this was merely created to completely decouple canvas from the base Mesh class and we are +// unable to add `canvasPadding` in the constructor anymore, as the case was for PixiJS v4. + +/** + * Internal variable for `canvasPadding`. + * + * @private + * @memberof PIXI.Mesh2d + * @member {number} + * @default null + */ +Mesh2d.prototype._canvasPadding = null; + +/** + * Triangles in canvas mode are automatically antialiased, use this value to force triangles + * to overlap a bit with each other. To set the global default, set {@link PIXI.settings.MESH_CANVAS_PADDING} + * + * @see PIXI.settings.MESH_CANVAS_PADDING + * @member {number} canvasPadding + * @memberof PIXI.Mesh2d# + * @default 0 + */ +Object.defineProperty(Mesh2d.prototype, 'canvasPadding', { + get() + { + return this._canvasPadding !== null ? this._canvasPadding : settings.MESH_CANVAS_PADDING; + }, + set(value) + { + this._canvasPadding = value; + }, +}); diff --git a/packages/canvas/canvas-mesh/src/NineSlicePlane.js b/packages/canvas/canvas-mesh/src/NineSlicePlane.js index 09eaf9c..2fd5acc 100644 --- a/packages/canvas/canvas-mesh/src/NineSlicePlane.js +++ b/packages/canvas/canvas-mesh/src/NineSlicePlane.js @@ -1,4 +1,4 @@ -import { NineSlicePlane } from '@pixi/mesh'; +import { NineSlicePlane } from '@pixi/mesh-extras'; /** * Renders the object using the Canvas renderer diff --git a/packages/canvas/canvas-mesh/src/RawMesh.js b/packages/canvas/canvas-mesh/src/RawMesh.js deleted file mode 100644 index bf40184..0000000 --- a/packages/canvas/canvas-mesh/src/RawMesh.js +++ /dev/null @@ -1,14 +0,0 @@ -import { RawMesh } from '@pixi/mesh'; - -/** - * Renders the object using the Canvas renderer - * - * @private - * @method _renderCanvas - * @memberof PIXI.RawMesh# - * @param {PIXI.CanvasRenderer} renderer - The canvas renderer. - */ -RawMesh.prototype._renderCanvas = function _renderCanvas(renderer) -{ - renderer.plugins[this.pluginName].render(this); -}; diff --git a/packages/canvas/canvas-mesh/src/index.js b/packages/canvas/canvas-mesh/src/index.js index 2295016..f4fa31d 100644 --- a/packages/canvas/canvas-mesh/src/index.js +++ b/packages/canvas/canvas-mesh/src/index.js @@ -1,6 +1,6 @@ export { default as CanvasMeshRenderer } from './CanvasMeshRenderer'; import './settings'; -import './Mesh'; +import './Mesh2d'; import './NineSlicePlane'; -import './RawMesh'; +import './Mesh'; diff --git a/packages/canvas/canvas-mesh/src/settings.js b/packages/canvas/canvas-mesh/src/settings.js index 4cefb4c..e81b8e0 100644 --- a/packages/canvas/canvas-mesh/src/settings.js +++ b/packages/canvas/canvas-mesh/src/settings.js @@ -3,7 +3,7 @@ /** * Default `canvasPadding` for canvas-based Mesh rendering. * - * @see PIXI.Mesh#canvasPadding + * @see PIXI.Mesh2d#canvasPadding * @static * @constant * @memberof PIXI.settings diff --git a/packages/mesh-extras/LICENSE b/packages/mesh-extras/LICENSE new file mode 100644 index 0000000..148e3eb --- /dev/null +++ b/packages/mesh-extras/LICENSE @@ -0,0 +1,21 @@ +The MIT License + +Copyright (c) 2013-2018 Mathew Groves, Chad Engler + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/packages/mesh-extras/README.md b/packages/mesh-extras/README.md new file mode 100644 index 0000000..1d9b0e1 --- /dev/null +++ b/packages/mesh-extras/README.md @@ -0,0 +1,19 @@ +# @pixi/mesh-extras + +## Installation + +```bash +npm install @pixi/mesh-extras +``` + +## Usage + +```js +import { MeshRenderer } from '@pixi/mesh'; +import { Renderer } from '@pixi/core'; +import { Rope } from '@pixi/mesh-extras'; + +Renderer.registerPlugin('mesh', MeshRenderer); + +const rope = new Rope(); +``` \ No newline at end of file diff --git a/packages/mesh-extras/package.json b/packages/mesh-extras/package.json new file mode 100644 index 0000000..d134f64 --- /dev/null +++ b/packages/mesh-extras/package.json @@ -0,0 +1,38 @@ +{ + "name": "@pixi/mesh-extras", + "version": "5.0.0-alpha.2", + "main": "lib/mesh-extras.js", + "module": "lib/mesh-extras.es.js", + "description": "Custom Mesh display objects, like Rope and Plane", + "author": "Mat Groves", + "contributors": [ + "Matt Karl " + ], + "homepage": "http://pixijs.com/", + "bugs": "https://github.com/pixijs/pixi.js/issues", + "license": "MIT", + "repository": { + "type": "git", + "url": "https://github.com/pixijs/pixi.js.git" + }, + "publishConfig": { + "access": "public" + }, + "scripts": { + "test": "floss --path test" + }, + "files": [ + "lib" + ], + "dependencies": { + "@pixi/constants": "^5.0.0-alpha.2", + "@pixi/core": "^5.0.0-alpha.2", + "@pixi/math": "^5.0.0-alpha.2", + "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/utils": "^5.0.0-alpha.2" + }, + "devDependencies": { + "@pixi/loaders": "^5.0.0-alpha.2", + "floss": "^2.1.3" + } +} diff --git a/packages/mesh-extras/src/Mesh2d.js b/packages/mesh-extras/src/Mesh2d.js new file mode 100644 index 0000000..d113a5e --- /dev/null +++ b/packages/mesh-extras/src/Mesh2d.js @@ -0,0 +1,263 @@ +import { Mesh } from '@pixi/mesh'; +import { Geometry, Program, Shader, Texture, TextureMatrix } from '@pixi/core'; +import { Matrix } from '@pixi/math'; +import { BLEND_MODES } from '@pixi/constants'; +import { hex2rgb, premultiplyRgba } from '@pixi/utils'; +import vertex from './mesh.vert'; +import fragment from './mesh.frag'; + +let meshProgram; + +/** + * Base mesh class + * @class + * @extends PIXI.Container + * @memberof PIXI + */ +export default class Mesh2d extends Mesh +{ + /** + * @param {PIXI.Texture} [texture=Texture.EMPTY] - The texture to use + * @param {Float32Array} [vertices] - if you want to specify the vertices + * @param {Float32Array} [uvs] - if you want to specify the uvs + * @param {Uint16Array} [indices] - if you want to specify the indices + * @param {number} [drawMode] - the drawMode, can be any of the Mesh.DRAW_MODES consts + */ + constructor(texture = Texture.EMPTY, vertices, uvs, indices, drawMode) + { + const geometry = new Geometry(); + + if (!meshProgram) + { + meshProgram = new Program(vertex, fragment); + } + + geometry.addAttribute('aVertexPosition', vertices) + .addAttribute('aTextureCoord', uvs) + .addIndex(indices); + + geometry.getAttribute('aVertexPosition').static = false; + + const uniforms = { + uSampler: texture, + uTextureMatrix: Matrix.IDENTITY, + alpha: 1, + uColor: new Float32Array([1, 1, 1, 1]), + }; + + super(geometry, new Shader(meshProgram, uniforms), null, drawMode); + + /** + * The Uvs of the Mesh + * + * @member {Float32Array} + */ + this.uvs = geometry.getAttribute('aTextureCoord').data; + + /** + * An array of vertices + * + * @member {Float32Array} + */ + this.vertices = geometry.getAttribute('aVertexPosition').data; + + this.uniforms = uniforms; + + /** + * The texture of the Mesh + * + * @member {PIXI.Texture} + * @default PIXI.Texture.EMPTY + * @private + */ + this.texture = texture; + + /** + * The tint applied to the mesh. This is a [r,g,b] value. A value of [1,1,1] will remove any + * tint effect. + * + * @member {number} + * @private + */ + this._tintRGB = new Float32Array([1, 1, 1]); + + // Set default tint + this.tint = 0xFFFFFF; + + this.blendMode = BLEND_MODES.NORMAL; + + /** + * TextureMatrix instance for this Mesh, used to track Texture changes + * + * @member {PIXI.TextureMatrix} + * @readonly + */ + this.uvMatrix = new TextureMatrix(this._texture); + + /** + * whether or not upload uvMatrix to shader + * if its false, then uvs should be pre-multiplied + * if you change it for generated mesh, please call 'refresh(true)' + * @member {boolean} + * @default false + */ + this.uploadUvMatrix = false; + + /** + * Uploads vertices buffer every frame, like in PixiJS V3 and V4. + * + * @member {boolean} + * @default true + */ + this.autoUpdate = true; + } + + /** + * The tint applied to the Rope. This is a hex value. A value of + * 0xFFFFFF will remove any tint effect. + * + * @member {number} + * @memberof PIXI.Sprite# + * @default 0xFFFFFF + */ + get tint() + { + return this._tint; + } + + /** + * Sets the tint of the rope. + * + * @param {number} value - The value to set to. + */ + set tint(value) + { + this._tint = value; + + hex2rgb(this._tint, this._tintRGB); + } + + /** + * The blend mode to be applied to the sprite. Set to `PIXI.BLEND_MODES.NORMAL` to remove any blend mode. + * + * @member {number} + * @default PIXI.BLEND_MODES.NORMAL + * @see PIXI.BLEND_MODES + */ + get blendMode() + { + return this.state.blendMode; + } + + set blendMode(value) // eslint-disable-line require-jsdoc + { + this.state.blendMode = value; + } + + /** + * The texture that the mesh uses. + * + * @member {PIXI.Texture} + */ + get texture() + { + return this._texture; + } + + set texture(value) // eslint-disable-line require-jsdoc + { + if (this._texture === value) + { + return; + } + + this._texture = value; + this.uniforms.uSampler = this.texture; + + if (value) + { + // wait for the texture to load + if (value.baseTexture.valid) + { + this._onTextureUpdate(); + } + else + { + value.once('update', this._onTextureUpdate, this); + } + } + } + + _render(renderer) + { + const baseTex = this._texture.baseTexture; + + premultiplyRgba(this._tintRGB, this.worldAlpha, this.uniforms.uColor, baseTex.premultiplyAlpha); + super._render(renderer); + } + /** + * When the texture is updated, this event will fire to update the scale and frame + * + * @private + */ + _onTextureUpdate() + { + // constructor texture update stop + if (!this.uvMatrix) + { + return; + } + this.uvMatrix.texture = this._texture; + this.refresh(); + } + + /** + * multiplies uvs only if uploadUvMatrix is false + * call it after you change uvs manually + * make sure that texture is valid + */ + multiplyUvs() + { + if (!this.uploadUvMatrix) + { + this.uvMatrix.multiplyUvs(this.uvs); + } + } + + /** + * Refreshes uvs for generated meshes (rope, plane) + * sometimes refreshes vertices too + * + * @param {boolean} [forceUpdate=false] if true, matrices will be updated any case + */ + refresh(forceUpdate) + { + if (this.uvMatrix.update(forceUpdate)) + { + this._refresh(); + } + } + + /** + * Updates the object transform for rendering + * + * @private + */ + updateTransform() + { + if (this.autoUpdate) + { + this.geometry.buffers[0].update(); + } + this.containerUpdateTransform(); + } + + /** + * re-calculates mesh coords + * @private + */ + _refresh() + { + /* empty */ + } +} diff --git a/packages/mesh-extras/src/NineSlicePlane.js b/packages/mesh-extras/src/NineSlicePlane.js new file mode 100644 index 0000000..0bae92c --- /dev/null +++ b/packages/mesh-extras/src/NineSlicePlane.js @@ -0,0 +1,270 @@ +import Plane from './Plane'; + +const DEFAULT_BORDER_SIZE = 10; + +/** + * The NineSlicePlane allows you to stretch a texture using 9-slice scaling. The corners will remain unscaled (useful + * for buttons with rounded corners for example) and the other areas will be scaled horizontally and or vertically + * + *```js + * let Plane9 = new PIXI.NineSlicePlane(PIXI.Texture.from('BoxWithRoundedCorners.png'), 15, 15, 15, 15); + * ``` + *
+ *      A                          B
+ *    +---+----------------------+---+
+ *  C | 1 |          2           | 3 |
+ *    +---+----------------------+---+
+ *    |   |                      |   |
+ *    | 4 |          5           | 6 |
+ *    |   |                      |   |
+ *    +---+----------------------+---+
+ *  D | 7 |          8           | 9 |
+ *    +---+----------------------+---+
+
+ *  When changing this objects width and/or height:
+ *     areas 1 3 7 and 9 will remain unscaled.
+ *     areas 2 and 8 will be stretched horizontally
+ *     areas 4 and 6 will be stretched vertically
+ *     area 5 will be stretched both horizontally and vertically
+ * 
+ * + * @class + * @extends PIXI.Plane + * @memberof PIXI + * + */ +export default class NineSlicePlane extends Plane +{ + /** + * @param {PIXI.Texture} texture - The texture to use on the NineSlicePlane. + * @param {int} [leftWidth=10] size of the left vertical bar (A) + * @param {int} [topHeight=10] size of the top horizontal bar (C) + * @param {int} [rightWidth=10] size of the right vertical bar (B) + * @param {int} [bottomHeight=10] size of the bottom horizontal bar (D) + */ + constructor(texture, leftWidth, topHeight, rightWidth, bottomHeight) + { + super(texture, 4, 4); + + this._origWidth = texture.orig.width; + this._origHeight = texture.orig.height; + + /** + * The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._width = this._origWidth; + + /** + * The height of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._height = this._origHeight; + + /** + * The width of the left column (a) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._leftWidth = typeof leftWidth !== 'undefined' ? leftWidth : DEFAULT_BORDER_SIZE; + + /** + * The width of the right column (b) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._rightWidth = typeof rightWidth !== 'undefined' ? rightWidth : DEFAULT_BORDER_SIZE; + + /** + * The height of the top row (c) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._topHeight = typeof topHeight !== 'undefined' ? topHeight : DEFAULT_BORDER_SIZE; + + /** + * The height of the bottom row (d) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._bottomHeight = typeof bottomHeight !== 'undefined' ? bottomHeight : DEFAULT_BORDER_SIZE; + + this.refresh(true); + } + + /** + * Updates the horizontal vertices. + * + */ + updateHorizontalVertices() + { + const vertices = this.vertices; + + const h = this._topHeight + this._bottomHeight; + const scale = this._height > h ? 1.0 : this._height / h; + + vertices[9] = vertices[11] = vertices[13] = vertices[15] = this._topHeight * scale; + vertices[17] = vertices[19] = vertices[21] = vertices[23] = this._height - (this._bottomHeight * scale); + vertices[25] = vertices[27] = vertices[29] = vertices[31] = this._height; + } + + /** + * Updates the vertical vertices. + * + */ + updateVerticalVertices() + { + const vertices = this.vertices; + + const w = this._leftWidth + this._rightWidth; + const scale = this._width > w ? 1.0 : this._width / w; + + vertices[2] = vertices[10] = vertices[18] = vertices[26] = this._leftWidth * scale; + vertices[4] = vertices[12] = vertices[20] = vertices[28] = this._width - (this._rightWidth * scale); + vertices[6] = vertices[14] = vertices[22] = vertices[30] = this._width; + } + + /** + * The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + */ + get width() + { + return this._width; + } + + set width(value) // eslint-disable-line require-jsdoc + { + this._width = value; + this._refresh(); + } + + /** + * The height of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + */ + get height() + { + return this._height; + } + + set height(value) // eslint-disable-line require-jsdoc + { + this._height = value; + this._refresh(); + } + + /** + * The width of the left column + * + * @member {number} + */ + get leftWidth() + { + return this._leftWidth; + } + + set leftWidth(value) // eslint-disable-line require-jsdoc + { + this._leftWidth = value; + this._refresh(); + } + + /** + * The width of the right column + * + * @member {number} + */ + get rightWidth() + { + return this._rightWidth; + } + + set rightWidth(value) // eslint-disable-line require-jsdoc + { + this._rightWidth = value; + this._refresh(); + } + + /** + * The height of the top row + * + * @member {number} + */ + get topHeight() + { + return this._topHeight; + } + + set topHeight(value) // eslint-disable-line require-jsdoc + { + this._topHeight = value; + this._refresh(); + } + + /** + * The height of the bottom row + * + * @member {number} + */ + get bottomHeight() + { + return this._bottomHeight; + } + + set bottomHeight(value) // eslint-disable-line require-jsdoc + { + this._bottomHeight = value; + this._refresh(); + } + + /** + * Refreshes NineSlicePlane coords. All of them. + */ + _refresh() + { + super._refresh(); + + const uvs = this.uvs; + const texture = this._texture; + + this._origWidth = texture.orig.width; + this._origHeight = texture.orig.height; + + const _uvw = 1.0 / this._origWidth; + const _uvh = 1.0 / this._origHeight; + + uvs[0] = uvs[8] = uvs[16] = uvs[24] = 0; + uvs[1] = uvs[3] = uvs[5] = uvs[7] = 0; + uvs[6] = uvs[14] = uvs[22] = uvs[30] = 1; + uvs[25] = uvs[27] = uvs[29] = uvs[31] = 1; + + uvs[2] = uvs[10] = uvs[18] = uvs[26] = _uvw * this._leftWidth; + uvs[4] = uvs[12] = uvs[20] = uvs[28] = 1 - (_uvw * this._rightWidth); + uvs[9] = uvs[11] = uvs[13] = uvs[15] = _uvh * this._topHeight; + uvs[17] = uvs[19] = uvs[21] = uvs[23] = 1 - (_uvh * this._bottomHeight); + + this.updateHorizontalVertices(); + this.updateVerticalVertices(); + + this.geometry.buffers[1].update(); + + this.multiplyUvs(); + } +} diff --git a/packages/mesh-extras/src/Plane.js b/packages/mesh-extras/src/Plane.js new file mode 100644 index 0000000..1c240c4 --- /dev/null +++ b/packages/mesh-extras/src/Plane.js @@ -0,0 +1,100 @@ +import Mesh2d from './Mesh2d'; + +/** + * The Plane allows you to draw a texture across several points and them manipulate these points + * + *```js + * for (let i = 0; i < 20; i++) { + * points.push(new PIXI.Point(i * 50, 0)); + * }; + * let Plane = new PIXI.Plane(PIXI.Texture.from("snake.png"), points); + * ``` + * + * @class + * @extends PIXI.Mesh + * @memberof PIXI + * + */ +export default class Plane extends Mesh2d +{ + /** + * @param {PIXI.Texture} texture - The texture to use on the Plane. + * @param {number} verticesX - The number of vertices in the x-axis + * @param {number} verticesY - The number of vertices in the y-axis + * @param {object} [opts] - an options object - add meshWidth and meshHeight, temporary object for PixiJS v5 alpha + */ + constructor(texture, verticesX, verticesY, opts = {}) + { + super(texture, new Float32Array(1), new Float32Array(1), new Uint16Array(1), 4); + + this.verticesX = verticesX || 10; + this.verticesY = verticesY || 10; + + this.meshWidth = opts.meshWidth || 0; + this.meshHeight = opts.meshHeight || 0; + + this.refresh(); + } + + /** + * Refreshes plane coordinates + * @private + */ + _refresh() + { + const texture = this._texture; + const total = this.verticesX * this.verticesY; + const verts = []; + const uvs = []; + const indices = []; + + const segmentsX = this.verticesX - 1; + const segmentsY = this.verticesY - 1; + + const sizeX = (this.meshWidth || texture.width) / segmentsX; + const sizeY = (this.meshHeight || texture.height) / segmentsY; + + for (let i = 0; i < total; i++) + { + const x = (i % this.verticesX); + const y = ((i / this.verticesX) | 0); + + verts.push(x * sizeX, y * sizeY); + + uvs.push(x / segmentsX, y / segmentsY); + } + + // cons + + const totalSub = segmentsX * segmentsY; + + for (let i = 0; i < totalSub; i++) + { + const xpos = i % segmentsX; + const ypos = (i / segmentsX) | 0; + + const value = (ypos * this.verticesX) + xpos; + const value2 = (ypos * this.verticesX) + xpos + 1; + const value3 = ((ypos + 1) * this.verticesX) + xpos; + const value4 = ((ypos + 1) * this.verticesX) + xpos + 1; + + indices.push(value, value2, value3); + indices.push(value2, value4, value3); + } + + this.vertices = new Float32Array(verts); + this.uvs = new Float32Array(uvs); + this.indices = new Uint16Array(indices); + + this.geometry.buffers[0].data = this.vertices; + this.geometry.buffers[1].data = this.uvs; + this.geometry.indexBuffer.data = this.indices; + + // ensure that the changes are uploaded + this.geometry.buffers[0].update(); + this.geometry.buffers[1].update(); + this.geometry.indexBuffer.update(); + + this.multiplyUvs(); + } +} diff --git a/packages/mesh-extras/src/Rope.js b/packages/mesh-extras/src/Rope.js new file mode 100644 index 0000000..9cfde38 --- /dev/null +++ b/packages/mesh-extras/src/Rope.js @@ -0,0 +1,182 @@ +import Mesh2d from './Mesh2d'; + +/** + * The rope allows you to draw a texture across several points and them manipulate these points + * + *```js + * for (let i = 0; i < 20; i++) { + * points.push(new PIXI.Point(i * 50, 0)); + * }; + * let rope = new PIXI.Rope(PIXI.Texture.from("snake.png"), points); + * ``` + * + * @class + * @extends PIXI.Mesh + * @memberof PIXI + * + */ +export default class Rope extends Mesh2d +{ + /** + * @param {PIXI.Texture} texture - The texture to use on the rope. + * @param {PIXI.Point[]} points - An array of {@link PIXI.Point} objects to construct this rope. + */ + constructor(texture, points) + { + super(texture, new Float32Array(points.length * 4), + new Float32Array(points.length * 4), + new Uint16Array(points.length * 2), + 5); + + /* + * @member {PIXI.Point[]} An array of points that determine the rope + */ + this.points = points; + this.refresh(); + } + /** + * Refreshes Rope indices and uvs + * @private + */ + _refresh() + { + const points = this.points; + + if (!points) return; + + const vertexBuffer = this.geometry.getAttribute('aVertexPosition'); + const uvBuffer = this.geometry.getAttribute('aTextureCoord'); + const indexBuffer = this.geometry.getIndex(); + + // if too little points, or texture hasn't got UVs set yet just move on. + if (points.length < 1 || !this.texture._uvs) + { + return; + } + + // if the number of points has changed we will need to recreate the arraybuffers + if (vertexBuffer.data.length / 4 !== points.length) + { + vertexBuffer.data = new Float32Array(points.length * 4); + uvBuffer.data = new Float32Array(points.length * 4); + indexBuffer.data = new Uint16Array(points.length * 2); + } + + const uvs = uvBuffer.data; + const indices = indexBuffer.data; + + uvs[0] = 0; + uvs[1] = 0; + uvs[2] = 0; + uvs[3] = 1; + + indices[0] = 0; + indices[1] = 1; + + const total = points.length; + + for (let i = 1; i < total; i++) + { + // time to do some smart drawing! + let index = i * 4; + const amount = i / (total - 1); + + uvs[index] = amount; + uvs[index + 1] = 0; + + uvs[index + 2] = amount; + uvs[index + 3] = 1; + + index = i * 2; + indices[index] = index; + indices[index + 1] = index + 1; + } + + // ensure that the changes are uploaded + uvBuffer.update(); + indexBuffer.update(); + + this.multiplyUvs(); + this.refreshVertices(); + } + + /** + * refreshes vertices of Rope mesh + */ + refreshVertices() + { + const points = this.points; + + if (points.length < 1) + { + return; + } + + let lastPoint = points[0]; + let nextPoint; + let perpX = 0; + let perpY = 0; + + // this.count -= 0.2; + + const vertices = this.vertices; + const total = points.length; + + for (let i = 0; i < total; i++) + { + const point = points[i]; + const index = i * 4; + + if (i < points.length - 1) + { + nextPoint = points[i + 1]; + } + else + { + nextPoint = point; + } + + perpY = -(nextPoint.x - lastPoint.x); + perpX = nextPoint.y - lastPoint.y; + + let ratio = (1 - (i / (total - 1))) * 10; + + if (ratio > 1) + { + ratio = 1; + } + + const perpLength = Math.sqrt((perpX * perpX) + (perpY * perpY)); + const num = this._texture.height / 2; // (20 + Math.abs(Math.sin((i + this.count) * 0.3) * 50) )* ratio; + + perpX /= perpLength; + perpY /= perpLength; + + perpX *= num; + perpY *= num; + + vertices[index] = point.x + perpX; + vertices[index + 1] = point.y + perpY; + vertices[index + 2] = point.x - perpX; + vertices[index + 3] = point.y - perpY; + + lastPoint = point; + } + + this.geometry.buffers[0].update(); + } + + /** + * Updates the object transform for rendering + * + * @private + */ + updateTransform() + { + if (this.autoUpdate) + { + this.refreshVertices(); + } + this.containerUpdateTransform(); + } +} diff --git a/packages/mesh-extras/src/index.js b/packages/mesh-extras/src/index.js new file mode 100644 index 0000000..decf454 --- /dev/null +++ b/packages/mesh-extras/src/index.js @@ -0,0 +1,4 @@ +export { default as Mesh2d } from './Mesh2d'; +export { default as Plane } from './Plane'; +export { default as NineSlicePlane } from './NineSlicePlane'; +export { default as Rope } from './Rope'; diff --git a/packages/mesh-extras/src/mesh.frag b/packages/mesh-extras/src/mesh.frag new file mode 100644 index 0000000..6096983 --- /dev/null +++ b/packages/mesh-extras/src/mesh.frag @@ -0,0 +1,9 @@ +varying vec2 vTextureCoord; +uniform vec4 uColor; + +uniform sampler2D uSampler; + +void main(void) +{ + gl_FragColor = texture2D(uSampler, vTextureCoord) * uColor; +} diff --git a/packages/mesh-extras/src/mesh.vert b/packages/mesh-extras/src/mesh.vert new file mode 100644 index 0000000..0526df9 --- /dev/null +++ b/packages/mesh-extras/src/mesh.vert @@ -0,0 +1,15 @@ +attribute vec2 aVertexPosition; +attribute vec2 aTextureCoord; + +uniform mat3 projectionMatrix; +uniform mat3 translationMatrix; +uniform mat3 uTextureMatrix; + +varying vec2 vTextureCoord; + +void main(void) +{ + gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); + + vTextureCoord = (uTextureMatrix * vec3(aTextureCoord, 1.0)).xy; +} diff --git a/packages/mesh-extras/test/.eslintrc.json b/packages/mesh-extras/test/.eslintrc.json new file mode 100644 index 0000000..2ad8efb --- /dev/null +++ b/packages/mesh-extras/test/.eslintrc.json @@ -0,0 +1,12 @@ +{ + "globals": { + "expect": false, + "assert": false, + "sinon": false, + "PIXI": false + }, + "rules": { + "func-names": 0, + "no-unused-expressions": 0 + } +} \ No newline at end of file diff --git a/packages/mesh-extras/test/Plane.js b/packages/mesh-extras/test/Plane.js new file mode 100644 index 0000000..f9b1c25 --- /dev/null +++ b/packages/mesh-extras/test/Plane.js @@ -0,0 +1,60 @@ +const { Plane } = require('../'); +const { isWebGLSupported, skipHello } = require('@pixi/utils'); +const { Loader } = require('@pixi/loaders'); +const { Point } = require('@pixi/math'); +const { RenderTexture, Texture } = require('@pixi/core'); + +skipHello(); + +function withGL(fn) +{ + return isWebGLSupported() ? fn : undefined; +} + +// TODO: fix with webglrenderer +describe('PIXI.mesh.Plane', function () +{ + it.skip('should create a plane from an external image', withGL(function (done) + { + const loader = new Loader(); + + loader.add('testBitmap', `file://${__dirname}/resources/bitmap-1.png`) + .load(function (loader, resources) + { + const plane = new Plane(resources.testBitmap.texture, 100, 100); + + expect(plane.verticesX).to.equal(100); + expect(plane.verticesY).to.equal(100); + done(); + }); + })); + + it.skip('should create a new empty textured Plane', withGL(function () + { + const plane = new Plane(Texture.EMPTY, 100, 100); + + expect(plane.verticesX).to.equal(100); + expect(plane.verticesY).to.equal(100); + })); + + describe('containsPoint', function () + { + it.skip('should return true when point inside', withGL(function () + { + const point = new Point(10, 10); + const texture = new RenderTexture.create(20, 30); + const plane = new Plane(texture, 100, 100); + + expect(plane.containsPoint(point)).to.be.true; + })); + + it.skip('should return false when point outside', withGL(function () + { + const point = new Point(100, 100); + const texture = new RenderTexture.create(20, 30); + const plane = new Plane(texture, 100, 100); + + expect(plane.containsPoint(point)).to.be.false; + })); + }); +}); diff --git a/packages/mesh-extras/test/index.js b/packages/mesh-extras/test/index.js new file mode 100644 index 0000000..d767624 --- /dev/null +++ b/packages/mesh-extras/test/index.js @@ -0,0 +1 @@ +require('./Plane'); diff --git a/packages/mesh-extras/test/resources/bitmap-1.png b/packages/mesh-extras/test/resources/bitmap-1.png new file mode 100644 index 0000000..1284fb8 --- /dev/null +++ b/packages/mesh-extras/test/resources/bitmap-1.png Binary files differ diff --git a/packages/mesh/package.json b/packages/mesh/package.json index 8b1f8d9..10bd8e3 100644 --- a/packages/mesh/package.json +++ b/packages/mesh/package.json @@ -18,22 +18,16 @@ "publishConfig": { "access": "public" }, - "scripts": { - "test": "floss --path test" - }, "files": [ "lib" ], "dependencies": { - "@pixi/canvas-renderer": "^5.0.0-alpha.2", "@pixi/constants": "^5.0.0-alpha.2", "@pixi/core": "^5.0.0-alpha.2", "@pixi/display": "^5.0.0-alpha.2", - "@pixi/math": "^5.0.0-alpha.2", - "@pixi/utils": "^5.0.0-alpha.2" + "@pixi/math": "^5.0.0-alpha.2" }, "devDependencies": { - "@pixi/loaders": "^5.0.0-alpha.2", "floss": "^2.1.3" } } diff --git a/bundles/pixi.js/package.json b/bundles/pixi.js/package.json index 49c7276..177e059 100644 --- a/bundles/pixi.js/package.json +++ b/bundles/pixi.js/package.json @@ -49,6 +49,7 @@ "@pixi/loaders": "^5.0.0-alpha.2", "@pixi/math": "^5.0.0-alpha.2", "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/mesh-extras": "^5.0.0-alpha.2", "@pixi/mixin-cache-as-bitmap": "^5.0.0-alpha.2", "@pixi/mixin-get-child-by-name": "^5.0.0-alpha.2", "@pixi/mixin-get-global-position": "^5.0.0-alpha.2", diff --git a/bundles/pixi.js/src/deprecated.js b/bundles/pixi.js/src/deprecated.js index 147617c..dbebeb0 100644 --- a/bundles/pixi.js/src/deprecated.js +++ b/bundles/pixi.js/src/deprecated.js @@ -263,15 +263,15 @@ Object.defineProperties(PIXI.mesh, { /** * @class PIXI.mesh.Mesh - * @see PIXI.Mesh + * @see PIXI.Mesh2d * @deprecated since 5.0.0 */ Mesh: { get() { - warn('PIXI.mesh.Mesh has moved to PIXI.Mesh'); + warn('PIXI.mesh.Mesh has moved to PIXI.Mesh2d'); - return PIXI.Mesh; + return PIXI.Mesh2d; }, }, /** @@ -315,15 +315,15 @@ }, /** * @class PIXI.mesh.RawMesh - * @see PIXI.RawMesh + * @see PIXI.Mesh * @deprecated since 5.0.0 */ RawMesh: { get() { - warn('PIXI.mesh.RawMesh has moved to PIXI.RawMesh'); + warn('PIXI.mesh.RawMesh has moved to PIXI.Mesh'); - return PIXI.RawMesh; + return PIXI.Mesh; }, }, /** diff --git a/bundles/pixi.js/src/index.js b/bundles/pixi.js/src/index.js index a3a0d1b..6fdabf0 100644 --- a/bundles/pixi.js/src/index.js +++ b/bundles/pixi.js/src/index.js @@ -9,6 +9,7 @@ import * as loaders from '@pixi/loaders'; import * as math from '@pixi/math'; import * as mesh from '@pixi/mesh'; +import * as meshExtras from '@pixi/mesh-extras'; import * as particles from '@pixi/particles'; import * as prepare from '@pixi/prepare'; import * as sprite from '@pixi/sprite'; @@ -128,6 +129,7 @@ loaders, math, mesh, + meshExtras, particles, sprite, spriteAnimated, @@ -152,6 +154,7 @@ export * from '@pixi/loaders'; export * from '@pixi/math'; export * from '@pixi/mesh'; +export * from '@pixi/mesh-extras'; export * from '@pixi/particles'; export * from '@pixi/sprite'; export * from '@pixi/spritesheet'; diff --git a/package-lock.json b/package-lock.json index 7fe6db7..0814729 100644 --- a/package-lock.json +++ b/package-lock.json @@ -209,7 +209,7 @@ "argparse": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", - "integrity": "sha1-vNZ5HqWuCXJeF+WtmIE0zUCz2RE=", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", "dev": true, "requires": { "sprintf-js": "1.0.3" @@ -228,7 +228,7 @@ "arr-flatten": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz", - "integrity": "sha1-NgSLv/TntH4TZkQxbJlmnqWukfE=", + "integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==", "dev": true }, "arr-union": { @@ -297,7 +297,7 @@ "assertion-error": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", - "integrity": "sha1-5gtrDo8wG9l+U3UhW9pAbIURjAs=", + "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", "dev": true }, "async": { @@ -396,7 +396,7 @@ "brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha1-PH/L9SnYcibz0vUrlm/1Jx60Qd0=", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, "requires": { "balanced-match": "1.0.0", @@ -568,7 +568,7 @@ "circular-json": { "version": "0.3.3", "resolved": "https://registry.npmjs.org/circular-json/-/circular-json-0.3.3.tgz", - "integrity": "sha1-gVyZ6oT2gJUp0vRXkb34JxE1LWY=", + "integrity": "sha512-UZK3NBx2Mca+b5LsG7bY183pHWt5Y1xts4P3Pz7ENTwGVnJOUWbRb3ocjvX7hx9tq/yTAdclXm9sZ38gNuem4A==", "dev": true }, "cli-cursor": { @@ -638,7 +638,7 @@ "color-convert": { "version": "1.9.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.1.tgz", - "integrity": "sha1-wSYRB66y8pTr/+ye2eytUppgl+0=", + "integrity": "sha512-mjGanIiwQJskCC18rPR6OmrZ6fm2Lc7PeGFYwCmy5J34wC6F1PzdGL6xeMfmgicfYcNLGuVFA3WzXtIDCQSZxQ==", "dev": true, "requires": { "color-name": "1.1.3" @@ -1427,7 +1427,7 @@ "boom": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/boom/-/boom-5.2.0.tgz", - "integrity": "sha1-XdnabuOl8wIHdDYpDLcX0/SlTgI=", + "integrity": "sha512-Z5BTk6ZRe4tXXQlkqftmsAUANpXmuwlsF5Oov8ThoMbQRzdGTA1ngYRW160GexgOgjsFOKJz0LYhoNi+2AMBUw==", "dev": true, "requires": { "hoek": "4.2.1" @@ -1471,7 +1471,7 @@ "debug": { "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha1-XRKFFd8TT/Mn6QpMk/Tgd6U2NB8=", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", "dev": true, "requires": { "ms": "2.0.0" @@ -1585,7 +1585,7 @@ "doctrine": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", - "integrity": "sha1-XNAfwQFiG0LEzX9dGmYkNxbT850=", + "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", "dev": true, "requires": { "esutils": "2.0.2" @@ -1662,7 +1662,7 @@ "es6-promise": { "version": "4.2.4", "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.4.tgz", - "integrity": "sha1-3EIhwrFlGHYL2MOaUtjzVvwA7Sk=", + "integrity": "sha512-/NdNZVJg+uZgtm9eS3O6lrOLYmQag2DjdEXuPaHlZ6RuVqgqaVZfgYCepEIKsLqwdQArOPtC3XzRLqGGfT8KQQ==", "dev": true }, "escape-string-regexp": { @@ -1788,7 +1788,7 @@ "espree": { "version": "3.5.4", "resolved": "https://registry.npmjs.org/espree/-/espree-3.5.4.tgz", - "integrity": "sha1-sPRHGHyKi+2US4FaZgvd9d610ac=", + "integrity": "sha512-yAcIQxtmMiB/jL32dzEp2enBeidsB7xWPLNiw3IIkpVds1P+h7qF9YwJq1yUNzp2OKXgAprs4F61ih66UsoD1A==", "dev": true, "requires": { "acorn": "5.5.0", @@ -1798,7 +1798,7 @@ "esprima": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.0.tgz", - "integrity": "sha1-RJnt3NERDgshi6zy+n9/WfVcqAQ=", + "integrity": "sha512-oftTcaMu/EGrEIu904mWteKIv8vMuOgGYo7EhVJJN00R/EED9DCua/xxHRdYnKtcECzVg7xOWhflvJMnqcFZjw==", "dev": true }, "esquery": { @@ -1813,7 +1813,7 @@ "esrecurse": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.2.1.tgz", - "integrity": "sha1-AHo7n9vCs7uH5IeeoZyS/b05Qs8=", + "integrity": "sha512-64RBB++fIOAXPw3P9cy89qfMlvZEXZkqqJkjqqXIvzP5ezRZjW+lPWjw35UX/3EhUPFYbg5ER4JYgDw4007/DQ==", "dev": true, "requires": { "estraverse": "4.2.0" @@ -2024,7 +2024,7 @@ "find-root": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/find-root/-/find-root-1.1.0.tgz", - "integrity": "sha1-q8/Iunb3CMQql7PWhbfpRQv7nOQ=", + "integrity": "sha512-NKfW6bec6GfKc0SGx1e07QZY9PE99u0Bft/0rzSD5k3sO/vwkVUpDUKVm5Gpp5Ue3YfShPFTX2070tDs5kB9Ng==", "dev": true }, "find-up": { @@ -2103,7 +2103,7 @@ "supports-color": { "version": "5.3.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.3.0.tgz", - "integrity": "sha1-WySsFduA+pJ89SJ6SjP9PEx2dsA=", + "integrity": "sha512-0aP01LLIskjKs3lq52EC0aGBAJhLq7B2Rd8HC/DR/PtNNpcLilNmHC12O+hu0usQpo7wtHNRqtrhBwtDb0+dNg==", "dev": true, "requires": { "has-flag": "3.0.0" @@ -2567,7 +2567,7 @@ "glob": { "version": "7.1.2", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", - "integrity": "sha1-wZyd+aAocC1nhhI4SmVSQExjbRU=", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", "dev": true, "requires": { "fs.realpath": "1.0.0", @@ -2672,7 +2672,7 @@ "growl": { "version": "1.10.3", "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.3.tgz", - "integrity": "sha1-GSa6kM8+3+KttJJ/WIC8IsZseQ8=", + "integrity": "sha512-hKlsbA5Vu3xsh1Cg3J7jSmX/WaW6A5oBeqzM88oNbCRQFz+zUaXm6yxS4RVytp1scBoJzSYl4YAEOQIt6O8V1Q==", "dev": true }, "handlebars": { @@ -2738,7 +2738,7 @@ "hawk": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/hawk/-/hawk-6.0.2.tgz", - "integrity": "sha1-r02RTrBl+bXOTZ0RwcshJu7MMDg=", + "integrity": "sha512-miowhl2+U7Qle4vdLqDdPt9m09K6yZhkLDTWGoUiUzrQCn+mHHSmfJgAyGaLRZbPmTqfFFjRV1QWCW0VWUJBbQ==", "dev": true, "requires": { "boom": "4.3.1", @@ -2756,7 +2756,7 @@ "hoek": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/hoek/-/hoek-4.2.1.tgz", - "integrity": "sha1-ljRQKqEsRF3Vp8VzS1cruHOKrLs=", + "integrity": "sha512-QLg82fGkfnJ/4iy1xZ81/9SIJiq1NGFUMGs6ParyjBZr6jW2Ufj/snDqTHixNlHdPNwN2RLVD0Pi3igeK9+JfA==", "dev": true }, "home-path": { @@ -2791,7 +2791,7 @@ "ignore": { "version": "3.3.7", "resolved": "https://registry.npmjs.org/ignore/-/ignore-3.3.7.tgz", - "integrity": "sha1-YSKJv7PCIOGGpYEYYY1b6MG6sCE=", + "integrity": "sha512-YGG3ejvBNHRqu0559EOxxNFihD0AjpvHlC/pdGKd3X3ofe+CoJkYazwNJYTNebqpPKN+VVQbh4ZFn1DivMNuHA==", "dev": true }, "imurmurhash": { @@ -2828,7 +2828,7 @@ "ini": { "version": "1.3.5", "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", - "integrity": "sha1-7uJfVtscnsYIXgwid4CD9Zar+Sc=", + "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==", "dev": true }, "inquirer": { @@ -2901,7 +2901,7 @@ "is-buffer": { "version": "1.1.6", "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", - "integrity": "sha1-76ouqdqg16suoTqXsritUf776L4=", + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", "dev": true }, "is-builtin-module": { @@ -3054,7 +3054,7 @@ "is-resolvable": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/is-resolvable/-/is-resolvable-1.1.0.tgz", - "integrity": "sha1-+xj4fOH+uSUWnJpAfBkxijIG7Yg=", + "integrity": "sha512-qgDYXFSR5WvEfuS5dMj6oTMEbrrSaM0CrFk2Yiq/gXnBvD9pMa2jGXxyhGLfvhZpuMZe18CJpFxAt3CRs42NMg==", "dev": true }, "is-retry-allowed": { @@ -3204,7 +3204,7 @@ "js-yaml": { "version": "3.11.0", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.11.0.tgz", - "integrity": "sha1-WXwai9VxUvJtYizkEXhRpR9euu8=", + "integrity": "sha512-saJstZWv7oNeOyBh3+Dx1qWzhW0+e6/8eDzo7p5rDFqxntSztloLtuKu+Ejhtq82jsilwOIZYsCz+lIjthg1Hw==", "dev": true, "requires": { "argparse": "1.0.10", @@ -3324,7 +3324,7 @@ "just-extend": { "version": "1.1.27", "resolved": "https://registry.npmjs.org/just-extend/-/just-extend-1.1.27.tgz", - "integrity": "sha1-7G55QQ/5FORyZSq/oOYDwD1g6QU=", + "integrity": "sha512-mJVp13Ix6gFo3SBAy9U/kL+oeZqzlYYYLQBwXVBlVzIsZwBqGREnOro24oC/8s8aox+rJhtZ2DiQof++IrkA+g==", "dev": true }, "kind-of": { @@ -3703,7 +3703,7 @@ "lodash": { "version": "4.17.5", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.5.tgz", - "integrity": "sha1-maktZcAnLevoyWtgV7yPv6O+1RE=", + "integrity": "sha512-svL3uiZf1RwhH+cWrfZn3A4+U58wbP0tGVTLQPbjplZxZ8ROD9VLuNgsRniTlLe7OlSqR79RUehXgpBW/s0IQw==", "dev": true }, "lodash._reinterpolate": { @@ -3740,7 +3740,7 @@ "lolex": { "version": "2.3.2", "resolved": "https://registry.npmjs.org/lolex/-/lolex-2.3.2.tgz", - "integrity": "sha1-hflFBCUQO/nnpgZo6iXcQydMqAc=", + "integrity": "sha512-A5pN2tkFj7H0dGIAM6MFvHKMJcPnjZsOMvR7ujCjfgW5TbV6H9vb1PgxLtHvjqNZTHsUolz+6/WEO0N1xNx2ng==", "dev": true }, "longest": { @@ -3816,7 +3816,7 @@ "marked": { "version": "0.3.17", "resolved": "https://registry.npmjs.org/marked/-/marked-0.3.17.tgz", - "integrity": "sha1-YH8GZos8axJGso8T2nYRasGqLSs=", + "integrity": "sha512-+AKbNsjZl6jFfLPwHhWmGTqE009wTKn3RTmn9K8oUKHrX/abPJjtcRtXpYB/FFrwPJRUA86LX/de3T0knkPCmQ==", "dev": true }, "mem": { @@ -3896,13 +3896,13 @@ "mime-db": { "version": "1.33.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.33.0.tgz", - "integrity": "sha1-o0kgUKXLm2NFBUHjnZeI0icng9s=", + "integrity": "sha512-BHJ/EKruNIqJf/QahvxwQZXKygOQ256myeN/Ew+THcAa5q+PjyTTMMeNQC4DZw5AwfvelsUrA6B67NKMqXDbzQ==", "dev": true }, "mime-types": { "version": "2.1.18", "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.18.tgz", - "integrity": "sha1-bzI/YKg9ERRvgx/xH9ZuL+VQO7g=", + "integrity": "sha512-lc/aahn+t4/SWV/qcmumYjymLsWfN3ELhpmVuUFjgsORruuZPVSwAQryq+HHGvO/SI2KVX26bx+En+zhM8g8hQ==", "dev": true, "requires": { "mime-db": "1.33.0" @@ -3917,7 +3917,7 @@ "minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha1-UWbihkV/AzBgZL5Ul+jbsMPTIIM=", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "dev": true, "requires": { "brace-expansion": "1.1.11" @@ -4071,7 +4071,7 @@ "normalize-package-data": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.4.0.tgz", - "integrity": "sha1-EvlaMH1YNSB1oEkHuErIvpisAS8=", + "integrity": "sha512-9jjUFbTPfEy3R/ad/2oNbKtW9Hgovl5O1FvFWKkKblNXoN/Oou6+9+KKohPK13Yc3/TyunyWhJp6gvRNR/PPAw==", "dev": true, "requires": { "hosted-git-info": "2.5.0", @@ -4511,7 +4511,7 @@ "process-nextick-args": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", - "integrity": "sha1-o31zL0JxtKsa0HDTVQjoKQeI/6o=", + "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==", "dev": true }, "progress": { @@ -4584,7 +4584,7 @@ "qs": { "version": "6.5.1", "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.1.tgz", - "integrity": "sha1-NJzfbu+J7EXBLX1es/wMhwNDptg=", + "integrity": "sha512-eRzhrN1WSINYCDCbrz796z37LOe3m5tmW7RQf6oBntukAG1nmovJvhnwHHRMAfeoItc1m2Hk02WER2aQ/iqs+A==", "dev": true }, "quick-lru": { @@ -4596,7 +4596,7 @@ "randomatic": { "version": "1.1.7", "resolved": "https://registry.npmjs.org/randomatic/-/randomatic-1.1.7.tgz", - "integrity": "sha1-x6vpzIuHwLqodrGf3oP9RkeX44w=", + "integrity": "sha512-D5JUjPyJbaJDkuAazpVnSfVkLlpeO3wDlPROTMLGKG1zMFNFRgrciKo1ltz/AzNTkqE0HzDx655QOL51N06how==", "dev": true, "requires": { "is-number": "3.0.0", @@ -4701,7 +4701,7 @@ "regex-cache": { "version": "0.4.4", "resolved": "https://registry.npmjs.org/regex-cache/-/regex-cache-0.4.4.tgz", - "integrity": "sha1-db3FiioUls7EihKDW8VMjVYjNt0=", + "integrity": "sha512-nVIZwtCjkC9YgvWkpM55B5rBhBYRZhAaJbgcFYXXsHnbZ9UZI9nnVWYZpBlCqv9ho2eZryPnWrZGsOdPwVWXWQ==", "dev": true, "requires": { "is-equal-shallow": "0.1.3" @@ -4729,7 +4729,7 @@ "remap-istanbul": { "version": "0.10.1", "resolved": "https://registry.npmjs.org/remap-istanbul/-/remap-istanbul-0.10.1.tgz", - "integrity": "sha1-OqWN1QIdSZ8zbTulvzu7kcG4jjc=", + "integrity": "sha512-gsNQXs5kJLhErICSyYhzVZ++C8LBW8dgwr874Y2QvzAUS75zBlD/juZgXs39nbYJ09fZDlX2AVLVJAY2jbFJoQ==", "dev": true, "requires": { "amdefine": "1.0.1", @@ -4769,7 +4769,7 @@ "source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha1-dHIq8y6WFOnCh6jQu95IteLxomM=", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", "dev": true }, "through2": { @@ -4883,7 +4883,7 @@ "resolve": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.5.0.tgz", - "integrity": "sha1-HwmsznlsmnYlefMbLBzEw83fnzY=", + "integrity": "sha512-hgoSGrc3pjzAPHNBg+KnFcK2HwlHTs/YrAGUr6qgTVUZmXv1UEXXl0bZNBKMA9fud6lRYFdPGz0xXxycPzmmiw==", "dev": true, "requires": { "path-parse": "1.0.5" @@ -4924,7 +4924,7 @@ "rimraf": { "version": "2.6.2", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", - "integrity": "sha1-LtgVDSShbqhlHm1u8PR8QVjOejY=", + "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", "dev": true, "requires": { "glob": "7.1.2" @@ -5063,19 +5063,19 @@ "safe-buffer": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", - "integrity": "sha1-iTMSr2myEj3vcfV4iQAWce6yyFM=", + "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", "dev": true }, "samsam": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/samsam/-/samsam-1.3.0.tgz", - "integrity": "sha1-jR2TUOJWItow3j5EumkrUiGrfFA=", + "integrity": "sha512-1HwIYD/8UlOtFS3QO3w7ey+SdSDFE4HRNLZoZRYVQefrOY3l17epswImeB1ijgJFQJodIaHcwkp3r/myBjFVbg==", "dev": true }, "semver": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz", - "integrity": "sha1-3Eu8emyp2Rbe5dQ1FvAJK1j3uKs=", + "integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==", "dev": true }, "set-blocking": { @@ -5117,7 +5117,7 @@ "sinon-chai": { "version": "2.14.0", "resolved": "https://registry.npmjs.org/sinon-chai/-/sinon-chai-2.14.0.tgz", - "integrity": "sha1-2n3UzIPNaiYLZ8yg96n9riahIF0=", + "integrity": "sha512-9stIF1utB0ywNHNT7RgiXbdmen8QDCRsrTjw+G9TgKt1Yexjiv8TOWZ6WHsTPz57Yky3DIswZvEqX8fpuHNDtQ==", "dev": true }, "slash": { @@ -5146,7 +5146,7 @@ "sntp": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/sntp/-/sntp-2.1.0.tgz", - "integrity": "sha1-LGzsFP7cIiJznK+bXD2F0cxaLMg=", + "integrity": "sha512-FL1b58BDrqS3A11lJ0zEdnJ3UOKqVxawAkF3k7F0CVN7VQ34aZrV+G8BZ1WC9ZL7NyrwsW0oviwsWDgRuVYtJg==", "dev": true, "requires": { "hoek": "4.2.1" @@ -5203,7 +5203,7 @@ "spdx-correct": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.0.0.tgz", - "integrity": "sha1-BaW01xU6GVvJLDxCW2nzsqlSTII=", + "integrity": "sha512-N19o9z5cEyc8yQQPukRCZ9EUmb4HUpnrmaL/fxS2pBo2jbfcFRVuFZ/oFC+vZz0MNNk0h80iMn5/S6qGZOL5+g==", "dev": true, "requires": { "spdx-expression-parse": "3.0.0", @@ -5213,13 +5213,13 @@ "spdx-exceptions": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.1.0.tgz", - "integrity": "sha1-LHrmEFbHFKW5ubKyr30xHvXHj+k=", + "integrity": "sha512-4K1NsmrlCU1JJgUrtgEeTVyfx8VaYea9J9LvARxhbHtVtohPs/gFGG5yy49beySjlIMhhXZ4QqujIZEfS4l6Cg==", "dev": true }, "spdx-expression-parse": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.0.tgz", - "integrity": "sha1-meEZt6XaAOBUkcn6M4t5BII7QdA=", + "integrity": "sha512-Yg6D3XpRD4kkOmTpdgbUiEJFKghJH03fiC1OPll5h/0sO6neh2jqRDVHOQ4o/LMea0tgCkbMgea5ip/e+MkWyg==", "dev": true, "requires": { "spdx-exceptions": "2.1.0", @@ -5229,7 +5229,7 @@ "spdx-license-ids": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.0.tgz", - "integrity": "sha1-enzShHDMbToc/m1miG9rxDDTrIc=", + "integrity": "sha512-2+EPwgbnmOIl8HjGBXXMd9NAu02vLjOO1nWw4kmeRDFyHn+M/ETfHxQUK0oXg8ctgVnl9t3rosNVsZ1jG61nDA==", "dev": true }, "speedometer": { @@ -5566,7 +5566,7 @@ "tough-cookie": { "version": "2.3.4", "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.4.tgz", - "integrity": "sha1-7GDO44rGdQY//JelwYlwV47oNlU=", + "integrity": "sha512-TZ6TTfI5NtZnuyy/Kecv+CnoROnyXn2DN97LontgQpCwsX2XyLYCC0ENhYkehSOwAp8rTQKc/NUIF7BkQ5rKLA==", "dev": true, "requires": { "punycode": "1.4.1" @@ -5708,13 +5708,13 @@ "uuid": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.2.1.tgz", - "integrity": "sha1-EsUou51Y0LkmXZovbw/ovhf/HxQ=", + "integrity": "sha512-jZnMwlb9Iku/O3smGWvZhauCf6cvvpKi4BKRiliS3cxnI+Gz9j5MEpTz2UFuXiKPJocb7gnsLHwiS05ige5BEA==", "dev": true }, "validate-npm-package-license": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.3.tgz", - "integrity": "sha1-gWQ7y+8b3+zUYjeT3EZIlIupgzg=", + "integrity": "sha512-63ZOUnL4SIXj4L0NixR3L1lcjO38crAbgrTpl28t8jjrfuiOBL5Iygm+60qPs/KsZGzPNg6Smnc/oY16QTjF0g==", "dev": true, "requires": { "spdx-correct": "3.0.0", @@ -5750,7 +5750,7 @@ "which": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/which/-/which-1.3.0.tgz", - "integrity": "sha1-/wS9/AEO5UfXgL7DjhrBwnd9JTo=", + "integrity": "sha512-xcJpopdamTuY5duC/KnTTNBraPK54YwpenP4lzxU8H91GudWpFv38u0CKjclE1Wi2EH2EDz5LRcHcKbCIzqGyg==", "dev": true, "requires": { "isexe": "2.0.0" diff --git a/packages/canvas/canvas-mesh/package.json b/packages/canvas/canvas-mesh/package.json index 691cd2c..6744a17 100644 --- a/packages/canvas/canvas-mesh/package.json +++ b/packages/canvas/canvas-mesh/package.json @@ -24,6 +24,7 @@ "dependencies": { "@pixi/constants": "^5.0.0-alpha.2", "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/mesh-extras": "^5.0.0-alpha.2", "@pixi/settings": "^5.0.0-alpha.2" }, "devDependencies": { diff --git a/packages/canvas/canvas-mesh/src/Mesh.js b/packages/canvas/canvas-mesh/src/Mesh.js index 900a872..c43a74b 100644 --- a/packages/canvas/canvas-mesh/src/Mesh.js +++ b/packages/canvas/canvas-mesh/src/Mesh.js @@ -1,36 +1,14 @@ import { Mesh } from '@pixi/mesh'; -import { settings } from './settings'; - -// IMPORTANT: Please do NOT use this as a precedent to use `settings` after the object is created -// this was merely created to completely decouple canvas from the base Mesh class and we are -// unable to add `canvasPadding` in the constructor anymore, as the case was for PixiJS v4. /** - * Internal variable for `canvasPadding`. + * Renders the object using the Canvas renderer * * @private - * @memberof PIXI.Mesh - * @member {number} - * @default null - */ -Mesh.prototype._canvasPadding = null; - -/** - * Triangles in canvas mode are automatically antialiased, use this value to force triangles - * to overlap a bit with each other. To set the global default, set {@link PIXI.settings.MESH_CANVAS_PADDING} - * - * @see PIXI.settings.MESH_CANVAS_PADDING - * @member {number} canvasPadding + * @method _renderCanvas * @memberof PIXI.Mesh# - * @default 0 + * @param {PIXI.CanvasRenderer} renderer - The canvas renderer. */ -Object.defineProperty(Mesh.prototype, 'canvasPadding', { - get() - { - return this._canvasPadding !== null ? this._canvasPadding : settings.MESH_CANVAS_PADDING; - }, - set(value) - { - this._canvasPadding = value; - }, -}); +Mesh.prototype._renderCanvas = function _renderCanvas(renderer) +{ + renderer.plugins[this.pluginName].render(this); +}; diff --git a/packages/canvas/canvas-mesh/src/Mesh2d.js b/packages/canvas/canvas-mesh/src/Mesh2d.js new file mode 100644 index 0000000..d0bd80f --- /dev/null +++ b/packages/canvas/canvas-mesh/src/Mesh2d.js @@ -0,0 +1,36 @@ +import { Mesh2d } from '@pixi/mesh-extras'; +import { settings } from './settings'; + +// IMPORTANT: Please do NOT use this as a precedent to use `settings` after the object is created +// this was merely created to completely decouple canvas from the base Mesh class and we are +// unable to add `canvasPadding` in the constructor anymore, as the case was for PixiJS v4. + +/** + * Internal variable for `canvasPadding`. + * + * @private + * @memberof PIXI.Mesh2d + * @member {number} + * @default null + */ +Mesh2d.prototype._canvasPadding = null; + +/** + * Triangles in canvas mode are automatically antialiased, use this value to force triangles + * to overlap a bit with each other. To set the global default, set {@link PIXI.settings.MESH_CANVAS_PADDING} + * + * @see PIXI.settings.MESH_CANVAS_PADDING + * @member {number} canvasPadding + * @memberof PIXI.Mesh2d# + * @default 0 + */ +Object.defineProperty(Mesh2d.prototype, 'canvasPadding', { + get() + { + return this._canvasPadding !== null ? this._canvasPadding : settings.MESH_CANVAS_PADDING; + }, + set(value) + { + this._canvasPadding = value; + }, +}); diff --git a/packages/canvas/canvas-mesh/src/NineSlicePlane.js b/packages/canvas/canvas-mesh/src/NineSlicePlane.js index 09eaf9c..2fd5acc 100644 --- a/packages/canvas/canvas-mesh/src/NineSlicePlane.js +++ b/packages/canvas/canvas-mesh/src/NineSlicePlane.js @@ -1,4 +1,4 @@ -import { NineSlicePlane } from '@pixi/mesh'; +import { NineSlicePlane } from '@pixi/mesh-extras'; /** * Renders the object using the Canvas renderer diff --git a/packages/canvas/canvas-mesh/src/RawMesh.js b/packages/canvas/canvas-mesh/src/RawMesh.js deleted file mode 100644 index bf40184..0000000 --- a/packages/canvas/canvas-mesh/src/RawMesh.js +++ /dev/null @@ -1,14 +0,0 @@ -import { RawMesh } from '@pixi/mesh'; - -/** - * Renders the object using the Canvas renderer - * - * @private - * @method _renderCanvas - * @memberof PIXI.RawMesh# - * @param {PIXI.CanvasRenderer} renderer - The canvas renderer. - */ -RawMesh.prototype._renderCanvas = function _renderCanvas(renderer) -{ - renderer.plugins[this.pluginName].render(this); -}; diff --git a/packages/canvas/canvas-mesh/src/index.js b/packages/canvas/canvas-mesh/src/index.js index 2295016..f4fa31d 100644 --- a/packages/canvas/canvas-mesh/src/index.js +++ b/packages/canvas/canvas-mesh/src/index.js @@ -1,6 +1,6 @@ export { default as CanvasMeshRenderer } from './CanvasMeshRenderer'; import './settings'; -import './Mesh'; +import './Mesh2d'; import './NineSlicePlane'; -import './RawMesh'; +import './Mesh'; diff --git a/packages/canvas/canvas-mesh/src/settings.js b/packages/canvas/canvas-mesh/src/settings.js index 4cefb4c..e81b8e0 100644 --- a/packages/canvas/canvas-mesh/src/settings.js +++ b/packages/canvas/canvas-mesh/src/settings.js @@ -3,7 +3,7 @@ /** * Default `canvasPadding` for canvas-based Mesh rendering. * - * @see PIXI.Mesh#canvasPadding + * @see PIXI.Mesh2d#canvasPadding * @static * @constant * @memberof PIXI.settings diff --git a/packages/mesh-extras/LICENSE b/packages/mesh-extras/LICENSE new file mode 100644 index 0000000..148e3eb --- /dev/null +++ b/packages/mesh-extras/LICENSE @@ -0,0 +1,21 @@ +The MIT License + +Copyright (c) 2013-2018 Mathew Groves, Chad Engler + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/packages/mesh-extras/README.md b/packages/mesh-extras/README.md new file mode 100644 index 0000000..1d9b0e1 --- /dev/null +++ b/packages/mesh-extras/README.md @@ -0,0 +1,19 @@ +# @pixi/mesh-extras + +## Installation + +```bash +npm install @pixi/mesh-extras +``` + +## Usage + +```js +import { MeshRenderer } from '@pixi/mesh'; +import { Renderer } from '@pixi/core'; +import { Rope } from '@pixi/mesh-extras'; + +Renderer.registerPlugin('mesh', MeshRenderer); + +const rope = new Rope(); +``` \ No newline at end of file diff --git a/packages/mesh-extras/package.json b/packages/mesh-extras/package.json new file mode 100644 index 0000000..d134f64 --- /dev/null +++ b/packages/mesh-extras/package.json @@ -0,0 +1,38 @@ +{ + "name": "@pixi/mesh-extras", + "version": "5.0.0-alpha.2", + "main": "lib/mesh-extras.js", + "module": "lib/mesh-extras.es.js", + "description": "Custom Mesh display objects, like Rope and Plane", + "author": "Mat Groves", + "contributors": [ + "Matt Karl " + ], + "homepage": "http://pixijs.com/", + "bugs": "https://github.com/pixijs/pixi.js/issues", + "license": "MIT", + "repository": { + "type": "git", + "url": "https://github.com/pixijs/pixi.js.git" + }, + "publishConfig": { + "access": "public" + }, + "scripts": { + "test": "floss --path test" + }, + "files": [ + "lib" + ], + "dependencies": { + "@pixi/constants": "^5.0.0-alpha.2", + "@pixi/core": "^5.0.0-alpha.2", + "@pixi/math": "^5.0.0-alpha.2", + "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/utils": "^5.0.0-alpha.2" + }, + "devDependencies": { + "@pixi/loaders": "^5.0.0-alpha.2", + "floss": "^2.1.3" + } +} diff --git a/packages/mesh-extras/src/Mesh2d.js b/packages/mesh-extras/src/Mesh2d.js new file mode 100644 index 0000000..d113a5e --- /dev/null +++ b/packages/mesh-extras/src/Mesh2d.js @@ -0,0 +1,263 @@ +import { Mesh } from '@pixi/mesh'; +import { Geometry, Program, Shader, Texture, TextureMatrix } from '@pixi/core'; +import { Matrix } from '@pixi/math'; +import { BLEND_MODES } from '@pixi/constants'; +import { hex2rgb, premultiplyRgba } from '@pixi/utils'; +import vertex from './mesh.vert'; +import fragment from './mesh.frag'; + +let meshProgram; + +/** + * Base mesh class + * @class + * @extends PIXI.Container + * @memberof PIXI + */ +export default class Mesh2d extends Mesh +{ + /** + * @param {PIXI.Texture} [texture=Texture.EMPTY] - The texture to use + * @param {Float32Array} [vertices] - if you want to specify the vertices + * @param {Float32Array} [uvs] - if you want to specify the uvs + * @param {Uint16Array} [indices] - if you want to specify the indices + * @param {number} [drawMode] - the drawMode, can be any of the Mesh.DRAW_MODES consts + */ + constructor(texture = Texture.EMPTY, vertices, uvs, indices, drawMode) + { + const geometry = new Geometry(); + + if (!meshProgram) + { + meshProgram = new Program(vertex, fragment); + } + + geometry.addAttribute('aVertexPosition', vertices) + .addAttribute('aTextureCoord', uvs) + .addIndex(indices); + + geometry.getAttribute('aVertexPosition').static = false; + + const uniforms = { + uSampler: texture, + uTextureMatrix: Matrix.IDENTITY, + alpha: 1, + uColor: new Float32Array([1, 1, 1, 1]), + }; + + super(geometry, new Shader(meshProgram, uniforms), null, drawMode); + + /** + * The Uvs of the Mesh + * + * @member {Float32Array} + */ + this.uvs = geometry.getAttribute('aTextureCoord').data; + + /** + * An array of vertices + * + * @member {Float32Array} + */ + this.vertices = geometry.getAttribute('aVertexPosition').data; + + this.uniforms = uniforms; + + /** + * The texture of the Mesh + * + * @member {PIXI.Texture} + * @default PIXI.Texture.EMPTY + * @private + */ + this.texture = texture; + + /** + * The tint applied to the mesh. This is a [r,g,b] value. A value of [1,1,1] will remove any + * tint effect. + * + * @member {number} + * @private + */ + this._tintRGB = new Float32Array([1, 1, 1]); + + // Set default tint + this.tint = 0xFFFFFF; + + this.blendMode = BLEND_MODES.NORMAL; + + /** + * TextureMatrix instance for this Mesh, used to track Texture changes + * + * @member {PIXI.TextureMatrix} + * @readonly + */ + this.uvMatrix = new TextureMatrix(this._texture); + + /** + * whether or not upload uvMatrix to shader + * if its false, then uvs should be pre-multiplied + * if you change it for generated mesh, please call 'refresh(true)' + * @member {boolean} + * @default false + */ + this.uploadUvMatrix = false; + + /** + * Uploads vertices buffer every frame, like in PixiJS V3 and V4. + * + * @member {boolean} + * @default true + */ + this.autoUpdate = true; + } + + /** + * The tint applied to the Rope. This is a hex value. A value of + * 0xFFFFFF will remove any tint effect. + * + * @member {number} + * @memberof PIXI.Sprite# + * @default 0xFFFFFF + */ + get tint() + { + return this._tint; + } + + /** + * Sets the tint of the rope. + * + * @param {number} value - The value to set to. + */ + set tint(value) + { + this._tint = value; + + hex2rgb(this._tint, this._tintRGB); + } + + /** + * The blend mode to be applied to the sprite. Set to `PIXI.BLEND_MODES.NORMAL` to remove any blend mode. + * + * @member {number} + * @default PIXI.BLEND_MODES.NORMAL + * @see PIXI.BLEND_MODES + */ + get blendMode() + { + return this.state.blendMode; + } + + set blendMode(value) // eslint-disable-line require-jsdoc + { + this.state.blendMode = value; + } + + /** + * The texture that the mesh uses. + * + * @member {PIXI.Texture} + */ + get texture() + { + return this._texture; + } + + set texture(value) // eslint-disable-line require-jsdoc + { + if (this._texture === value) + { + return; + } + + this._texture = value; + this.uniforms.uSampler = this.texture; + + if (value) + { + // wait for the texture to load + if (value.baseTexture.valid) + { + this._onTextureUpdate(); + } + else + { + value.once('update', this._onTextureUpdate, this); + } + } + } + + _render(renderer) + { + const baseTex = this._texture.baseTexture; + + premultiplyRgba(this._tintRGB, this.worldAlpha, this.uniforms.uColor, baseTex.premultiplyAlpha); + super._render(renderer); + } + /** + * When the texture is updated, this event will fire to update the scale and frame + * + * @private + */ + _onTextureUpdate() + { + // constructor texture update stop + if (!this.uvMatrix) + { + return; + } + this.uvMatrix.texture = this._texture; + this.refresh(); + } + + /** + * multiplies uvs only if uploadUvMatrix is false + * call it after you change uvs manually + * make sure that texture is valid + */ + multiplyUvs() + { + if (!this.uploadUvMatrix) + { + this.uvMatrix.multiplyUvs(this.uvs); + } + } + + /** + * Refreshes uvs for generated meshes (rope, plane) + * sometimes refreshes vertices too + * + * @param {boolean} [forceUpdate=false] if true, matrices will be updated any case + */ + refresh(forceUpdate) + { + if (this.uvMatrix.update(forceUpdate)) + { + this._refresh(); + } + } + + /** + * Updates the object transform for rendering + * + * @private + */ + updateTransform() + { + if (this.autoUpdate) + { + this.geometry.buffers[0].update(); + } + this.containerUpdateTransform(); + } + + /** + * re-calculates mesh coords + * @private + */ + _refresh() + { + /* empty */ + } +} diff --git a/packages/mesh-extras/src/NineSlicePlane.js b/packages/mesh-extras/src/NineSlicePlane.js new file mode 100644 index 0000000..0bae92c --- /dev/null +++ b/packages/mesh-extras/src/NineSlicePlane.js @@ -0,0 +1,270 @@ +import Plane from './Plane'; + +const DEFAULT_BORDER_SIZE = 10; + +/** + * The NineSlicePlane allows you to stretch a texture using 9-slice scaling. The corners will remain unscaled (useful + * for buttons with rounded corners for example) and the other areas will be scaled horizontally and or vertically + * + *```js + * let Plane9 = new PIXI.NineSlicePlane(PIXI.Texture.from('BoxWithRoundedCorners.png'), 15, 15, 15, 15); + * ``` + *
+ *      A                          B
+ *    +---+----------------------+---+
+ *  C | 1 |          2           | 3 |
+ *    +---+----------------------+---+
+ *    |   |                      |   |
+ *    | 4 |          5           | 6 |
+ *    |   |                      |   |
+ *    +---+----------------------+---+
+ *  D | 7 |          8           | 9 |
+ *    +---+----------------------+---+
+
+ *  When changing this objects width and/or height:
+ *     areas 1 3 7 and 9 will remain unscaled.
+ *     areas 2 and 8 will be stretched horizontally
+ *     areas 4 and 6 will be stretched vertically
+ *     area 5 will be stretched both horizontally and vertically
+ * 
+ * + * @class + * @extends PIXI.Plane + * @memberof PIXI + * + */ +export default class NineSlicePlane extends Plane +{ + /** + * @param {PIXI.Texture} texture - The texture to use on the NineSlicePlane. + * @param {int} [leftWidth=10] size of the left vertical bar (A) + * @param {int} [topHeight=10] size of the top horizontal bar (C) + * @param {int} [rightWidth=10] size of the right vertical bar (B) + * @param {int} [bottomHeight=10] size of the bottom horizontal bar (D) + */ + constructor(texture, leftWidth, topHeight, rightWidth, bottomHeight) + { + super(texture, 4, 4); + + this._origWidth = texture.orig.width; + this._origHeight = texture.orig.height; + + /** + * The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._width = this._origWidth; + + /** + * The height of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._height = this._origHeight; + + /** + * The width of the left column (a) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._leftWidth = typeof leftWidth !== 'undefined' ? leftWidth : DEFAULT_BORDER_SIZE; + + /** + * The width of the right column (b) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._rightWidth = typeof rightWidth !== 'undefined' ? rightWidth : DEFAULT_BORDER_SIZE; + + /** + * The height of the top row (c) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._topHeight = typeof topHeight !== 'undefined' ? topHeight : DEFAULT_BORDER_SIZE; + + /** + * The height of the bottom row (d) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._bottomHeight = typeof bottomHeight !== 'undefined' ? bottomHeight : DEFAULT_BORDER_SIZE; + + this.refresh(true); + } + + /** + * Updates the horizontal vertices. + * + */ + updateHorizontalVertices() + { + const vertices = this.vertices; + + const h = this._topHeight + this._bottomHeight; + const scale = this._height > h ? 1.0 : this._height / h; + + vertices[9] = vertices[11] = vertices[13] = vertices[15] = this._topHeight * scale; + vertices[17] = vertices[19] = vertices[21] = vertices[23] = this._height - (this._bottomHeight * scale); + vertices[25] = vertices[27] = vertices[29] = vertices[31] = this._height; + } + + /** + * Updates the vertical vertices. + * + */ + updateVerticalVertices() + { + const vertices = this.vertices; + + const w = this._leftWidth + this._rightWidth; + const scale = this._width > w ? 1.0 : this._width / w; + + vertices[2] = vertices[10] = vertices[18] = vertices[26] = this._leftWidth * scale; + vertices[4] = vertices[12] = vertices[20] = vertices[28] = this._width - (this._rightWidth * scale); + vertices[6] = vertices[14] = vertices[22] = vertices[30] = this._width; + } + + /** + * The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + */ + get width() + { + return this._width; + } + + set width(value) // eslint-disable-line require-jsdoc + { + this._width = value; + this._refresh(); + } + + /** + * The height of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + */ + get height() + { + return this._height; + } + + set height(value) // eslint-disable-line require-jsdoc + { + this._height = value; + this._refresh(); + } + + /** + * The width of the left column + * + * @member {number} + */ + get leftWidth() + { + return this._leftWidth; + } + + set leftWidth(value) // eslint-disable-line require-jsdoc + { + this._leftWidth = value; + this._refresh(); + } + + /** + * The width of the right column + * + * @member {number} + */ + get rightWidth() + { + return this._rightWidth; + } + + set rightWidth(value) // eslint-disable-line require-jsdoc + { + this._rightWidth = value; + this._refresh(); + } + + /** + * The height of the top row + * + * @member {number} + */ + get topHeight() + { + return this._topHeight; + } + + set topHeight(value) // eslint-disable-line require-jsdoc + { + this._topHeight = value; + this._refresh(); + } + + /** + * The height of the bottom row + * + * @member {number} + */ + get bottomHeight() + { + return this._bottomHeight; + } + + set bottomHeight(value) // eslint-disable-line require-jsdoc + { + this._bottomHeight = value; + this._refresh(); + } + + /** + * Refreshes NineSlicePlane coords. All of them. + */ + _refresh() + { + super._refresh(); + + const uvs = this.uvs; + const texture = this._texture; + + this._origWidth = texture.orig.width; + this._origHeight = texture.orig.height; + + const _uvw = 1.0 / this._origWidth; + const _uvh = 1.0 / this._origHeight; + + uvs[0] = uvs[8] = uvs[16] = uvs[24] = 0; + uvs[1] = uvs[3] = uvs[5] = uvs[7] = 0; + uvs[6] = uvs[14] = uvs[22] = uvs[30] = 1; + uvs[25] = uvs[27] = uvs[29] = uvs[31] = 1; + + uvs[2] = uvs[10] = uvs[18] = uvs[26] = _uvw * this._leftWidth; + uvs[4] = uvs[12] = uvs[20] = uvs[28] = 1 - (_uvw * this._rightWidth); + uvs[9] = uvs[11] = uvs[13] = uvs[15] = _uvh * this._topHeight; + uvs[17] = uvs[19] = uvs[21] = uvs[23] = 1 - (_uvh * this._bottomHeight); + + this.updateHorizontalVertices(); + this.updateVerticalVertices(); + + this.geometry.buffers[1].update(); + + this.multiplyUvs(); + } +} diff --git a/packages/mesh-extras/src/Plane.js b/packages/mesh-extras/src/Plane.js new file mode 100644 index 0000000..1c240c4 --- /dev/null +++ b/packages/mesh-extras/src/Plane.js @@ -0,0 +1,100 @@ +import Mesh2d from './Mesh2d'; + +/** + * The Plane allows you to draw a texture across several points and them manipulate these points + * + *```js + * for (let i = 0; i < 20; i++) { + * points.push(new PIXI.Point(i * 50, 0)); + * }; + * let Plane = new PIXI.Plane(PIXI.Texture.from("snake.png"), points); + * ``` + * + * @class + * @extends PIXI.Mesh + * @memberof PIXI + * + */ +export default class Plane extends Mesh2d +{ + /** + * @param {PIXI.Texture} texture - The texture to use on the Plane. + * @param {number} verticesX - The number of vertices in the x-axis + * @param {number} verticesY - The number of vertices in the y-axis + * @param {object} [opts] - an options object - add meshWidth and meshHeight, temporary object for PixiJS v5 alpha + */ + constructor(texture, verticesX, verticesY, opts = {}) + { + super(texture, new Float32Array(1), new Float32Array(1), new Uint16Array(1), 4); + + this.verticesX = verticesX || 10; + this.verticesY = verticesY || 10; + + this.meshWidth = opts.meshWidth || 0; + this.meshHeight = opts.meshHeight || 0; + + this.refresh(); + } + + /** + * Refreshes plane coordinates + * @private + */ + _refresh() + { + const texture = this._texture; + const total = this.verticesX * this.verticesY; + const verts = []; + const uvs = []; + const indices = []; + + const segmentsX = this.verticesX - 1; + const segmentsY = this.verticesY - 1; + + const sizeX = (this.meshWidth || texture.width) / segmentsX; + const sizeY = (this.meshHeight || texture.height) / segmentsY; + + for (let i = 0; i < total; i++) + { + const x = (i % this.verticesX); + const y = ((i / this.verticesX) | 0); + + verts.push(x * sizeX, y * sizeY); + + uvs.push(x / segmentsX, y / segmentsY); + } + + // cons + + const totalSub = segmentsX * segmentsY; + + for (let i = 0; i < totalSub; i++) + { + const xpos = i % segmentsX; + const ypos = (i / segmentsX) | 0; + + const value = (ypos * this.verticesX) + xpos; + const value2 = (ypos * this.verticesX) + xpos + 1; + const value3 = ((ypos + 1) * this.verticesX) + xpos; + const value4 = ((ypos + 1) * this.verticesX) + xpos + 1; + + indices.push(value, value2, value3); + indices.push(value2, value4, value3); + } + + this.vertices = new Float32Array(verts); + this.uvs = new Float32Array(uvs); + this.indices = new Uint16Array(indices); + + this.geometry.buffers[0].data = this.vertices; + this.geometry.buffers[1].data = this.uvs; + this.geometry.indexBuffer.data = this.indices; + + // ensure that the changes are uploaded + this.geometry.buffers[0].update(); + this.geometry.buffers[1].update(); + this.geometry.indexBuffer.update(); + + this.multiplyUvs(); + } +} diff --git a/packages/mesh-extras/src/Rope.js b/packages/mesh-extras/src/Rope.js new file mode 100644 index 0000000..9cfde38 --- /dev/null +++ b/packages/mesh-extras/src/Rope.js @@ -0,0 +1,182 @@ +import Mesh2d from './Mesh2d'; + +/** + * The rope allows you to draw a texture across several points and them manipulate these points + * + *```js + * for (let i = 0; i < 20; i++) { + * points.push(new PIXI.Point(i * 50, 0)); + * }; + * let rope = new PIXI.Rope(PIXI.Texture.from("snake.png"), points); + * ``` + * + * @class + * @extends PIXI.Mesh + * @memberof PIXI + * + */ +export default class Rope extends Mesh2d +{ + /** + * @param {PIXI.Texture} texture - The texture to use on the rope. + * @param {PIXI.Point[]} points - An array of {@link PIXI.Point} objects to construct this rope. + */ + constructor(texture, points) + { + super(texture, new Float32Array(points.length * 4), + new Float32Array(points.length * 4), + new Uint16Array(points.length * 2), + 5); + + /* + * @member {PIXI.Point[]} An array of points that determine the rope + */ + this.points = points; + this.refresh(); + } + /** + * Refreshes Rope indices and uvs + * @private + */ + _refresh() + { + const points = this.points; + + if (!points) return; + + const vertexBuffer = this.geometry.getAttribute('aVertexPosition'); + const uvBuffer = this.geometry.getAttribute('aTextureCoord'); + const indexBuffer = this.geometry.getIndex(); + + // if too little points, or texture hasn't got UVs set yet just move on. + if (points.length < 1 || !this.texture._uvs) + { + return; + } + + // if the number of points has changed we will need to recreate the arraybuffers + if (vertexBuffer.data.length / 4 !== points.length) + { + vertexBuffer.data = new Float32Array(points.length * 4); + uvBuffer.data = new Float32Array(points.length * 4); + indexBuffer.data = new Uint16Array(points.length * 2); + } + + const uvs = uvBuffer.data; + const indices = indexBuffer.data; + + uvs[0] = 0; + uvs[1] = 0; + uvs[2] = 0; + uvs[3] = 1; + + indices[0] = 0; + indices[1] = 1; + + const total = points.length; + + for (let i = 1; i < total; i++) + { + // time to do some smart drawing! + let index = i * 4; + const amount = i / (total - 1); + + uvs[index] = amount; + uvs[index + 1] = 0; + + uvs[index + 2] = amount; + uvs[index + 3] = 1; + + index = i * 2; + indices[index] = index; + indices[index + 1] = index + 1; + } + + // ensure that the changes are uploaded + uvBuffer.update(); + indexBuffer.update(); + + this.multiplyUvs(); + this.refreshVertices(); + } + + /** + * refreshes vertices of Rope mesh + */ + refreshVertices() + { + const points = this.points; + + if (points.length < 1) + { + return; + } + + let lastPoint = points[0]; + let nextPoint; + let perpX = 0; + let perpY = 0; + + // this.count -= 0.2; + + const vertices = this.vertices; + const total = points.length; + + for (let i = 0; i < total; i++) + { + const point = points[i]; + const index = i * 4; + + if (i < points.length - 1) + { + nextPoint = points[i + 1]; + } + else + { + nextPoint = point; + } + + perpY = -(nextPoint.x - lastPoint.x); + perpX = nextPoint.y - lastPoint.y; + + let ratio = (1 - (i / (total - 1))) * 10; + + if (ratio > 1) + { + ratio = 1; + } + + const perpLength = Math.sqrt((perpX * perpX) + (perpY * perpY)); + const num = this._texture.height / 2; // (20 + Math.abs(Math.sin((i + this.count) * 0.3) * 50) )* ratio; + + perpX /= perpLength; + perpY /= perpLength; + + perpX *= num; + perpY *= num; + + vertices[index] = point.x + perpX; + vertices[index + 1] = point.y + perpY; + vertices[index + 2] = point.x - perpX; + vertices[index + 3] = point.y - perpY; + + lastPoint = point; + } + + this.geometry.buffers[0].update(); + } + + /** + * Updates the object transform for rendering + * + * @private + */ + updateTransform() + { + if (this.autoUpdate) + { + this.refreshVertices(); + } + this.containerUpdateTransform(); + } +} diff --git a/packages/mesh-extras/src/index.js b/packages/mesh-extras/src/index.js new file mode 100644 index 0000000..decf454 --- /dev/null +++ b/packages/mesh-extras/src/index.js @@ -0,0 +1,4 @@ +export { default as Mesh2d } from './Mesh2d'; +export { default as Plane } from './Plane'; +export { default as NineSlicePlane } from './NineSlicePlane'; +export { default as Rope } from './Rope'; diff --git a/packages/mesh-extras/src/mesh.frag b/packages/mesh-extras/src/mesh.frag new file mode 100644 index 0000000..6096983 --- /dev/null +++ b/packages/mesh-extras/src/mesh.frag @@ -0,0 +1,9 @@ +varying vec2 vTextureCoord; +uniform vec4 uColor; + +uniform sampler2D uSampler; + +void main(void) +{ + gl_FragColor = texture2D(uSampler, vTextureCoord) * uColor; +} diff --git a/packages/mesh-extras/src/mesh.vert b/packages/mesh-extras/src/mesh.vert new file mode 100644 index 0000000..0526df9 --- /dev/null +++ b/packages/mesh-extras/src/mesh.vert @@ -0,0 +1,15 @@ +attribute vec2 aVertexPosition; +attribute vec2 aTextureCoord; + +uniform mat3 projectionMatrix; +uniform mat3 translationMatrix; +uniform mat3 uTextureMatrix; + +varying vec2 vTextureCoord; + +void main(void) +{ + gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); + + vTextureCoord = (uTextureMatrix * vec3(aTextureCoord, 1.0)).xy; +} diff --git a/packages/mesh-extras/test/.eslintrc.json b/packages/mesh-extras/test/.eslintrc.json new file mode 100644 index 0000000..2ad8efb --- /dev/null +++ b/packages/mesh-extras/test/.eslintrc.json @@ -0,0 +1,12 @@ +{ + "globals": { + "expect": false, + "assert": false, + "sinon": false, + "PIXI": false + }, + "rules": { + "func-names": 0, + "no-unused-expressions": 0 + } +} \ No newline at end of file diff --git a/packages/mesh-extras/test/Plane.js b/packages/mesh-extras/test/Plane.js new file mode 100644 index 0000000..f9b1c25 --- /dev/null +++ b/packages/mesh-extras/test/Plane.js @@ -0,0 +1,60 @@ +const { Plane } = require('../'); +const { isWebGLSupported, skipHello } = require('@pixi/utils'); +const { Loader } = require('@pixi/loaders'); +const { Point } = require('@pixi/math'); +const { RenderTexture, Texture } = require('@pixi/core'); + +skipHello(); + +function withGL(fn) +{ + return isWebGLSupported() ? fn : undefined; +} + +// TODO: fix with webglrenderer +describe('PIXI.mesh.Plane', function () +{ + it.skip('should create a plane from an external image', withGL(function (done) + { + const loader = new Loader(); + + loader.add('testBitmap', `file://${__dirname}/resources/bitmap-1.png`) + .load(function (loader, resources) + { + const plane = new Plane(resources.testBitmap.texture, 100, 100); + + expect(plane.verticesX).to.equal(100); + expect(plane.verticesY).to.equal(100); + done(); + }); + })); + + it.skip('should create a new empty textured Plane', withGL(function () + { + const plane = new Plane(Texture.EMPTY, 100, 100); + + expect(plane.verticesX).to.equal(100); + expect(plane.verticesY).to.equal(100); + })); + + describe('containsPoint', function () + { + it.skip('should return true when point inside', withGL(function () + { + const point = new Point(10, 10); + const texture = new RenderTexture.create(20, 30); + const plane = new Plane(texture, 100, 100); + + expect(plane.containsPoint(point)).to.be.true; + })); + + it.skip('should return false when point outside', withGL(function () + { + const point = new Point(100, 100); + const texture = new RenderTexture.create(20, 30); + const plane = new Plane(texture, 100, 100); + + expect(plane.containsPoint(point)).to.be.false; + })); + }); +}); diff --git a/packages/mesh-extras/test/index.js b/packages/mesh-extras/test/index.js new file mode 100644 index 0000000..d767624 --- /dev/null +++ b/packages/mesh-extras/test/index.js @@ -0,0 +1 @@ +require('./Plane'); diff --git a/packages/mesh-extras/test/resources/bitmap-1.png b/packages/mesh-extras/test/resources/bitmap-1.png new file mode 100644 index 0000000..1284fb8 --- /dev/null +++ b/packages/mesh-extras/test/resources/bitmap-1.png Binary files differ diff --git a/packages/mesh/package.json b/packages/mesh/package.json index 8b1f8d9..10bd8e3 100644 --- a/packages/mesh/package.json +++ b/packages/mesh/package.json @@ -18,22 +18,16 @@ "publishConfig": { "access": "public" }, - "scripts": { - "test": "floss --path test" - }, "files": [ "lib" ], "dependencies": { - "@pixi/canvas-renderer": "^5.0.0-alpha.2", "@pixi/constants": "^5.0.0-alpha.2", "@pixi/core": "^5.0.0-alpha.2", "@pixi/display": "^5.0.0-alpha.2", - "@pixi/math": "^5.0.0-alpha.2", - "@pixi/utils": "^5.0.0-alpha.2" + "@pixi/math": "^5.0.0-alpha.2" }, "devDependencies": { - "@pixi/loaders": "^5.0.0-alpha.2", "floss": "^2.1.3" } } diff --git a/packages/mesh/src/Mesh.js b/packages/mesh/src/Mesh.js index e7c8f9e..1f35b7a 100644 --- a/packages/mesh/src/Mesh.js +++ b/packages/mesh/src/Mesh.js @@ -1,263 +1,220 @@ -import RawMesh from './RawMesh'; -import { Geometry, Program, Shader, Texture, TextureMatrix } from '@pixi/core'; -import { Matrix } from '@pixi/math'; -import { BLEND_MODES } from '@pixi/constants'; -import { hex2rgb, premultiplyRgba } from '@pixi/utils'; -import vertex from './mesh.vert'; -import fragment from './mesh.frag'; +import { State } from '@pixi/core'; +import { DRAW_MODES } from '@pixi/constants'; +import { Point, Polygon } from '@pixi/math'; +import { Container } from '@pixi/display'; -let meshProgram; +const tempPoint = new Point(); +const tempPolygon = new Polygon(); /** - * Base mesh class + * Base mesh class. + * The reason for this class is to empower you to have maximum flexibility to render any kind of webGL you can think of. + * This class assumes a certain level of webGL knowledge. + * If you know a bit this should abstract enough away to make you life easier! + * Pretty much ALL WebGL can be broken down into the following: + * Geometry - The structure and data for the mesh. This can include anything from positions, uvs, normals, colors etc.. + * Shader - This is the shader that pixi will render the geometry with. (attributes in the shader must match the geometry!) + * Uniforms - These are the values passed to the shader when the mesh is rendered. + * As a shader can be reused across multiple objects, it made sense to allow uniforms to exist outside of the shader + * State - This is the state of WebGL required to render the mesh. + * Through a combination of the above elements you can render anything you want, 2D or 3D! + * * @class * @extends PIXI.Container * @memberof PIXI */ -export default class Mesh extends RawMesh +export default class Mesh extends Container { /** - * @param {PIXI.Texture} [texture=Texture.EMPTY] - The texture to use - * @param {Float32Array} [vertices] - if you want to specify the vertices - * @param {Float32Array} [uvs] - if you want to specify the uvs - * @param {Uint16Array} [indices] - if you want to specify the indices - * @param {number} [drawMode] - the drawMode, can be any of the Mesh.DRAW_MODES consts + * @param {PIXI.Geometry} geometry the geometry the mesh will use + * @param {PIXI.Shader} shader the shader the mesh will use + * @param {PIXI.State} state the state that the webGL context is required to be in to render the mesh + * @param {number} drawMode the drawMode, can be any of the PIXI.DRAW_MODES consts */ - constructor(texture = Texture.EMPTY, vertices, uvs, indices, drawMode) + constructor(geometry, shader, state, drawMode = DRAW_MODES.TRIANGLES) { - const geometry = new Geometry(); - - if (!meshProgram) - { - meshProgram = new Program(vertex, fragment); - } - - geometry.addAttribute('aVertexPosition', vertices) - .addAttribute('aTextureCoord', uvs) - .addIndex(indices); - - geometry.getAttribute('aVertexPosition').static = false; - - const uniforms = { - uSampler: texture, - uTextureMatrix: Matrix.IDENTITY, - alpha: 1, - uColor: new Float32Array([1, 1, 1, 1]), - }; - - super(geometry, new Shader(meshProgram, uniforms), null, drawMode); + super(); /** - * The Uvs of the Mesh - * - * @member {Float32Array} + * the geometry the mesh will use + * @type {PIXI.Geometry} */ - this.uvs = geometry.getAttribute('aTextureCoord').data; + this.geometry = geometry; /** - * An array of vertices - * - * @member {Float32Array} + * the shader the mesh will use + * @type {PIXI.Shader} */ - this.vertices = geometry.getAttribute('aVertexPosition').data; - - this.uniforms = uniforms; + this.shader = shader; /** - * The texture of the Mesh - * - * @member {PIXI.Texture} - * @default PIXI.Texture.EMPTY - * @private + * the webGL state the mesh requires to render + * @type {PIXI.State} */ - this.texture = texture; + this.state = state || new State(); /** - * The tint applied to the mesh. This is a [r,g,b] value. A value of [1,1,1] will remove any - * tint effect. + * The way the Mesh should be drawn, can be any of the {@link PIXI.Mesh.DRAW_MODES} consts * * @member {number} + * @see PIXI.Mesh.DRAW_MODES + */ + this.drawMode = drawMode; + + /** + * The way uniforms that will be used by the mesh's shader. + * @member {Object} + */ + + /** + * A map of renderer IDs to webgl render data + * * @private + * @member {object} */ - this._tintRGB = new Float32Array([1, 1, 1]); - - // Set default tint - this.tint = 0xFFFFFF; - - this.blendMode = BLEND_MODES.NORMAL; + this._glDatas = {}; /** - * TextureMatrix instance for this Mesh, used to track Texture changes + * Plugin that is responsible for rendering this element. + * Allows to customize the rendering process without overriding '_render' & '_renderCanvas' methods. * - * @member {PIXI.TextureMatrix} - * @readonly + * @member {string} + * @default 'mesh' */ - this.uvMatrix = new TextureMatrix(this._texture); + this.pluginName = 'mesh'; - /** - * whether or not upload uvMatrix to shader - * if its false, then uvs should be pre-multiplied - * if you change it for generated mesh, please call 'refresh(true)' - * @member {boolean} - * @default false - */ - this.uploadUvMatrix = false; - - /** - * Uploads vertices buffer every frame, like in PixiJS V3 and V4. - * - * @member {boolean} - * @default true - */ - this.autoUpdate = true; + this.start = 0; + this.size = 0; } /** - * The tint applied to the Rope. This is a hex value. A value of - * 0xFFFFFF will remove any tint effect. + * Renders the object using the WebGL renderer * - * @member {number} - * @memberof PIXI.Sprite# - * @default 0xFFFFFF + * @param {PIXI.Renderer} renderer a reference to the WebGL renderer + * @private */ - get tint() + _render(renderer) { - return this._tint; + renderer.batch.setObjectRenderer(renderer.plugins[this.pluginName]); + renderer.plugins[this.pluginName].render(this); } /** - * Sets the tint of the rope. + * Updates the bounds of the mesh as a rectangle. The bounds calculation takes the worldTransform into account. + * there must be a aVertexPosition attribute present in the geometry for bounds to be calculated correctly. * - * @param {number} value - The value to set to. + * @private */ - set tint(value) + _calculateBounds() { - this._tint = value; - - hex2rgb(this._tint, this._tintRGB); - } - - /** - * The blend mode to be applied to the sprite. Set to `PIXI.BLEND_MODES.NORMAL` to remove any blend mode. - * - * @member {number} - * @default PIXI.BLEND_MODES.NORMAL - * @see PIXI.BLEND_MODES - */ - get blendMode() - { - return this.state.blendMode; - } - - set blendMode(value) // eslint-disable-line require-jsdoc - { - this.state.blendMode = value; - } - - /** - * The texture that the mesh uses. - * - * @member {PIXI.Texture} - */ - get texture() - { - return this._texture; - } - - set texture(value) // eslint-disable-line require-jsdoc - { - if (this._texture === value) + // The position property could be set manually? + if (this.geometry.attributes.aVertexPosition) { - return; + const vertices = this.geometry.getAttribute('aVertexPosition').data; + + // TODO - we can cache local bounds and use them if they are dirty (like graphics) + this._bounds.addVertices(this.transform, vertices, 0, vertices.length); + } + } + + /** + * Tests if a point is inside this mesh. Works only for TRIANGLE_MESH + * + * @param {PIXI.Point} point the point to test + * @return {boolean} the result of the test + */ + containsPoint(point) + { + if (!this.getBounds().contains(point.x, point.y)) + { + return false; } - this._texture = value; - this.uniforms.uSampler = this.texture; + this.worldTransform.applyInverse(point, tempPoint); - if (value) + const vertices = this.geometry.getAttribute('aVertexPosition').data; + + const points = tempPolygon.points; + const indices = this.geometry.getIndex().data; + const len = indices.length; + const step = this.drawMode === 4 ? 3 : 1; + + for (let i = 0; i + 2 < len; i += step) { - // wait for the texture to load - if (value.baseTexture.valid) + const ind0 = indices[i] * 2; + const ind1 = indices[i + 1] * 2; + const ind2 = indices[i + 2] * 2; + + points[0] = vertices[ind0]; + points[1] = vertices[ind0 + 1]; + points[2] = vertices[ind1]; + points[3] = vertices[ind1 + 1]; + points[4] = vertices[ind2]; + points[5] = vertices[ind2 + 1]; + + if (tempPolygon.contains(tempPoint.x, tempPoint.y)) { - this._onTextureUpdate(); + return true; + } + } + + return false; + } + + /** + * Destroys the Mesh object. + * + * @param {object|boolean} [options] - Options parameter. A boolean will act as if all + * options have been set to that value + * @param {boolean} [options.children=false] - if set to true, all the children will have + * their destroy method called as well. 'options' will be passed on to those calls. + * @param {boolean} [options.texture=false] - Only used for child Sprites if options.children is set to true + * Should it destroy the texture of the child sprite + * @param {boolean} [options.baseTexture=false] - Only used for child Sprites if options.children is set to true + * Should it destroy the base texture of the child sprite + */ + destroy(options) + { + // for each webgl data entry, destroy the WebGLGraphicsData + for (const id in this._glDatas) + { + const data = this._glDatas[id]; + + if (data.destroy) + { + data.destroy(); } else { - value.once('update', this._onTextureUpdate, this); + if (data.vertexBuffer) + { + data.vertexBuffer.destroy(); + data.vertexBuffer = null; + } + if (data.indexBuffer) + { + data.indexBuffer.destroy(); + data.indexBuffer = null; + } + if (data.uvBuffer) + { + data.uvBuffer.destroy(); + data.uvBuffer = null; + } + if (data.vao) + { + data.vao.destroy(); + data.vao = null; + } } } - } - _render(renderer) - { - const baseTex = this._texture.baseTexture; + this._glDatas = null; - premultiplyRgba(this._tintRGB, this.worldAlpha, this.uniforms.uColor, baseTex.premultiplyAlpha); - super._render(renderer); - } - /** - * When the texture is updated, this event will fire to update the scale and frame - * - * @private - */ - _onTextureUpdate() - { - // constructor texture update stop - if (!this.uvMatrix) - { - return; - } - this.uvMatrix.texture = this._texture; - this.refresh(); - } + this.geometry = null; + this.shader = null; + this.state = null; - /** - * multiplies uvs only if uploadUvMatrix is false - * call it after you change uvs manually - * make sure that texture is valid - */ - multiplyUvs() - { - if (!this.uploadUvMatrix) - { - this.uvMatrix.multiplyUvs(this.uvs); - } - } - - /** - * Refreshes uvs for generated meshes (rope, plane) - * sometimes refreshes vertices too - * - * @param {boolean} [forceUpdate=false] if true, matrices will be updated any case - */ - refresh(forceUpdate) - { - if (this.uvMatrix.update(forceUpdate)) - { - this._refresh(); - } - } - - /** - * Updates the object transform for rendering - * - * @private - */ - updateTransform() - { - if (this.autoUpdate) - { - this.geometry.buffers[0].update(); - } - this.containerUpdateTransform(); - } - - /** - * re-calculates mesh coords - * @private - */ - _refresh() - { - /* empty */ + super.destroy(options); } } diff --git a/bundles/pixi.js/package.json b/bundles/pixi.js/package.json index 49c7276..177e059 100644 --- a/bundles/pixi.js/package.json +++ b/bundles/pixi.js/package.json @@ -49,6 +49,7 @@ "@pixi/loaders": "^5.0.0-alpha.2", "@pixi/math": "^5.0.0-alpha.2", "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/mesh-extras": "^5.0.0-alpha.2", "@pixi/mixin-cache-as-bitmap": "^5.0.0-alpha.2", "@pixi/mixin-get-child-by-name": "^5.0.0-alpha.2", "@pixi/mixin-get-global-position": "^5.0.0-alpha.2", diff --git a/bundles/pixi.js/src/deprecated.js b/bundles/pixi.js/src/deprecated.js index 147617c..dbebeb0 100644 --- a/bundles/pixi.js/src/deprecated.js +++ b/bundles/pixi.js/src/deprecated.js @@ -263,15 +263,15 @@ Object.defineProperties(PIXI.mesh, { /** * @class PIXI.mesh.Mesh - * @see PIXI.Mesh + * @see PIXI.Mesh2d * @deprecated since 5.0.0 */ Mesh: { get() { - warn('PIXI.mesh.Mesh has moved to PIXI.Mesh'); + warn('PIXI.mesh.Mesh has moved to PIXI.Mesh2d'); - return PIXI.Mesh; + return PIXI.Mesh2d; }, }, /** @@ -315,15 +315,15 @@ }, /** * @class PIXI.mesh.RawMesh - * @see PIXI.RawMesh + * @see PIXI.Mesh * @deprecated since 5.0.0 */ RawMesh: { get() { - warn('PIXI.mesh.RawMesh has moved to PIXI.RawMesh'); + warn('PIXI.mesh.RawMesh has moved to PIXI.Mesh'); - return PIXI.RawMesh; + return PIXI.Mesh; }, }, /** diff --git a/bundles/pixi.js/src/index.js b/bundles/pixi.js/src/index.js index a3a0d1b..6fdabf0 100644 --- a/bundles/pixi.js/src/index.js +++ b/bundles/pixi.js/src/index.js @@ -9,6 +9,7 @@ import * as loaders from '@pixi/loaders'; import * as math from '@pixi/math'; import * as mesh from '@pixi/mesh'; +import * as meshExtras from '@pixi/mesh-extras'; import * as particles from '@pixi/particles'; import * as prepare from '@pixi/prepare'; import * as sprite from '@pixi/sprite'; @@ -128,6 +129,7 @@ loaders, math, mesh, + meshExtras, particles, sprite, spriteAnimated, @@ -152,6 +154,7 @@ export * from '@pixi/loaders'; export * from '@pixi/math'; export * from '@pixi/mesh'; +export * from '@pixi/mesh-extras'; export * from '@pixi/particles'; export * from '@pixi/sprite'; export * from '@pixi/spritesheet'; diff --git a/package-lock.json b/package-lock.json index 7fe6db7..0814729 100644 --- a/package-lock.json +++ b/package-lock.json @@ -209,7 +209,7 @@ "argparse": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", - "integrity": "sha1-vNZ5HqWuCXJeF+WtmIE0zUCz2RE=", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", "dev": true, "requires": { "sprintf-js": "1.0.3" @@ -228,7 +228,7 @@ "arr-flatten": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz", - "integrity": "sha1-NgSLv/TntH4TZkQxbJlmnqWukfE=", + "integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==", "dev": true }, "arr-union": { @@ -297,7 +297,7 @@ "assertion-error": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", - "integrity": "sha1-5gtrDo8wG9l+U3UhW9pAbIURjAs=", + "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", "dev": true }, "async": { @@ -396,7 +396,7 @@ "brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha1-PH/L9SnYcibz0vUrlm/1Jx60Qd0=", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, "requires": { "balanced-match": "1.0.0", @@ -568,7 +568,7 @@ "circular-json": { "version": "0.3.3", "resolved": "https://registry.npmjs.org/circular-json/-/circular-json-0.3.3.tgz", - "integrity": "sha1-gVyZ6oT2gJUp0vRXkb34JxE1LWY=", + "integrity": "sha512-UZK3NBx2Mca+b5LsG7bY183pHWt5Y1xts4P3Pz7ENTwGVnJOUWbRb3ocjvX7hx9tq/yTAdclXm9sZ38gNuem4A==", "dev": true }, "cli-cursor": { @@ -638,7 +638,7 @@ "color-convert": { "version": "1.9.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.1.tgz", - "integrity": "sha1-wSYRB66y8pTr/+ye2eytUppgl+0=", + "integrity": "sha512-mjGanIiwQJskCC18rPR6OmrZ6fm2Lc7PeGFYwCmy5J34wC6F1PzdGL6xeMfmgicfYcNLGuVFA3WzXtIDCQSZxQ==", "dev": true, "requires": { "color-name": "1.1.3" @@ -1427,7 +1427,7 @@ "boom": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/boom/-/boom-5.2.0.tgz", - "integrity": "sha1-XdnabuOl8wIHdDYpDLcX0/SlTgI=", + "integrity": "sha512-Z5BTk6ZRe4tXXQlkqftmsAUANpXmuwlsF5Oov8ThoMbQRzdGTA1ngYRW160GexgOgjsFOKJz0LYhoNi+2AMBUw==", "dev": true, "requires": { "hoek": "4.2.1" @@ -1471,7 +1471,7 @@ "debug": { "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha1-XRKFFd8TT/Mn6QpMk/Tgd6U2NB8=", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", "dev": true, "requires": { "ms": "2.0.0" @@ -1585,7 +1585,7 @@ "doctrine": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", - "integrity": "sha1-XNAfwQFiG0LEzX9dGmYkNxbT850=", + "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", "dev": true, "requires": { "esutils": "2.0.2" @@ -1662,7 +1662,7 @@ "es6-promise": { "version": "4.2.4", "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.4.tgz", - "integrity": "sha1-3EIhwrFlGHYL2MOaUtjzVvwA7Sk=", + "integrity": "sha512-/NdNZVJg+uZgtm9eS3O6lrOLYmQag2DjdEXuPaHlZ6RuVqgqaVZfgYCepEIKsLqwdQArOPtC3XzRLqGGfT8KQQ==", "dev": true }, "escape-string-regexp": { @@ -1788,7 +1788,7 @@ "espree": { "version": "3.5.4", "resolved": "https://registry.npmjs.org/espree/-/espree-3.5.4.tgz", - "integrity": "sha1-sPRHGHyKi+2US4FaZgvd9d610ac=", + "integrity": "sha512-yAcIQxtmMiB/jL32dzEp2enBeidsB7xWPLNiw3IIkpVds1P+h7qF9YwJq1yUNzp2OKXgAprs4F61ih66UsoD1A==", "dev": true, "requires": { "acorn": "5.5.0", @@ -1798,7 +1798,7 @@ "esprima": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.0.tgz", - "integrity": "sha1-RJnt3NERDgshi6zy+n9/WfVcqAQ=", + "integrity": "sha512-oftTcaMu/EGrEIu904mWteKIv8vMuOgGYo7EhVJJN00R/EED9DCua/xxHRdYnKtcECzVg7xOWhflvJMnqcFZjw==", "dev": true }, "esquery": { @@ -1813,7 +1813,7 @@ "esrecurse": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.2.1.tgz", - "integrity": "sha1-AHo7n9vCs7uH5IeeoZyS/b05Qs8=", + "integrity": "sha512-64RBB++fIOAXPw3P9cy89qfMlvZEXZkqqJkjqqXIvzP5ezRZjW+lPWjw35UX/3EhUPFYbg5ER4JYgDw4007/DQ==", "dev": true, "requires": { "estraverse": "4.2.0" @@ -2024,7 +2024,7 @@ "find-root": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/find-root/-/find-root-1.1.0.tgz", - "integrity": "sha1-q8/Iunb3CMQql7PWhbfpRQv7nOQ=", + "integrity": "sha512-NKfW6bec6GfKc0SGx1e07QZY9PE99u0Bft/0rzSD5k3sO/vwkVUpDUKVm5Gpp5Ue3YfShPFTX2070tDs5kB9Ng==", "dev": true }, "find-up": { @@ -2103,7 +2103,7 @@ "supports-color": { "version": "5.3.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.3.0.tgz", - "integrity": "sha1-WySsFduA+pJ89SJ6SjP9PEx2dsA=", + "integrity": "sha512-0aP01LLIskjKs3lq52EC0aGBAJhLq7B2Rd8HC/DR/PtNNpcLilNmHC12O+hu0usQpo7wtHNRqtrhBwtDb0+dNg==", "dev": true, "requires": { "has-flag": "3.0.0" @@ -2567,7 +2567,7 @@ "glob": { "version": "7.1.2", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", - "integrity": "sha1-wZyd+aAocC1nhhI4SmVSQExjbRU=", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", "dev": true, "requires": { "fs.realpath": "1.0.0", @@ -2672,7 +2672,7 @@ "growl": { "version": "1.10.3", "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.3.tgz", - "integrity": "sha1-GSa6kM8+3+KttJJ/WIC8IsZseQ8=", + "integrity": "sha512-hKlsbA5Vu3xsh1Cg3J7jSmX/WaW6A5oBeqzM88oNbCRQFz+zUaXm6yxS4RVytp1scBoJzSYl4YAEOQIt6O8V1Q==", "dev": true }, "handlebars": { @@ -2738,7 +2738,7 @@ "hawk": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/hawk/-/hawk-6.0.2.tgz", - "integrity": "sha1-r02RTrBl+bXOTZ0RwcshJu7MMDg=", + "integrity": "sha512-miowhl2+U7Qle4vdLqDdPt9m09K6yZhkLDTWGoUiUzrQCn+mHHSmfJgAyGaLRZbPmTqfFFjRV1QWCW0VWUJBbQ==", "dev": true, "requires": { "boom": "4.3.1", @@ -2756,7 +2756,7 @@ "hoek": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/hoek/-/hoek-4.2.1.tgz", - "integrity": "sha1-ljRQKqEsRF3Vp8VzS1cruHOKrLs=", + "integrity": "sha512-QLg82fGkfnJ/4iy1xZ81/9SIJiq1NGFUMGs6ParyjBZr6jW2Ufj/snDqTHixNlHdPNwN2RLVD0Pi3igeK9+JfA==", "dev": true }, "home-path": { @@ -2791,7 +2791,7 @@ "ignore": { "version": "3.3.7", "resolved": "https://registry.npmjs.org/ignore/-/ignore-3.3.7.tgz", - "integrity": "sha1-YSKJv7PCIOGGpYEYYY1b6MG6sCE=", + "integrity": "sha512-YGG3ejvBNHRqu0559EOxxNFihD0AjpvHlC/pdGKd3X3ofe+CoJkYazwNJYTNebqpPKN+VVQbh4ZFn1DivMNuHA==", "dev": true }, "imurmurhash": { @@ -2828,7 +2828,7 @@ "ini": { "version": "1.3.5", "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", - "integrity": "sha1-7uJfVtscnsYIXgwid4CD9Zar+Sc=", + "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==", "dev": true }, "inquirer": { @@ -2901,7 +2901,7 @@ "is-buffer": { "version": "1.1.6", "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", - "integrity": "sha1-76ouqdqg16suoTqXsritUf776L4=", + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", "dev": true }, "is-builtin-module": { @@ -3054,7 +3054,7 @@ "is-resolvable": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/is-resolvable/-/is-resolvable-1.1.0.tgz", - "integrity": "sha1-+xj4fOH+uSUWnJpAfBkxijIG7Yg=", + "integrity": "sha512-qgDYXFSR5WvEfuS5dMj6oTMEbrrSaM0CrFk2Yiq/gXnBvD9pMa2jGXxyhGLfvhZpuMZe18CJpFxAt3CRs42NMg==", "dev": true }, "is-retry-allowed": { @@ -3204,7 +3204,7 @@ "js-yaml": { "version": "3.11.0", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.11.0.tgz", - "integrity": "sha1-WXwai9VxUvJtYizkEXhRpR9euu8=", + "integrity": "sha512-saJstZWv7oNeOyBh3+Dx1qWzhW0+e6/8eDzo7p5rDFqxntSztloLtuKu+Ejhtq82jsilwOIZYsCz+lIjthg1Hw==", "dev": true, "requires": { "argparse": "1.0.10", @@ -3324,7 +3324,7 @@ "just-extend": { "version": "1.1.27", "resolved": "https://registry.npmjs.org/just-extend/-/just-extend-1.1.27.tgz", - "integrity": "sha1-7G55QQ/5FORyZSq/oOYDwD1g6QU=", + "integrity": "sha512-mJVp13Ix6gFo3SBAy9U/kL+oeZqzlYYYLQBwXVBlVzIsZwBqGREnOro24oC/8s8aox+rJhtZ2DiQof++IrkA+g==", "dev": true }, "kind-of": { @@ -3703,7 +3703,7 @@ "lodash": { "version": "4.17.5", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.5.tgz", - "integrity": "sha1-maktZcAnLevoyWtgV7yPv6O+1RE=", + "integrity": "sha512-svL3uiZf1RwhH+cWrfZn3A4+U58wbP0tGVTLQPbjplZxZ8ROD9VLuNgsRniTlLe7OlSqR79RUehXgpBW/s0IQw==", "dev": true }, "lodash._reinterpolate": { @@ -3740,7 +3740,7 @@ "lolex": { "version": "2.3.2", "resolved": "https://registry.npmjs.org/lolex/-/lolex-2.3.2.tgz", - "integrity": "sha1-hflFBCUQO/nnpgZo6iXcQydMqAc=", + "integrity": "sha512-A5pN2tkFj7H0dGIAM6MFvHKMJcPnjZsOMvR7ujCjfgW5TbV6H9vb1PgxLtHvjqNZTHsUolz+6/WEO0N1xNx2ng==", "dev": true }, "longest": { @@ -3816,7 +3816,7 @@ "marked": { "version": "0.3.17", "resolved": "https://registry.npmjs.org/marked/-/marked-0.3.17.tgz", - "integrity": "sha1-YH8GZos8axJGso8T2nYRasGqLSs=", + "integrity": "sha512-+AKbNsjZl6jFfLPwHhWmGTqE009wTKn3RTmn9K8oUKHrX/abPJjtcRtXpYB/FFrwPJRUA86LX/de3T0knkPCmQ==", "dev": true }, "mem": { @@ -3896,13 +3896,13 @@ "mime-db": { "version": "1.33.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.33.0.tgz", - "integrity": "sha1-o0kgUKXLm2NFBUHjnZeI0icng9s=", + "integrity": "sha512-BHJ/EKruNIqJf/QahvxwQZXKygOQ256myeN/Ew+THcAa5q+PjyTTMMeNQC4DZw5AwfvelsUrA6B67NKMqXDbzQ==", "dev": true }, "mime-types": { "version": "2.1.18", "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.18.tgz", - "integrity": "sha1-bzI/YKg9ERRvgx/xH9ZuL+VQO7g=", + "integrity": "sha512-lc/aahn+t4/SWV/qcmumYjymLsWfN3ELhpmVuUFjgsORruuZPVSwAQryq+HHGvO/SI2KVX26bx+En+zhM8g8hQ==", "dev": true, "requires": { "mime-db": "1.33.0" @@ -3917,7 +3917,7 @@ "minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha1-UWbihkV/AzBgZL5Ul+jbsMPTIIM=", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "dev": true, "requires": { "brace-expansion": "1.1.11" @@ -4071,7 +4071,7 @@ "normalize-package-data": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.4.0.tgz", - "integrity": "sha1-EvlaMH1YNSB1oEkHuErIvpisAS8=", + "integrity": "sha512-9jjUFbTPfEy3R/ad/2oNbKtW9Hgovl5O1FvFWKkKblNXoN/Oou6+9+KKohPK13Yc3/TyunyWhJp6gvRNR/PPAw==", "dev": true, "requires": { "hosted-git-info": "2.5.0", @@ -4511,7 +4511,7 @@ "process-nextick-args": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", - "integrity": "sha1-o31zL0JxtKsa0HDTVQjoKQeI/6o=", + "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==", "dev": true }, "progress": { @@ -4584,7 +4584,7 @@ "qs": { "version": "6.5.1", "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.1.tgz", - "integrity": "sha1-NJzfbu+J7EXBLX1es/wMhwNDptg=", + "integrity": "sha512-eRzhrN1WSINYCDCbrz796z37LOe3m5tmW7RQf6oBntukAG1nmovJvhnwHHRMAfeoItc1m2Hk02WER2aQ/iqs+A==", "dev": true }, "quick-lru": { @@ -4596,7 +4596,7 @@ "randomatic": { "version": "1.1.7", "resolved": "https://registry.npmjs.org/randomatic/-/randomatic-1.1.7.tgz", - "integrity": "sha1-x6vpzIuHwLqodrGf3oP9RkeX44w=", + "integrity": "sha512-D5JUjPyJbaJDkuAazpVnSfVkLlpeO3wDlPROTMLGKG1zMFNFRgrciKo1ltz/AzNTkqE0HzDx655QOL51N06how==", "dev": true, "requires": { "is-number": "3.0.0", @@ -4701,7 +4701,7 @@ "regex-cache": { "version": "0.4.4", "resolved": "https://registry.npmjs.org/regex-cache/-/regex-cache-0.4.4.tgz", - "integrity": "sha1-db3FiioUls7EihKDW8VMjVYjNt0=", + "integrity": "sha512-nVIZwtCjkC9YgvWkpM55B5rBhBYRZhAaJbgcFYXXsHnbZ9UZI9nnVWYZpBlCqv9ho2eZryPnWrZGsOdPwVWXWQ==", "dev": true, "requires": { "is-equal-shallow": "0.1.3" @@ -4729,7 +4729,7 @@ "remap-istanbul": { "version": "0.10.1", "resolved": "https://registry.npmjs.org/remap-istanbul/-/remap-istanbul-0.10.1.tgz", - "integrity": "sha1-OqWN1QIdSZ8zbTulvzu7kcG4jjc=", + "integrity": "sha512-gsNQXs5kJLhErICSyYhzVZ++C8LBW8dgwr874Y2QvzAUS75zBlD/juZgXs39nbYJ09fZDlX2AVLVJAY2jbFJoQ==", "dev": true, "requires": { "amdefine": "1.0.1", @@ -4769,7 +4769,7 @@ "source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha1-dHIq8y6WFOnCh6jQu95IteLxomM=", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", "dev": true }, "through2": { @@ -4883,7 +4883,7 @@ "resolve": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.5.0.tgz", - "integrity": "sha1-HwmsznlsmnYlefMbLBzEw83fnzY=", + "integrity": "sha512-hgoSGrc3pjzAPHNBg+KnFcK2HwlHTs/YrAGUr6qgTVUZmXv1UEXXl0bZNBKMA9fud6lRYFdPGz0xXxycPzmmiw==", "dev": true, "requires": { "path-parse": "1.0.5" @@ -4924,7 +4924,7 @@ "rimraf": { "version": "2.6.2", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", - "integrity": "sha1-LtgVDSShbqhlHm1u8PR8QVjOejY=", + "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", "dev": true, "requires": { "glob": "7.1.2" @@ -5063,19 +5063,19 @@ "safe-buffer": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", - "integrity": "sha1-iTMSr2myEj3vcfV4iQAWce6yyFM=", + "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", "dev": true }, "samsam": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/samsam/-/samsam-1.3.0.tgz", - "integrity": "sha1-jR2TUOJWItow3j5EumkrUiGrfFA=", + "integrity": "sha512-1HwIYD/8UlOtFS3QO3w7ey+SdSDFE4HRNLZoZRYVQefrOY3l17epswImeB1ijgJFQJodIaHcwkp3r/myBjFVbg==", "dev": true }, "semver": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz", - "integrity": "sha1-3Eu8emyp2Rbe5dQ1FvAJK1j3uKs=", + "integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==", "dev": true }, "set-blocking": { @@ -5117,7 +5117,7 @@ "sinon-chai": { "version": "2.14.0", "resolved": "https://registry.npmjs.org/sinon-chai/-/sinon-chai-2.14.0.tgz", - "integrity": "sha1-2n3UzIPNaiYLZ8yg96n9riahIF0=", + "integrity": "sha512-9stIF1utB0ywNHNT7RgiXbdmen8QDCRsrTjw+G9TgKt1Yexjiv8TOWZ6WHsTPz57Yky3DIswZvEqX8fpuHNDtQ==", "dev": true }, "slash": { @@ -5146,7 +5146,7 @@ "sntp": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/sntp/-/sntp-2.1.0.tgz", - "integrity": "sha1-LGzsFP7cIiJznK+bXD2F0cxaLMg=", + "integrity": "sha512-FL1b58BDrqS3A11lJ0zEdnJ3UOKqVxawAkF3k7F0CVN7VQ34aZrV+G8BZ1WC9ZL7NyrwsW0oviwsWDgRuVYtJg==", "dev": true, "requires": { "hoek": "4.2.1" @@ -5203,7 +5203,7 @@ "spdx-correct": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.0.0.tgz", - "integrity": "sha1-BaW01xU6GVvJLDxCW2nzsqlSTII=", + "integrity": "sha512-N19o9z5cEyc8yQQPukRCZ9EUmb4HUpnrmaL/fxS2pBo2jbfcFRVuFZ/oFC+vZz0MNNk0h80iMn5/S6qGZOL5+g==", "dev": true, "requires": { "spdx-expression-parse": "3.0.0", @@ -5213,13 +5213,13 @@ "spdx-exceptions": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.1.0.tgz", - "integrity": "sha1-LHrmEFbHFKW5ubKyr30xHvXHj+k=", + "integrity": "sha512-4K1NsmrlCU1JJgUrtgEeTVyfx8VaYea9J9LvARxhbHtVtohPs/gFGG5yy49beySjlIMhhXZ4QqujIZEfS4l6Cg==", "dev": true }, "spdx-expression-parse": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.0.tgz", - "integrity": "sha1-meEZt6XaAOBUkcn6M4t5BII7QdA=", + "integrity": "sha512-Yg6D3XpRD4kkOmTpdgbUiEJFKghJH03fiC1OPll5h/0sO6neh2jqRDVHOQ4o/LMea0tgCkbMgea5ip/e+MkWyg==", "dev": true, "requires": { "spdx-exceptions": "2.1.0", @@ -5229,7 +5229,7 @@ "spdx-license-ids": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.0.tgz", - "integrity": "sha1-enzShHDMbToc/m1miG9rxDDTrIc=", + "integrity": "sha512-2+EPwgbnmOIl8HjGBXXMd9NAu02vLjOO1nWw4kmeRDFyHn+M/ETfHxQUK0oXg8ctgVnl9t3rosNVsZ1jG61nDA==", "dev": true }, "speedometer": { @@ -5566,7 +5566,7 @@ "tough-cookie": { "version": "2.3.4", "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.4.tgz", - "integrity": "sha1-7GDO44rGdQY//JelwYlwV47oNlU=", + "integrity": "sha512-TZ6TTfI5NtZnuyy/Kecv+CnoROnyXn2DN97LontgQpCwsX2XyLYCC0ENhYkehSOwAp8rTQKc/NUIF7BkQ5rKLA==", "dev": true, "requires": { "punycode": "1.4.1" @@ -5708,13 +5708,13 @@ "uuid": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.2.1.tgz", - "integrity": "sha1-EsUou51Y0LkmXZovbw/ovhf/HxQ=", + "integrity": "sha512-jZnMwlb9Iku/O3smGWvZhauCf6cvvpKi4BKRiliS3cxnI+Gz9j5MEpTz2UFuXiKPJocb7gnsLHwiS05ige5BEA==", "dev": true }, "validate-npm-package-license": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.3.tgz", - "integrity": "sha1-gWQ7y+8b3+zUYjeT3EZIlIupgzg=", + "integrity": "sha512-63ZOUnL4SIXj4L0NixR3L1lcjO38crAbgrTpl28t8jjrfuiOBL5Iygm+60qPs/KsZGzPNg6Smnc/oY16QTjF0g==", "dev": true, "requires": { "spdx-correct": "3.0.0", @@ -5750,7 +5750,7 @@ "which": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/which/-/which-1.3.0.tgz", - "integrity": "sha1-/wS9/AEO5UfXgL7DjhrBwnd9JTo=", + "integrity": "sha512-xcJpopdamTuY5duC/KnTTNBraPK54YwpenP4lzxU8H91GudWpFv38u0CKjclE1Wi2EH2EDz5LRcHcKbCIzqGyg==", "dev": true, "requires": { "isexe": "2.0.0" diff --git a/packages/canvas/canvas-mesh/package.json b/packages/canvas/canvas-mesh/package.json index 691cd2c..6744a17 100644 --- a/packages/canvas/canvas-mesh/package.json +++ b/packages/canvas/canvas-mesh/package.json @@ -24,6 +24,7 @@ "dependencies": { "@pixi/constants": "^5.0.0-alpha.2", "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/mesh-extras": "^5.0.0-alpha.2", "@pixi/settings": "^5.0.0-alpha.2" }, "devDependencies": { diff --git a/packages/canvas/canvas-mesh/src/Mesh.js b/packages/canvas/canvas-mesh/src/Mesh.js index 900a872..c43a74b 100644 --- a/packages/canvas/canvas-mesh/src/Mesh.js +++ b/packages/canvas/canvas-mesh/src/Mesh.js @@ -1,36 +1,14 @@ import { Mesh } from '@pixi/mesh'; -import { settings } from './settings'; - -// IMPORTANT: Please do NOT use this as a precedent to use `settings` after the object is created -// this was merely created to completely decouple canvas from the base Mesh class and we are -// unable to add `canvasPadding` in the constructor anymore, as the case was for PixiJS v4. /** - * Internal variable for `canvasPadding`. + * Renders the object using the Canvas renderer * * @private - * @memberof PIXI.Mesh - * @member {number} - * @default null - */ -Mesh.prototype._canvasPadding = null; - -/** - * Triangles in canvas mode are automatically antialiased, use this value to force triangles - * to overlap a bit with each other. To set the global default, set {@link PIXI.settings.MESH_CANVAS_PADDING} - * - * @see PIXI.settings.MESH_CANVAS_PADDING - * @member {number} canvasPadding + * @method _renderCanvas * @memberof PIXI.Mesh# - * @default 0 + * @param {PIXI.CanvasRenderer} renderer - The canvas renderer. */ -Object.defineProperty(Mesh.prototype, 'canvasPadding', { - get() - { - return this._canvasPadding !== null ? this._canvasPadding : settings.MESH_CANVAS_PADDING; - }, - set(value) - { - this._canvasPadding = value; - }, -}); +Mesh.prototype._renderCanvas = function _renderCanvas(renderer) +{ + renderer.plugins[this.pluginName].render(this); +}; diff --git a/packages/canvas/canvas-mesh/src/Mesh2d.js b/packages/canvas/canvas-mesh/src/Mesh2d.js new file mode 100644 index 0000000..d0bd80f --- /dev/null +++ b/packages/canvas/canvas-mesh/src/Mesh2d.js @@ -0,0 +1,36 @@ +import { Mesh2d } from '@pixi/mesh-extras'; +import { settings } from './settings'; + +// IMPORTANT: Please do NOT use this as a precedent to use `settings` after the object is created +// this was merely created to completely decouple canvas from the base Mesh class and we are +// unable to add `canvasPadding` in the constructor anymore, as the case was for PixiJS v4. + +/** + * Internal variable for `canvasPadding`. + * + * @private + * @memberof PIXI.Mesh2d + * @member {number} + * @default null + */ +Mesh2d.prototype._canvasPadding = null; + +/** + * Triangles in canvas mode are automatically antialiased, use this value to force triangles + * to overlap a bit with each other. To set the global default, set {@link PIXI.settings.MESH_CANVAS_PADDING} + * + * @see PIXI.settings.MESH_CANVAS_PADDING + * @member {number} canvasPadding + * @memberof PIXI.Mesh2d# + * @default 0 + */ +Object.defineProperty(Mesh2d.prototype, 'canvasPadding', { + get() + { + return this._canvasPadding !== null ? this._canvasPadding : settings.MESH_CANVAS_PADDING; + }, + set(value) + { + this._canvasPadding = value; + }, +}); diff --git a/packages/canvas/canvas-mesh/src/NineSlicePlane.js b/packages/canvas/canvas-mesh/src/NineSlicePlane.js index 09eaf9c..2fd5acc 100644 --- a/packages/canvas/canvas-mesh/src/NineSlicePlane.js +++ b/packages/canvas/canvas-mesh/src/NineSlicePlane.js @@ -1,4 +1,4 @@ -import { NineSlicePlane } from '@pixi/mesh'; +import { NineSlicePlane } from '@pixi/mesh-extras'; /** * Renders the object using the Canvas renderer diff --git a/packages/canvas/canvas-mesh/src/RawMesh.js b/packages/canvas/canvas-mesh/src/RawMesh.js deleted file mode 100644 index bf40184..0000000 --- a/packages/canvas/canvas-mesh/src/RawMesh.js +++ /dev/null @@ -1,14 +0,0 @@ -import { RawMesh } from '@pixi/mesh'; - -/** - * Renders the object using the Canvas renderer - * - * @private - * @method _renderCanvas - * @memberof PIXI.RawMesh# - * @param {PIXI.CanvasRenderer} renderer - The canvas renderer. - */ -RawMesh.prototype._renderCanvas = function _renderCanvas(renderer) -{ - renderer.plugins[this.pluginName].render(this); -}; diff --git a/packages/canvas/canvas-mesh/src/index.js b/packages/canvas/canvas-mesh/src/index.js index 2295016..f4fa31d 100644 --- a/packages/canvas/canvas-mesh/src/index.js +++ b/packages/canvas/canvas-mesh/src/index.js @@ -1,6 +1,6 @@ export { default as CanvasMeshRenderer } from './CanvasMeshRenderer'; import './settings'; -import './Mesh'; +import './Mesh2d'; import './NineSlicePlane'; -import './RawMesh'; +import './Mesh'; diff --git a/packages/canvas/canvas-mesh/src/settings.js b/packages/canvas/canvas-mesh/src/settings.js index 4cefb4c..e81b8e0 100644 --- a/packages/canvas/canvas-mesh/src/settings.js +++ b/packages/canvas/canvas-mesh/src/settings.js @@ -3,7 +3,7 @@ /** * Default `canvasPadding` for canvas-based Mesh rendering. * - * @see PIXI.Mesh#canvasPadding + * @see PIXI.Mesh2d#canvasPadding * @static * @constant * @memberof PIXI.settings diff --git a/packages/mesh-extras/LICENSE b/packages/mesh-extras/LICENSE new file mode 100644 index 0000000..148e3eb --- /dev/null +++ b/packages/mesh-extras/LICENSE @@ -0,0 +1,21 @@ +The MIT License + +Copyright (c) 2013-2018 Mathew Groves, Chad Engler + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/packages/mesh-extras/README.md b/packages/mesh-extras/README.md new file mode 100644 index 0000000..1d9b0e1 --- /dev/null +++ b/packages/mesh-extras/README.md @@ -0,0 +1,19 @@ +# @pixi/mesh-extras + +## Installation + +```bash +npm install @pixi/mesh-extras +``` + +## Usage + +```js +import { MeshRenderer } from '@pixi/mesh'; +import { Renderer } from '@pixi/core'; +import { Rope } from '@pixi/mesh-extras'; + +Renderer.registerPlugin('mesh', MeshRenderer); + +const rope = new Rope(); +``` \ No newline at end of file diff --git a/packages/mesh-extras/package.json b/packages/mesh-extras/package.json new file mode 100644 index 0000000..d134f64 --- /dev/null +++ b/packages/mesh-extras/package.json @@ -0,0 +1,38 @@ +{ + "name": "@pixi/mesh-extras", + "version": "5.0.0-alpha.2", + "main": "lib/mesh-extras.js", + "module": "lib/mesh-extras.es.js", + "description": "Custom Mesh display objects, like Rope and Plane", + "author": "Mat Groves", + "contributors": [ + "Matt Karl " + ], + "homepage": "http://pixijs.com/", + "bugs": "https://github.com/pixijs/pixi.js/issues", + "license": "MIT", + "repository": { + "type": "git", + "url": "https://github.com/pixijs/pixi.js.git" + }, + "publishConfig": { + "access": "public" + }, + "scripts": { + "test": "floss --path test" + }, + "files": [ + "lib" + ], + "dependencies": { + "@pixi/constants": "^5.0.0-alpha.2", + "@pixi/core": "^5.0.0-alpha.2", + "@pixi/math": "^5.0.0-alpha.2", + "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/utils": "^5.0.0-alpha.2" + }, + "devDependencies": { + "@pixi/loaders": "^5.0.0-alpha.2", + "floss": "^2.1.3" + } +} diff --git a/packages/mesh-extras/src/Mesh2d.js b/packages/mesh-extras/src/Mesh2d.js new file mode 100644 index 0000000..d113a5e --- /dev/null +++ b/packages/mesh-extras/src/Mesh2d.js @@ -0,0 +1,263 @@ +import { Mesh } from '@pixi/mesh'; +import { Geometry, Program, Shader, Texture, TextureMatrix } from '@pixi/core'; +import { Matrix } from '@pixi/math'; +import { BLEND_MODES } from '@pixi/constants'; +import { hex2rgb, premultiplyRgba } from '@pixi/utils'; +import vertex from './mesh.vert'; +import fragment from './mesh.frag'; + +let meshProgram; + +/** + * Base mesh class + * @class + * @extends PIXI.Container + * @memberof PIXI + */ +export default class Mesh2d extends Mesh +{ + /** + * @param {PIXI.Texture} [texture=Texture.EMPTY] - The texture to use + * @param {Float32Array} [vertices] - if you want to specify the vertices + * @param {Float32Array} [uvs] - if you want to specify the uvs + * @param {Uint16Array} [indices] - if you want to specify the indices + * @param {number} [drawMode] - the drawMode, can be any of the Mesh.DRAW_MODES consts + */ + constructor(texture = Texture.EMPTY, vertices, uvs, indices, drawMode) + { + const geometry = new Geometry(); + + if (!meshProgram) + { + meshProgram = new Program(vertex, fragment); + } + + geometry.addAttribute('aVertexPosition', vertices) + .addAttribute('aTextureCoord', uvs) + .addIndex(indices); + + geometry.getAttribute('aVertexPosition').static = false; + + const uniforms = { + uSampler: texture, + uTextureMatrix: Matrix.IDENTITY, + alpha: 1, + uColor: new Float32Array([1, 1, 1, 1]), + }; + + super(geometry, new Shader(meshProgram, uniforms), null, drawMode); + + /** + * The Uvs of the Mesh + * + * @member {Float32Array} + */ + this.uvs = geometry.getAttribute('aTextureCoord').data; + + /** + * An array of vertices + * + * @member {Float32Array} + */ + this.vertices = geometry.getAttribute('aVertexPosition').data; + + this.uniforms = uniforms; + + /** + * The texture of the Mesh + * + * @member {PIXI.Texture} + * @default PIXI.Texture.EMPTY + * @private + */ + this.texture = texture; + + /** + * The tint applied to the mesh. This is a [r,g,b] value. A value of [1,1,1] will remove any + * tint effect. + * + * @member {number} + * @private + */ + this._tintRGB = new Float32Array([1, 1, 1]); + + // Set default tint + this.tint = 0xFFFFFF; + + this.blendMode = BLEND_MODES.NORMAL; + + /** + * TextureMatrix instance for this Mesh, used to track Texture changes + * + * @member {PIXI.TextureMatrix} + * @readonly + */ + this.uvMatrix = new TextureMatrix(this._texture); + + /** + * whether or not upload uvMatrix to shader + * if its false, then uvs should be pre-multiplied + * if you change it for generated mesh, please call 'refresh(true)' + * @member {boolean} + * @default false + */ + this.uploadUvMatrix = false; + + /** + * Uploads vertices buffer every frame, like in PixiJS V3 and V4. + * + * @member {boolean} + * @default true + */ + this.autoUpdate = true; + } + + /** + * The tint applied to the Rope. This is a hex value. A value of + * 0xFFFFFF will remove any tint effect. + * + * @member {number} + * @memberof PIXI.Sprite# + * @default 0xFFFFFF + */ + get tint() + { + return this._tint; + } + + /** + * Sets the tint of the rope. + * + * @param {number} value - The value to set to. + */ + set tint(value) + { + this._tint = value; + + hex2rgb(this._tint, this._tintRGB); + } + + /** + * The blend mode to be applied to the sprite. Set to `PIXI.BLEND_MODES.NORMAL` to remove any blend mode. + * + * @member {number} + * @default PIXI.BLEND_MODES.NORMAL + * @see PIXI.BLEND_MODES + */ + get blendMode() + { + return this.state.blendMode; + } + + set blendMode(value) // eslint-disable-line require-jsdoc + { + this.state.blendMode = value; + } + + /** + * The texture that the mesh uses. + * + * @member {PIXI.Texture} + */ + get texture() + { + return this._texture; + } + + set texture(value) // eslint-disable-line require-jsdoc + { + if (this._texture === value) + { + return; + } + + this._texture = value; + this.uniforms.uSampler = this.texture; + + if (value) + { + // wait for the texture to load + if (value.baseTexture.valid) + { + this._onTextureUpdate(); + } + else + { + value.once('update', this._onTextureUpdate, this); + } + } + } + + _render(renderer) + { + const baseTex = this._texture.baseTexture; + + premultiplyRgba(this._tintRGB, this.worldAlpha, this.uniforms.uColor, baseTex.premultiplyAlpha); + super._render(renderer); + } + /** + * When the texture is updated, this event will fire to update the scale and frame + * + * @private + */ + _onTextureUpdate() + { + // constructor texture update stop + if (!this.uvMatrix) + { + return; + } + this.uvMatrix.texture = this._texture; + this.refresh(); + } + + /** + * multiplies uvs only if uploadUvMatrix is false + * call it after you change uvs manually + * make sure that texture is valid + */ + multiplyUvs() + { + if (!this.uploadUvMatrix) + { + this.uvMatrix.multiplyUvs(this.uvs); + } + } + + /** + * Refreshes uvs for generated meshes (rope, plane) + * sometimes refreshes vertices too + * + * @param {boolean} [forceUpdate=false] if true, matrices will be updated any case + */ + refresh(forceUpdate) + { + if (this.uvMatrix.update(forceUpdate)) + { + this._refresh(); + } + } + + /** + * Updates the object transform for rendering + * + * @private + */ + updateTransform() + { + if (this.autoUpdate) + { + this.geometry.buffers[0].update(); + } + this.containerUpdateTransform(); + } + + /** + * re-calculates mesh coords + * @private + */ + _refresh() + { + /* empty */ + } +} diff --git a/packages/mesh-extras/src/NineSlicePlane.js b/packages/mesh-extras/src/NineSlicePlane.js new file mode 100644 index 0000000..0bae92c --- /dev/null +++ b/packages/mesh-extras/src/NineSlicePlane.js @@ -0,0 +1,270 @@ +import Plane from './Plane'; + +const DEFAULT_BORDER_SIZE = 10; + +/** + * The NineSlicePlane allows you to stretch a texture using 9-slice scaling. The corners will remain unscaled (useful + * for buttons with rounded corners for example) and the other areas will be scaled horizontally and or vertically + * + *```js + * let Plane9 = new PIXI.NineSlicePlane(PIXI.Texture.from('BoxWithRoundedCorners.png'), 15, 15, 15, 15); + * ``` + *
+ *      A                          B
+ *    +---+----------------------+---+
+ *  C | 1 |          2           | 3 |
+ *    +---+----------------------+---+
+ *    |   |                      |   |
+ *    | 4 |          5           | 6 |
+ *    |   |                      |   |
+ *    +---+----------------------+---+
+ *  D | 7 |          8           | 9 |
+ *    +---+----------------------+---+
+
+ *  When changing this objects width and/or height:
+ *     areas 1 3 7 and 9 will remain unscaled.
+ *     areas 2 and 8 will be stretched horizontally
+ *     areas 4 and 6 will be stretched vertically
+ *     area 5 will be stretched both horizontally and vertically
+ * 
+ * + * @class + * @extends PIXI.Plane + * @memberof PIXI + * + */ +export default class NineSlicePlane extends Plane +{ + /** + * @param {PIXI.Texture} texture - The texture to use on the NineSlicePlane. + * @param {int} [leftWidth=10] size of the left vertical bar (A) + * @param {int} [topHeight=10] size of the top horizontal bar (C) + * @param {int} [rightWidth=10] size of the right vertical bar (B) + * @param {int} [bottomHeight=10] size of the bottom horizontal bar (D) + */ + constructor(texture, leftWidth, topHeight, rightWidth, bottomHeight) + { + super(texture, 4, 4); + + this._origWidth = texture.orig.width; + this._origHeight = texture.orig.height; + + /** + * The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._width = this._origWidth; + + /** + * The height of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._height = this._origHeight; + + /** + * The width of the left column (a) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._leftWidth = typeof leftWidth !== 'undefined' ? leftWidth : DEFAULT_BORDER_SIZE; + + /** + * The width of the right column (b) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._rightWidth = typeof rightWidth !== 'undefined' ? rightWidth : DEFAULT_BORDER_SIZE; + + /** + * The height of the top row (c) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._topHeight = typeof topHeight !== 'undefined' ? topHeight : DEFAULT_BORDER_SIZE; + + /** + * The height of the bottom row (d) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._bottomHeight = typeof bottomHeight !== 'undefined' ? bottomHeight : DEFAULT_BORDER_SIZE; + + this.refresh(true); + } + + /** + * Updates the horizontal vertices. + * + */ + updateHorizontalVertices() + { + const vertices = this.vertices; + + const h = this._topHeight + this._bottomHeight; + const scale = this._height > h ? 1.0 : this._height / h; + + vertices[9] = vertices[11] = vertices[13] = vertices[15] = this._topHeight * scale; + vertices[17] = vertices[19] = vertices[21] = vertices[23] = this._height - (this._bottomHeight * scale); + vertices[25] = vertices[27] = vertices[29] = vertices[31] = this._height; + } + + /** + * Updates the vertical vertices. + * + */ + updateVerticalVertices() + { + const vertices = this.vertices; + + const w = this._leftWidth + this._rightWidth; + const scale = this._width > w ? 1.0 : this._width / w; + + vertices[2] = vertices[10] = vertices[18] = vertices[26] = this._leftWidth * scale; + vertices[4] = vertices[12] = vertices[20] = vertices[28] = this._width - (this._rightWidth * scale); + vertices[6] = vertices[14] = vertices[22] = vertices[30] = this._width; + } + + /** + * The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + */ + get width() + { + return this._width; + } + + set width(value) // eslint-disable-line require-jsdoc + { + this._width = value; + this._refresh(); + } + + /** + * The height of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + */ + get height() + { + return this._height; + } + + set height(value) // eslint-disable-line require-jsdoc + { + this._height = value; + this._refresh(); + } + + /** + * The width of the left column + * + * @member {number} + */ + get leftWidth() + { + return this._leftWidth; + } + + set leftWidth(value) // eslint-disable-line require-jsdoc + { + this._leftWidth = value; + this._refresh(); + } + + /** + * The width of the right column + * + * @member {number} + */ + get rightWidth() + { + return this._rightWidth; + } + + set rightWidth(value) // eslint-disable-line require-jsdoc + { + this._rightWidth = value; + this._refresh(); + } + + /** + * The height of the top row + * + * @member {number} + */ + get topHeight() + { + return this._topHeight; + } + + set topHeight(value) // eslint-disable-line require-jsdoc + { + this._topHeight = value; + this._refresh(); + } + + /** + * The height of the bottom row + * + * @member {number} + */ + get bottomHeight() + { + return this._bottomHeight; + } + + set bottomHeight(value) // eslint-disable-line require-jsdoc + { + this._bottomHeight = value; + this._refresh(); + } + + /** + * Refreshes NineSlicePlane coords. All of them. + */ + _refresh() + { + super._refresh(); + + const uvs = this.uvs; + const texture = this._texture; + + this._origWidth = texture.orig.width; + this._origHeight = texture.orig.height; + + const _uvw = 1.0 / this._origWidth; + const _uvh = 1.0 / this._origHeight; + + uvs[0] = uvs[8] = uvs[16] = uvs[24] = 0; + uvs[1] = uvs[3] = uvs[5] = uvs[7] = 0; + uvs[6] = uvs[14] = uvs[22] = uvs[30] = 1; + uvs[25] = uvs[27] = uvs[29] = uvs[31] = 1; + + uvs[2] = uvs[10] = uvs[18] = uvs[26] = _uvw * this._leftWidth; + uvs[4] = uvs[12] = uvs[20] = uvs[28] = 1 - (_uvw * this._rightWidth); + uvs[9] = uvs[11] = uvs[13] = uvs[15] = _uvh * this._topHeight; + uvs[17] = uvs[19] = uvs[21] = uvs[23] = 1 - (_uvh * this._bottomHeight); + + this.updateHorizontalVertices(); + this.updateVerticalVertices(); + + this.geometry.buffers[1].update(); + + this.multiplyUvs(); + } +} diff --git a/packages/mesh-extras/src/Plane.js b/packages/mesh-extras/src/Plane.js new file mode 100644 index 0000000..1c240c4 --- /dev/null +++ b/packages/mesh-extras/src/Plane.js @@ -0,0 +1,100 @@ +import Mesh2d from './Mesh2d'; + +/** + * The Plane allows you to draw a texture across several points and them manipulate these points + * + *```js + * for (let i = 0; i < 20; i++) { + * points.push(new PIXI.Point(i * 50, 0)); + * }; + * let Plane = new PIXI.Plane(PIXI.Texture.from("snake.png"), points); + * ``` + * + * @class + * @extends PIXI.Mesh + * @memberof PIXI + * + */ +export default class Plane extends Mesh2d +{ + /** + * @param {PIXI.Texture} texture - The texture to use on the Plane. + * @param {number} verticesX - The number of vertices in the x-axis + * @param {number} verticesY - The number of vertices in the y-axis + * @param {object} [opts] - an options object - add meshWidth and meshHeight, temporary object for PixiJS v5 alpha + */ + constructor(texture, verticesX, verticesY, opts = {}) + { + super(texture, new Float32Array(1), new Float32Array(1), new Uint16Array(1), 4); + + this.verticesX = verticesX || 10; + this.verticesY = verticesY || 10; + + this.meshWidth = opts.meshWidth || 0; + this.meshHeight = opts.meshHeight || 0; + + this.refresh(); + } + + /** + * Refreshes plane coordinates + * @private + */ + _refresh() + { + const texture = this._texture; + const total = this.verticesX * this.verticesY; + const verts = []; + const uvs = []; + const indices = []; + + const segmentsX = this.verticesX - 1; + const segmentsY = this.verticesY - 1; + + const sizeX = (this.meshWidth || texture.width) / segmentsX; + const sizeY = (this.meshHeight || texture.height) / segmentsY; + + for (let i = 0; i < total; i++) + { + const x = (i % this.verticesX); + const y = ((i / this.verticesX) | 0); + + verts.push(x * sizeX, y * sizeY); + + uvs.push(x / segmentsX, y / segmentsY); + } + + // cons + + const totalSub = segmentsX * segmentsY; + + for (let i = 0; i < totalSub; i++) + { + const xpos = i % segmentsX; + const ypos = (i / segmentsX) | 0; + + const value = (ypos * this.verticesX) + xpos; + const value2 = (ypos * this.verticesX) + xpos + 1; + const value3 = ((ypos + 1) * this.verticesX) + xpos; + const value4 = ((ypos + 1) * this.verticesX) + xpos + 1; + + indices.push(value, value2, value3); + indices.push(value2, value4, value3); + } + + this.vertices = new Float32Array(verts); + this.uvs = new Float32Array(uvs); + this.indices = new Uint16Array(indices); + + this.geometry.buffers[0].data = this.vertices; + this.geometry.buffers[1].data = this.uvs; + this.geometry.indexBuffer.data = this.indices; + + // ensure that the changes are uploaded + this.geometry.buffers[0].update(); + this.geometry.buffers[1].update(); + this.geometry.indexBuffer.update(); + + this.multiplyUvs(); + } +} diff --git a/packages/mesh-extras/src/Rope.js b/packages/mesh-extras/src/Rope.js new file mode 100644 index 0000000..9cfde38 --- /dev/null +++ b/packages/mesh-extras/src/Rope.js @@ -0,0 +1,182 @@ +import Mesh2d from './Mesh2d'; + +/** + * The rope allows you to draw a texture across several points and them manipulate these points + * + *```js + * for (let i = 0; i < 20; i++) { + * points.push(new PIXI.Point(i * 50, 0)); + * }; + * let rope = new PIXI.Rope(PIXI.Texture.from("snake.png"), points); + * ``` + * + * @class + * @extends PIXI.Mesh + * @memberof PIXI + * + */ +export default class Rope extends Mesh2d +{ + /** + * @param {PIXI.Texture} texture - The texture to use on the rope. + * @param {PIXI.Point[]} points - An array of {@link PIXI.Point} objects to construct this rope. + */ + constructor(texture, points) + { + super(texture, new Float32Array(points.length * 4), + new Float32Array(points.length * 4), + new Uint16Array(points.length * 2), + 5); + + /* + * @member {PIXI.Point[]} An array of points that determine the rope + */ + this.points = points; + this.refresh(); + } + /** + * Refreshes Rope indices and uvs + * @private + */ + _refresh() + { + const points = this.points; + + if (!points) return; + + const vertexBuffer = this.geometry.getAttribute('aVertexPosition'); + const uvBuffer = this.geometry.getAttribute('aTextureCoord'); + const indexBuffer = this.geometry.getIndex(); + + // if too little points, or texture hasn't got UVs set yet just move on. + if (points.length < 1 || !this.texture._uvs) + { + return; + } + + // if the number of points has changed we will need to recreate the arraybuffers + if (vertexBuffer.data.length / 4 !== points.length) + { + vertexBuffer.data = new Float32Array(points.length * 4); + uvBuffer.data = new Float32Array(points.length * 4); + indexBuffer.data = new Uint16Array(points.length * 2); + } + + const uvs = uvBuffer.data; + const indices = indexBuffer.data; + + uvs[0] = 0; + uvs[1] = 0; + uvs[2] = 0; + uvs[3] = 1; + + indices[0] = 0; + indices[1] = 1; + + const total = points.length; + + for (let i = 1; i < total; i++) + { + // time to do some smart drawing! + let index = i * 4; + const amount = i / (total - 1); + + uvs[index] = amount; + uvs[index + 1] = 0; + + uvs[index + 2] = amount; + uvs[index + 3] = 1; + + index = i * 2; + indices[index] = index; + indices[index + 1] = index + 1; + } + + // ensure that the changes are uploaded + uvBuffer.update(); + indexBuffer.update(); + + this.multiplyUvs(); + this.refreshVertices(); + } + + /** + * refreshes vertices of Rope mesh + */ + refreshVertices() + { + const points = this.points; + + if (points.length < 1) + { + return; + } + + let lastPoint = points[0]; + let nextPoint; + let perpX = 0; + let perpY = 0; + + // this.count -= 0.2; + + const vertices = this.vertices; + const total = points.length; + + for (let i = 0; i < total; i++) + { + const point = points[i]; + const index = i * 4; + + if (i < points.length - 1) + { + nextPoint = points[i + 1]; + } + else + { + nextPoint = point; + } + + perpY = -(nextPoint.x - lastPoint.x); + perpX = nextPoint.y - lastPoint.y; + + let ratio = (1 - (i / (total - 1))) * 10; + + if (ratio > 1) + { + ratio = 1; + } + + const perpLength = Math.sqrt((perpX * perpX) + (perpY * perpY)); + const num = this._texture.height / 2; // (20 + Math.abs(Math.sin((i + this.count) * 0.3) * 50) )* ratio; + + perpX /= perpLength; + perpY /= perpLength; + + perpX *= num; + perpY *= num; + + vertices[index] = point.x + perpX; + vertices[index + 1] = point.y + perpY; + vertices[index + 2] = point.x - perpX; + vertices[index + 3] = point.y - perpY; + + lastPoint = point; + } + + this.geometry.buffers[0].update(); + } + + /** + * Updates the object transform for rendering + * + * @private + */ + updateTransform() + { + if (this.autoUpdate) + { + this.refreshVertices(); + } + this.containerUpdateTransform(); + } +} diff --git a/packages/mesh-extras/src/index.js b/packages/mesh-extras/src/index.js new file mode 100644 index 0000000..decf454 --- /dev/null +++ b/packages/mesh-extras/src/index.js @@ -0,0 +1,4 @@ +export { default as Mesh2d } from './Mesh2d'; +export { default as Plane } from './Plane'; +export { default as NineSlicePlane } from './NineSlicePlane'; +export { default as Rope } from './Rope'; diff --git a/packages/mesh-extras/src/mesh.frag b/packages/mesh-extras/src/mesh.frag new file mode 100644 index 0000000..6096983 --- /dev/null +++ b/packages/mesh-extras/src/mesh.frag @@ -0,0 +1,9 @@ +varying vec2 vTextureCoord; +uniform vec4 uColor; + +uniform sampler2D uSampler; + +void main(void) +{ + gl_FragColor = texture2D(uSampler, vTextureCoord) * uColor; +} diff --git a/packages/mesh-extras/src/mesh.vert b/packages/mesh-extras/src/mesh.vert new file mode 100644 index 0000000..0526df9 --- /dev/null +++ b/packages/mesh-extras/src/mesh.vert @@ -0,0 +1,15 @@ +attribute vec2 aVertexPosition; +attribute vec2 aTextureCoord; + +uniform mat3 projectionMatrix; +uniform mat3 translationMatrix; +uniform mat3 uTextureMatrix; + +varying vec2 vTextureCoord; + +void main(void) +{ + gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); + + vTextureCoord = (uTextureMatrix * vec3(aTextureCoord, 1.0)).xy; +} diff --git a/packages/mesh-extras/test/.eslintrc.json b/packages/mesh-extras/test/.eslintrc.json new file mode 100644 index 0000000..2ad8efb --- /dev/null +++ b/packages/mesh-extras/test/.eslintrc.json @@ -0,0 +1,12 @@ +{ + "globals": { + "expect": false, + "assert": false, + "sinon": false, + "PIXI": false + }, + "rules": { + "func-names": 0, + "no-unused-expressions": 0 + } +} \ No newline at end of file diff --git a/packages/mesh-extras/test/Plane.js b/packages/mesh-extras/test/Plane.js new file mode 100644 index 0000000..f9b1c25 --- /dev/null +++ b/packages/mesh-extras/test/Plane.js @@ -0,0 +1,60 @@ +const { Plane } = require('../'); +const { isWebGLSupported, skipHello } = require('@pixi/utils'); +const { Loader } = require('@pixi/loaders'); +const { Point } = require('@pixi/math'); +const { RenderTexture, Texture } = require('@pixi/core'); + +skipHello(); + +function withGL(fn) +{ + return isWebGLSupported() ? fn : undefined; +} + +// TODO: fix with webglrenderer +describe('PIXI.mesh.Plane', function () +{ + it.skip('should create a plane from an external image', withGL(function (done) + { + const loader = new Loader(); + + loader.add('testBitmap', `file://${__dirname}/resources/bitmap-1.png`) + .load(function (loader, resources) + { + const plane = new Plane(resources.testBitmap.texture, 100, 100); + + expect(plane.verticesX).to.equal(100); + expect(plane.verticesY).to.equal(100); + done(); + }); + })); + + it.skip('should create a new empty textured Plane', withGL(function () + { + const plane = new Plane(Texture.EMPTY, 100, 100); + + expect(plane.verticesX).to.equal(100); + expect(plane.verticesY).to.equal(100); + })); + + describe('containsPoint', function () + { + it.skip('should return true when point inside', withGL(function () + { + const point = new Point(10, 10); + const texture = new RenderTexture.create(20, 30); + const plane = new Plane(texture, 100, 100); + + expect(plane.containsPoint(point)).to.be.true; + })); + + it.skip('should return false when point outside', withGL(function () + { + const point = new Point(100, 100); + const texture = new RenderTexture.create(20, 30); + const plane = new Plane(texture, 100, 100); + + expect(plane.containsPoint(point)).to.be.false; + })); + }); +}); diff --git a/packages/mesh-extras/test/index.js b/packages/mesh-extras/test/index.js new file mode 100644 index 0000000..d767624 --- /dev/null +++ b/packages/mesh-extras/test/index.js @@ -0,0 +1 @@ +require('./Plane'); diff --git a/packages/mesh-extras/test/resources/bitmap-1.png b/packages/mesh-extras/test/resources/bitmap-1.png new file mode 100644 index 0000000..1284fb8 --- /dev/null +++ b/packages/mesh-extras/test/resources/bitmap-1.png Binary files differ diff --git a/packages/mesh/package.json b/packages/mesh/package.json index 8b1f8d9..10bd8e3 100644 --- a/packages/mesh/package.json +++ b/packages/mesh/package.json @@ -18,22 +18,16 @@ "publishConfig": { "access": "public" }, - "scripts": { - "test": "floss --path test" - }, "files": [ "lib" ], "dependencies": { - "@pixi/canvas-renderer": "^5.0.0-alpha.2", "@pixi/constants": "^5.0.0-alpha.2", "@pixi/core": "^5.0.0-alpha.2", "@pixi/display": "^5.0.0-alpha.2", - "@pixi/math": "^5.0.0-alpha.2", - "@pixi/utils": "^5.0.0-alpha.2" + "@pixi/math": "^5.0.0-alpha.2" }, "devDependencies": { - "@pixi/loaders": "^5.0.0-alpha.2", "floss": "^2.1.3" } } diff --git a/packages/mesh/src/Mesh.js b/packages/mesh/src/Mesh.js index e7c8f9e..1f35b7a 100644 --- a/packages/mesh/src/Mesh.js +++ b/packages/mesh/src/Mesh.js @@ -1,263 +1,220 @@ -import RawMesh from './RawMesh'; -import { Geometry, Program, Shader, Texture, TextureMatrix } from '@pixi/core'; -import { Matrix } from '@pixi/math'; -import { BLEND_MODES } from '@pixi/constants'; -import { hex2rgb, premultiplyRgba } from '@pixi/utils'; -import vertex from './mesh.vert'; -import fragment from './mesh.frag'; +import { State } from '@pixi/core'; +import { DRAW_MODES } from '@pixi/constants'; +import { Point, Polygon } from '@pixi/math'; +import { Container } from '@pixi/display'; -let meshProgram; +const tempPoint = new Point(); +const tempPolygon = new Polygon(); /** - * Base mesh class + * Base mesh class. + * The reason for this class is to empower you to have maximum flexibility to render any kind of webGL you can think of. + * This class assumes a certain level of webGL knowledge. + * If you know a bit this should abstract enough away to make you life easier! + * Pretty much ALL WebGL can be broken down into the following: + * Geometry - The structure and data for the mesh. This can include anything from positions, uvs, normals, colors etc.. + * Shader - This is the shader that pixi will render the geometry with. (attributes in the shader must match the geometry!) + * Uniforms - These are the values passed to the shader when the mesh is rendered. + * As a shader can be reused across multiple objects, it made sense to allow uniforms to exist outside of the shader + * State - This is the state of WebGL required to render the mesh. + * Through a combination of the above elements you can render anything you want, 2D or 3D! + * * @class * @extends PIXI.Container * @memberof PIXI */ -export default class Mesh extends RawMesh +export default class Mesh extends Container { /** - * @param {PIXI.Texture} [texture=Texture.EMPTY] - The texture to use - * @param {Float32Array} [vertices] - if you want to specify the vertices - * @param {Float32Array} [uvs] - if you want to specify the uvs - * @param {Uint16Array} [indices] - if you want to specify the indices - * @param {number} [drawMode] - the drawMode, can be any of the Mesh.DRAW_MODES consts + * @param {PIXI.Geometry} geometry the geometry the mesh will use + * @param {PIXI.Shader} shader the shader the mesh will use + * @param {PIXI.State} state the state that the webGL context is required to be in to render the mesh + * @param {number} drawMode the drawMode, can be any of the PIXI.DRAW_MODES consts */ - constructor(texture = Texture.EMPTY, vertices, uvs, indices, drawMode) + constructor(geometry, shader, state, drawMode = DRAW_MODES.TRIANGLES) { - const geometry = new Geometry(); - - if (!meshProgram) - { - meshProgram = new Program(vertex, fragment); - } - - geometry.addAttribute('aVertexPosition', vertices) - .addAttribute('aTextureCoord', uvs) - .addIndex(indices); - - geometry.getAttribute('aVertexPosition').static = false; - - const uniforms = { - uSampler: texture, - uTextureMatrix: Matrix.IDENTITY, - alpha: 1, - uColor: new Float32Array([1, 1, 1, 1]), - }; - - super(geometry, new Shader(meshProgram, uniforms), null, drawMode); + super(); /** - * The Uvs of the Mesh - * - * @member {Float32Array} + * the geometry the mesh will use + * @type {PIXI.Geometry} */ - this.uvs = geometry.getAttribute('aTextureCoord').data; + this.geometry = geometry; /** - * An array of vertices - * - * @member {Float32Array} + * the shader the mesh will use + * @type {PIXI.Shader} */ - this.vertices = geometry.getAttribute('aVertexPosition').data; - - this.uniforms = uniforms; + this.shader = shader; /** - * The texture of the Mesh - * - * @member {PIXI.Texture} - * @default PIXI.Texture.EMPTY - * @private + * the webGL state the mesh requires to render + * @type {PIXI.State} */ - this.texture = texture; + this.state = state || new State(); /** - * The tint applied to the mesh. This is a [r,g,b] value. A value of [1,1,1] will remove any - * tint effect. + * The way the Mesh should be drawn, can be any of the {@link PIXI.Mesh.DRAW_MODES} consts * * @member {number} + * @see PIXI.Mesh.DRAW_MODES + */ + this.drawMode = drawMode; + + /** + * The way uniforms that will be used by the mesh's shader. + * @member {Object} + */ + + /** + * A map of renderer IDs to webgl render data + * * @private + * @member {object} */ - this._tintRGB = new Float32Array([1, 1, 1]); - - // Set default tint - this.tint = 0xFFFFFF; - - this.blendMode = BLEND_MODES.NORMAL; + this._glDatas = {}; /** - * TextureMatrix instance for this Mesh, used to track Texture changes + * Plugin that is responsible for rendering this element. + * Allows to customize the rendering process without overriding '_render' & '_renderCanvas' methods. * - * @member {PIXI.TextureMatrix} - * @readonly + * @member {string} + * @default 'mesh' */ - this.uvMatrix = new TextureMatrix(this._texture); + this.pluginName = 'mesh'; - /** - * whether or not upload uvMatrix to shader - * if its false, then uvs should be pre-multiplied - * if you change it for generated mesh, please call 'refresh(true)' - * @member {boolean} - * @default false - */ - this.uploadUvMatrix = false; - - /** - * Uploads vertices buffer every frame, like in PixiJS V3 and V4. - * - * @member {boolean} - * @default true - */ - this.autoUpdate = true; + this.start = 0; + this.size = 0; } /** - * The tint applied to the Rope. This is a hex value. A value of - * 0xFFFFFF will remove any tint effect. + * Renders the object using the WebGL renderer * - * @member {number} - * @memberof PIXI.Sprite# - * @default 0xFFFFFF + * @param {PIXI.Renderer} renderer a reference to the WebGL renderer + * @private */ - get tint() + _render(renderer) { - return this._tint; + renderer.batch.setObjectRenderer(renderer.plugins[this.pluginName]); + renderer.plugins[this.pluginName].render(this); } /** - * Sets the tint of the rope. + * Updates the bounds of the mesh as a rectangle. The bounds calculation takes the worldTransform into account. + * there must be a aVertexPosition attribute present in the geometry for bounds to be calculated correctly. * - * @param {number} value - The value to set to. + * @private */ - set tint(value) + _calculateBounds() { - this._tint = value; - - hex2rgb(this._tint, this._tintRGB); - } - - /** - * The blend mode to be applied to the sprite. Set to `PIXI.BLEND_MODES.NORMAL` to remove any blend mode. - * - * @member {number} - * @default PIXI.BLEND_MODES.NORMAL - * @see PIXI.BLEND_MODES - */ - get blendMode() - { - return this.state.blendMode; - } - - set blendMode(value) // eslint-disable-line require-jsdoc - { - this.state.blendMode = value; - } - - /** - * The texture that the mesh uses. - * - * @member {PIXI.Texture} - */ - get texture() - { - return this._texture; - } - - set texture(value) // eslint-disable-line require-jsdoc - { - if (this._texture === value) + // The position property could be set manually? + if (this.geometry.attributes.aVertexPosition) { - return; + const vertices = this.geometry.getAttribute('aVertexPosition').data; + + // TODO - we can cache local bounds and use them if they are dirty (like graphics) + this._bounds.addVertices(this.transform, vertices, 0, vertices.length); + } + } + + /** + * Tests if a point is inside this mesh. Works only for TRIANGLE_MESH + * + * @param {PIXI.Point} point the point to test + * @return {boolean} the result of the test + */ + containsPoint(point) + { + if (!this.getBounds().contains(point.x, point.y)) + { + return false; } - this._texture = value; - this.uniforms.uSampler = this.texture; + this.worldTransform.applyInverse(point, tempPoint); - if (value) + const vertices = this.geometry.getAttribute('aVertexPosition').data; + + const points = tempPolygon.points; + const indices = this.geometry.getIndex().data; + const len = indices.length; + const step = this.drawMode === 4 ? 3 : 1; + + for (let i = 0; i + 2 < len; i += step) { - // wait for the texture to load - if (value.baseTexture.valid) + const ind0 = indices[i] * 2; + const ind1 = indices[i + 1] * 2; + const ind2 = indices[i + 2] * 2; + + points[0] = vertices[ind0]; + points[1] = vertices[ind0 + 1]; + points[2] = vertices[ind1]; + points[3] = vertices[ind1 + 1]; + points[4] = vertices[ind2]; + points[5] = vertices[ind2 + 1]; + + if (tempPolygon.contains(tempPoint.x, tempPoint.y)) { - this._onTextureUpdate(); + return true; + } + } + + return false; + } + + /** + * Destroys the Mesh object. + * + * @param {object|boolean} [options] - Options parameter. A boolean will act as if all + * options have been set to that value + * @param {boolean} [options.children=false] - if set to true, all the children will have + * their destroy method called as well. 'options' will be passed on to those calls. + * @param {boolean} [options.texture=false] - Only used for child Sprites if options.children is set to true + * Should it destroy the texture of the child sprite + * @param {boolean} [options.baseTexture=false] - Only used for child Sprites if options.children is set to true + * Should it destroy the base texture of the child sprite + */ + destroy(options) + { + // for each webgl data entry, destroy the WebGLGraphicsData + for (const id in this._glDatas) + { + const data = this._glDatas[id]; + + if (data.destroy) + { + data.destroy(); } else { - value.once('update', this._onTextureUpdate, this); + if (data.vertexBuffer) + { + data.vertexBuffer.destroy(); + data.vertexBuffer = null; + } + if (data.indexBuffer) + { + data.indexBuffer.destroy(); + data.indexBuffer = null; + } + if (data.uvBuffer) + { + data.uvBuffer.destroy(); + data.uvBuffer = null; + } + if (data.vao) + { + data.vao.destroy(); + data.vao = null; + } } } - } - _render(renderer) - { - const baseTex = this._texture.baseTexture; + this._glDatas = null; - premultiplyRgba(this._tintRGB, this.worldAlpha, this.uniforms.uColor, baseTex.premultiplyAlpha); - super._render(renderer); - } - /** - * When the texture is updated, this event will fire to update the scale and frame - * - * @private - */ - _onTextureUpdate() - { - // constructor texture update stop - if (!this.uvMatrix) - { - return; - } - this.uvMatrix.texture = this._texture; - this.refresh(); - } + this.geometry = null; + this.shader = null; + this.state = null; - /** - * multiplies uvs only if uploadUvMatrix is false - * call it after you change uvs manually - * make sure that texture is valid - */ - multiplyUvs() - { - if (!this.uploadUvMatrix) - { - this.uvMatrix.multiplyUvs(this.uvs); - } - } - - /** - * Refreshes uvs for generated meshes (rope, plane) - * sometimes refreshes vertices too - * - * @param {boolean} [forceUpdate=false] if true, matrices will be updated any case - */ - refresh(forceUpdate) - { - if (this.uvMatrix.update(forceUpdate)) - { - this._refresh(); - } - } - - /** - * Updates the object transform for rendering - * - * @private - */ - updateTransform() - { - if (this.autoUpdate) - { - this.geometry.buffers[0].update(); - } - this.containerUpdateTransform(); - } - - /** - * re-calculates mesh coords - * @private - */ - _refresh() - { - /* empty */ + super.destroy(options); } } diff --git a/packages/mesh/src/MeshRenderer.js b/packages/mesh/src/MeshRenderer.js index 12b159b..d7baf9b 100644 --- a/packages/mesh/src/MeshRenderer.js +++ b/packages/mesh/src/MeshRenderer.js @@ -36,7 +36,7 @@ /** * renders mesh * @private - * @param {PIXI.RawMesh} mesh mesh instance + * @param {PIXI.Mesh} mesh mesh instance */ render(mesh) { diff --git a/bundles/pixi.js/package.json b/bundles/pixi.js/package.json index 49c7276..177e059 100644 --- a/bundles/pixi.js/package.json +++ b/bundles/pixi.js/package.json @@ -49,6 +49,7 @@ "@pixi/loaders": "^5.0.0-alpha.2", "@pixi/math": "^5.0.0-alpha.2", "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/mesh-extras": "^5.0.0-alpha.2", "@pixi/mixin-cache-as-bitmap": "^5.0.0-alpha.2", "@pixi/mixin-get-child-by-name": "^5.0.0-alpha.2", "@pixi/mixin-get-global-position": "^5.0.0-alpha.2", diff --git a/bundles/pixi.js/src/deprecated.js b/bundles/pixi.js/src/deprecated.js index 147617c..dbebeb0 100644 --- a/bundles/pixi.js/src/deprecated.js +++ b/bundles/pixi.js/src/deprecated.js @@ -263,15 +263,15 @@ Object.defineProperties(PIXI.mesh, { /** * @class PIXI.mesh.Mesh - * @see PIXI.Mesh + * @see PIXI.Mesh2d * @deprecated since 5.0.0 */ Mesh: { get() { - warn('PIXI.mesh.Mesh has moved to PIXI.Mesh'); + warn('PIXI.mesh.Mesh has moved to PIXI.Mesh2d'); - return PIXI.Mesh; + return PIXI.Mesh2d; }, }, /** @@ -315,15 +315,15 @@ }, /** * @class PIXI.mesh.RawMesh - * @see PIXI.RawMesh + * @see PIXI.Mesh * @deprecated since 5.0.0 */ RawMesh: { get() { - warn('PIXI.mesh.RawMesh has moved to PIXI.RawMesh'); + warn('PIXI.mesh.RawMesh has moved to PIXI.Mesh'); - return PIXI.RawMesh; + return PIXI.Mesh; }, }, /** diff --git a/bundles/pixi.js/src/index.js b/bundles/pixi.js/src/index.js index a3a0d1b..6fdabf0 100644 --- a/bundles/pixi.js/src/index.js +++ b/bundles/pixi.js/src/index.js @@ -9,6 +9,7 @@ import * as loaders from '@pixi/loaders'; import * as math from '@pixi/math'; import * as mesh from '@pixi/mesh'; +import * as meshExtras from '@pixi/mesh-extras'; import * as particles from '@pixi/particles'; import * as prepare from '@pixi/prepare'; import * as sprite from '@pixi/sprite'; @@ -128,6 +129,7 @@ loaders, math, mesh, + meshExtras, particles, sprite, spriteAnimated, @@ -152,6 +154,7 @@ export * from '@pixi/loaders'; export * from '@pixi/math'; export * from '@pixi/mesh'; +export * from '@pixi/mesh-extras'; export * from '@pixi/particles'; export * from '@pixi/sprite'; export * from '@pixi/spritesheet'; diff --git a/package-lock.json b/package-lock.json index 7fe6db7..0814729 100644 --- a/package-lock.json +++ b/package-lock.json @@ -209,7 +209,7 @@ "argparse": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", - "integrity": "sha1-vNZ5HqWuCXJeF+WtmIE0zUCz2RE=", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", "dev": true, "requires": { "sprintf-js": "1.0.3" @@ -228,7 +228,7 @@ "arr-flatten": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz", - "integrity": "sha1-NgSLv/TntH4TZkQxbJlmnqWukfE=", + "integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==", "dev": true }, "arr-union": { @@ -297,7 +297,7 @@ "assertion-error": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", - "integrity": "sha1-5gtrDo8wG9l+U3UhW9pAbIURjAs=", + "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", "dev": true }, "async": { @@ -396,7 +396,7 @@ "brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha1-PH/L9SnYcibz0vUrlm/1Jx60Qd0=", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, "requires": { "balanced-match": "1.0.0", @@ -568,7 +568,7 @@ "circular-json": { "version": "0.3.3", "resolved": "https://registry.npmjs.org/circular-json/-/circular-json-0.3.3.tgz", - "integrity": "sha1-gVyZ6oT2gJUp0vRXkb34JxE1LWY=", + "integrity": "sha512-UZK3NBx2Mca+b5LsG7bY183pHWt5Y1xts4P3Pz7ENTwGVnJOUWbRb3ocjvX7hx9tq/yTAdclXm9sZ38gNuem4A==", "dev": true }, "cli-cursor": { @@ -638,7 +638,7 @@ "color-convert": { "version": "1.9.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.1.tgz", - "integrity": "sha1-wSYRB66y8pTr/+ye2eytUppgl+0=", + "integrity": "sha512-mjGanIiwQJskCC18rPR6OmrZ6fm2Lc7PeGFYwCmy5J34wC6F1PzdGL6xeMfmgicfYcNLGuVFA3WzXtIDCQSZxQ==", "dev": true, "requires": { "color-name": "1.1.3" @@ -1427,7 +1427,7 @@ "boom": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/boom/-/boom-5.2.0.tgz", - "integrity": "sha1-XdnabuOl8wIHdDYpDLcX0/SlTgI=", + "integrity": "sha512-Z5BTk6ZRe4tXXQlkqftmsAUANpXmuwlsF5Oov8ThoMbQRzdGTA1ngYRW160GexgOgjsFOKJz0LYhoNi+2AMBUw==", "dev": true, "requires": { "hoek": "4.2.1" @@ -1471,7 +1471,7 @@ "debug": { "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha1-XRKFFd8TT/Mn6QpMk/Tgd6U2NB8=", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", "dev": true, "requires": { "ms": "2.0.0" @@ -1585,7 +1585,7 @@ "doctrine": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", - "integrity": "sha1-XNAfwQFiG0LEzX9dGmYkNxbT850=", + "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", "dev": true, "requires": { "esutils": "2.0.2" @@ -1662,7 +1662,7 @@ "es6-promise": { "version": "4.2.4", "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.4.tgz", - "integrity": "sha1-3EIhwrFlGHYL2MOaUtjzVvwA7Sk=", + "integrity": "sha512-/NdNZVJg+uZgtm9eS3O6lrOLYmQag2DjdEXuPaHlZ6RuVqgqaVZfgYCepEIKsLqwdQArOPtC3XzRLqGGfT8KQQ==", "dev": true }, "escape-string-regexp": { @@ -1788,7 +1788,7 @@ "espree": { "version": "3.5.4", "resolved": "https://registry.npmjs.org/espree/-/espree-3.5.4.tgz", - "integrity": "sha1-sPRHGHyKi+2US4FaZgvd9d610ac=", + "integrity": "sha512-yAcIQxtmMiB/jL32dzEp2enBeidsB7xWPLNiw3IIkpVds1P+h7qF9YwJq1yUNzp2OKXgAprs4F61ih66UsoD1A==", "dev": true, "requires": { "acorn": "5.5.0", @@ -1798,7 +1798,7 @@ "esprima": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.0.tgz", - "integrity": "sha1-RJnt3NERDgshi6zy+n9/WfVcqAQ=", + "integrity": "sha512-oftTcaMu/EGrEIu904mWteKIv8vMuOgGYo7EhVJJN00R/EED9DCua/xxHRdYnKtcECzVg7xOWhflvJMnqcFZjw==", "dev": true }, "esquery": { @@ -1813,7 +1813,7 @@ "esrecurse": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.2.1.tgz", - "integrity": "sha1-AHo7n9vCs7uH5IeeoZyS/b05Qs8=", + "integrity": "sha512-64RBB++fIOAXPw3P9cy89qfMlvZEXZkqqJkjqqXIvzP5ezRZjW+lPWjw35UX/3EhUPFYbg5ER4JYgDw4007/DQ==", "dev": true, "requires": { "estraverse": "4.2.0" @@ -2024,7 +2024,7 @@ "find-root": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/find-root/-/find-root-1.1.0.tgz", - "integrity": "sha1-q8/Iunb3CMQql7PWhbfpRQv7nOQ=", + "integrity": "sha512-NKfW6bec6GfKc0SGx1e07QZY9PE99u0Bft/0rzSD5k3sO/vwkVUpDUKVm5Gpp5Ue3YfShPFTX2070tDs5kB9Ng==", "dev": true }, "find-up": { @@ -2103,7 +2103,7 @@ "supports-color": { "version": "5.3.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.3.0.tgz", - "integrity": "sha1-WySsFduA+pJ89SJ6SjP9PEx2dsA=", + "integrity": "sha512-0aP01LLIskjKs3lq52EC0aGBAJhLq7B2Rd8HC/DR/PtNNpcLilNmHC12O+hu0usQpo7wtHNRqtrhBwtDb0+dNg==", "dev": true, "requires": { "has-flag": "3.0.0" @@ -2567,7 +2567,7 @@ "glob": { "version": "7.1.2", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", - "integrity": "sha1-wZyd+aAocC1nhhI4SmVSQExjbRU=", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", "dev": true, "requires": { "fs.realpath": "1.0.0", @@ -2672,7 +2672,7 @@ "growl": { "version": "1.10.3", "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.3.tgz", - "integrity": "sha1-GSa6kM8+3+KttJJ/WIC8IsZseQ8=", + "integrity": "sha512-hKlsbA5Vu3xsh1Cg3J7jSmX/WaW6A5oBeqzM88oNbCRQFz+zUaXm6yxS4RVytp1scBoJzSYl4YAEOQIt6O8V1Q==", "dev": true }, "handlebars": { @@ -2738,7 +2738,7 @@ "hawk": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/hawk/-/hawk-6.0.2.tgz", - "integrity": "sha1-r02RTrBl+bXOTZ0RwcshJu7MMDg=", + "integrity": "sha512-miowhl2+U7Qle4vdLqDdPt9m09K6yZhkLDTWGoUiUzrQCn+mHHSmfJgAyGaLRZbPmTqfFFjRV1QWCW0VWUJBbQ==", "dev": true, "requires": { "boom": "4.3.1", @@ -2756,7 +2756,7 @@ "hoek": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/hoek/-/hoek-4.2.1.tgz", - "integrity": "sha1-ljRQKqEsRF3Vp8VzS1cruHOKrLs=", + "integrity": "sha512-QLg82fGkfnJ/4iy1xZ81/9SIJiq1NGFUMGs6ParyjBZr6jW2Ufj/snDqTHixNlHdPNwN2RLVD0Pi3igeK9+JfA==", "dev": true }, "home-path": { @@ -2791,7 +2791,7 @@ "ignore": { "version": "3.3.7", "resolved": "https://registry.npmjs.org/ignore/-/ignore-3.3.7.tgz", - "integrity": "sha1-YSKJv7PCIOGGpYEYYY1b6MG6sCE=", + "integrity": "sha512-YGG3ejvBNHRqu0559EOxxNFihD0AjpvHlC/pdGKd3X3ofe+CoJkYazwNJYTNebqpPKN+VVQbh4ZFn1DivMNuHA==", "dev": true }, "imurmurhash": { @@ -2828,7 +2828,7 @@ "ini": { "version": "1.3.5", "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", - "integrity": "sha1-7uJfVtscnsYIXgwid4CD9Zar+Sc=", + "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==", "dev": true }, "inquirer": { @@ -2901,7 +2901,7 @@ "is-buffer": { "version": "1.1.6", "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", - "integrity": "sha1-76ouqdqg16suoTqXsritUf776L4=", + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", "dev": true }, "is-builtin-module": { @@ -3054,7 +3054,7 @@ "is-resolvable": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/is-resolvable/-/is-resolvable-1.1.0.tgz", - "integrity": "sha1-+xj4fOH+uSUWnJpAfBkxijIG7Yg=", + "integrity": "sha512-qgDYXFSR5WvEfuS5dMj6oTMEbrrSaM0CrFk2Yiq/gXnBvD9pMa2jGXxyhGLfvhZpuMZe18CJpFxAt3CRs42NMg==", "dev": true }, "is-retry-allowed": { @@ -3204,7 +3204,7 @@ "js-yaml": { "version": "3.11.0", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.11.0.tgz", - "integrity": "sha1-WXwai9VxUvJtYizkEXhRpR9euu8=", + "integrity": "sha512-saJstZWv7oNeOyBh3+Dx1qWzhW0+e6/8eDzo7p5rDFqxntSztloLtuKu+Ejhtq82jsilwOIZYsCz+lIjthg1Hw==", "dev": true, "requires": { "argparse": "1.0.10", @@ -3324,7 +3324,7 @@ "just-extend": { "version": "1.1.27", "resolved": "https://registry.npmjs.org/just-extend/-/just-extend-1.1.27.tgz", - "integrity": "sha1-7G55QQ/5FORyZSq/oOYDwD1g6QU=", + "integrity": "sha512-mJVp13Ix6gFo3SBAy9U/kL+oeZqzlYYYLQBwXVBlVzIsZwBqGREnOro24oC/8s8aox+rJhtZ2DiQof++IrkA+g==", "dev": true }, "kind-of": { @@ -3703,7 +3703,7 @@ "lodash": { "version": "4.17.5", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.5.tgz", - "integrity": "sha1-maktZcAnLevoyWtgV7yPv6O+1RE=", + "integrity": "sha512-svL3uiZf1RwhH+cWrfZn3A4+U58wbP0tGVTLQPbjplZxZ8ROD9VLuNgsRniTlLe7OlSqR79RUehXgpBW/s0IQw==", "dev": true }, "lodash._reinterpolate": { @@ -3740,7 +3740,7 @@ "lolex": { "version": "2.3.2", "resolved": "https://registry.npmjs.org/lolex/-/lolex-2.3.2.tgz", - "integrity": "sha1-hflFBCUQO/nnpgZo6iXcQydMqAc=", + "integrity": "sha512-A5pN2tkFj7H0dGIAM6MFvHKMJcPnjZsOMvR7ujCjfgW5TbV6H9vb1PgxLtHvjqNZTHsUolz+6/WEO0N1xNx2ng==", "dev": true }, "longest": { @@ -3816,7 +3816,7 @@ "marked": { "version": "0.3.17", "resolved": "https://registry.npmjs.org/marked/-/marked-0.3.17.tgz", - "integrity": "sha1-YH8GZos8axJGso8T2nYRasGqLSs=", + "integrity": "sha512-+AKbNsjZl6jFfLPwHhWmGTqE009wTKn3RTmn9K8oUKHrX/abPJjtcRtXpYB/FFrwPJRUA86LX/de3T0knkPCmQ==", "dev": true }, "mem": { @@ -3896,13 +3896,13 @@ "mime-db": { "version": "1.33.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.33.0.tgz", - "integrity": "sha1-o0kgUKXLm2NFBUHjnZeI0icng9s=", + "integrity": "sha512-BHJ/EKruNIqJf/QahvxwQZXKygOQ256myeN/Ew+THcAa5q+PjyTTMMeNQC4DZw5AwfvelsUrA6B67NKMqXDbzQ==", "dev": true }, "mime-types": { "version": "2.1.18", "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.18.tgz", - "integrity": "sha1-bzI/YKg9ERRvgx/xH9ZuL+VQO7g=", + "integrity": "sha512-lc/aahn+t4/SWV/qcmumYjymLsWfN3ELhpmVuUFjgsORruuZPVSwAQryq+HHGvO/SI2KVX26bx+En+zhM8g8hQ==", "dev": true, "requires": { "mime-db": "1.33.0" @@ -3917,7 +3917,7 @@ "minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha1-UWbihkV/AzBgZL5Ul+jbsMPTIIM=", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "dev": true, "requires": { "brace-expansion": "1.1.11" @@ -4071,7 +4071,7 @@ "normalize-package-data": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.4.0.tgz", - "integrity": "sha1-EvlaMH1YNSB1oEkHuErIvpisAS8=", + "integrity": "sha512-9jjUFbTPfEy3R/ad/2oNbKtW9Hgovl5O1FvFWKkKblNXoN/Oou6+9+KKohPK13Yc3/TyunyWhJp6gvRNR/PPAw==", "dev": true, "requires": { "hosted-git-info": "2.5.0", @@ -4511,7 +4511,7 @@ "process-nextick-args": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", - "integrity": "sha1-o31zL0JxtKsa0HDTVQjoKQeI/6o=", + "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==", "dev": true }, "progress": { @@ -4584,7 +4584,7 @@ "qs": { "version": "6.5.1", "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.1.tgz", - "integrity": "sha1-NJzfbu+J7EXBLX1es/wMhwNDptg=", + "integrity": "sha512-eRzhrN1WSINYCDCbrz796z37LOe3m5tmW7RQf6oBntukAG1nmovJvhnwHHRMAfeoItc1m2Hk02WER2aQ/iqs+A==", "dev": true }, "quick-lru": { @@ -4596,7 +4596,7 @@ "randomatic": { "version": "1.1.7", "resolved": "https://registry.npmjs.org/randomatic/-/randomatic-1.1.7.tgz", - "integrity": "sha1-x6vpzIuHwLqodrGf3oP9RkeX44w=", + "integrity": "sha512-D5JUjPyJbaJDkuAazpVnSfVkLlpeO3wDlPROTMLGKG1zMFNFRgrciKo1ltz/AzNTkqE0HzDx655QOL51N06how==", "dev": true, "requires": { "is-number": "3.0.0", @@ -4701,7 +4701,7 @@ "regex-cache": { "version": "0.4.4", "resolved": "https://registry.npmjs.org/regex-cache/-/regex-cache-0.4.4.tgz", - "integrity": "sha1-db3FiioUls7EihKDW8VMjVYjNt0=", + "integrity": "sha512-nVIZwtCjkC9YgvWkpM55B5rBhBYRZhAaJbgcFYXXsHnbZ9UZI9nnVWYZpBlCqv9ho2eZryPnWrZGsOdPwVWXWQ==", "dev": true, "requires": { "is-equal-shallow": "0.1.3" @@ -4729,7 +4729,7 @@ "remap-istanbul": { "version": "0.10.1", "resolved": "https://registry.npmjs.org/remap-istanbul/-/remap-istanbul-0.10.1.tgz", - "integrity": "sha1-OqWN1QIdSZ8zbTulvzu7kcG4jjc=", + "integrity": "sha512-gsNQXs5kJLhErICSyYhzVZ++C8LBW8dgwr874Y2QvzAUS75zBlD/juZgXs39nbYJ09fZDlX2AVLVJAY2jbFJoQ==", "dev": true, "requires": { "amdefine": "1.0.1", @@ -4769,7 +4769,7 @@ "source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha1-dHIq8y6WFOnCh6jQu95IteLxomM=", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", "dev": true }, "through2": { @@ -4883,7 +4883,7 @@ "resolve": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.5.0.tgz", - "integrity": "sha1-HwmsznlsmnYlefMbLBzEw83fnzY=", + "integrity": "sha512-hgoSGrc3pjzAPHNBg+KnFcK2HwlHTs/YrAGUr6qgTVUZmXv1UEXXl0bZNBKMA9fud6lRYFdPGz0xXxycPzmmiw==", "dev": true, "requires": { "path-parse": "1.0.5" @@ -4924,7 +4924,7 @@ "rimraf": { "version": "2.6.2", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", - "integrity": "sha1-LtgVDSShbqhlHm1u8PR8QVjOejY=", + "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", "dev": true, "requires": { "glob": "7.1.2" @@ -5063,19 +5063,19 @@ "safe-buffer": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", - "integrity": "sha1-iTMSr2myEj3vcfV4iQAWce6yyFM=", + "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", "dev": true }, "samsam": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/samsam/-/samsam-1.3.0.tgz", - "integrity": "sha1-jR2TUOJWItow3j5EumkrUiGrfFA=", + "integrity": "sha512-1HwIYD/8UlOtFS3QO3w7ey+SdSDFE4HRNLZoZRYVQefrOY3l17epswImeB1ijgJFQJodIaHcwkp3r/myBjFVbg==", "dev": true }, "semver": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz", - "integrity": "sha1-3Eu8emyp2Rbe5dQ1FvAJK1j3uKs=", + "integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==", "dev": true }, "set-blocking": { @@ -5117,7 +5117,7 @@ "sinon-chai": { "version": "2.14.0", "resolved": "https://registry.npmjs.org/sinon-chai/-/sinon-chai-2.14.0.tgz", - "integrity": "sha1-2n3UzIPNaiYLZ8yg96n9riahIF0=", + "integrity": "sha512-9stIF1utB0ywNHNT7RgiXbdmen8QDCRsrTjw+G9TgKt1Yexjiv8TOWZ6WHsTPz57Yky3DIswZvEqX8fpuHNDtQ==", "dev": true }, "slash": { @@ -5146,7 +5146,7 @@ "sntp": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/sntp/-/sntp-2.1.0.tgz", - "integrity": "sha1-LGzsFP7cIiJznK+bXD2F0cxaLMg=", + "integrity": "sha512-FL1b58BDrqS3A11lJ0zEdnJ3UOKqVxawAkF3k7F0CVN7VQ34aZrV+G8BZ1WC9ZL7NyrwsW0oviwsWDgRuVYtJg==", "dev": true, "requires": { "hoek": "4.2.1" @@ -5203,7 +5203,7 @@ "spdx-correct": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.0.0.tgz", - "integrity": "sha1-BaW01xU6GVvJLDxCW2nzsqlSTII=", + "integrity": "sha512-N19o9z5cEyc8yQQPukRCZ9EUmb4HUpnrmaL/fxS2pBo2jbfcFRVuFZ/oFC+vZz0MNNk0h80iMn5/S6qGZOL5+g==", "dev": true, "requires": { "spdx-expression-parse": "3.0.0", @@ -5213,13 +5213,13 @@ "spdx-exceptions": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.1.0.tgz", - "integrity": "sha1-LHrmEFbHFKW5ubKyr30xHvXHj+k=", + "integrity": "sha512-4K1NsmrlCU1JJgUrtgEeTVyfx8VaYea9J9LvARxhbHtVtohPs/gFGG5yy49beySjlIMhhXZ4QqujIZEfS4l6Cg==", "dev": true }, "spdx-expression-parse": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.0.tgz", - "integrity": "sha1-meEZt6XaAOBUkcn6M4t5BII7QdA=", + "integrity": "sha512-Yg6D3XpRD4kkOmTpdgbUiEJFKghJH03fiC1OPll5h/0sO6neh2jqRDVHOQ4o/LMea0tgCkbMgea5ip/e+MkWyg==", "dev": true, "requires": { "spdx-exceptions": "2.1.0", @@ -5229,7 +5229,7 @@ "spdx-license-ids": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.0.tgz", - "integrity": "sha1-enzShHDMbToc/m1miG9rxDDTrIc=", + "integrity": "sha512-2+EPwgbnmOIl8HjGBXXMd9NAu02vLjOO1nWw4kmeRDFyHn+M/ETfHxQUK0oXg8ctgVnl9t3rosNVsZ1jG61nDA==", "dev": true }, "speedometer": { @@ -5566,7 +5566,7 @@ "tough-cookie": { "version": "2.3.4", "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.4.tgz", - "integrity": "sha1-7GDO44rGdQY//JelwYlwV47oNlU=", + "integrity": "sha512-TZ6TTfI5NtZnuyy/Kecv+CnoROnyXn2DN97LontgQpCwsX2XyLYCC0ENhYkehSOwAp8rTQKc/NUIF7BkQ5rKLA==", "dev": true, "requires": { "punycode": "1.4.1" @@ -5708,13 +5708,13 @@ "uuid": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.2.1.tgz", - "integrity": "sha1-EsUou51Y0LkmXZovbw/ovhf/HxQ=", + "integrity": "sha512-jZnMwlb9Iku/O3smGWvZhauCf6cvvpKi4BKRiliS3cxnI+Gz9j5MEpTz2UFuXiKPJocb7gnsLHwiS05ige5BEA==", "dev": true }, "validate-npm-package-license": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.3.tgz", - "integrity": "sha1-gWQ7y+8b3+zUYjeT3EZIlIupgzg=", + "integrity": "sha512-63ZOUnL4SIXj4L0NixR3L1lcjO38crAbgrTpl28t8jjrfuiOBL5Iygm+60qPs/KsZGzPNg6Smnc/oY16QTjF0g==", "dev": true, "requires": { "spdx-correct": "3.0.0", @@ -5750,7 +5750,7 @@ "which": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/which/-/which-1.3.0.tgz", - "integrity": "sha1-/wS9/AEO5UfXgL7DjhrBwnd9JTo=", + "integrity": "sha512-xcJpopdamTuY5duC/KnTTNBraPK54YwpenP4lzxU8H91GudWpFv38u0CKjclE1Wi2EH2EDz5LRcHcKbCIzqGyg==", "dev": true, "requires": { "isexe": "2.0.0" diff --git a/packages/canvas/canvas-mesh/package.json b/packages/canvas/canvas-mesh/package.json index 691cd2c..6744a17 100644 --- a/packages/canvas/canvas-mesh/package.json +++ b/packages/canvas/canvas-mesh/package.json @@ -24,6 +24,7 @@ "dependencies": { "@pixi/constants": "^5.0.0-alpha.2", "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/mesh-extras": "^5.0.0-alpha.2", "@pixi/settings": "^5.0.0-alpha.2" }, "devDependencies": { diff --git a/packages/canvas/canvas-mesh/src/Mesh.js b/packages/canvas/canvas-mesh/src/Mesh.js index 900a872..c43a74b 100644 --- a/packages/canvas/canvas-mesh/src/Mesh.js +++ b/packages/canvas/canvas-mesh/src/Mesh.js @@ -1,36 +1,14 @@ import { Mesh } from '@pixi/mesh'; -import { settings } from './settings'; - -// IMPORTANT: Please do NOT use this as a precedent to use `settings` after the object is created -// this was merely created to completely decouple canvas from the base Mesh class and we are -// unable to add `canvasPadding` in the constructor anymore, as the case was for PixiJS v4. /** - * Internal variable for `canvasPadding`. + * Renders the object using the Canvas renderer * * @private - * @memberof PIXI.Mesh - * @member {number} - * @default null - */ -Mesh.prototype._canvasPadding = null; - -/** - * Triangles in canvas mode are automatically antialiased, use this value to force triangles - * to overlap a bit with each other. To set the global default, set {@link PIXI.settings.MESH_CANVAS_PADDING} - * - * @see PIXI.settings.MESH_CANVAS_PADDING - * @member {number} canvasPadding + * @method _renderCanvas * @memberof PIXI.Mesh# - * @default 0 + * @param {PIXI.CanvasRenderer} renderer - The canvas renderer. */ -Object.defineProperty(Mesh.prototype, 'canvasPadding', { - get() - { - return this._canvasPadding !== null ? this._canvasPadding : settings.MESH_CANVAS_PADDING; - }, - set(value) - { - this._canvasPadding = value; - }, -}); +Mesh.prototype._renderCanvas = function _renderCanvas(renderer) +{ + renderer.plugins[this.pluginName].render(this); +}; diff --git a/packages/canvas/canvas-mesh/src/Mesh2d.js b/packages/canvas/canvas-mesh/src/Mesh2d.js new file mode 100644 index 0000000..d0bd80f --- /dev/null +++ b/packages/canvas/canvas-mesh/src/Mesh2d.js @@ -0,0 +1,36 @@ +import { Mesh2d } from '@pixi/mesh-extras'; +import { settings } from './settings'; + +// IMPORTANT: Please do NOT use this as a precedent to use `settings` after the object is created +// this was merely created to completely decouple canvas from the base Mesh class and we are +// unable to add `canvasPadding` in the constructor anymore, as the case was for PixiJS v4. + +/** + * Internal variable for `canvasPadding`. + * + * @private + * @memberof PIXI.Mesh2d + * @member {number} + * @default null + */ +Mesh2d.prototype._canvasPadding = null; + +/** + * Triangles in canvas mode are automatically antialiased, use this value to force triangles + * to overlap a bit with each other. To set the global default, set {@link PIXI.settings.MESH_CANVAS_PADDING} + * + * @see PIXI.settings.MESH_CANVAS_PADDING + * @member {number} canvasPadding + * @memberof PIXI.Mesh2d# + * @default 0 + */ +Object.defineProperty(Mesh2d.prototype, 'canvasPadding', { + get() + { + return this._canvasPadding !== null ? this._canvasPadding : settings.MESH_CANVAS_PADDING; + }, + set(value) + { + this._canvasPadding = value; + }, +}); diff --git a/packages/canvas/canvas-mesh/src/NineSlicePlane.js b/packages/canvas/canvas-mesh/src/NineSlicePlane.js index 09eaf9c..2fd5acc 100644 --- a/packages/canvas/canvas-mesh/src/NineSlicePlane.js +++ b/packages/canvas/canvas-mesh/src/NineSlicePlane.js @@ -1,4 +1,4 @@ -import { NineSlicePlane } from '@pixi/mesh'; +import { NineSlicePlane } from '@pixi/mesh-extras'; /** * Renders the object using the Canvas renderer diff --git a/packages/canvas/canvas-mesh/src/RawMesh.js b/packages/canvas/canvas-mesh/src/RawMesh.js deleted file mode 100644 index bf40184..0000000 --- a/packages/canvas/canvas-mesh/src/RawMesh.js +++ /dev/null @@ -1,14 +0,0 @@ -import { RawMesh } from '@pixi/mesh'; - -/** - * Renders the object using the Canvas renderer - * - * @private - * @method _renderCanvas - * @memberof PIXI.RawMesh# - * @param {PIXI.CanvasRenderer} renderer - The canvas renderer. - */ -RawMesh.prototype._renderCanvas = function _renderCanvas(renderer) -{ - renderer.plugins[this.pluginName].render(this); -}; diff --git a/packages/canvas/canvas-mesh/src/index.js b/packages/canvas/canvas-mesh/src/index.js index 2295016..f4fa31d 100644 --- a/packages/canvas/canvas-mesh/src/index.js +++ b/packages/canvas/canvas-mesh/src/index.js @@ -1,6 +1,6 @@ export { default as CanvasMeshRenderer } from './CanvasMeshRenderer'; import './settings'; -import './Mesh'; +import './Mesh2d'; import './NineSlicePlane'; -import './RawMesh'; +import './Mesh'; diff --git a/packages/canvas/canvas-mesh/src/settings.js b/packages/canvas/canvas-mesh/src/settings.js index 4cefb4c..e81b8e0 100644 --- a/packages/canvas/canvas-mesh/src/settings.js +++ b/packages/canvas/canvas-mesh/src/settings.js @@ -3,7 +3,7 @@ /** * Default `canvasPadding` for canvas-based Mesh rendering. * - * @see PIXI.Mesh#canvasPadding + * @see PIXI.Mesh2d#canvasPadding * @static * @constant * @memberof PIXI.settings diff --git a/packages/mesh-extras/LICENSE b/packages/mesh-extras/LICENSE new file mode 100644 index 0000000..148e3eb --- /dev/null +++ b/packages/mesh-extras/LICENSE @@ -0,0 +1,21 @@ +The MIT License + +Copyright (c) 2013-2018 Mathew Groves, Chad Engler + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/packages/mesh-extras/README.md b/packages/mesh-extras/README.md new file mode 100644 index 0000000..1d9b0e1 --- /dev/null +++ b/packages/mesh-extras/README.md @@ -0,0 +1,19 @@ +# @pixi/mesh-extras + +## Installation + +```bash +npm install @pixi/mesh-extras +``` + +## Usage + +```js +import { MeshRenderer } from '@pixi/mesh'; +import { Renderer } from '@pixi/core'; +import { Rope } from '@pixi/mesh-extras'; + +Renderer.registerPlugin('mesh', MeshRenderer); + +const rope = new Rope(); +``` \ No newline at end of file diff --git a/packages/mesh-extras/package.json b/packages/mesh-extras/package.json new file mode 100644 index 0000000..d134f64 --- /dev/null +++ b/packages/mesh-extras/package.json @@ -0,0 +1,38 @@ +{ + "name": "@pixi/mesh-extras", + "version": "5.0.0-alpha.2", + "main": "lib/mesh-extras.js", + "module": "lib/mesh-extras.es.js", + "description": "Custom Mesh display objects, like Rope and Plane", + "author": "Mat Groves", + "contributors": [ + "Matt Karl " + ], + "homepage": "http://pixijs.com/", + "bugs": "https://github.com/pixijs/pixi.js/issues", + "license": "MIT", + "repository": { + "type": "git", + "url": "https://github.com/pixijs/pixi.js.git" + }, + "publishConfig": { + "access": "public" + }, + "scripts": { + "test": "floss --path test" + }, + "files": [ + "lib" + ], + "dependencies": { + "@pixi/constants": "^5.0.0-alpha.2", + "@pixi/core": "^5.0.0-alpha.2", + "@pixi/math": "^5.0.0-alpha.2", + "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/utils": "^5.0.0-alpha.2" + }, + "devDependencies": { + "@pixi/loaders": "^5.0.0-alpha.2", + "floss": "^2.1.3" + } +} diff --git a/packages/mesh-extras/src/Mesh2d.js b/packages/mesh-extras/src/Mesh2d.js new file mode 100644 index 0000000..d113a5e --- /dev/null +++ b/packages/mesh-extras/src/Mesh2d.js @@ -0,0 +1,263 @@ +import { Mesh } from '@pixi/mesh'; +import { Geometry, Program, Shader, Texture, TextureMatrix } from '@pixi/core'; +import { Matrix } from '@pixi/math'; +import { BLEND_MODES } from '@pixi/constants'; +import { hex2rgb, premultiplyRgba } from '@pixi/utils'; +import vertex from './mesh.vert'; +import fragment from './mesh.frag'; + +let meshProgram; + +/** + * Base mesh class + * @class + * @extends PIXI.Container + * @memberof PIXI + */ +export default class Mesh2d extends Mesh +{ + /** + * @param {PIXI.Texture} [texture=Texture.EMPTY] - The texture to use + * @param {Float32Array} [vertices] - if you want to specify the vertices + * @param {Float32Array} [uvs] - if you want to specify the uvs + * @param {Uint16Array} [indices] - if you want to specify the indices + * @param {number} [drawMode] - the drawMode, can be any of the Mesh.DRAW_MODES consts + */ + constructor(texture = Texture.EMPTY, vertices, uvs, indices, drawMode) + { + const geometry = new Geometry(); + + if (!meshProgram) + { + meshProgram = new Program(vertex, fragment); + } + + geometry.addAttribute('aVertexPosition', vertices) + .addAttribute('aTextureCoord', uvs) + .addIndex(indices); + + geometry.getAttribute('aVertexPosition').static = false; + + const uniforms = { + uSampler: texture, + uTextureMatrix: Matrix.IDENTITY, + alpha: 1, + uColor: new Float32Array([1, 1, 1, 1]), + }; + + super(geometry, new Shader(meshProgram, uniforms), null, drawMode); + + /** + * The Uvs of the Mesh + * + * @member {Float32Array} + */ + this.uvs = geometry.getAttribute('aTextureCoord').data; + + /** + * An array of vertices + * + * @member {Float32Array} + */ + this.vertices = geometry.getAttribute('aVertexPosition').data; + + this.uniforms = uniforms; + + /** + * The texture of the Mesh + * + * @member {PIXI.Texture} + * @default PIXI.Texture.EMPTY + * @private + */ + this.texture = texture; + + /** + * The tint applied to the mesh. This is a [r,g,b] value. A value of [1,1,1] will remove any + * tint effect. + * + * @member {number} + * @private + */ + this._tintRGB = new Float32Array([1, 1, 1]); + + // Set default tint + this.tint = 0xFFFFFF; + + this.blendMode = BLEND_MODES.NORMAL; + + /** + * TextureMatrix instance for this Mesh, used to track Texture changes + * + * @member {PIXI.TextureMatrix} + * @readonly + */ + this.uvMatrix = new TextureMatrix(this._texture); + + /** + * whether or not upload uvMatrix to shader + * if its false, then uvs should be pre-multiplied + * if you change it for generated mesh, please call 'refresh(true)' + * @member {boolean} + * @default false + */ + this.uploadUvMatrix = false; + + /** + * Uploads vertices buffer every frame, like in PixiJS V3 and V4. + * + * @member {boolean} + * @default true + */ + this.autoUpdate = true; + } + + /** + * The tint applied to the Rope. This is a hex value. A value of + * 0xFFFFFF will remove any tint effect. + * + * @member {number} + * @memberof PIXI.Sprite# + * @default 0xFFFFFF + */ + get tint() + { + return this._tint; + } + + /** + * Sets the tint of the rope. + * + * @param {number} value - The value to set to. + */ + set tint(value) + { + this._tint = value; + + hex2rgb(this._tint, this._tintRGB); + } + + /** + * The blend mode to be applied to the sprite. Set to `PIXI.BLEND_MODES.NORMAL` to remove any blend mode. + * + * @member {number} + * @default PIXI.BLEND_MODES.NORMAL + * @see PIXI.BLEND_MODES + */ + get blendMode() + { + return this.state.blendMode; + } + + set blendMode(value) // eslint-disable-line require-jsdoc + { + this.state.blendMode = value; + } + + /** + * The texture that the mesh uses. + * + * @member {PIXI.Texture} + */ + get texture() + { + return this._texture; + } + + set texture(value) // eslint-disable-line require-jsdoc + { + if (this._texture === value) + { + return; + } + + this._texture = value; + this.uniforms.uSampler = this.texture; + + if (value) + { + // wait for the texture to load + if (value.baseTexture.valid) + { + this._onTextureUpdate(); + } + else + { + value.once('update', this._onTextureUpdate, this); + } + } + } + + _render(renderer) + { + const baseTex = this._texture.baseTexture; + + premultiplyRgba(this._tintRGB, this.worldAlpha, this.uniforms.uColor, baseTex.premultiplyAlpha); + super._render(renderer); + } + /** + * When the texture is updated, this event will fire to update the scale and frame + * + * @private + */ + _onTextureUpdate() + { + // constructor texture update stop + if (!this.uvMatrix) + { + return; + } + this.uvMatrix.texture = this._texture; + this.refresh(); + } + + /** + * multiplies uvs only if uploadUvMatrix is false + * call it after you change uvs manually + * make sure that texture is valid + */ + multiplyUvs() + { + if (!this.uploadUvMatrix) + { + this.uvMatrix.multiplyUvs(this.uvs); + } + } + + /** + * Refreshes uvs for generated meshes (rope, plane) + * sometimes refreshes vertices too + * + * @param {boolean} [forceUpdate=false] if true, matrices will be updated any case + */ + refresh(forceUpdate) + { + if (this.uvMatrix.update(forceUpdate)) + { + this._refresh(); + } + } + + /** + * Updates the object transform for rendering + * + * @private + */ + updateTransform() + { + if (this.autoUpdate) + { + this.geometry.buffers[0].update(); + } + this.containerUpdateTransform(); + } + + /** + * re-calculates mesh coords + * @private + */ + _refresh() + { + /* empty */ + } +} diff --git a/packages/mesh-extras/src/NineSlicePlane.js b/packages/mesh-extras/src/NineSlicePlane.js new file mode 100644 index 0000000..0bae92c --- /dev/null +++ b/packages/mesh-extras/src/NineSlicePlane.js @@ -0,0 +1,270 @@ +import Plane from './Plane'; + +const DEFAULT_BORDER_SIZE = 10; + +/** + * The NineSlicePlane allows you to stretch a texture using 9-slice scaling. The corners will remain unscaled (useful + * for buttons with rounded corners for example) and the other areas will be scaled horizontally and or vertically + * + *```js + * let Plane9 = new PIXI.NineSlicePlane(PIXI.Texture.from('BoxWithRoundedCorners.png'), 15, 15, 15, 15); + * ``` + *
+ *      A                          B
+ *    +---+----------------------+---+
+ *  C | 1 |          2           | 3 |
+ *    +---+----------------------+---+
+ *    |   |                      |   |
+ *    | 4 |          5           | 6 |
+ *    |   |                      |   |
+ *    +---+----------------------+---+
+ *  D | 7 |          8           | 9 |
+ *    +---+----------------------+---+
+
+ *  When changing this objects width and/or height:
+ *     areas 1 3 7 and 9 will remain unscaled.
+ *     areas 2 and 8 will be stretched horizontally
+ *     areas 4 and 6 will be stretched vertically
+ *     area 5 will be stretched both horizontally and vertically
+ * 
+ * + * @class + * @extends PIXI.Plane + * @memberof PIXI + * + */ +export default class NineSlicePlane extends Plane +{ + /** + * @param {PIXI.Texture} texture - The texture to use on the NineSlicePlane. + * @param {int} [leftWidth=10] size of the left vertical bar (A) + * @param {int} [topHeight=10] size of the top horizontal bar (C) + * @param {int} [rightWidth=10] size of the right vertical bar (B) + * @param {int} [bottomHeight=10] size of the bottom horizontal bar (D) + */ + constructor(texture, leftWidth, topHeight, rightWidth, bottomHeight) + { + super(texture, 4, 4); + + this._origWidth = texture.orig.width; + this._origHeight = texture.orig.height; + + /** + * The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._width = this._origWidth; + + /** + * The height of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._height = this._origHeight; + + /** + * The width of the left column (a) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._leftWidth = typeof leftWidth !== 'undefined' ? leftWidth : DEFAULT_BORDER_SIZE; + + /** + * The width of the right column (b) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._rightWidth = typeof rightWidth !== 'undefined' ? rightWidth : DEFAULT_BORDER_SIZE; + + /** + * The height of the top row (c) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._topHeight = typeof topHeight !== 'undefined' ? topHeight : DEFAULT_BORDER_SIZE; + + /** + * The height of the bottom row (d) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._bottomHeight = typeof bottomHeight !== 'undefined' ? bottomHeight : DEFAULT_BORDER_SIZE; + + this.refresh(true); + } + + /** + * Updates the horizontal vertices. + * + */ + updateHorizontalVertices() + { + const vertices = this.vertices; + + const h = this._topHeight + this._bottomHeight; + const scale = this._height > h ? 1.0 : this._height / h; + + vertices[9] = vertices[11] = vertices[13] = vertices[15] = this._topHeight * scale; + vertices[17] = vertices[19] = vertices[21] = vertices[23] = this._height - (this._bottomHeight * scale); + vertices[25] = vertices[27] = vertices[29] = vertices[31] = this._height; + } + + /** + * Updates the vertical vertices. + * + */ + updateVerticalVertices() + { + const vertices = this.vertices; + + const w = this._leftWidth + this._rightWidth; + const scale = this._width > w ? 1.0 : this._width / w; + + vertices[2] = vertices[10] = vertices[18] = vertices[26] = this._leftWidth * scale; + vertices[4] = vertices[12] = vertices[20] = vertices[28] = this._width - (this._rightWidth * scale); + vertices[6] = vertices[14] = vertices[22] = vertices[30] = this._width; + } + + /** + * The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + */ + get width() + { + return this._width; + } + + set width(value) // eslint-disable-line require-jsdoc + { + this._width = value; + this._refresh(); + } + + /** + * The height of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + */ + get height() + { + return this._height; + } + + set height(value) // eslint-disable-line require-jsdoc + { + this._height = value; + this._refresh(); + } + + /** + * The width of the left column + * + * @member {number} + */ + get leftWidth() + { + return this._leftWidth; + } + + set leftWidth(value) // eslint-disable-line require-jsdoc + { + this._leftWidth = value; + this._refresh(); + } + + /** + * The width of the right column + * + * @member {number} + */ + get rightWidth() + { + return this._rightWidth; + } + + set rightWidth(value) // eslint-disable-line require-jsdoc + { + this._rightWidth = value; + this._refresh(); + } + + /** + * The height of the top row + * + * @member {number} + */ + get topHeight() + { + return this._topHeight; + } + + set topHeight(value) // eslint-disable-line require-jsdoc + { + this._topHeight = value; + this._refresh(); + } + + /** + * The height of the bottom row + * + * @member {number} + */ + get bottomHeight() + { + return this._bottomHeight; + } + + set bottomHeight(value) // eslint-disable-line require-jsdoc + { + this._bottomHeight = value; + this._refresh(); + } + + /** + * Refreshes NineSlicePlane coords. All of them. + */ + _refresh() + { + super._refresh(); + + const uvs = this.uvs; + const texture = this._texture; + + this._origWidth = texture.orig.width; + this._origHeight = texture.orig.height; + + const _uvw = 1.0 / this._origWidth; + const _uvh = 1.0 / this._origHeight; + + uvs[0] = uvs[8] = uvs[16] = uvs[24] = 0; + uvs[1] = uvs[3] = uvs[5] = uvs[7] = 0; + uvs[6] = uvs[14] = uvs[22] = uvs[30] = 1; + uvs[25] = uvs[27] = uvs[29] = uvs[31] = 1; + + uvs[2] = uvs[10] = uvs[18] = uvs[26] = _uvw * this._leftWidth; + uvs[4] = uvs[12] = uvs[20] = uvs[28] = 1 - (_uvw * this._rightWidth); + uvs[9] = uvs[11] = uvs[13] = uvs[15] = _uvh * this._topHeight; + uvs[17] = uvs[19] = uvs[21] = uvs[23] = 1 - (_uvh * this._bottomHeight); + + this.updateHorizontalVertices(); + this.updateVerticalVertices(); + + this.geometry.buffers[1].update(); + + this.multiplyUvs(); + } +} diff --git a/packages/mesh-extras/src/Plane.js b/packages/mesh-extras/src/Plane.js new file mode 100644 index 0000000..1c240c4 --- /dev/null +++ b/packages/mesh-extras/src/Plane.js @@ -0,0 +1,100 @@ +import Mesh2d from './Mesh2d'; + +/** + * The Plane allows you to draw a texture across several points and them manipulate these points + * + *```js + * for (let i = 0; i < 20; i++) { + * points.push(new PIXI.Point(i * 50, 0)); + * }; + * let Plane = new PIXI.Plane(PIXI.Texture.from("snake.png"), points); + * ``` + * + * @class + * @extends PIXI.Mesh + * @memberof PIXI + * + */ +export default class Plane extends Mesh2d +{ + /** + * @param {PIXI.Texture} texture - The texture to use on the Plane. + * @param {number} verticesX - The number of vertices in the x-axis + * @param {number} verticesY - The number of vertices in the y-axis + * @param {object} [opts] - an options object - add meshWidth and meshHeight, temporary object for PixiJS v5 alpha + */ + constructor(texture, verticesX, verticesY, opts = {}) + { + super(texture, new Float32Array(1), new Float32Array(1), new Uint16Array(1), 4); + + this.verticesX = verticesX || 10; + this.verticesY = verticesY || 10; + + this.meshWidth = opts.meshWidth || 0; + this.meshHeight = opts.meshHeight || 0; + + this.refresh(); + } + + /** + * Refreshes plane coordinates + * @private + */ + _refresh() + { + const texture = this._texture; + const total = this.verticesX * this.verticesY; + const verts = []; + const uvs = []; + const indices = []; + + const segmentsX = this.verticesX - 1; + const segmentsY = this.verticesY - 1; + + const sizeX = (this.meshWidth || texture.width) / segmentsX; + const sizeY = (this.meshHeight || texture.height) / segmentsY; + + for (let i = 0; i < total; i++) + { + const x = (i % this.verticesX); + const y = ((i / this.verticesX) | 0); + + verts.push(x * sizeX, y * sizeY); + + uvs.push(x / segmentsX, y / segmentsY); + } + + // cons + + const totalSub = segmentsX * segmentsY; + + for (let i = 0; i < totalSub; i++) + { + const xpos = i % segmentsX; + const ypos = (i / segmentsX) | 0; + + const value = (ypos * this.verticesX) + xpos; + const value2 = (ypos * this.verticesX) + xpos + 1; + const value3 = ((ypos + 1) * this.verticesX) + xpos; + const value4 = ((ypos + 1) * this.verticesX) + xpos + 1; + + indices.push(value, value2, value3); + indices.push(value2, value4, value3); + } + + this.vertices = new Float32Array(verts); + this.uvs = new Float32Array(uvs); + this.indices = new Uint16Array(indices); + + this.geometry.buffers[0].data = this.vertices; + this.geometry.buffers[1].data = this.uvs; + this.geometry.indexBuffer.data = this.indices; + + // ensure that the changes are uploaded + this.geometry.buffers[0].update(); + this.geometry.buffers[1].update(); + this.geometry.indexBuffer.update(); + + this.multiplyUvs(); + } +} diff --git a/packages/mesh-extras/src/Rope.js b/packages/mesh-extras/src/Rope.js new file mode 100644 index 0000000..9cfde38 --- /dev/null +++ b/packages/mesh-extras/src/Rope.js @@ -0,0 +1,182 @@ +import Mesh2d from './Mesh2d'; + +/** + * The rope allows you to draw a texture across several points and them manipulate these points + * + *```js + * for (let i = 0; i < 20; i++) { + * points.push(new PIXI.Point(i * 50, 0)); + * }; + * let rope = new PIXI.Rope(PIXI.Texture.from("snake.png"), points); + * ``` + * + * @class + * @extends PIXI.Mesh + * @memberof PIXI + * + */ +export default class Rope extends Mesh2d +{ + /** + * @param {PIXI.Texture} texture - The texture to use on the rope. + * @param {PIXI.Point[]} points - An array of {@link PIXI.Point} objects to construct this rope. + */ + constructor(texture, points) + { + super(texture, new Float32Array(points.length * 4), + new Float32Array(points.length * 4), + new Uint16Array(points.length * 2), + 5); + + /* + * @member {PIXI.Point[]} An array of points that determine the rope + */ + this.points = points; + this.refresh(); + } + /** + * Refreshes Rope indices and uvs + * @private + */ + _refresh() + { + const points = this.points; + + if (!points) return; + + const vertexBuffer = this.geometry.getAttribute('aVertexPosition'); + const uvBuffer = this.geometry.getAttribute('aTextureCoord'); + const indexBuffer = this.geometry.getIndex(); + + // if too little points, or texture hasn't got UVs set yet just move on. + if (points.length < 1 || !this.texture._uvs) + { + return; + } + + // if the number of points has changed we will need to recreate the arraybuffers + if (vertexBuffer.data.length / 4 !== points.length) + { + vertexBuffer.data = new Float32Array(points.length * 4); + uvBuffer.data = new Float32Array(points.length * 4); + indexBuffer.data = new Uint16Array(points.length * 2); + } + + const uvs = uvBuffer.data; + const indices = indexBuffer.data; + + uvs[0] = 0; + uvs[1] = 0; + uvs[2] = 0; + uvs[3] = 1; + + indices[0] = 0; + indices[1] = 1; + + const total = points.length; + + for (let i = 1; i < total; i++) + { + // time to do some smart drawing! + let index = i * 4; + const amount = i / (total - 1); + + uvs[index] = amount; + uvs[index + 1] = 0; + + uvs[index + 2] = amount; + uvs[index + 3] = 1; + + index = i * 2; + indices[index] = index; + indices[index + 1] = index + 1; + } + + // ensure that the changes are uploaded + uvBuffer.update(); + indexBuffer.update(); + + this.multiplyUvs(); + this.refreshVertices(); + } + + /** + * refreshes vertices of Rope mesh + */ + refreshVertices() + { + const points = this.points; + + if (points.length < 1) + { + return; + } + + let lastPoint = points[0]; + let nextPoint; + let perpX = 0; + let perpY = 0; + + // this.count -= 0.2; + + const vertices = this.vertices; + const total = points.length; + + for (let i = 0; i < total; i++) + { + const point = points[i]; + const index = i * 4; + + if (i < points.length - 1) + { + nextPoint = points[i + 1]; + } + else + { + nextPoint = point; + } + + perpY = -(nextPoint.x - lastPoint.x); + perpX = nextPoint.y - lastPoint.y; + + let ratio = (1 - (i / (total - 1))) * 10; + + if (ratio > 1) + { + ratio = 1; + } + + const perpLength = Math.sqrt((perpX * perpX) + (perpY * perpY)); + const num = this._texture.height / 2; // (20 + Math.abs(Math.sin((i + this.count) * 0.3) * 50) )* ratio; + + perpX /= perpLength; + perpY /= perpLength; + + perpX *= num; + perpY *= num; + + vertices[index] = point.x + perpX; + vertices[index + 1] = point.y + perpY; + vertices[index + 2] = point.x - perpX; + vertices[index + 3] = point.y - perpY; + + lastPoint = point; + } + + this.geometry.buffers[0].update(); + } + + /** + * Updates the object transform for rendering + * + * @private + */ + updateTransform() + { + if (this.autoUpdate) + { + this.refreshVertices(); + } + this.containerUpdateTransform(); + } +} diff --git a/packages/mesh-extras/src/index.js b/packages/mesh-extras/src/index.js new file mode 100644 index 0000000..decf454 --- /dev/null +++ b/packages/mesh-extras/src/index.js @@ -0,0 +1,4 @@ +export { default as Mesh2d } from './Mesh2d'; +export { default as Plane } from './Plane'; +export { default as NineSlicePlane } from './NineSlicePlane'; +export { default as Rope } from './Rope'; diff --git a/packages/mesh-extras/src/mesh.frag b/packages/mesh-extras/src/mesh.frag new file mode 100644 index 0000000..6096983 --- /dev/null +++ b/packages/mesh-extras/src/mesh.frag @@ -0,0 +1,9 @@ +varying vec2 vTextureCoord; +uniform vec4 uColor; + +uniform sampler2D uSampler; + +void main(void) +{ + gl_FragColor = texture2D(uSampler, vTextureCoord) * uColor; +} diff --git a/packages/mesh-extras/src/mesh.vert b/packages/mesh-extras/src/mesh.vert new file mode 100644 index 0000000..0526df9 --- /dev/null +++ b/packages/mesh-extras/src/mesh.vert @@ -0,0 +1,15 @@ +attribute vec2 aVertexPosition; +attribute vec2 aTextureCoord; + +uniform mat3 projectionMatrix; +uniform mat3 translationMatrix; +uniform mat3 uTextureMatrix; + +varying vec2 vTextureCoord; + +void main(void) +{ + gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); + + vTextureCoord = (uTextureMatrix * vec3(aTextureCoord, 1.0)).xy; +} diff --git a/packages/mesh-extras/test/.eslintrc.json b/packages/mesh-extras/test/.eslintrc.json new file mode 100644 index 0000000..2ad8efb --- /dev/null +++ b/packages/mesh-extras/test/.eslintrc.json @@ -0,0 +1,12 @@ +{ + "globals": { + "expect": false, + "assert": false, + "sinon": false, + "PIXI": false + }, + "rules": { + "func-names": 0, + "no-unused-expressions": 0 + } +} \ No newline at end of file diff --git a/packages/mesh-extras/test/Plane.js b/packages/mesh-extras/test/Plane.js new file mode 100644 index 0000000..f9b1c25 --- /dev/null +++ b/packages/mesh-extras/test/Plane.js @@ -0,0 +1,60 @@ +const { Plane } = require('../'); +const { isWebGLSupported, skipHello } = require('@pixi/utils'); +const { Loader } = require('@pixi/loaders'); +const { Point } = require('@pixi/math'); +const { RenderTexture, Texture } = require('@pixi/core'); + +skipHello(); + +function withGL(fn) +{ + return isWebGLSupported() ? fn : undefined; +} + +// TODO: fix with webglrenderer +describe('PIXI.mesh.Plane', function () +{ + it.skip('should create a plane from an external image', withGL(function (done) + { + const loader = new Loader(); + + loader.add('testBitmap', `file://${__dirname}/resources/bitmap-1.png`) + .load(function (loader, resources) + { + const plane = new Plane(resources.testBitmap.texture, 100, 100); + + expect(plane.verticesX).to.equal(100); + expect(plane.verticesY).to.equal(100); + done(); + }); + })); + + it.skip('should create a new empty textured Plane', withGL(function () + { + const plane = new Plane(Texture.EMPTY, 100, 100); + + expect(plane.verticesX).to.equal(100); + expect(plane.verticesY).to.equal(100); + })); + + describe('containsPoint', function () + { + it.skip('should return true when point inside', withGL(function () + { + const point = new Point(10, 10); + const texture = new RenderTexture.create(20, 30); + const plane = new Plane(texture, 100, 100); + + expect(plane.containsPoint(point)).to.be.true; + })); + + it.skip('should return false when point outside', withGL(function () + { + const point = new Point(100, 100); + const texture = new RenderTexture.create(20, 30); + const plane = new Plane(texture, 100, 100); + + expect(plane.containsPoint(point)).to.be.false; + })); + }); +}); diff --git a/packages/mesh-extras/test/index.js b/packages/mesh-extras/test/index.js new file mode 100644 index 0000000..d767624 --- /dev/null +++ b/packages/mesh-extras/test/index.js @@ -0,0 +1 @@ +require('./Plane'); diff --git a/packages/mesh-extras/test/resources/bitmap-1.png b/packages/mesh-extras/test/resources/bitmap-1.png new file mode 100644 index 0000000..1284fb8 --- /dev/null +++ b/packages/mesh-extras/test/resources/bitmap-1.png Binary files differ diff --git a/packages/mesh/package.json b/packages/mesh/package.json index 8b1f8d9..10bd8e3 100644 --- a/packages/mesh/package.json +++ b/packages/mesh/package.json @@ -18,22 +18,16 @@ "publishConfig": { "access": "public" }, - "scripts": { - "test": "floss --path test" - }, "files": [ "lib" ], "dependencies": { - "@pixi/canvas-renderer": "^5.0.0-alpha.2", "@pixi/constants": "^5.0.0-alpha.2", "@pixi/core": "^5.0.0-alpha.2", "@pixi/display": "^5.0.0-alpha.2", - "@pixi/math": "^5.0.0-alpha.2", - "@pixi/utils": "^5.0.0-alpha.2" + "@pixi/math": "^5.0.0-alpha.2" }, "devDependencies": { - "@pixi/loaders": "^5.0.0-alpha.2", "floss": "^2.1.3" } } diff --git a/packages/mesh/src/Mesh.js b/packages/mesh/src/Mesh.js index e7c8f9e..1f35b7a 100644 --- a/packages/mesh/src/Mesh.js +++ b/packages/mesh/src/Mesh.js @@ -1,263 +1,220 @@ -import RawMesh from './RawMesh'; -import { Geometry, Program, Shader, Texture, TextureMatrix } from '@pixi/core'; -import { Matrix } from '@pixi/math'; -import { BLEND_MODES } from '@pixi/constants'; -import { hex2rgb, premultiplyRgba } from '@pixi/utils'; -import vertex from './mesh.vert'; -import fragment from './mesh.frag'; +import { State } from '@pixi/core'; +import { DRAW_MODES } from '@pixi/constants'; +import { Point, Polygon } from '@pixi/math'; +import { Container } from '@pixi/display'; -let meshProgram; +const tempPoint = new Point(); +const tempPolygon = new Polygon(); /** - * Base mesh class + * Base mesh class. + * The reason for this class is to empower you to have maximum flexibility to render any kind of webGL you can think of. + * This class assumes a certain level of webGL knowledge. + * If you know a bit this should abstract enough away to make you life easier! + * Pretty much ALL WebGL can be broken down into the following: + * Geometry - The structure and data for the mesh. This can include anything from positions, uvs, normals, colors etc.. + * Shader - This is the shader that pixi will render the geometry with. (attributes in the shader must match the geometry!) + * Uniforms - These are the values passed to the shader when the mesh is rendered. + * As a shader can be reused across multiple objects, it made sense to allow uniforms to exist outside of the shader + * State - This is the state of WebGL required to render the mesh. + * Through a combination of the above elements you can render anything you want, 2D or 3D! + * * @class * @extends PIXI.Container * @memberof PIXI */ -export default class Mesh extends RawMesh +export default class Mesh extends Container { /** - * @param {PIXI.Texture} [texture=Texture.EMPTY] - The texture to use - * @param {Float32Array} [vertices] - if you want to specify the vertices - * @param {Float32Array} [uvs] - if you want to specify the uvs - * @param {Uint16Array} [indices] - if you want to specify the indices - * @param {number} [drawMode] - the drawMode, can be any of the Mesh.DRAW_MODES consts + * @param {PIXI.Geometry} geometry the geometry the mesh will use + * @param {PIXI.Shader} shader the shader the mesh will use + * @param {PIXI.State} state the state that the webGL context is required to be in to render the mesh + * @param {number} drawMode the drawMode, can be any of the PIXI.DRAW_MODES consts */ - constructor(texture = Texture.EMPTY, vertices, uvs, indices, drawMode) + constructor(geometry, shader, state, drawMode = DRAW_MODES.TRIANGLES) { - const geometry = new Geometry(); - - if (!meshProgram) - { - meshProgram = new Program(vertex, fragment); - } - - geometry.addAttribute('aVertexPosition', vertices) - .addAttribute('aTextureCoord', uvs) - .addIndex(indices); - - geometry.getAttribute('aVertexPosition').static = false; - - const uniforms = { - uSampler: texture, - uTextureMatrix: Matrix.IDENTITY, - alpha: 1, - uColor: new Float32Array([1, 1, 1, 1]), - }; - - super(geometry, new Shader(meshProgram, uniforms), null, drawMode); + super(); /** - * The Uvs of the Mesh - * - * @member {Float32Array} + * the geometry the mesh will use + * @type {PIXI.Geometry} */ - this.uvs = geometry.getAttribute('aTextureCoord').data; + this.geometry = geometry; /** - * An array of vertices - * - * @member {Float32Array} + * the shader the mesh will use + * @type {PIXI.Shader} */ - this.vertices = geometry.getAttribute('aVertexPosition').data; - - this.uniforms = uniforms; + this.shader = shader; /** - * The texture of the Mesh - * - * @member {PIXI.Texture} - * @default PIXI.Texture.EMPTY - * @private + * the webGL state the mesh requires to render + * @type {PIXI.State} */ - this.texture = texture; + this.state = state || new State(); /** - * The tint applied to the mesh. This is a [r,g,b] value. A value of [1,1,1] will remove any - * tint effect. + * The way the Mesh should be drawn, can be any of the {@link PIXI.Mesh.DRAW_MODES} consts * * @member {number} + * @see PIXI.Mesh.DRAW_MODES + */ + this.drawMode = drawMode; + + /** + * The way uniforms that will be used by the mesh's shader. + * @member {Object} + */ + + /** + * A map of renderer IDs to webgl render data + * * @private + * @member {object} */ - this._tintRGB = new Float32Array([1, 1, 1]); - - // Set default tint - this.tint = 0xFFFFFF; - - this.blendMode = BLEND_MODES.NORMAL; + this._glDatas = {}; /** - * TextureMatrix instance for this Mesh, used to track Texture changes + * Plugin that is responsible for rendering this element. + * Allows to customize the rendering process without overriding '_render' & '_renderCanvas' methods. * - * @member {PIXI.TextureMatrix} - * @readonly + * @member {string} + * @default 'mesh' */ - this.uvMatrix = new TextureMatrix(this._texture); + this.pluginName = 'mesh'; - /** - * whether or not upload uvMatrix to shader - * if its false, then uvs should be pre-multiplied - * if you change it for generated mesh, please call 'refresh(true)' - * @member {boolean} - * @default false - */ - this.uploadUvMatrix = false; - - /** - * Uploads vertices buffer every frame, like in PixiJS V3 and V4. - * - * @member {boolean} - * @default true - */ - this.autoUpdate = true; + this.start = 0; + this.size = 0; } /** - * The tint applied to the Rope. This is a hex value. A value of - * 0xFFFFFF will remove any tint effect. + * Renders the object using the WebGL renderer * - * @member {number} - * @memberof PIXI.Sprite# - * @default 0xFFFFFF + * @param {PIXI.Renderer} renderer a reference to the WebGL renderer + * @private */ - get tint() + _render(renderer) { - return this._tint; + renderer.batch.setObjectRenderer(renderer.plugins[this.pluginName]); + renderer.plugins[this.pluginName].render(this); } /** - * Sets the tint of the rope. + * Updates the bounds of the mesh as a rectangle. The bounds calculation takes the worldTransform into account. + * there must be a aVertexPosition attribute present in the geometry for bounds to be calculated correctly. * - * @param {number} value - The value to set to. + * @private */ - set tint(value) + _calculateBounds() { - this._tint = value; - - hex2rgb(this._tint, this._tintRGB); - } - - /** - * The blend mode to be applied to the sprite. Set to `PIXI.BLEND_MODES.NORMAL` to remove any blend mode. - * - * @member {number} - * @default PIXI.BLEND_MODES.NORMAL - * @see PIXI.BLEND_MODES - */ - get blendMode() - { - return this.state.blendMode; - } - - set blendMode(value) // eslint-disable-line require-jsdoc - { - this.state.blendMode = value; - } - - /** - * The texture that the mesh uses. - * - * @member {PIXI.Texture} - */ - get texture() - { - return this._texture; - } - - set texture(value) // eslint-disable-line require-jsdoc - { - if (this._texture === value) + // The position property could be set manually? + if (this.geometry.attributes.aVertexPosition) { - return; + const vertices = this.geometry.getAttribute('aVertexPosition').data; + + // TODO - we can cache local bounds and use them if they are dirty (like graphics) + this._bounds.addVertices(this.transform, vertices, 0, vertices.length); + } + } + + /** + * Tests if a point is inside this mesh. Works only for TRIANGLE_MESH + * + * @param {PIXI.Point} point the point to test + * @return {boolean} the result of the test + */ + containsPoint(point) + { + if (!this.getBounds().contains(point.x, point.y)) + { + return false; } - this._texture = value; - this.uniforms.uSampler = this.texture; + this.worldTransform.applyInverse(point, tempPoint); - if (value) + const vertices = this.geometry.getAttribute('aVertexPosition').data; + + const points = tempPolygon.points; + const indices = this.geometry.getIndex().data; + const len = indices.length; + const step = this.drawMode === 4 ? 3 : 1; + + for (let i = 0; i + 2 < len; i += step) { - // wait for the texture to load - if (value.baseTexture.valid) + const ind0 = indices[i] * 2; + const ind1 = indices[i + 1] * 2; + const ind2 = indices[i + 2] * 2; + + points[0] = vertices[ind0]; + points[1] = vertices[ind0 + 1]; + points[2] = vertices[ind1]; + points[3] = vertices[ind1 + 1]; + points[4] = vertices[ind2]; + points[5] = vertices[ind2 + 1]; + + if (tempPolygon.contains(tempPoint.x, tempPoint.y)) { - this._onTextureUpdate(); + return true; + } + } + + return false; + } + + /** + * Destroys the Mesh object. + * + * @param {object|boolean} [options] - Options parameter. A boolean will act as if all + * options have been set to that value + * @param {boolean} [options.children=false] - if set to true, all the children will have + * their destroy method called as well. 'options' will be passed on to those calls. + * @param {boolean} [options.texture=false] - Only used for child Sprites if options.children is set to true + * Should it destroy the texture of the child sprite + * @param {boolean} [options.baseTexture=false] - Only used for child Sprites if options.children is set to true + * Should it destroy the base texture of the child sprite + */ + destroy(options) + { + // for each webgl data entry, destroy the WebGLGraphicsData + for (const id in this._glDatas) + { + const data = this._glDatas[id]; + + if (data.destroy) + { + data.destroy(); } else { - value.once('update', this._onTextureUpdate, this); + if (data.vertexBuffer) + { + data.vertexBuffer.destroy(); + data.vertexBuffer = null; + } + if (data.indexBuffer) + { + data.indexBuffer.destroy(); + data.indexBuffer = null; + } + if (data.uvBuffer) + { + data.uvBuffer.destroy(); + data.uvBuffer = null; + } + if (data.vao) + { + data.vao.destroy(); + data.vao = null; + } } } - } - _render(renderer) - { - const baseTex = this._texture.baseTexture; + this._glDatas = null; - premultiplyRgba(this._tintRGB, this.worldAlpha, this.uniforms.uColor, baseTex.premultiplyAlpha); - super._render(renderer); - } - /** - * When the texture is updated, this event will fire to update the scale and frame - * - * @private - */ - _onTextureUpdate() - { - // constructor texture update stop - if (!this.uvMatrix) - { - return; - } - this.uvMatrix.texture = this._texture; - this.refresh(); - } + this.geometry = null; + this.shader = null; + this.state = null; - /** - * multiplies uvs only if uploadUvMatrix is false - * call it after you change uvs manually - * make sure that texture is valid - */ - multiplyUvs() - { - if (!this.uploadUvMatrix) - { - this.uvMatrix.multiplyUvs(this.uvs); - } - } - - /** - * Refreshes uvs for generated meshes (rope, plane) - * sometimes refreshes vertices too - * - * @param {boolean} [forceUpdate=false] if true, matrices will be updated any case - */ - refresh(forceUpdate) - { - if (this.uvMatrix.update(forceUpdate)) - { - this._refresh(); - } - } - - /** - * Updates the object transform for rendering - * - * @private - */ - updateTransform() - { - if (this.autoUpdate) - { - this.geometry.buffers[0].update(); - } - this.containerUpdateTransform(); - } - - /** - * re-calculates mesh coords - * @private - */ - _refresh() - { - /* empty */ + super.destroy(options); } } diff --git a/packages/mesh/src/MeshRenderer.js b/packages/mesh/src/MeshRenderer.js index 12b159b..d7baf9b 100644 --- a/packages/mesh/src/MeshRenderer.js +++ b/packages/mesh/src/MeshRenderer.js @@ -36,7 +36,7 @@ /** * renders mesh * @private - * @param {PIXI.RawMesh} mesh mesh instance + * @param {PIXI.Mesh} mesh mesh instance */ render(mesh) { diff --git a/packages/mesh/src/NineSlicePlane.js b/packages/mesh/src/NineSlicePlane.js deleted file mode 100644 index 0bae92c..0000000 --- a/packages/mesh/src/NineSlicePlane.js +++ /dev/null @@ -1,270 +0,0 @@ -import Plane from './Plane'; - -const DEFAULT_BORDER_SIZE = 10; - -/** - * The NineSlicePlane allows you to stretch a texture using 9-slice scaling. The corners will remain unscaled (useful - * for buttons with rounded corners for example) and the other areas will be scaled horizontally and or vertically - * - *```js - * let Plane9 = new PIXI.NineSlicePlane(PIXI.Texture.from('BoxWithRoundedCorners.png'), 15, 15, 15, 15); - * ``` - *
- *      A                          B
- *    +---+----------------------+---+
- *  C | 1 |          2           | 3 |
- *    +---+----------------------+---+
- *    |   |                      |   |
- *    | 4 |          5           | 6 |
- *    |   |                      |   |
- *    +---+----------------------+---+
- *  D | 7 |          8           | 9 |
- *    +---+----------------------+---+
-
- *  When changing this objects width and/or height:
- *     areas 1 3 7 and 9 will remain unscaled.
- *     areas 2 and 8 will be stretched horizontally
- *     areas 4 and 6 will be stretched vertically
- *     area 5 will be stretched both horizontally and vertically
- * 
- * - * @class - * @extends PIXI.Plane - * @memberof PIXI - * - */ -export default class NineSlicePlane extends Plane -{ - /** - * @param {PIXI.Texture} texture - The texture to use on the NineSlicePlane. - * @param {int} [leftWidth=10] size of the left vertical bar (A) - * @param {int} [topHeight=10] size of the top horizontal bar (C) - * @param {int} [rightWidth=10] size of the right vertical bar (B) - * @param {int} [bottomHeight=10] size of the bottom horizontal bar (D) - */ - constructor(texture, leftWidth, topHeight, rightWidth, bottomHeight) - { - super(texture, 4, 4); - - this._origWidth = texture.orig.width; - this._origHeight = texture.orig.height; - - /** - * The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane - * - * @member {number} - * @memberof PIXI.NineSlicePlane# - * @override - */ - this._width = this._origWidth; - - /** - * The height of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane - * - * @member {number} - * @memberof PIXI.NineSlicePlane# - * @override - */ - this._height = this._origHeight; - - /** - * The width of the left column (a) - * - * @member {number} - * @memberof PIXI.NineSlicePlane# - * @override - */ - this._leftWidth = typeof leftWidth !== 'undefined' ? leftWidth : DEFAULT_BORDER_SIZE; - - /** - * The width of the right column (b) - * - * @member {number} - * @memberof PIXI.NineSlicePlane# - * @override - */ - this._rightWidth = typeof rightWidth !== 'undefined' ? rightWidth : DEFAULT_BORDER_SIZE; - - /** - * The height of the top row (c) - * - * @member {number} - * @memberof PIXI.NineSlicePlane# - * @override - */ - this._topHeight = typeof topHeight !== 'undefined' ? topHeight : DEFAULT_BORDER_SIZE; - - /** - * The height of the bottom row (d) - * - * @member {number} - * @memberof PIXI.NineSlicePlane# - * @override - */ - this._bottomHeight = typeof bottomHeight !== 'undefined' ? bottomHeight : DEFAULT_BORDER_SIZE; - - this.refresh(true); - } - - /** - * Updates the horizontal vertices. - * - */ - updateHorizontalVertices() - { - const vertices = this.vertices; - - const h = this._topHeight + this._bottomHeight; - const scale = this._height > h ? 1.0 : this._height / h; - - vertices[9] = vertices[11] = vertices[13] = vertices[15] = this._topHeight * scale; - vertices[17] = vertices[19] = vertices[21] = vertices[23] = this._height - (this._bottomHeight * scale); - vertices[25] = vertices[27] = vertices[29] = vertices[31] = this._height; - } - - /** - * Updates the vertical vertices. - * - */ - updateVerticalVertices() - { - const vertices = this.vertices; - - const w = this._leftWidth + this._rightWidth; - const scale = this._width > w ? 1.0 : this._width / w; - - vertices[2] = vertices[10] = vertices[18] = vertices[26] = this._leftWidth * scale; - vertices[4] = vertices[12] = vertices[20] = vertices[28] = this._width - (this._rightWidth * scale); - vertices[6] = vertices[14] = vertices[22] = vertices[30] = this._width; - } - - /** - * The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane - * - * @member {number} - */ - get width() - { - return this._width; - } - - set width(value) // eslint-disable-line require-jsdoc - { - this._width = value; - this._refresh(); - } - - /** - * The height of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane - * - * @member {number} - */ - get height() - { - return this._height; - } - - set height(value) // eslint-disable-line require-jsdoc - { - this._height = value; - this._refresh(); - } - - /** - * The width of the left column - * - * @member {number} - */ - get leftWidth() - { - return this._leftWidth; - } - - set leftWidth(value) // eslint-disable-line require-jsdoc - { - this._leftWidth = value; - this._refresh(); - } - - /** - * The width of the right column - * - * @member {number} - */ - get rightWidth() - { - return this._rightWidth; - } - - set rightWidth(value) // eslint-disable-line require-jsdoc - { - this._rightWidth = value; - this._refresh(); - } - - /** - * The height of the top row - * - * @member {number} - */ - get topHeight() - { - return this._topHeight; - } - - set topHeight(value) // eslint-disable-line require-jsdoc - { - this._topHeight = value; - this._refresh(); - } - - /** - * The height of the bottom row - * - * @member {number} - */ - get bottomHeight() - { - return this._bottomHeight; - } - - set bottomHeight(value) // eslint-disable-line require-jsdoc - { - this._bottomHeight = value; - this._refresh(); - } - - /** - * Refreshes NineSlicePlane coords. All of them. - */ - _refresh() - { - super._refresh(); - - const uvs = this.uvs; - const texture = this._texture; - - this._origWidth = texture.orig.width; - this._origHeight = texture.orig.height; - - const _uvw = 1.0 / this._origWidth; - const _uvh = 1.0 / this._origHeight; - - uvs[0] = uvs[8] = uvs[16] = uvs[24] = 0; - uvs[1] = uvs[3] = uvs[5] = uvs[7] = 0; - uvs[6] = uvs[14] = uvs[22] = uvs[30] = 1; - uvs[25] = uvs[27] = uvs[29] = uvs[31] = 1; - - uvs[2] = uvs[10] = uvs[18] = uvs[26] = _uvw * this._leftWidth; - uvs[4] = uvs[12] = uvs[20] = uvs[28] = 1 - (_uvw * this._rightWidth); - uvs[9] = uvs[11] = uvs[13] = uvs[15] = _uvh * this._topHeight; - uvs[17] = uvs[19] = uvs[21] = uvs[23] = 1 - (_uvh * this._bottomHeight); - - this.updateHorizontalVertices(); - this.updateVerticalVertices(); - - this.geometry.buffers[1].update(); - - this.multiplyUvs(); - } -} diff --git a/bundles/pixi.js/package.json b/bundles/pixi.js/package.json index 49c7276..177e059 100644 --- a/bundles/pixi.js/package.json +++ b/bundles/pixi.js/package.json @@ -49,6 +49,7 @@ "@pixi/loaders": "^5.0.0-alpha.2", "@pixi/math": "^5.0.0-alpha.2", "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/mesh-extras": "^5.0.0-alpha.2", "@pixi/mixin-cache-as-bitmap": "^5.0.0-alpha.2", "@pixi/mixin-get-child-by-name": "^5.0.0-alpha.2", "@pixi/mixin-get-global-position": "^5.0.0-alpha.2", diff --git a/bundles/pixi.js/src/deprecated.js b/bundles/pixi.js/src/deprecated.js index 147617c..dbebeb0 100644 --- a/bundles/pixi.js/src/deprecated.js +++ b/bundles/pixi.js/src/deprecated.js @@ -263,15 +263,15 @@ Object.defineProperties(PIXI.mesh, { /** * @class PIXI.mesh.Mesh - * @see PIXI.Mesh + * @see PIXI.Mesh2d * @deprecated since 5.0.0 */ Mesh: { get() { - warn('PIXI.mesh.Mesh has moved to PIXI.Mesh'); + warn('PIXI.mesh.Mesh has moved to PIXI.Mesh2d'); - return PIXI.Mesh; + return PIXI.Mesh2d; }, }, /** @@ -315,15 +315,15 @@ }, /** * @class PIXI.mesh.RawMesh - * @see PIXI.RawMesh + * @see PIXI.Mesh * @deprecated since 5.0.0 */ RawMesh: { get() { - warn('PIXI.mesh.RawMesh has moved to PIXI.RawMesh'); + warn('PIXI.mesh.RawMesh has moved to PIXI.Mesh'); - return PIXI.RawMesh; + return PIXI.Mesh; }, }, /** diff --git a/bundles/pixi.js/src/index.js b/bundles/pixi.js/src/index.js index a3a0d1b..6fdabf0 100644 --- a/bundles/pixi.js/src/index.js +++ b/bundles/pixi.js/src/index.js @@ -9,6 +9,7 @@ import * as loaders from '@pixi/loaders'; import * as math from '@pixi/math'; import * as mesh from '@pixi/mesh'; +import * as meshExtras from '@pixi/mesh-extras'; import * as particles from '@pixi/particles'; import * as prepare from '@pixi/prepare'; import * as sprite from '@pixi/sprite'; @@ -128,6 +129,7 @@ loaders, math, mesh, + meshExtras, particles, sprite, spriteAnimated, @@ -152,6 +154,7 @@ export * from '@pixi/loaders'; export * from '@pixi/math'; export * from '@pixi/mesh'; +export * from '@pixi/mesh-extras'; export * from '@pixi/particles'; export * from '@pixi/sprite'; export * from '@pixi/spritesheet'; diff --git a/package-lock.json b/package-lock.json index 7fe6db7..0814729 100644 --- a/package-lock.json +++ b/package-lock.json @@ -209,7 +209,7 @@ "argparse": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", - "integrity": "sha1-vNZ5HqWuCXJeF+WtmIE0zUCz2RE=", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", "dev": true, "requires": { "sprintf-js": "1.0.3" @@ -228,7 +228,7 @@ "arr-flatten": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz", - "integrity": "sha1-NgSLv/TntH4TZkQxbJlmnqWukfE=", + "integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==", "dev": true }, "arr-union": { @@ -297,7 +297,7 @@ "assertion-error": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", - "integrity": "sha1-5gtrDo8wG9l+U3UhW9pAbIURjAs=", + "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", "dev": true }, "async": { @@ -396,7 +396,7 @@ "brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha1-PH/L9SnYcibz0vUrlm/1Jx60Qd0=", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, "requires": { "balanced-match": "1.0.0", @@ -568,7 +568,7 @@ "circular-json": { "version": "0.3.3", "resolved": "https://registry.npmjs.org/circular-json/-/circular-json-0.3.3.tgz", - "integrity": "sha1-gVyZ6oT2gJUp0vRXkb34JxE1LWY=", + "integrity": "sha512-UZK3NBx2Mca+b5LsG7bY183pHWt5Y1xts4P3Pz7ENTwGVnJOUWbRb3ocjvX7hx9tq/yTAdclXm9sZ38gNuem4A==", "dev": true }, "cli-cursor": { @@ -638,7 +638,7 @@ "color-convert": { "version": "1.9.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.1.tgz", - "integrity": "sha1-wSYRB66y8pTr/+ye2eytUppgl+0=", + "integrity": "sha512-mjGanIiwQJskCC18rPR6OmrZ6fm2Lc7PeGFYwCmy5J34wC6F1PzdGL6xeMfmgicfYcNLGuVFA3WzXtIDCQSZxQ==", "dev": true, "requires": { "color-name": "1.1.3" @@ -1427,7 +1427,7 @@ "boom": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/boom/-/boom-5.2.0.tgz", - "integrity": "sha1-XdnabuOl8wIHdDYpDLcX0/SlTgI=", + "integrity": "sha512-Z5BTk6ZRe4tXXQlkqftmsAUANpXmuwlsF5Oov8ThoMbQRzdGTA1ngYRW160GexgOgjsFOKJz0LYhoNi+2AMBUw==", "dev": true, "requires": { "hoek": "4.2.1" @@ -1471,7 +1471,7 @@ "debug": { "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha1-XRKFFd8TT/Mn6QpMk/Tgd6U2NB8=", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", "dev": true, "requires": { "ms": "2.0.0" @@ -1585,7 +1585,7 @@ "doctrine": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", - "integrity": "sha1-XNAfwQFiG0LEzX9dGmYkNxbT850=", + "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", "dev": true, "requires": { "esutils": "2.0.2" @@ -1662,7 +1662,7 @@ "es6-promise": { "version": "4.2.4", "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.4.tgz", - "integrity": "sha1-3EIhwrFlGHYL2MOaUtjzVvwA7Sk=", + "integrity": "sha512-/NdNZVJg+uZgtm9eS3O6lrOLYmQag2DjdEXuPaHlZ6RuVqgqaVZfgYCepEIKsLqwdQArOPtC3XzRLqGGfT8KQQ==", "dev": true }, "escape-string-regexp": { @@ -1788,7 +1788,7 @@ "espree": { "version": "3.5.4", "resolved": "https://registry.npmjs.org/espree/-/espree-3.5.4.tgz", - "integrity": "sha1-sPRHGHyKi+2US4FaZgvd9d610ac=", + "integrity": "sha512-yAcIQxtmMiB/jL32dzEp2enBeidsB7xWPLNiw3IIkpVds1P+h7qF9YwJq1yUNzp2OKXgAprs4F61ih66UsoD1A==", "dev": true, "requires": { "acorn": "5.5.0", @@ -1798,7 +1798,7 @@ "esprima": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.0.tgz", - "integrity": "sha1-RJnt3NERDgshi6zy+n9/WfVcqAQ=", + "integrity": "sha512-oftTcaMu/EGrEIu904mWteKIv8vMuOgGYo7EhVJJN00R/EED9DCua/xxHRdYnKtcECzVg7xOWhflvJMnqcFZjw==", "dev": true }, "esquery": { @@ -1813,7 +1813,7 @@ "esrecurse": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.2.1.tgz", - "integrity": "sha1-AHo7n9vCs7uH5IeeoZyS/b05Qs8=", + "integrity": "sha512-64RBB++fIOAXPw3P9cy89qfMlvZEXZkqqJkjqqXIvzP5ezRZjW+lPWjw35UX/3EhUPFYbg5ER4JYgDw4007/DQ==", "dev": true, "requires": { "estraverse": "4.2.0" @@ -2024,7 +2024,7 @@ "find-root": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/find-root/-/find-root-1.1.0.tgz", - "integrity": "sha1-q8/Iunb3CMQql7PWhbfpRQv7nOQ=", + "integrity": "sha512-NKfW6bec6GfKc0SGx1e07QZY9PE99u0Bft/0rzSD5k3sO/vwkVUpDUKVm5Gpp5Ue3YfShPFTX2070tDs5kB9Ng==", "dev": true }, "find-up": { @@ -2103,7 +2103,7 @@ "supports-color": { "version": "5.3.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.3.0.tgz", - "integrity": "sha1-WySsFduA+pJ89SJ6SjP9PEx2dsA=", + "integrity": "sha512-0aP01LLIskjKs3lq52EC0aGBAJhLq7B2Rd8HC/DR/PtNNpcLilNmHC12O+hu0usQpo7wtHNRqtrhBwtDb0+dNg==", "dev": true, "requires": { "has-flag": "3.0.0" @@ -2567,7 +2567,7 @@ "glob": { "version": "7.1.2", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", - "integrity": "sha1-wZyd+aAocC1nhhI4SmVSQExjbRU=", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", "dev": true, "requires": { "fs.realpath": "1.0.0", @@ -2672,7 +2672,7 @@ "growl": { "version": "1.10.3", "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.3.tgz", - "integrity": "sha1-GSa6kM8+3+KttJJ/WIC8IsZseQ8=", + "integrity": "sha512-hKlsbA5Vu3xsh1Cg3J7jSmX/WaW6A5oBeqzM88oNbCRQFz+zUaXm6yxS4RVytp1scBoJzSYl4YAEOQIt6O8V1Q==", "dev": true }, "handlebars": { @@ -2738,7 +2738,7 @@ "hawk": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/hawk/-/hawk-6.0.2.tgz", - "integrity": "sha1-r02RTrBl+bXOTZ0RwcshJu7MMDg=", + "integrity": "sha512-miowhl2+U7Qle4vdLqDdPt9m09K6yZhkLDTWGoUiUzrQCn+mHHSmfJgAyGaLRZbPmTqfFFjRV1QWCW0VWUJBbQ==", "dev": true, "requires": { "boom": "4.3.1", @@ -2756,7 +2756,7 @@ "hoek": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/hoek/-/hoek-4.2.1.tgz", - "integrity": "sha1-ljRQKqEsRF3Vp8VzS1cruHOKrLs=", + "integrity": "sha512-QLg82fGkfnJ/4iy1xZ81/9SIJiq1NGFUMGs6ParyjBZr6jW2Ufj/snDqTHixNlHdPNwN2RLVD0Pi3igeK9+JfA==", "dev": true }, "home-path": { @@ -2791,7 +2791,7 @@ "ignore": { "version": "3.3.7", "resolved": "https://registry.npmjs.org/ignore/-/ignore-3.3.7.tgz", - "integrity": "sha1-YSKJv7PCIOGGpYEYYY1b6MG6sCE=", + "integrity": "sha512-YGG3ejvBNHRqu0559EOxxNFihD0AjpvHlC/pdGKd3X3ofe+CoJkYazwNJYTNebqpPKN+VVQbh4ZFn1DivMNuHA==", "dev": true }, "imurmurhash": { @@ -2828,7 +2828,7 @@ "ini": { "version": "1.3.5", "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", - "integrity": "sha1-7uJfVtscnsYIXgwid4CD9Zar+Sc=", + "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==", "dev": true }, "inquirer": { @@ -2901,7 +2901,7 @@ "is-buffer": { "version": "1.1.6", "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", - "integrity": "sha1-76ouqdqg16suoTqXsritUf776L4=", + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", "dev": true }, "is-builtin-module": { @@ -3054,7 +3054,7 @@ "is-resolvable": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/is-resolvable/-/is-resolvable-1.1.0.tgz", - "integrity": "sha1-+xj4fOH+uSUWnJpAfBkxijIG7Yg=", + "integrity": "sha512-qgDYXFSR5WvEfuS5dMj6oTMEbrrSaM0CrFk2Yiq/gXnBvD9pMa2jGXxyhGLfvhZpuMZe18CJpFxAt3CRs42NMg==", "dev": true }, "is-retry-allowed": { @@ -3204,7 +3204,7 @@ "js-yaml": { "version": "3.11.0", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.11.0.tgz", - "integrity": "sha1-WXwai9VxUvJtYizkEXhRpR9euu8=", + "integrity": "sha512-saJstZWv7oNeOyBh3+Dx1qWzhW0+e6/8eDzo7p5rDFqxntSztloLtuKu+Ejhtq82jsilwOIZYsCz+lIjthg1Hw==", "dev": true, "requires": { "argparse": "1.0.10", @@ -3324,7 +3324,7 @@ "just-extend": { "version": "1.1.27", "resolved": "https://registry.npmjs.org/just-extend/-/just-extend-1.1.27.tgz", - "integrity": "sha1-7G55QQ/5FORyZSq/oOYDwD1g6QU=", + "integrity": "sha512-mJVp13Ix6gFo3SBAy9U/kL+oeZqzlYYYLQBwXVBlVzIsZwBqGREnOro24oC/8s8aox+rJhtZ2DiQof++IrkA+g==", "dev": true }, "kind-of": { @@ -3703,7 +3703,7 @@ "lodash": { "version": "4.17.5", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.5.tgz", - "integrity": "sha1-maktZcAnLevoyWtgV7yPv6O+1RE=", + "integrity": "sha512-svL3uiZf1RwhH+cWrfZn3A4+U58wbP0tGVTLQPbjplZxZ8ROD9VLuNgsRniTlLe7OlSqR79RUehXgpBW/s0IQw==", "dev": true }, "lodash._reinterpolate": { @@ -3740,7 +3740,7 @@ "lolex": { "version": "2.3.2", "resolved": "https://registry.npmjs.org/lolex/-/lolex-2.3.2.tgz", - "integrity": "sha1-hflFBCUQO/nnpgZo6iXcQydMqAc=", + "integrity": "sha512-A5pN2tkFj7H0dGIAM6MFvHKMJcPnjZsOMvR7ujCjfgW5TbV6H9vb1PgxLtHvjqNZTHsUolz+6/WEO0N1xNx2ng==", "dev": true }, "longest": { @@ -3816,7 +3816,7 @@ "marked": { "version": "0.3.17", "resolved": "https://registry.npmjs.org/marked/-/marked-0.3.17.tgz", - "integrity": "sha1-YH8GZos8axJGso8T2nYRasGqLSs=", + "integrity": "sha512-+AKbNsjZl6jFfLPwHhWmGTqE009wTKn3RTmn9K8oUKHrX/abPJjtcRtXpYB/FFrwPJRUA86LX/de3T0knkPCmQ==", "dev": true }, "mem": { @@ -3896,13 +3896,13 @@ "mime-db": { "version": "1.33.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.33.0.tgz", - "integrity": "sha1-o0kgUKXLm2NFBUHjnZeI0icng9s=", + "integrity": "sha512-BHJ/EKruNIqJf/QahvxwQZXKygOQ256myeN/Ew+THcAa5q+PjyTTMMeNQC4DZw5AwfvelsUrA6B67NKMqXDbzQ==", "dev": true }, "mime-types": { "version": "2.1.18", "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.18.tgz", - "integrity": "sha1-bzI/YKg9ERRvgx/xH9ZuL+VQO7g=", + "integrity": "sha512-lc/aahn+t4/SWV/qcmumYjymLsWfN3ELhpmVuUFjgsORruuZPVSwAQryq+HHGvO/SI2KVX26bx+En+zhM8g8hQ==", "dev": true, "requires": { "mime-db": "1.33.0" @@ -3917,7 +3917,7 @@ "minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha1-UWbihkV/AzBgZL5Ul+jbsMPTIIM=", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "dev": true, "requires": { "brace-expansion": "1.1.11" @@ -4071,7 +4071,7 @@ "normalize-package-data": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.4.0.tgz", - "integrity": "sha1-EvlaMH1YNSB1oEkHuErIvpisAS8=", + "integrity": "sha512-9jjUFbTPfEy3R/ad/2oNbKtW9Hgovl5O1FvFWKkKblNXoN/Oou6+9+KKohPK13Yc3/TyunyWhJp6gvRNR/PPAw==", "dev": true, "requires": { "hosted-git-info": "2.5.0", @@ -4511,7 +4511,7 @@ "process-nextick-args": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", - "integrity": "sha1-o31zL0JxtKsa0HDTVQjoKQeI/6o=", + "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==", "dev": true }, "progress": { @@ -4584,7 +4584,7 @@ "qs": { "version": "6.5.1", "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.1.tgz", - "integrity": "sha1-NJzfbu+J7EXBLX1es/wMhwNDptg=", + "integrity": "sha512-eRzhrN1WSINYCDCbrz796z37LOe3m5tmW7RQf6oBntukAG1nmovJvhnwHHRMAfeoItc1m2Hk02WER2aQ/iqs+A==", "dev": true }, "quick-lru": { @@ -4596,7 +4596,7 @@ "randomatic": { "version": "1.1.7", "resolved": "https://registry.npmjs.org/randomatic/-/randomatic-1.1.7.tgz", - "integrity": "sha1-x6vpzIuHwLqodrGf3oP9RkeX44w=", + "integrity": "sha512-D5JUjPyJbaJDkuAazpVnSfVkLlpeO3wDlPROTMLGKG1zMFNFRgrciKo1ltz/AzNTkqE0HzDx655QOL51N06how==", "dev": true, "requires": { "is-number": "3.0.0", @@ -4701,7 +4701,7 @@ "regex-cache": { "version": "0.4.4", "resolved": "https://registry.npmjs.org/regex-cache/-/regex-cache-0.4.4.tgz", - "integrity": "sha1-db3FiioUls7EihKDW8VMjVYjNt0=", + "integrity": "sha512-nVIZwtCjkC9YgvWkpM55B5rBhBYRZhAaJbgcFYXXsHnbZ9UZI9nnVWYZpBlCqv9ho2eZryPnWrZGsOdPwVWXWQ==", "dev": true, "requires": { "is-equal-shallow": "0.1.3" @@ -4729,7 +4729,7 @@ "remap-istanbul": { "version": "0.10.1", "resolved": "https://registry.npmjs.org/remap-istanbul/-/remap-istanbul-0.10.1.tgz", - "integrity": "sha1-OqWN1QIdSZ8zbTulvzu7kcG4jjc=", + "integrity": "sha512-gsNQXs5kJLhErICSyYhzVZ++C8LBW8dgwr874Y2QvzAUS75zBlD/juZgXs39nbYJ09fZDlX2AVLVJAY2jbFJoQ==", "dev": true, "requires": { "amdefine": "1.0.1", @@ -4769,7 +4769,7 @@ "source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha1-dHIq8y6WFOnCh6jQu95IteLxomM=", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", "dev": true }, "through2": { @@ -4883,7 +4883,7 @@ "resolve": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.5.0.tgz", - "integrity": "sha1-HwmsznlsmnYlefMbLBzEw83fnzY=", + "integrity": "sha512-hgoSGrc3pjzAPHNBg+KnFcK2HwlHTs/YrAGUr6qgTVUZmXv1UEXXl0bZNBKMA9fud6lRYFdPGz0xXxycPzmmiw==", "dev": true, "requires": { "path-parse": "1.0.5" @@ -4924,7 +4924,7 @@ "rimraf": { "version": "2.6.2", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", - "integrity": "sha1-LtgVDSShbqhlHm1u8PR8QVjOejY=", + "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", "dev": true, "requires": { "glob": "7.1.2" @@ -5063,19 +5063,19 @@ "safe-buffer": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", - "integrity": "sha1-iTMSr2myEj3vcfV4iQAWce6yyFM=", + "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", "dev": true }, "samsam": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/samsam/-/samsam-1.3.0.tgz", - "integrity": "sha1-jR2TUOJWItow3j5EumkrUiGrfFA=", + "integrity": "sha512-1HwIYD/8UlOtFS3QO3w7ey+SdSDFE4HRNLZoZRYVQefrOY3l17epswImeB1ijgJFQJodIaHcwkp3r/myBjFVbg==", "dev": true }, "semver": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz", - "integrity": "sha1-3Eu8emyp2Rbe5dQ1FvAJK1j3uKs=", + "integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==", "dev": true }, "set-blocking": { @@ -5117,7 +5117,7 @@ "sinon-chai": { "version": "2.14.0", "resolved": "https://registry.npmjs.org/sinon-chai/-/sinon-chai-2.14.0.tgz", - "integrity": "sha1-2n3UzIPNaiYLZ8yg96n9riahIF0=", + "integrity": "sha512-9stIF1utB0ywNHNT7RgiXbdmen8QDCRsrTjw+G9TgKt1Yexjiv8TOWZ6WHsTPz57Yky3DIswZvEqX8fpuHNDtQ==", "dev": true }, "slash": { @@ -5146,7 +5146,7 @@ "sntp": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/sntp/-/sntp-2.1.0.tgz", - "integrity": "sha1-LGzsFP7cIiJznK+bXD2F0cxaLMg=", + "integrity": "sha512-FL1b58BDrqS3A11lJ0zEdnJ3UOKqVxawAkF3k7F0CVN7VQ34aZrV+G8BZ1WC9ZL7NyrwsW0oviwsWDgRuVYtJg==", "dev": true, "requires": { "hoek": "4.2.1" @@ -5203,7 +5203,7 @@ "spdx-correct": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.0.0.tgz", - "integrity": "sha1-BaW01xU6GVvJLDxCW2nzsqlSTII=", + "integrity": "sha512-N19o9z5cEyc8yQQPukRCZ9EUmb4HUpnrmaL/fxS2pBo2jbfcFRVuFZ/oFC+vZz0MNNk0h80iMn5/S6qGZOL5+g==", "dev": true, "requires": { "spdx-expression-parse": "3.0.0", @@ -5213,13 +5213,13 @@ "spdx-exceptions": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.1.0.tgz", - "integrity": "sha1-LHrmEFbHFKW5ubKyr30xHvXHj+k=", + "integrity": "sha512-4K1NsmrlCU1JJgUrtgEeTVyfx8VaYea9J9LvARxhbHtVtohPs/gFGG5yy49beySjlIMhhXZ4QqujIZEfS4l6Cg==", "dev": true }, "spdx-expression-parse": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.0.tgz", - "integrity": "sha1-meEZt6XaAOBUkcn6M4t5BII7QdA=", + "integrity": "sha512-Yg6D3XpRD4kkOmTpdgbUiEJFKghJH03fiC1OPll5h/0sO6neh2jqRDVHOQ4o/LMea0tgCkbMgea5ip/e+MkWyg==", "dev": true, "requires": { "spdx-exceptions": "2.1.0", @@ -5229,7 +5229,7 @@ "spdx-license-ids": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.0.tgz", - "integrity": "sha1-enzShHDMbToc/m1miG9rxDDTrIc=", + "integrity": "sha512-2+EPwgbnmOIl8HjGBXXMd9NAu02vLjOO1nWw4kmeRDFyHn+M/ETfHxQUK0oXg8ctgVnl9t3rosNVsZ1jG61nDA==", "dev": true }, "speedometer": { @@ -5566,7 +5566,7 @@ "tough-cookie": { "version": "2.3.4", "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.4.tgz", - "integrity": "sha1-7GDO44rGdQY//JelwYlwV47oNlU=", + "integrity": "sha512-TZ6TTfI5NtZnuyy/Kecv+CnoROnyXn2DN97LontgQpCwsX2XyLYCC0ENhYkehSOwAp8rTQKc/NUIF7BkQ5rKLA==", "dev": true, "requires": { "punycode": "1.4.1" @@ -5708,13 +5708,13 @@ "uuid": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.2.1.tgz", - "integrity": "sha1-EsUou51Y0LkmXZovbw/ovhf/HxQ=", + "integrity": "sha512-jZnMwlb9Iku/O3smGWvZhauCf6cvvpKi4BKRiliS3cxnI+Gz9j5MEpTz2UFuXiKPJocb7gnsLHwiS05ige5BEA==", "dev": true }, "validate-npm-package-license": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.3.tgz", - "integrity": "sha1-gWQ7y+8b3+zUYjeT3EZIlIupgzg=", + "integrity": "sha512-63ZOUnL4SIXj4L0NixR3L1lcjO38crAbgrTpl28t8jjrfuiOBL5Iygm+60qPs/KsZGzPNg6Smnc/oY16QTjF0g==", "dev": true, "requires": { "spdx-correct": "3.0.0", @@ -5750,7 +5750,7 @@ "which": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/which/-/which-1.3.0.tgz", - "integrity": "sha1-/wS9/AEO5UfXgL7DjhrBwnd9JTo=", + "integrity": "sha512-xcJpopdamTuY5duC/KnTTNBraPK54YwpenP4lzxU8H91GudWpFv38u0CKjclE1Wi2EH2EDz5LRcHcKbCIzqGyg==", "dev": true, "requires": { "isexe": "2.0.0" diff --git a/packages/canvas/canvas-mesh/package.json b/packages/canvas/canvas-mesh/package.json index 691cd2c..6744a17 100644 --- a/packages/canvas/canvas-mesh/package.json +++ b/packages/canvas/canvas-mesh/package.json @@ -24,6 +24,7 @@ "dependencies": { "@pixi/constants": "^5.0.0-alpha.2", "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/mesh-extras": "^5.0.0-alpha.2", "@pixi/settings": "^5.0.0-alpha.2" }, "devDependencies": { diff --git a/packages/canvas/canvas-mesh/src/Mesh.js b/packages/canvas/canvas-mesh/src/Mesh.js index 900a872..c43a74b 100644 --- a/packages/canvas/canvas-mesh/src/Mesh.js +++ b/packages/canvas/canvas-mesh/src/Mesh.js @@ -1,36 +1,14 @@ import { Mesh } from '@pixi/mesh'; -import { settings } from './settings'; - -// IMPORTANT: Please do NOT use this as a precedent to use `settings` after the object is created -// this was merely created to completely decouple canvas from the base Mesh class and we are -// unable to add `canvasPadding` in the constructor anymore, as the case was for PixiJS v4. /** - * Internal variable for `canvasPadding`. + * Renders the object using the Canvas renderer * * @private - * @memberof PIXI.Mesh - * @member {number} - * @default null - */ -Mesh.prototype._canvasPadding = null; - -/** - * Triangles in canvas mode are automatically antialiased, use this value to force triangles - * to overlap a bit with each other. To set the global default, set {@link PIXI.settings.MESH_CANVAS_PADDING} - * - * @see PIXI.settings.MESH_CANVAS_PADDING - * @member {number} canvasPadding + * @method _renderCanvas * @memberof PIXI.Mesh# - * @default 0 + * @param {PIXI.CanvasRenderer} renderer - The canvas renderer. */ -Object.defineProperty(Mesh.prototype, 'canvasPadding', { - get() - { - return this._canvasPadding !== null ? this._canvasPadding : settings.MESH_CANVAS_PADDING; - }, - set(value) - { - this._canvasPadding = value; - }, -}); +Mesh.prototype._renderCanvas = function _renderCanvas(renderer) +{ + renderer.plugins[this.pluginName].render(this); +}; diff --git a/packages/canvas/canvas-mesh/src/Mesh2d.js b/packages/canvas/canvas-mesh/src/Mesh2d.js new file mode 100644 index 0000000..d0bd80f --- /dev/null +++ b/packages/canvas/canvas-mesh/src/Mesh2d.js @@ -0,0 +1,36 @@ +import { Mesh2d } from '@pixi/mesh-extras'; +import { settings } from './settings'; + +// IMPORTANT: Please do NOT use this as a precedent to use `settings` after the object is created +// this was merely created to completely decouple canvas from the base Mesh class and we are +// unable to add `canvasPadding` in the constructor anymore, as the case was for PixiJS v4. + +/** + * Internal variable for `canvasPadding`. + * + * @private + * @memberof PIXI.Mesh2d + * @member {number} + * @default null + */ +Mesh2d.prototype._canvasPadding = null; + +/** + * Triangles in canvas mode are automatically antialiased, use this value to force triangles + * to overlap a bit with each other. To set the global default, set {@link PIXI.settings.MESH_CANVAS_PADDING} + * + * @see PIXI.settings.MESH_CANVAS_PADDING + * @member {number} canvasPadding + * @memberof PIXI.Mesh2d# + * @default 0 + */ +Object.defineProperty(Mesh2d.prototype, 'canvasPadding', { + get() + { + return this._canvasPadding !== null ? this._canvasPadding : settings.MESH_CANVAS_PADDING; + }, + set(value) + { + this._canvasPadding = value; + }, +}); diff --git a/packages/canvas/canvas-mesh/src/NineSlicePlane.js b/packages/canvas/canvas-mesh/src/NineSlicePlane.js index 09eaf9c..2fd5acc 100644 --- a/packages/canvas/canvas-mesh/src/NineSlicePlane.js +++ b/packages/canvas/canvas-mesh/src/NineSlicePlane.js @@ -1,4 +1,4 @@ -import { NineSlicePlane } from '@pixi/mesh'; +import { NineSlicePlane } from '@pixi/mesh-extras'; /** * Renders the object using the Canvas renderer diff --git a/packages/canvas/canvas-mesh/src/RawMesh.js b/packages/canvas/canvas-mesh/src/RawMesh.js deleted file mode 100644 index bf40184..0000000 --- a/packages/canvas/canvas-mesh/src/RawMesh.js +++ /dev/null @@ -1,14 +0,0 @@ -import { RawMesh } from '@pixi/mesh'; - -/** - * Renders the object using the Canvas renderer - * - * @private - * @method _renderCanvas - * @memberof PIXI.RawMesh# - * @param {PIXI.CanvasRenderer} renderer - The canvas renderer. - */ -RawMesh.prototype._renderCanvas = function _renderCanvas(renderer) -{ - renderer.plugins[this.pluginName].render(this); -}; diff --git a/packages/canvas/canvas-mesh/src/index.js b/packages/canvas/canvas-mesh/src/index.js index 2295016..f4fa31d 100644 --- a/packages/canvas/canvas-mesh/src/index.js +++ b/packages/canvas/canvas-mesh/src/index.js @@ -1,6 +1,6 @@ export { default as CanvasMeshRenderer } from './CanvasMeshRenderer'; import './settings'; -import './Mesh'; +import './Mesh2d'; import './NineSlicePlane'; -import './RawMesh'; +import './Mesh'; diff --git a/packages/canvas/canvas-mesh/src/settings.js b/packages/canvas/canvas-mesh/src/settings.js index 4cefb4c..e81b8e0 100644 --- a/packages/canvas/canvas-mesh/src/settings.js +++ b/packages/canvas/canvas-mesh/src/settings.js @@ -3,7 +3,7 @@ /** * Default `canvasPadding` for canvas-based Mesh rendering. * - * @see PIXI.Mesh#canvasPadding + * @see PIXI.Mesh2d#canvasPadding * @static * @constant * @memberof PIXI.settings diff --git a/packages/mesh-extras/LICENSE b/packages/mesh-extras/LICENSE new file mode 100644 index 0000000..148e3eb --- /dev/null +++ b/packages/mesh-extras/LICENSE @@ -0,0 +1,21 @@ +The MIT License + +Copyright (c) 2013-2018 Mathew Groves, Chad Engler + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/packages/mesh-extras/README.md b/packages/mesh-extras/README.md new file mode 100644 index 0000000..1d9b0e1 --- /dev/null +++ b/packages/mesh-extras/README.md @@ -0,0 +1,19 @@ +# @pixi/mesh-extras + +## Installation + +```bash +npm install @pixi/mesh-extras +``` + +## Usage + +```js +import { MeshRenderer } from '@pixi/mesh'; +import { Renderer } from '@pixi/core'; +import { Rope } from '@pixi/mesh-extras'; + +Renderer.registerPlugin('mesh', MeshRenderer); + +const rope = new Rope(); +``` \ No newline at end of file diff --git a/packages/mesh-extras/package.json b/packages/mesh-extras/package.json new file mode 100644 index 0000000..d134f64 --- /dev/null +++ b/packages/mesh-extras/package.json @@ -0,0 +1,38 @@ +{ + "name": "@pixi/mesh-extras", + "version": "5.0.0-alpha.2", + "main": "lib/mesh-extras.js", + "module": "lib/mesh-extras.es.js", + "description": "Custom Mesh display objects, like Rope and Plane", + "author": "Mat Groves", + "contributors": [ + "Matt Karl " + ], + "homepage": "http://pixijs.com/", + "bugs": "https://github.com/pixijs/pixi.js/issues", + "license": "MIT", + "repository": { + "type": "git", + "url": "https://github.com/pixijs/pixi.js.git" + }, + "publishConfig": { + "access": "public" + }, + "scripts": { + "test": "floss --path test" + }, + "files": [ + "lib" + ], + "dependencies": { + "@pixi/constants": "^5.0.0-alpha.2", + "@pixi/core": "^5.0.0-alpha.2", + "@pixi/math": "^5.0.0-alpha.2", + "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/utils": "^5.0.0-alpha.2" + }, + "devDependencies": { + "@pixi/loaders": "^5.0.0-alpha.2", + "floss": "^2.1.3" + } +} diff --git a/packages/mesh-extras/src/Mesh2d.js b/packages/mesh-extras/src/Mesh2d.js new file mode 100644 index 0000000..d113a5e --- /dev/null +++ b/packages/mesh-extras/src/Mesh2d.js @@ -0,0 +1,263 @@ +import { Mesh } from '@pixi/mesh'; +import { Geometry, Program, Shader, Texture, TextureMatrix } from '@pixi/core'; +import { Matrix } from '@pixi/math'; +import { BLEND_MODES } from '@pixi/constants'; +import { hex2rgb, premultiplyRgba } from '@pixi/utils'; +import vertex from './mesh.vert'; +import fragment from './mesh.frag'; + +let meshProgram; + +/** + * Base mesh class + * @class + * @extends PIXI.Container + * @memberof PIXI + */ +export default class Mesh2d extends Mesh +{ + /** + * @param {PIXI.Texture} [texture=Texture.EMPTY] - The texture to use + * @param {Float32Array} [vertices] - if you want to specify the vertices + * @param {Float32Array} [uvs] - if you want to specify the uvs + * @param {Uint16Array} [indices] - if you want to specify the indices + * @param {number} [drawMode] - the drawMode, can be any of the Mesh.DRAW_MODES consts + */ + constructor(texture = Texture.EMPTY, vertices, uvs, indices, drawMode) + { + const geometry = new Geometry(); + + if (!meshProgram) + { + meshProgram = new Program(vertex, fragment); + } + + geometry.addAttribute('aVertexPosition', vertices) + .addAttribute('aTextureCoord', uvs) + .addIndex(indices); + + geometry.getAttribute('aVertexPosition').static = false; + + const uniforms = { + uSampler: texture, + uTextureMatrix: Matrix.IDENTITY, + alpha: 1, + uColor: new Float32Array([1, 1, 1, 1]), + }; + + super(geometry, new Shader(meshProgram, uniforms), null, drawMode); + + /** + * The Uvs of the Mesh + * + * @member {Float32Array} + */ + this.uvs = geometry.getAttribute('aTextureCoord').data; + + /** + * An array of vertices + * + * @member {Float32Array} + */ + this.vertices = geometry.getAttribute('aVertexPosition').data; + + this.uniforms = uniforms; + + /** + * The texture of the Mesh + * + * @member {PIXI.Texture} + * @default PIXI.Texture.EMPTY + * @private + */ + this.texture = texture; + + /** + * The tint applied to the mesh. This is a [r,g,b] value. A value of [1,1,1] will remove any + * tint effect. + * + * @member {number} + * @private + */ + this._tintRGB = new Float32Array([1, 1, 1]); + + // Set default tint + this.tint = 0xFFFFFF; + + this.blendMode = BLEND_MODES.NORMAL; + + /** + * TextureMatrix instance for this Mesh, used to track Texture changes + * + * @member {PIXI.TextureMatrix} + * @readonly + */ + this.uvMatrix = new TextureMatrix(this._texture); + + /** + * whether or not upload uvMatrix to shader + * if its false, then uvs should be pre-multiplied + * if you change it for generated mesh, please call 'refresh(true)' + * @member {boolean} + * @default false + */ + this.uploadUvMatrix = false; + + /** + * Uploads vertices buffer every frame, like in PixiJS V3 and V4. + * + * @member {boolean} + * @default true + */ + this.autoUpdate = true; + } + + /** + * The tint applied to the Rope. This is a hex value. A value of + * 0xFFFFFF will remove any tint effect. + * + * @member {number} + * @memberof PIXI.Sprite# + * @default 0xFFFFFF + */ + get tint() + { + return this._tint; + } + + /** + * Sets the tint of the rope. + * + * @param {number} value - The value to set to. + */ + set tint(value) + { + this._tint = value; + + hex2rgb(this._tint, this._tintRGB); + } + + /** + * The blend mode to be applied to the sprite. Set to `PIXI.BLEND_MODES.NORMAL` to remove any blend mode. + * + * @member {number} + * @default PIXI.BLEND_MODES.NORMAL + * @see PIXI.BLEND_MODES + */ + get blendMode() + { + return this.state.blendMode; + } + + set blendMode(value) // eslint-disable-line require-jsdoc + { + this.state.blendMode = value; + } + + /** + * The texture that the mesh uses. + * + * @member {PIXI.Texture} + */ + get texture() + { + return this._texture; + } + + set texture(value) // eslint-disable-line require-jsdoc + { + if (this._texture === value) + { + return; + } + + this._texture = value; + this.uniforms.uSampler = this.texture; + + if (value) + { + // wait for the texture to load + if (value.baseTexture.valid) + { + this._onTextureUpdate(); + } + else + { + value.once('update', this._onTextureUpdate, this); + } + } + } + + _render(renderer) + { + const baseTex = this._texture.baseTexture; + + premultiplyRgba(this._tintRGB, this.worldAlpha, this.uniforms.uColor, baseTex.premultiplyAlpha); + super._render(renderer); + } + /** + * When the texture is updated, this event will fire to update the scale and frame + * + * @private + */ + _onTextureUpdate() + { + // constructor texture update stop + if (!this.uvMatrix) + { + return; + } + this.uvMatrix.texture = this._texture; + this.refresh(); + } + + /** + * multiplies uvs only if uploadUvMatrix is false + * call it after you change uvs manually + * make sure that texture is valid + */ + multiplyUvs() + { + if (!this.uploadUvMatrix) + { + this.uvMatrix.multiplyUvs(this.uvs); + } + } + + /** + * Refreshes uvs for generated meshes (rope, plane) + * sometimes refreshes vertices too + * + * @param {boolean} [forceUpdate=false] if true, matrices will be updated any case + */ + refresh(forceUpdate) + { + if (this.uvMatrix.update(forceUpdate)) + { + this._refresh(); + } + } + + /** + * Updates the object transform for rendering + * + * @private + */ + updateTransform() + { + if (this.autoUpdate) + { + this.geometry.buffers[0].update(); + } + this.containerUpdateTransform(); + } + + /** + * re-calculates mesh coords + * @private + */ + _refresh() + { + /* empty */ + } +} diff --git a/packages/mesh-extras/src/NineSlicePlane.js b/packages/mesh-extras/src/NineSlicePlane.js new file mode 100644 index 0000000..0bae92c --- /dev/null +++ b/packages/mesh-extras/src/NineSlicePlane.js @@ -0,0 +1,270 @@ +import Plane from './Plane'; + +const DEFAULT_BORDER_SIZE = 10; + +/** + * The NineSlicePlane allows you to stretch a texture using 9-slice scaling. The corners will remain unscaled (useful + * for buttons with rounded corners for example) and the other areas will be scaled horizontally and or vertically + * + *```js + * let Plane9 = new PIXI.NineSlicePlane(PIXI.Texture.from('BoxWithRoundedCorners.png'), 15, 15, 15, 15); + * ``` + *
+ *      A                          B
+ *    +---+----------------------+---+
+ *  C | 1 |          2           | 3 |
+ *    +---+----------------------+---+
+ *    |   |                      |   |
+ *    | 4 |          5           | 6 |
+ *    |   |                      |   |
+ *    +---+----------------------+---+
+ *  D | 7 |          8           | 9 |
+ *    +---+----------------------+---+
+
+ *  When changing this objects width and/or height:
+ *     areas 1 3 7 and 9 will remain unscaled.
+ *     areas 2 and 8 will be stretched horizontally
+ *     areas 4 and 6 will be stretched vertically
+ *     area 5 will be stretched both horizontally and vertically
+ * 
+ * + * @class + * @extends PIXI.Plane + * @memberof PIXI + * + */ +export default class NineSlicePlane extends Plane +{ + /** + * @param {PIXI.Texture} texture - The texture to use on the NineSlicePlane. + * @param {int} [leftWidth=10] size of the left vertical bar (A) + * @param {int} [topHeight=10] size of the top horizontal bar (C) + * @param {int} [rightWidth=10] size of the right vertical bar (B) + * @param {int} [bottomHeight=10] size of the bottom horizontal bar (D) + */ + constructor(texture, leftWidth, topHeight, rightWidth, bottomHeight) + { + super(texture, 4, 4); + + this._origWidth = texture.orig.width; + this._origHeight = texture.orig.height; + + /** + * The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._width = this._origWidth; + + /** + * The height of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._height = this._origHeight; + + /** + * The width of the left column (a) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._leftWidth = typeof leftWidth !== 'undefined' ? leftWidth : DEFAULT_BORDER_SIZE; + + /** + * The width of the right column (b) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._rightWidth = typeof rightWidth !== 'undefined' ? rightWidth : DEFAULT_BORDER_SIZE; + + /** + * The height of the top row (c) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._topHeight = typeof topHeight !== 'undefined' ? topHeight : DEFAULT_BORDER_SIZE; + + /** + * The height of the bottom row (d) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._bottomHeight = typeof bottomHeight !== 'undefined' ? bottomHeight : DEFAULT_BORDER_SIZE; + + this.refresh(true); + } + + /** + * Updates the horizontal vertices. + * + */ + updateHorizontalVertices() + { + const vertices = this.vertices; + + const h = this._topHeight + this._bottomHeight; + const scale = this._height > h ? 1.0 : this._height / h; + + vertices[9] = vertices[11] = vertices[13] = vertices[15] = this._topHeight * scale; + vertices[17] = vertices[19] = vertices[21] = vertices[23] = this._height - (this._bottomHeight * scale); + vertices[25] = vertices[27] = vertices[29] = vertices[31] = this._height; + } + + /** + * Updates the vertical vertices. + * + */ + updateVerticalVertices() + { + const vertices = this.vertices; + + const w = this._leftWidth + this._rightWidth; + const scale = this._width > w ? 1.0 : this._width / w; + + vertices[2] = vertices[10] = vertices[18] = vertices[26] = this._leftWidth * scale; + vertices[4] = vertices[12] = vertices[20] = vertices[28] = this._width - (this._rightWidth * scale); + vertices[6] = vertices[14] = vertices[22] = vertices[30] = this._width; + } + + /** + * The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + */ + get width() + { + return this._width; + } + + set width(value) // eslint-disable-line require-jsdoc + { + this._width = value; + this._refresh(); + } + + /** + * The height of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + */ + get height() + { + return this._height; + } + + set height(value) // eslint-disable-line require-jsdoc + { + this._height = value; + this._refresh(); + } + + /** + * The width of the left column + * + * @member {number} + */ + get leftWidth() + { + return this._leftWidth; + } + + set leftWidth(value) // eslint-disable-line require-jsdoc + { + this._leftWidth = value; + this._refresh(); + } + + /** + * The width of the right column + * + * @member {number} + */ + get rightWidth() + { + return this._rightWidth; + } + + set rightWidth(value) // eslint-disable-line require-jsdoc + { + this._rightWidth = value; + this._refresh(); + } + + /** + * The height of the top row + * + * @member {number} + */ + get topHeight() + { + return this._topHeight; + } + + set topHeight(value) // eslint-disable-line require-jsdoc + { + this._topHeight = value; + this._refresh(); + } + + /** + * The height of the bottom row + * + * @member {number} + */ + get bottomHeight() + { + return this._bottomHeight; + } + + set bottomHeight(value) // eslint-disable-line require-jsdoc + { + this._bottomHeight = value; + this._refresh(); + } + + /** + * Refreshes NineSlicePlane coords. All of them. + */ + _refresh() + { + super._refresh(); + + const uvs = this.uvs; + const texture = this._texture; + + this._origWidth = texture.orig.width; + this._origHeight = texture.orig.height; + + const _uvw = 1.0 / this._origWidth; + const _uvh = 1.0 / this._origHeight; + + uvs[0] = uvs[8] = uvs[16] = uvs[24] = 0; + uvs[1] = uvs[3] = uvs[5] = uvs[7] = 0; + uvs[6] = uvs[14] = uvs[22] = uvs[30] = 1; + uvs[25] = uvs[27] = uvs[29] = uvs[31] = 1; + + uvs[2] = uvs[10] = uvs[18] = uvs[26] = _uvw * this._leftWidth; + uvs[4] = uvs[12] = uvs[20] = uvs[28] = 1 - (_uvw * this._rightWidth); + uvs[9] = uvs[11] = uvs[13] = uvs[15] = _uvh * this._topHeight; + uvs[17] = uvs[19] = uvs[21] = uvs[23] = 1 - (_uvh * this._bottomHeight); + + this.updateHorizontalVertices(); + this.updateVerticalVertices(); + + this.geometry.buffers[1].update(); + + this.multiplyUvs(); + } +} diff --git a/packages/mesh-extras/src/Plane.js b/packages/mesh-extras/src/Plane.js new file mode 100644 index 0000000..1c240c4 --- /dev/null +++ b/packages/mesh-extras/src/Plane.js @@ -0,0 +1,100 @@ +import Mesh2d from './Mesh2d'; + +/** + * The Plane allows you to draw a texture across several points and them manipulate these points + * + *```js + * for (let i = 0; i < 20; i++) { + * points.push(new PIXI.Point(i * 50, 0)); + * }; + * let Plane = new PIXI.Plane(PIXI.Texture.from("snake.png"), points); + * ``` + * + * @class + * @extends PIXI.Mesh + * @memberof PIXI + * + */ +export default class Plane extends Mesh2d +{ + /** + * @param {PIXI.Texture} texture - The texture to use on the Plane. + * @param {number} verticesX - The number of vertices in the x-axis + * @param {number} verticesY - The number of vertices in the y-axis + * @param {object} [opts] - an options object - add meshWidth and meshHeight, temporary object for PixiJS v5 alpha + */ + constructor(texture, verticesX, verticesY, opts = {}) + { + super(texture, new Float32Array(1), new Float32Array(1), new Uint16Array(1), 4); + + this.verticesX = verticesX || 10; + this.verticesY = verticesY || 10; + + this.meshWidth = opts.meshWidth || 0; + this.meshHeight = opts.meshHeight || 0; + + this.refresh(); + } + + /** + * Refreshes plane coordinates + * @private + */ + _refresh() + { + const texture = this._texture; + const total = this.verticesX * this.verticesY; + const verts = []; + const uvs = []; + const indices = []; + + const segmentsX = this.verticesX - 1; + const segmentsY = this.verticesY - 1; + + const sizeX = (this.meshWidth || texture.width) / segmentsX; + const sizeY = (this.meshHeight || texture.height) / segmentsY; + + for (let i = 0; i < total; i++) + { + const x = (i % this.verticesX); + const y = ((i / this.verticesX) | 0); + + verts.push(x * sizeX, y * sizeY); + + uvs.push(x / segmentsX, y / segmentsY); + } + + // cons + + const totalSub = segmentsX * segmentsY; + + for (let i = 0; i < totalSub; i++) + { + const xpos = i % segmentsX; + const ypos = (i / segmentsX) | 0; + + const value = (ypos * this.verticesX) + xpos; + const value2 = (ypos * this.verticesX) + xpos + 1; + const value3 = ((ypos + 1) * this.verticesX) + xpos; + const value4 = ((ypos + 1) * this.verticesX) + xpos + 1; + + indices.push(value, value2, value3); + indices.push(value2, value4, value3); + } + + this.vertices = new Float32Array(verts); + this.uvs = new Float32Array(uvs); + this.indices = new Uint16Array(indices); + + this.geometry.buffers[0].data = this.vertices; + this.geometry.buffers[1].data = this.uvs; + this.geometry.indexBuffer.data = this.indices; + + // ensure that the changes are uploaded + this.geometry.buffers[0].update(); + this.geometry.buffers[1].update(); + this.geometry.indexBuffer.update(); + + this.multiplyUvs(); + } +} diff --git a/packages/mesh-extras/src/Rope.js b/packages/mesh-extras/src/Rope.js new file mode 100644 index 0000000..9cfde38 --- /dev/null +++ b/packages/mesh-extras/src/Rope.js @@ -0,0 +1,182 @@ +import Mesh2d from './Mesh2d'; + +/** + * The rope allows you to draw a texture across several points and them manipulate these points + * + *```js + * for (let i = 0; i < 20; i++) { + * points.push(new PIXI.Point(i * 50, 0)); + * }; + * let rope = new PIXI.Rope(PIXI.Texture.from("snake.png"), points); + * ``` + * + * @class + * @extends PIXI.Mesh + * @memberof PIXI + * + */ +export default class Rope extends Mesh2d +{ + /** + * @param {PIXI.Texture} texture - The texture to use on the rope. + * @param {PIXI.Point[]} points - An array of {@link PIXI.Point} objects to construct this rope. + */ + constructor(texture, points) + { + super(texture, new Float32Array(points.length * 4), + new Float32Array(points.length * 4), + new Uint16Array(points.length * 2), + 5); + + /* + * @member {PIXI.Point[]} An array of points that determine the rope + */ + this.points = points; + this.refresh(); + } + /** + * Refreshes Rope indices and uvs + * @private + */ + _refresh() + { + const points = this.points; + + if (!points) return; + + const vertexBuffer = this.geometry.getAttribute('aVertexPosition'); + const uvBuffer = this.geometry.getAttribute('aTextureCoord'); + const indexBuffer = this.geometry.getIndex(); + + // if too little points, or texture hasn't got UVs set yet just move on. + if (points.length < 1 || !this.texture._uvs) + { + return; + } + + // if the number of points has changed we will need to recreate the arraybuffers + if (vertexBuffer.data.length / 4 !== points.length) + { + vertexBuffer.data = new Float32Array(points.length * 4); + uvBuffer.data = new Float32Array(points.length * 4); + indexBuffer.data = new Uint16Array(points.length * 2); + } + + const uvs = uvBuffer.data; + const indices = indexBuffer.data; + + uvs[0] = 0; + uvs[1] = 0; + uvs[2] = 0; + uvs[3] = 1; + + indices[0] = 0; + indices[1] = 1; + + const total = points.length; + + for (let i = 1; i < total; i++) + { + // time to do some smart drawing! + let index = i * 4; + const amount = i / (total - 1); + + uvs[index] = amount; + uvs[index + 1] = 0; + + uvs[index + 2] = amount; + uvs[index + 3] = 1; + + index = i * 2; + indices[index] = index; + indices[index + 1] = index + 1; + } + + // ensure that the changes are uploaded + uvBuffer.update(); + indexBuffer.update(); + + this.multiplyUvs(); + this.refreshVertices(); + } + + /** + * refreshes vertices of Rope mesh + */ + refreshVertices() + { + const points = this.points; + + if (points.length < 1) + { + return; + } + + let lastPoint = points[0]; + let nextPoint; + let perpX = 0; + let perpY = 0; + + // this.count -= 0.2; + + const vertices = this.vertices; + const total = points.length; + + for (let i = 0; i < total; i++) + { + const point = points[i]; + const index = i * 4; + + if (i < points.length - 1) + { + nextPoint = points[i + 1]; + } + else + { + nextPoint = point; + } + + perpY = -(nextPoint.x - lastPoint.x); + perpX = nextPoint.y - lastPoint.y; + + let ratio = (1 - (i / (total - 1))) * 10; + + if (ratio > 1) + { + ratio = 1; + } + + const perpLength = Math.sqrt((perpX * perpX) + (perpY * perpY)); + const num = this._texture.height / 2; // (20 + Math.abs(Math.sin((i + this.count) * 0.3) * 50) )* ratio; + + perpX /= perpLength; + perpY /= perpLength; + + perpX *= num; + perpY *= num; + + vertices[index] = point.x + perpX; + vertices[index + 1] = point.y + perpY; + vertices[index + 2] = point.x - perpX; + vertices[index + 3] = point.y - perpY; + + lastPoint = point; + } + + this.geometry.buffers[0].update(); + } + + /** + * Updates the object transform for rendering + * + * @private + */ + updateTransform() + { + if (this.autoUpdate) + { + this.refreshVertices(); + } + this.containerUpdateTransform(); + } +} diff --git a/packages/mesh-extras/src/index.js b/packages/mesh-extras/src/index.js new file mode 100644 index 0000000..decf454 --- /dev/null +++ b/packages/mesh-extras/src/index.js @@ -0,0 +1,4 @@ +export { default as Mesh2d } from './Mesh2d'; +export { default as Plane } from './Plane'; +export { default as NineSlicePlane } from './NineSlicePlane'; +export { default as Rope } from './Rope'; diff --git a/packages/mesh-extras/src/mesh.frag b/packages/mesh-extras/src/mesh.frag new file mode 100644 index 0000000..6096983 --- /dev/null +++ b/packages/mesh-extras/src/mesh.frag @@ -0,0 +1,9 @@ +varying vec2 vTextureCoord; +uniform vec4 uColor; + +uniform sampler2D uSampler; + +void main(void) +{ + gl_FragColor = texture2D(uSampler, vTextureCoord) * uColor; +} diff --git a/packages/mesh-extras/src/mesh.vert b/packages/mesh-extras/src/mesh.vert new file mode 100644 index 0000000..0526df9 --- /dev/null +++ b/packages/mesh-extras/src/mesh.vert @@ -0,0 +1,15 @@ +attribute vec2 aVertexPosition; +attribute vec2 aTextureCoord; + +uniform mat3 projectionMatrix; +uniform mat3 translationMatrix; +uniform mat3 uTextureMatrix; + +varying vec2 vTextureCoord; + +void main(void) +{ + gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); + + vTextureCoord = (uTextureMatrix * vec3(aTextureCoord, 1.0)).xy; +} diff --git a/packages/mesh-extras/test/.eslintrc.json b/packages/mesh-extras/test/.eslintrc.json new file mode 100644 index 0000000..2ad8efb --- /dev/null +++ b/packages/mesh-extras/test/.eslintrc.json @@ -0,0 +1,12 @@ +{ + "globals": { + "expect": false, + "assert": false, + "sinon": false, + "PIXI": false + }, + "rules": { + "func-names": 0, + "no-unused-expressions": 0 + } +} \ No newline at end of file diff --git a/packages/mesh-extras/test/Plane.js b/packages/mesh-extras/test/Plane.js new file mode 100644 index 0000000..f9b1c25 --- /dev/null +++ b/packages/mesh-extras/test/Plane.js @@ -0,0 +1,60 @@ +const { Plane } = require('../'); +const { isWebGLSupported, skipHello } = require('@pixi/utils'); +const { Loader } = require('@pixi/loaders'); +const { Point } = require('@pixi/math'); +const { RenderTexture, Texture } = require('@pixi/core'); + +skipHello(); + +function withGL(fn) +{ + return isWebGLSupported() ? fn : undefined; +} + +// TODO: fix with webglrenderer +describe('PIXI.mesh.Plane', function () +{ + it.skip('should create a plane from an external image', withGL(function (done) + { + const loader = new Loader(); + + loader.add('testBitmap', `file://${__dirname}/resources/bitmap-1.png`) + .load(function (loader, resources) + { + const plane = new Plane(resources.testBitmap.texture, 100, 100); + + expect(plane.verticesX).to.equal(100); + expect(plane.verticesY).to.equal(100); + done(); + }); + })); + + it.skip('should create a new empty textured Plane', withGL(function () + { + const plane = new Plane(Texture.EMPTY, 100, 100); + + expect(plane.verticesX).to.equal(100); + expect(plane.verticesY).to.equal(100); + })); + + describe('containsPoint', function () + { + it.skip('should return true when point inside', withGL(function () + { + const point = new Point(10, 10); + const texture = new RenderTexture.create(20, 30); + const plane = new Plane(texture, 100, 100); + + expect(plane.containsPoint(point)).to.be.true; + })); + + it.skip('should return false when point outside', withGL(function () + { + const point = new Point(100, 100); + const texture = new RenderTexture.create(20, 30); + const plane = new Plane(texture, 100, 100); + + expect(plane.containsPoint(point)).to.be.false; + })); + }); +}); diff --git a/packages/mesh-extras/test/index.js b/packages/mesh-extras/test/index.js new file mode 100644 index 0000000..d767624 --- /dev/null +++ b/packages/mesh-extras/test/index.js @@ -0,0 +1 @@ +require('./Plane'); diff --git a/packages/mesh-extras/test/resources/bitmap-1.png b/packages/mesh-extras/test/resources/bitmap-1.png new file mode 100644 index 0000000..1284fb8 --- /dev/null +++ b/packages/mesh-extras/test/resources/bitmap-1.png Binary files differ diff --git a/packages/mesh/package.json b/packages/mesh/package.json index 8b1f8d9..10bd8e3 100644 --- a/packages/mesh/package.json +++ b/packages/mesh/package.json @@ -18,22 +18,16 @@ "publishConfig": { "access": "public" }, - "scripts": { - "test": "floss --path test" - }, "files": [ "lib" ], "dependencies": { - "@pixi/canvas-renderer": "^5.0.0-alpha.2", "@pixi/constants": "^5.0.0-alpha.2", "@pixi/core": "^5.0.0-alpha.2", "@pixi/display": "^5.0.0-alpha.2", - "@pixi/math": "^5.0.0-alpha.2", - "@pixi/utils": "^5.0.0-alpha.2" + "@pixi/math": "^5.0.0-alpha.2" }, "devDependencies": { - "@pixi/loaders": "^5.0.0-alpha.2", "floss": "^2.1.3" } } diff --git a/packages/mesh/src/Mesh.js b/packages/mesh/src/Mesh.js index e7c8f9e..1f35b7a 100644 --- a/packages/mesh/src/Mesh.js +++ b/packages/mesh/src/Mesh.js @@ -1,263 +1,220 @@ -import RawMesh from './RawMesh'; -import { Geometry, Program, Shader, Texture, TextureMatrix } from '@pixi/core'; -import { Matrix } from '@pixi/math'; -import { BLEND_MODES } from '@pixi/constants'; -import { hex2rgb, premultiplyRgba } from '@pixi/utils'; -import vertex from './mesh.vert'; -import fragment from './mesh.frag'; +import { State } from '@pixi/core'; +import { DRAW_MODES } from '@pixi/constants'; +import { Point, Polygon } from '@pixi/math'; +import { Container } from '@pixi/display'; -let meshProgram; +const tempPoint = new Point(); +const tempPolygon = new Polygon(); /** - * Base mesh class + * Base mesh class. + * The reason for this class is to empower you to have maximum flexibility to render any kind of webGL you can think of. + * This class assumes a certain level of webGL knowledge. + * If you know a bit this should abstract enough away to make you life easier! + * Pretty much ALL WebGL can be broken down into the following: + * Geometry - The structure and data for the mesh. This can include anything from positions, uvs, normals, colors etc.. + * Shader - This is the shader that pixi will render the geometry with. (attributes in the shader must match the geometry!) + * Uniforms - These are the values passed to the shader when the mesh is rendered. + * As a shader can be reused across multiple objects, it made sense to allow uniforms to exist outside of the shader + * State - This is the state of WebGL required to render the mesh. + * Through a combination of the above elements you can render anything you want, 2D or 3D! + * * @class * @extends PIXI.Container * @memberof PIXI */ -export default class Mesh extends RawMesh +export default class Mesh extends Container { /** - * @param {PIXI.Texture} [texture=Texture.EMPTY] - The texture to use - * @param {Float32Array} [vertices] - if you want to specify the vertices - * @param {Float32Array} [uvs] - if you want to specify the uvs - * @param {Uint16Array} [indices] - if you want to specify the indices - * @param {number} [drawMode] - the drawMode, can be any of the Mesh.DRAW_MODES consts + * @param {PIXI.Geometry} geometry the geometry the mesh will use + * @param {PIXI.Shader} shader the shader the mesh will use + * @param {PIXI.State} state the state that the webGL context is required to be in to render the mesh + * @param {number} drawMode the drawMode, can be any of the PIXI.DRAW_MODES consts */ - constructor(texture = Texture.EMPTY, vertices, uvs, indices, drawMode) + constructor(geometry, shader, state, drawMode = DRAW_MODES.TRIANGLES) { - const geometry = new Geometry(); - - if (!meshProgram) - { - meshProgram = new Program(vertex, fragment); - } - - geometry.addAttribute('aVertexPosition', vertices) - .addAttribute('aTextureCoord', uvs) - .addIndex(indices); - - geometry.getAttribute('aVertexPosition').static = false; - - const uniforms = { - uSampler: texture, - uTextureMatrix: Matrix.IDENTITY, - alpha: 1, - uColor: new Float32Array([1, 1, 1, 1]), - }; - - super(geometry, new Shader(meshProgram, uniforms), null, drawMode); + super(); /** - * The Uvs of the Mesh - * - * @member {Float32Array} + * the geometry the mesh will use + * @type {PIXI.Geometry} */ - this.uvs = geometry.getAttribute('aTextureCoord').data; + this.geometry = geometry; /** - * An array of vertices - * - * @member {Float32Array} + * the shader the mesh will use + * @type {PIXI.Shader} */ - this.vertices = geometry.getAttribute('aVertexPosition').data; - - this.uniforms = uniforms; + this.shader = shader; /** - * The texture of the Mesh - * - * @member {PIXI.Texture} - * @default PIXI.Texture.EMPTY - * @private + * the webGL state the mesh requires to render + * @type {PIXI.State} */ - this.texture = texture; + this.state = state || new State(); /** - * The tint applied to the mesh. This is a [r,g,b] value. A value of [1,1,1] will remove any - * tint effect. + * The way the Mesh should be drawn, can be any of the {@link PIXI.Mesh.DRAW_MODES} consts * * @member {number} + * @see PIXI.Mesh.DRAW_MODES + */ + this.drawMode = drawMode; + + /** + * The way uniforms that will be used by the mesh's shader. + * @member {Object} + */ + + /** + * A map of renderer IDs to webgl render data + * * @private + * @member {object} */ - this._tintRGB = new Float32Array([1, 1, 1]); - - // Set default tint - this.tint = 0xFFFFFF; - - this.blendMode = BLEND_MODES.NORMAL; + this._glDatas = {}; /** - * TextureMatrix instance for this Mesh, used to track Texture changes + * Plugin that is responsible for rendering this element. + * Allows to customize the rendering process without overriding '_render' & '_renderCanvas' methods. * - * @member {PIXI.TextureMatrix} - * @readonly + * @member {string} + * @default 'mesh' */ - this.uvMatrix = new TextureMatrix(this._texture); + this.pluginName = 'mesh'; - /** - * whether or not upload uvMatrix to shader - * if its false, then uvs should be pre-multiplied - * if you change it for generated mesh, please call 'refresh(true)' - * @member {boolean} - * @default false - */ - this.uploadUvMatrix = false; - - /** - * Uploads vertices buffer every frame, like in PixiJS V3 and V4. - * - * @member {boolean} - * @default true - */ - this.autoUpdate = true; + this.start = 0; + this.size = 0; } /** - * The tint applied to the Rope. This is a hex value. A value of - * 0xFFFFFF will remove any tint effect. + * Renders the object using the WebGL renderer * - * @member {number} - * @memberof PIXI.Sprite# - * @default 0xFFFFFF + * @param {PIXI.Renderer} renderer a reference to the WebGL renderer + * @private */ - get tint() + _render(renderer) { - return this._tint; + renderer.batch.setObjectRenderer(renderer.plugins[this.pluginName]); + renderer.plugins[this.pluginName].render(this); } /** - * Sets the tint of the rope. + * Updates the bounds of the mesh as a rectangle. The bounds calculation takes the worldTransform into account. + * there must be a aVertexPosition attribute present in the geometry for bounds to be calculated correctly. * - * @param {number} value - The value to set to. + * @private */ - set tint(value) + _calculateBounds() { - this._tint = value; - - hex2rgb(this._tint, this._tintRGB); - } - - /** - * The blend mode to be applied to the sprite. Set to `PIXI.BLEND_MODES.NORMAL` to remove any blend mode. - * - * @member {number} - * @default PIXI.BLEND_MODES.NORMAL - * @see PIXI.BLEND_MODES - */ - get blendMode() - { - return this.state.blendMode; - } - - set blendMode(value) // eslint-disable-line require-jsdoc - { - this.state.blendMode = value; - } - - /** - * The texture that the mesh uses. - * - * @member {PIXI.Texture} - */ - get texture() - { - return this._texture; - } - - set texture(value) // eslint-disable-line require-jsdoc - { - if (this._texture === value) + // The position property could be set manually? + if (this.geometry.attributes.aVertexPosition) { - return; + const vertices = this.geometry.getAttribute('aVertexPosition').data; + + // TODO - we can cache local bounds and use them if they are dirty (like graphics) + this._bounds.addVertices(this.transform, vertices, 0, vertices.length); + } + } + + /** + * Tests if a point is inside this mesh. Works only for TRIANGLE_MESH + * + * @param {PIXI.Point} point the point to test + * @return {boolean} the result of the test + */ + containsPoint(point) + { + if (!this.getBounds().contains(point.x, point.y)) + { + return false; } - this._texture = value; - this.uniforms.uSampler = this.texture; + this.worldTransform.applyInverse(point, tempPoint); - if (value) + const vertices = this.geometry.getAttribute('aVertexPosition').data; + + const points = tempPolygon.points; + const indices = this.geometry.getIndex().data; + const len = indices.length; + const step = this.drawMode === 4 ? 3 : 1; + + for (let i = 0; i + 2 < len; i += step) { - // wait for the texture to load - if (value.baseTexture.valid) + const ind0 = indices[i] * 2; + const ind1 = indices[i + 1] * 2; + const ind2 = indices[i + 2] * 2; + + points[0] = vertices[ind0]; + points[1] = vertices[ind0 + 1]; + points[2] = vertices[ind1]; + points[3] = vertices[ind1 + 1]; + points[4] = vertices[ind2]; + points[5] = vertices[ind2 + 1]; + + if (tempPolygon.contains(tempPoint.x, tempPoint.y)) { - this._onTextureUpdate(); + return true; + } + } + + return false; + } + + /** + * Destroys the Mesh object. + * + * @param {object|boolean} [options] - Options parameter. A boolean will act as if all + * options have been set to that value + * @param {boolean} [options.children=false] - if set to true, all the children will have + * their destroy method called as well. 'options' will be passed on to those calls. + * @param {boolean} [options.texture=false] - Only used for child Sprites if options.children is set to true + * Should it destroy the texture of the child sprite + * @param {boolean} [options.baseTexture=false] - Only used for child Sprites if options.children is set to true + * Should it destroy the base texture of the child sprite + */ + destroy(options) + { + // for each webgl data entry, destroy the WebGLGraphicsData + for (const id in this._glDatas) + { + const data = this._glDatas[id]; + + if (data.destroy) + { + data.destroy(); } else { - value.once('update', this._onTextureUpdate, this); + if (data.vertexBuffer) + { + data.vertexBuffer.destroy(); + data.vertexBuffer = null; + } + if (data.indexBuffer) + { + data.indexBuffer.destroy(); + data.indexBuffer = null; + } + if (data.uvBuffer) + { + data.uvBuffer.destroy(); + data.uvBuffer = null; + } + if (data.vao) + { + data.vao.destroy(); + data.vao = null; + } } } - } - _render(renderer) - { - const baseTex = this._texture.baseTexture; + this._glDatas = null; - premultiplyRgba(this._tintRGB, this.worldAlpha, this.uniforms.uColor, baseTex.premultiplyAlpha); - super._render(renderer); - } - /** - * When the texture is updated, this event will fire to update the scale and frame - * - * @private - */ - _onTextureUpdate() - { - // constructor texture update stop - if (!this.uvMatrix) - { - return; - } - this.uvMatrix.texture = this._texture; - this.refresh(); - } + this.geometry = null; + this.shader = null; + this.state = null; - /** - * multiplies uvs only if uploadUvMatrix is false - * call it after you change uvs manually - * make sure that texture is valid - */ - multiplyUvs() - { - if (!this.uploadUvMatrix) - { - this.uvMatrix.multiplyUvs(this.uvs); - } - } - - /** - * Refreshes uvs for generated meshes (rope, plane) - * sometimes refreshes vertices too - * - * @param {boolean} [forceUpdate=false] if true, matrices will be updated any case - */ - refresh(forceUpdate) - { - if (this.uvMatrix.update(forceUpdate)) - { - this._refresh(); - } - } - - /** - * Updates the object transform for rendering - * - * @private - */ - updateTransform() - { - if (this.autoUpdate) - { - this.geometry.buffers[0].update(); - } - this.containerUpdateTransform(); - } - - /** - * re-calculates mesh coords - * @private - */ - _refresh() - { - /* empty */ + super.destroy(options); } } diff --git a/packages/mesh/src/MeshRenderer.js b/packages/mesh/src/MeshRenderer.js index 12b159b..d7baf9b 100644 --- a/packages/mesh/src/MeshRenderer.js +++ b/packages/mesh/src/MeshRenderer.js @@ -36,7 +36,7 @@ /** * renders mesh * @private - * @param {PIXI.RawMesh} mesh mesh instance + * @param {PIXI.Mesh} mesh mesh instance */ render(mesh) { diff --git a/packages/mesh/src/NineSlicePlane.js b/packages/mesh/src/NineSlicePlane.js deleted file mode 100644 index 0bae92c..0000000 --- a/packages/mesh/src/NineSlicePlane.js +++ /dev/null @@ -1,270 +0,0 @@ -import Plane from './Plane'; - -const DEFAULT_BORDER_SIZE = 10; - -/** - * The NineSlicePlane allows you to stretch a texture using 9-slice scaling. The corners will remain unscaled (useful - * for buttons with rounded corners for example) and the other areas will be scaled horizontally and or vertically - * - *```js - * let Plane9 = new PIXI.NineSlicePlane(PIXI.Texture.from('BoxWithRoundedCorners.png'), 15, 15, 15, 15); - * ``` - *
- *      A                          B
- *    +---+----------------------+---+
- *  C | 1 |          2           | 3 |
- *    +---+----------------------+---+
- *    |   |                      |   |
- *    | 4 |          5           | 6 |
- *    |   |                      |   |
- *    +---+----------------------+---+
- *  D | 7 |          8           | 9 |
- *    +---+----------------------+---+
-
- *  When changing this objects width and/or height:
- *     areas 1 3 7 and 9 will remain unscaled.
- *     areas 2 and 8 will be stretched horizontally
- *     areas 4 and 6 will be stretched vertically
- *     area 5 will be stretched both horizontally and vertically
- * 
- * - * @class - * @extends PIXI.Plane - * @memberof PIXI - * - */ -export default class NineSlicePlane extends Plane -{ - /** - * @param {PIXI.Texture} texture - The texture to use on the NineSlicePlane. - * @param {int} [leftWidth=10] size of the left vertical bar (A) - * @param {int} [topHeight=10] size of the top horizontal bar (C) - * @param {int} [rightWidth=10] size of the right vertical bar (B) - * @param {int} [bottomHeight=10] size of the bottom horizontal bar (D) - */ - constructor(texture, leftWidth, topHeight, rightWidth, bottomHeight) - { - super(texture, 4, 4); - - this._origWidth = texture.orig.width; - this._origHeight = texture.orig.height; - - /** - * The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane - * - * @member {number} - * @memberof PIXI.NineSlicePlane# - * @override - */ - this._width = this._origWidth; - - /** - * The height of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane - * - * @member {number} - * @memberof PIXI.NineSlicePlane# - * @override - */ - this._height = this._origHeight; - - /** - * The width of the left column (a) - * - * @member {number} - * @memberof PIXI.NineSlicePlane# - * @override - */ - this._leftWidth = typeof leftWidth !== 'undefined' ? leftWidth : DEFAULT_BORDER_SIZE; - - /** - * The width of the right column (b) - * - * @member {number} - * @memberof PIXI.NineSlicePlane# - * @override - */ - this._rightWidth = typeof rightWidth !== 'undefined' ? rightWidth : DEFAULT_BORDER_SIZE; - - /** - * The height of the top row (c) - * - * @member {number} - * @memberof PIXI.NineSlicePlane# - * @override - */ - this._topHeight = typeof topHeight !== 'undefined' ? topHeight : DEFAULT_BORDER_SIZE; - - /** - * The height of the bottom row (d) - * - * @member {number} - * @memberof PIXI.NineSlicePlane# - * @override - */ - this._bottomHeight = typeof bottomHeight !== 'undefined' ? bottomHeight : DEFAULT_BORDER_SIZE; - - this.refresh(true); - } - - /** - * Updates the horizontal vertices. - * - */ - updateHorizontalVertices() - { - const vertices = this.vertices; - - const h = this._topHeight + this._bottomHeight; - const scale = this._height > h ? 1.0 : this._height / h; - - vertices[9] = vertices[11] = vertices[13] = vertices[15] = this._topHeight * scale; - vertices[17] = vertices[19] = vertices[21] = vertices[23] = this._height - (this._bottomHeight * scale); - vertices[25] = vertices[27] = vertices[29] = vertices[31] = this._height; - } - - /** - * Updates the vertical vertices. - * - */ - updateVerticalVertices() - { - const vertices = this.vertices; - - const w = this._leftWidth + this._rightWidth; - const scale = this._width > w ? 1.0 : this._width / w; - - vertices[2] = vertices[10] = vertices[18] = vertices[26] = this._leftWidth * scale; - vertices[4] = vertices[12] = vertices[20] = vertices[28] = this._width - (this._rightWidth * scale); - vertices[6] = vertices[14] = vertices[22] = vertices[30] = this._width; - } - - /** - * The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane - * - * @member {number} - */ - get width() - { - return this._width; - } - - set width(value) // eslint-disable-line require-jsdoc - { - this._width = value; - this._refresh(); - } - - /** - * The height of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane - * - * @member {number} - */ - get height() - { - return this._height; - } - - set height(value) // eslint-disable-line require-jsdoc - { - this._height = value; - this._refresh(); - } - - /** - * The width of the left column - * - * @member {number} - */ - get leftWidth() - { - return this._leftWidth; - } - - set leftWidth(value) // eslint-disable-line require-jsdoc - { - this._leftWidth = value; - this._refresh(); - } - - /** - * The width of the right column - * - * @member {number} - */ - get rightWidth() - { - return this._rightWidth; - } - - set rightWidth(value) // eslint-disable-line require-jsdoc - { - this._rightWidth = value; - this._refresh(); - } - - /** - * The height of the top row - * - * @member {number} - */ - get topHeight() - { - return this._topHeight; - } - - set topHeight(value) // eslint-disable-line require-jsdoc - { - this._topHeight = value; - this._refresh(); - } - - /** - * The height of the bottom row - * - * @member {number} - */ - get bottomHeight() - { - return this._bottomHeight; - } - - set bottomHeight(value) // eslint-disable-line require-jsdoc - { - this._bottomHeight = value; - this._refresh(); - } - - /** - * Refreshes NineSlicePlane coords. All of them. - */ - _refresh() - { - super._refresh(); - - const uvs = this.uvs; - const texture = this._texture; - - this._origWidth = texture.orig.width; - this._origHeight = texture.orig.height; - - const _uvw = 1.0 / this._origWidth; - const _uvh = 1.0 / this._origHeight; - - uvs[0] = uvs[8] = uvs[16] = uvs[24] = 0; - uvs[1] = uvs[3] = uvs[5] = uvs[7] = 0; - uvs[6] = uvs[14] = uvs[22] = uvs[30] = 1; - uvs[25] = uvs[27] = uvs[29] = uvs[31] = 1; - - uvs[2] = uvs[10] = uvs[18] = uvs[26] = _uvw * this._leftWidth; - uvs[4] = uvs[12] = uvs[20] = uvs[28] = 1 - (_uvw * this._rightWidth); - uvs[9] = uvs[11] = uvs[13] = uvs[15] = _uvh * this._topHeight; - uvs[17] = uvs[19] = uvs[21] = uvs[23] = 1 - (_uvh * this._bottomHeight); - - this.updateHorizontalVertices(); - this.updateVerticalVertices(); - - this.geometry.buffers[1].update(); - - this.multiplyUvs(); - } -} diff --git a/packages/mesh/src/Plane.js b/packages/mesh/src/Plane.js deleted file mode 100644 index c416b4c..0000000 --- a/packages/mesh/src/Plane.js +++ /dev/null @@ -1,100 +0,0 @@ -import Mesh from './Mesh'; - -/** - * The Plane allows you to draw a texture across several points and them manipulate these points - * - *```js - * for (let i = 0; i < 20; i++) { - * points.push(new PIXI.Point(i * 50, 0)); - * }; - * let Plane = new PIXI.Plane(PIXI.Texture.from("snake.png"), points); - * ``` - * - * @class - * @extends PIXI.Mesh - * @memberof PIXI - * - */ -export default class Plane extends Mesh -{ - /** - * @param {PIXI.Texture} texture - The texture to use on the Plane. - * @param {number} verticesX - The number of vertices in the x-axis - * @param {number} verticesY - The number of vertices in the y-axis - * @param {object} [opts] - an options object - add meshWidth and meshHeight, temporary object for PixiJS v5 alpha - */ - constructor(texture, verticesX, verticesY, opts = {}) - { - super(texture, new Float32Array(1), new Float32Array(1), new Uint16Array(1), 4); - - this.verticesX = verticesX || 10; - this.verticesY = verticesY || 10; - - this.meshWidth = opts.meshWidth || 0; - this.meshHeight = opts.meshHeight || 0; - - this.refresh(); - } - - /** - * Refreshes plane coordinates - * @private - */ - _refresh() - { - const texture = this._texture; - const total = this.verticesX * this.verticesY; - const verts = []; - const uvs = []; - const indices = []; - - const segmentsX = this.verticesX - 1; - const segmentsY = this.verticesY - 1; - - const sizeX = (this.meshWidth || texture.width) / segmentsX; - const sizeY = (this.meshHeight || texture.height) / segmentsY; - - for (let i = 0; i < total; i++) - { - const x = (i % this.verticesX); - const y = ((i / this.verticesX) | 0); - - verts.push(x * sizeX, y * sizeY); - - uvs.push(x / segmentsX, y / segmentsY); - } - - // cons - - const totalSub = segmentsX * segmentsY; - - for (let i = 0; i < totalSub; i++) - { - const xpos = i % segmentsX; - const ypos = (i / segmentsX) | 0; - - const value = (ypos * this.verticesX) + xpos; - const value2 = (ypos * this.verticesX) + xpos + 1; - const value3 = ((ypos + 1) * this.verticesX) + xpos; - const value4 = ((ypos + 1) * this.verticesX) + xpos + 1; - - indices.push(value, value2, value3); - indices.push(value2, value4, value3); - } - - this.vertices = new Float32Array(verts); - this.uvs = new Float32Array(uvs); - this.indices = new Uint16Array(indices); - - this.geometry.buffers[0].data = this.vertices; - this.geometry.buffers[1].data = this.uvs; - this.geometry.indexBuffer.data = this.indices; - - // ensure that the changes are uploaded - this.geometry.buffers[0].update(); - this.geometry.buffers[1].update(); - this.geometry.indexBuffer.update(); - - this.multiplyUvs(); - } -} diff --git a/bundles/pixi.js/package.json b/bundles/pixi.js/package.json index 49c7276..177e059 100644 --- a/bundles/pixi.js/package.json +++ b/bundles/pixi.js/package.json @@ -49,6 +49,7 @@ "@pixi/loaders": "^5.0.0-alpha.2", "@pixi/math": "^5.0.0-alpha.2", "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/mesh-extras": "^5.0.0-alpha.2", "@pixi/mixin-cache-as-bitmap": "^5.0.0-alpha.2", "@pixi/mixin-get-child-by-name": "^5.0.0-alpha.2", "@pixi/mixin-get-global-position": "^5.0.0-alpha.2", diff --git a/bundles/pixi.js/src/deprecated.js b/bundles/pixi.js/src/deprecated.js index 147617c..dbebeb0 100644 --- a/bundles/pixi.js/src/deprecated.js +++ b/bundles/pixi.js/src/deprecated.js @@ -263,15 +263,15 @@ Object.defineProperties(PIXI.mesh, { /** * @class PIXI.mesh.Mesh - * @see PIXI.Mesh + * @see PIXI.Mesh2d * @deprecated since 5.0.0 */ Mesh: { get() { - warn('PIXI.mesh.Mesh has moved to PIXI.Mesh'); + warn('PIXI.mesh.Mesh has moved to PIXI.Mesh2d'); - return PIXI.Mesh; + return PIXI.Mesh2d; }, }, /** @@ -315,15 +315,15 @@ }, /** * @class PIXI.mesh.RawMesh - * @see PIXI.RawMesh + * @see PIXI.Mesh * @deprecated since 5.0.0 */ RawMesh: { get() { - warn('PIXI.mesh.RawMesh has moved to PIXI.RawMesh'); + warn('PIXI.mesh.RawMesh has moved to PIXI.Mesh'); - return PIXI.RawMesh; + return PIXI.Mesh; }, }, /** diff --git a/bundles/pixi.js/src/index.js b/bundles/pixi.js/src/index.js index a3a0d1b..6fdabf0 100644 --- a/bundles/pixi.js/src/index.js +++ b/bundles/pixi.js/src/index.js @@ -9,6 +9,7 @@ import * as loaders from '@pixi/loaders'; import * as math from '@pixi/math'; import * as mesh from '@pixi/mesh'; +import * as meshExtras from '@pixi/mesh-extras'; import * as particles from '@pixi/particles'; import * as prepare from '@pixi/prepare'; import * as sprite from '@pixi/sprite'; @@ -128,6 +129,7 @@ loaders, math, mesh, + meshExtras, particles, sprite, spriteAnimated, @@ -152,6 +154,7 @@ export * from '@pixi/loaders'; export * from '@pixi/math'; export * from '@pixi/mesh'; +export * from '@pixi/mesh-extras'; export * from '@pixi/particles'; export * from '@pixi/sprite'; export * from '@pixi/spritesheet'; diff --git a/package-lock.json b/package-lock.json index 7fe6db7..0814729 100644 --- a/package-lock.json +++ b/package-lock.json @@ -209,7 +209,7 @@ "argparse": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", - "integrity": "sha1-vNZ5HqWuCXJeF+WtmIE0zUCz2RE=", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", "dev": true, "requires": { "sprintf-js": "1.0.3" @@ -228,7 +228,7 @@ "arr-flatten": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz", - "integrity": "sha1-NgSLv/TntH4TZkQxbJlmnqWukfE=", + "integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==", "dev": true }, "arr-union": { @@ -297,7 +297,7 @@ "assertion-error": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", - "integrity": "sha1-5gtrDo8wG9l+U3UhW9pAbIURjAs=", + "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", "dev": true }, "async": { @@ -396,7 +396,7 @@ "brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha1-PH/L9SnYcibz0vUrlm/1Jx60Qd0=", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, "requires": { "balanced-match": "1.0.0", @@ -568,7 +568,7 @@ "circular-json": { "version": "0.3.3", "resolved": "https://registry.npmjs.org/circular-json/-/circular-json-0.3.3.tgz", - "integrity": "sha1-gVyZ6oT2gJUp0vRXkb34JxE1LWY=", + "integrity": "sha512-UZK3NBx2Mca+b5LsG7bY183pHWt5Y1xts4P3Pz7ENTwGVnJOUWbRb3ocjvX7hx9tq/yTAdclXm9sZ38gNuem4A==", "dev": true }, "cli-cursor": { @@ -638,7 +638,7 @@ "color-convert": { "version": "1.9.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.1.tgz", - "integrity": "sha1-wSYRB66y8pTr/+ye2eytUppgl+0=", + "integrity": "sha512-mjGanIiwQJskCC18rPR6OmrZ6fm2Lc7PeGFYwCmy5J34wC6F1PzdGL6xeMfmgicfYcNLGuVFA3WzXtIDCQSZxQ==", "dev": true, "requires": { "color-name": "1.1.3" @@ -1427,7 +1427,7 @@ "boom": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/boom/-/boom-5.2.0.tgz", - "integrity": "sha1-XdnabuOl8wIHdDYpDLcX0/SlTgI=", + "integrity": "sha512-Z5BTk6ZRe4tXXQlkqftmsAUANpXmuwlsF5Oov8ThoMbQRzdGTA1ngYRW160GexgOgjsFOKJz0LYhoNi+2AMBUw==", "dev": true, "requires": { "hoek": "4.2.1" @@ -1471,7 +1471,7 @@ "debug": { "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha1-XRKFFd8TT/Mn6QpMk/Tgd6U2NB8=", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", "dev": true, "requires": { "ms": "2.0.0" @@ -1585,7 +1585,7 @@ "doctrine": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", - "integrity": "sha1-XNAfwQFiG0LEzX9dGmYkNxbT850=", + "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", "dev": true, "requires": { "esutils": "2.0.2" @@ -1662,7 +1662,7 @@ "es6-promise": { "version": "4.2.4", "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.4.tgz", - "integrity": "sha1-3EIhwrFlGHYL2MOaUtjzVvwA7Sk=", + "integrity": "sha512-/NdNZVJg+uZgtm9eS3O6lrOLYmQag2DjdEXuPaHlZ6RuVqgqaVZfgYCepEIKsLqwdQArOPtC3XzRLqGGfT8KQQ==", "dev": true }, "escape-string-regexp": { @@ -1788,7 +1788,7 @@ "espree": { "version": "3.5.4", "resolved": "https://registry.npmjs.org/espree/-/espree-3.5.4.tgz", - "integrity": "sha1-sPRHGHyKi+2US4FaZgvd9d610ac=", + "integrity": "sha512-yAcIQxtmMiB/jL32dzEp2enBeidsB7xWPLNiw3IIkpVds1P+h7qF9YwJq1yUNzp2OKXgAprs4F61ih66UsoD1A==", "dev": true, "requires": { "acorn": "5.5.0", @@ -1798,7 +1798,7 @@ "esprima": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.0.tgz", - "integrity": "sha1-RJnt3NERDgshi6zy+n9/WfVcqAQ=", + "integrity": "sha512-oftTcaMu/EGrEIu904mWteKIv8vMuOgGYo7EhVJJN00R/EED9DCua/xxHRdYnKtcECzVg7xOWhflvJMnqcFZjw==", "dev": true }, "esquery": { @@ -1813,7 +1813,7 @@ "esrecurse": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.2.1.tgz", - "integrity": "sha1-AHo7n9vCs7uH5IeeoZyS/b05Qs8=", + "integrity": "sha512-64RBB++fIOAXPw3P9cy89qfMlvZEXZkqqJkjqqXIvzP5ezRZjW+lPWjw35UX/3EhUPFYbg5ER4JYgDw4007/DQ==", "dev": true, "requires": { "estraverse": "4.2.0" @@ -2024,7 +2024,7 @@ "find-root": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/find-root/-/find-root-1.1.0.tgz", - "integrity": "sha1-q8/Iunb3CMQql7PWhbfpRQv7nOQ=", + "integrity": "sha512-NKfW6bec6GfKc0SGx1e07QZY9PE99u0Bft/0rzSD5k3sO/vwkVUpDUKVm5Gpp5Ue3YfShPFTX2070tDs5kB9Ng==", "dev": true }, "find-up": { @@ -2103,7 +2103,7 @@ "supports-color": { "version": "5.3.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.3.0.tgz", - "integrity": "sha1-WySsFduA+pJ89SJ6SjP9PEx2dsA=", + "integrity": "sha512-0aP01LLIskjKs3lq52EC0aGBAJhLq7B2Rd8HC/DR/PtNNpcLilNmHC12O+hu0usQpo7wtHNRqtrhBwtDb0+dNg==", "dev": true, "requires": { "has-flag": "3.0.0" @@ -2567,7 +2567,7 @@ "glob": { "version": "7.1.2", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", - "integrity": "sha1-wZyd+aAocC1nhhI4SmVSQExjbRU=", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", "dev": true, "requires": { "fs.realpath": "1.0.0", @@ -2672,7 +2672,7 @@ "growl": { "version": "1.10.3", "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.3.tgz", - "integrity": "sha1-GSa6kM8+3+KttJJ/WIC8IsZseQ8=", + "integrity": "sha512-hKlsbA5Vu3xsh1Cg3J7jSmX/WaW6A5oBeqzM88oNbCRQFz+zUaXm6yxS4RVytp1scBoJzSYl4YAEOQIt6O8V1Q==", "dev": true }, "handlebars": { @@ -2738,7 +2738,7 @@ "hawk": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/hawk/-/hawk-6.0.2.tgz", - "integrity": "sha1-r02RTrBl+bXOTZ0RwcshJu7MMDg=", + "integrity": "sha512-miowhl2+U7Qle4vdLqDdPt9m09K6yZhkLDTWGoUiUzrQCn+mHHSmfJgAyGaLRZbPmTqfFFjRV1QWCW0VWUJBbQ==", "dev": true, "requires": { "boom": "4.3.1", @@ -2756,7 +2756,7 @@ "hoek": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/hoek/-/hoek-4.2.1.tgz", - "integrity": "sha1-ljRQKqEsRF3Vp8VzS1cruHOKrLs=", + "integrity": "sha512-QLg82fGkfnJ/4iy1xZ81/9SIJiq1NGFUMGs6ParyjBZr6jW2Ufj/snDqTHixNlHdPNwN2RLVD0Pi3igeK9+JfA==", "dev": true }, "home-path": { @@ -2791,7 +2791,7 @@ "ignore": { "version": "3.3.7", "resolved": "https://registry.npmjs.org/ignore/-/ignore-3.3.7.tgz", - "integrity": "sha1-YSKJv7PCIOGGpYEYYY1b6MG6sCE=", + "integrity": "sha512-YGG3ejvBNHRqu0559EOxxNFihD0AjpvHlC/pdGKd3X3ofe+CoJkYazwNJYTNebqpPKN+VVQbh4ZFn1DivMNuHA==", "dev": true }, "imurmurhash": { @@ -2828,7 +2828,7 @@ "ini": { "version": "1.3.5", "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", - "integrity": "sha1-7uJfVtscnsYIXgwid4CD9Zar+Sc=", + "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==", "dev": true }, "inquirer": { @@ -2901,7 +2901,7 @@ "is-buffer": { "version": "1.1.6", "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", - "integrity": "sha1-76ouqdqg16suoTqXsritUf776L4=", + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", "dev": true }, "is-builtin-module": { @@ -3054,7 +3054,7 @@ "is-resolvable": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/is-resolvable/-/is-resolvable-1.1.0.tgz", - "integrity": "sha1-+xj4fOH+uSUWnJpAfBkxijIG7Yg=", + "integrity": "sha512-qgDYXFSR5WvEfuS5dMj6oTMEbrrSaM0CrFk2Yiq/gXnBvD9pMa2jGXxyhGLfvhZpuMZe18CJpFxAt3CRs42NMg==", "dev": true }, "is-retry-allowed": { @@ -3204,7 +3204,7 @@ "js-yaml": { "version": "3.11.0", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.11.0.tgz", - "integrity": "sha1-WXwai9VxUvJtYizkEXhRpR9euu8=", + "integrity": "sha512-saJstZWv7oNeOyBh3+Dx1qWzhW0+e6/8eDzo7p5rDFqxntSztloLtuKu+Ejhtq82jsilwOIZYsCz+lIjthg1Hw==", "dev": true, "requires": { "argparse": "1.0.10", @@ -3324,7 +3324,7 @@ "just-extend": { "version": "1.1.27", "resolved": "https://registry.npmjs.org/just-extend/-/just-extend-1.1.27.tgz", - "integrity": "sha1-7G55QQ/5FORyZSq/oOYDwD1g6QU=", + "integrity": "sha512-mJVp13Ix6gFo3SBAy9U/kL+oeZqzlYYYLQBwXVBlVzIsZwBqGREnOro24oC/8s8aox+rJhtZ2DiQof++IrkA+g==", "dev": true }, "kind-of": { @@ -3703,7 +3703,7 @@ "lodash": { "version": "4.17.5", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.5.tgz", - "integrity": "sha1-maktZcAnLevoyWtgV7yPv6O+1RE=", + "integrity": "sha512-svL3uiZf1RwhH+cWrfZn3A4+U58wbP0tGVTLQPbjplZxZ8ROD9VLuNgsRniTlLe7OlSqR79RUehXgpBW/s0IQw==", "dev": true }, "lodash._reinterpolate": { @@ -3740,7 +3740,7 @@ "lolex": { "version": "2.3.2", "resolved": "https://registry.npmjs.org/lolex/-/lolex-2.3.2.tgz", - "integrity": "sha1-hflFBCUQO/nnpgZo6iXcQydMqAc=", + "integrity": "sha512-A5pN2tkFj7H0dGIAM6MFvHKMJcPnjZsOMvR7ujCjfgW5TbV6H9vb1PgxLtHvjqNZTHsUolz+6/WEO0N1xNx2ng==", "dev": true }, "longest": { @@ -3816,7 +3816,7 @@ "marked": { "version": "0.3.17", "resolved": "https://registry.npmjs.org/marked/-/marked-0.3.17.tgz", - "integrity": "sha1-YH8GZos8axJGso8T2nYRasGqLSs=", + "integrity": "sha512-+AKbNsjZl6jFfLPwHhWmGTqE009wTKn3RTmn9K8oUKHrX/abPJjtcRtXpYB/FFrwPJRUA86LX/de3T0knkPCmQ==", "dev": true }, "mem": { @@ -3896,13 +3896,13 @@ "mime-db": { "version": "1.33.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.33.0.tgz", - "integrity": "sha1-o0kgUKXLm2NFBUHjnZeI0icng9s=", + "integrity": "sha512-BHJ/EKruNIqJf/QahvxwQZXKygOQ256myeN/Ew+THcAa5q+PjyTTMMeNQC4DZw5AwfvelsUrA6B67NKMqXDbzQ==", "dev": true }, "mime-types": { "version": "2.1.18", "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.18.tgz", - "integrity": "sha1-bzI/YKg9ERRvgx/xH9ZuL+VQO7g=", + "integrity": "sha512-lc/aahn+t4/SWV/qcmumYjymLsWfN3ELhpmVuUFjgsORruuZPVSwAQryq+HHGvO/SI2KVX26bx+En+zhM8g8hQ==", "dev": true, "requires": { "mime-db": "1.33.0" @@ -3917,7 +3917,7 @@ "minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha1-UWbihkV/AzBgZL5Ul+jbsMPTIIM=", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "dev": true, "requires": { "brace-expansion": "1.1.11" @@ -4071,7 +4071,7 @@ "normalize-package-data": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.4.0.tgz", - "integrity": "sha1-EvlaMH1YNSB1oEkHuErIvpisAS8=", + "integrity": "sha512-9jjUFbTPfEy3R/ad/2oNbKtW9Hgovl5O1FvFWKkKblNXoN/Oou6+9+KKohPK13Yc3/TyunyWhJp6gvRNR/PPAw==", "dev": true, "requires": { "hosted-git-info": "2.5.0", @@ -4511,7 +4511,7 @@ "process-nextick-args": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", - "integrity": "sha1-o31zL0JxtKsa0HDTVQjoKQeI/6o=", + "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==", "dev": true }, "progress": { @@ -4584,7 +4584,7 @@ "qs": { "version": "6.5.1", "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.1.tgz", - "integrity": "sha1-NJzfbu+J7EXBLX1es/wMhwNDptg=", + "integrity": "sha512-eRzhrN1WSINYCDCbrz796z37LOe3m5tmW7RQf6oBntukAG1nmovJvhnwHHRMAfeoItc1m2Hk02WER2aQ/iqs+A==", "dev": true }, "quick-lru": { @@ -4596,7 +4596,7 @@ "randomatic": { "version": "1.1.7", "resolved": "https://registry.npmjs.org/randomatic/-/randomatic-1.1.7.tgz", - "integrity": "sha1-x6vpzIuHwLqodrGf3oP9RkeX44w=", + "integrity": "sha512-D5JUjPyJbaJDkuAazpVnSfVkLlpeO3wDlPROTMLGKG1zMFNFRgrciKo1ltz/AzNTkqE0HzDx655QOL51N06how==", "dev": true, "requires": { "is-number": "3.0.0", @@ -4701,7 +4701,7 @@ "regex-cache": { "version": "0.4.4", "resolved": "https://registry.npmjs.org/regex-cache/-/regex-cache-0.4.4.tgz", - "integrity": "sha1-db3FiioUls7EihKDW8VMjVYjNt0=", + "integrity": "sha512-nVIZwtCjkC9YgvWkpM55B5rBhBYRZhAaJbgcFYXXsHnbZ9UZI9nnVWYZpBlCqv9ho2eZryPnWrZGsOdPwVWXWQ==", "dev": true, "requires": { "is-equal-shallow": "0.1.3" @@ -4729,7 +4729,7 @@ "remap-istanbul": { "version": "0.10.1", "resolved": "https://registry.npmjs.org/remap-istanbul/-/remap-istanbul-0.10.1.tgz", - "integrity": "sha1-OqWN1QIdSZ8zbTulvzu7kcG4jjc=", + "integrity": "sha512-gsNQXs5kJLhErICSyYhzVZ++C8LBW8dgwr874Y2QvzAUS75zBlD/juZgXs39nbYJ09fZDlX2AVLVJAY2jbFJoQ==", "dev": true, "requires": { "amdefine": "1.0.1", @@ -4769,7 +4769,7 @@ "source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha1-dHIq8y6WFOnCh6jQu95IteLxomM=", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", "dev": true }, "through2": { @@ -4883,7 +4883,7 @@ "resolve": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.5.0.tgz", - "integrity": "sha1-HwmsznlsmnYlefMbLBzEw83fnzY=", + "integrity": "sha512-hgoSGrc3pjzAPHNBg+KnFcK2HwlHTs/YrAGUr6qgTVUZmXv1UEXXl0bZNBKMA9fud6lRYFdPGz0xXxycPzmmiw==", "dev": true, "requires": { "path-parse": "1.0.5" @@ -4924,7 +4924,7 @@ "rimraf": { "version": "2.6.2", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", - "integrity": "sha1-LtgVDSShbqhlHm1u8PR8QVjOejY=", + "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", "dev": true, "requires": { "glob": "7.1.2" @@ -5063,19 +5063,19 @@ "safe-buffer": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", - "integrity": "sha1-iTMSr2myEj3vcfV4iQAWce6yyFM=", + "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", "dev": true }, "samsam": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/samsam/-/samsam-1.3.0.tgz", - "integrity": "sha1-jR2TUOJWItow3j5EumkrUiGrfFA=", + "integrity": "sha512-1HwIYD/8UlOtFS3QO3w7ey+SdSDFE4HRNLZoZRYVQefrOY3l17epswImeB1ijgJFQJodIaHcwkp3r/myBjFVbg==", "dev": true }, "semver": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz", - "integrity": "sha1-3Eu8emyp2Rbe5dQ1FvAJK1j3uKs=", + "integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==", "dev": true }, "set-blocking": { @@ -5117,7 +5117,7 @@ "sinon-chai": { "version": "2.14.0", "resolved": "https://registry.npmjs.org/sinon-chai/-/sinon-chai-2.14.0.tgz", - "integrity": "sha1-2n3UzIPNaiYLZ8yg96n9riahIF0=", + "integrity": "sha512-9stIF1utB0ywNHNT7RgiXbdmen8QDCRsrTjw+G9TgKt1Yexjiv8TOWZ6WHsTPz57Yky3DIswZvEqX8fpuHNDtQ==", "dev": true }, "slash": { @@ -5146,7 +5146,7 @@ "sntp": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/sntp/-/sntp-2.1.0.tgz", - "integrity": "sha1-LGzsFP7cIiJznK+bXD2F0cxaLMg=", + "integrity": "sha512-FL1b58BDrqS3A11lJ0zEdnJ3UOKqVxawAkF3k7F0CVN7VQ34aZrV+G8BZ1WC9ZL7NyrwsW0oviwsWDgRuVYtJg==", "dev": true, "requires": { "hoek": "4.2.1" @@ -5203,7 +5203,7 @@ "spdx-correct": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.0.0.tgz", - "integrity": "sha1-BaW01xU6GVvJLDxCW2nzsqlSTII=", + "integrity": "sha512-N19o9z5cEyc8yQQPukRCZ9EUmb4HUpnrmaL/fxS2pBo2jbfcFRVuFZ/oFC+vZz0MNNk0h80iMn5/S6qGZOL5+g==", "dev": true, "requires": { "spdx-expression-parse": "3.0.0", @@ -5213,13 +5213,13 @@ "spdx-exceptions": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.1.0.tgz", - "integrity": "sha1-LHrmEFbHFKW5ubKyr30xHvXHj+k=", + "integrity": "sha512-4K1NsmrlCU1JJgUrtgEeTVyfx8VaYea9J9LvARxhbHtVtohPs/gFGG5yy49beySjlIMhhXZ4QqujIZEfS4l6Cg==", "dev": true }, "spdx-expression-parse": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.0.tgz", - "integrity": "sha1-meEZt6XaAOBUkcn6M4t5BII7QdA=", + "integrity": "sha512-Yg6D3XpRD4kkOmTpdgbUiEJFKghJH03fiC1OPll5h/0sO6neh2jqRDVHOQ4o/LMea0tgCkbMgea5ip/e+MkWyg==", "dev": true, "requires": { "spdx-exceptions": "2.1.0", @@ -5229,7 +5229,7 @@ "spdx-license-ids": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.0.tgz", - "integrity": "sha1-enzShHDMbToc/m1miG9rxDDTrIc=", + "integrity": "sha512-2+EPwgbnmOIl8HjGBXXMd9NAu02vLjOO1nWw4kmeRDFyHn+M/ETfHxQUK0oXg8ctgVnl9t3rosNVsZ1jG61nDA==", "dev": true }, "speedometer": { @@ -5566,7 +5566,7 @@ "tough-cookie": { "version": "2.3.4", "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.4.tgz", - "integrity": "sha1-7GDO44rGdQY//JelwYlwV47oNlU=", + "integrity": "sha512-TZ6TTfI5NtZnuyy/Kecv+CnoROnyXn2DN97LontgQpCwsX2XyLYCC0ENhYkehSOwAp8rTQKc/NUIF7BkQ5rKLA==", "dev": true, "requires": { "punycode": "1.4.1" @@ -5708,13 +5708,13 @@ "uuid": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.2.1.tgz", - "integrity": "sha1-EsUou51Y0LkmXZovbw/ovhf/HxQ=", + "integrity": "sha512-jZnMwlb9Iku/O3smGWvZhauCf6cvvpKi4BKRiliS3cxnI+Gz9j5MEpTz2UFuXiKPJocb7gnsLHwiS05ige5BEA==", "dev": true }, "validate-npm-package-license": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.3.tgz", - "integrity": "sha1-gWQ7y+8b3+zUYjeT3EZIlIupgzg=", + "integrity": "sha512-63ZOUnL4SIXj4L0NixR3L1lcjO38crAbgrTpl28t8jjrfuiOBL5Iygm+60qPs/KsZGzPNg6Smnc/oY16QTjF0g==", "dev": true, "requires": { "spdx-correct": "3.0.0", @@ -5750,7 +5750,7 @@ "which": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/which/-/which-1.3.0.tgz", - "integrity": "sha1-/wS9/AEO5UfXgL7DjhrBwnd9JTo=", + "integrity": "sha512-xcJpopdamTuY5duC/KnTTNBraPK54YwpenP4lzxU8H91GudWpFv38u0CKjclE1Wi2EH2EDz5LRcHcKbCIzqGyg==", "dev": true, "requires": { "isexe": "2.0.0" diff --git a/packages/canvas/canvas-mesh/package.json b/packages/canvas/canvas-mesh/package.json index 691cd2c..6744a17 100644 --- a/packages/canvas/canvas-mesh/package.json +++ b/packages/canvas/canvas-mesh/package.json @@ -24,6 +24,7 @@ "dependencies": { "@pixi/constants": "^5.0.0-alpha.2", "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/mesh-extras": "^5.0.0-alpha.2", "@pixi/settings": "^5.0.0-alpha.2" }, "devDependencies": { diff --git a/packages/canvas/canvas-mesh/src/Mesh.js b/packages/canvas/canvas-mesh/src/Mesh.js index 900a872..c43a74b 100644 --- a/packages/canvas/canvas-mesh/src/Mesh.js +++ b/packages/canvas/canvas-mesh/src/Mesh.js @@ -1,36 +1,14 @@ import { Mesh } from '@pixi/mesh'; -import { settings } from './settings'; - -// IMPORTANT: Please do NOT use this as a precedent to use `settings` after the object is created -// this was merely created to completely decouple canvas from the base Mesh class and we are -// unable to add `canvasPadding` in the constructor anymore, as the case was for PixiJS v4. /** - * Internal variable for `canvasPadding`. + * Renders the object using the Canvas renderer * * @private - * @memberof PIXI.Mesh - * @member {number} - * @default null - */ -Mesh.prototype._canvasPadding = null; - -/** - * Triangles in canvas mode are automatically antialiased, use this value to force triangles - * to overlap a bit with each other. To set the global default, set {@link PIXI.settings.MESH_CANVAS_PADDING} - * - * @see PIXI.settings.MESH_CANVAS_PADDING - * @member {number} canvasPadding + * @method _renderCanvas * @memberof PIXI.Mesh# - * @default 0 + * @param {PIXI.CanvasRenderer} renderer - The canvas renderer. */ -Object.defineProperty(Mesh.prototype, 'canvasPadding', { - get() - { - return this._canvasPadding !== null ? this._canvasPadding : settings.MESH_CANVAS_PADDING; - }, - set(value) - { - this._canvasPadding = value; - }, -}); +Mesh.prototype._renderCanvas = function _renderCanvas(renderer) +{ + renderer.plugins[this.pluginName].render(this); +}; diff --git a/packages/canvas/canvas-mesh/src/Mesh2d.js b/packages/canvas/canvas-mesh/src/Mesh2d.js new file mode 100644 index 0000000..d0bd80f --- /dev/null +++ b/packages/canvas/canvas-mesh/src/Mesh2d.js @@ -0,0 +1,36 @@ +import { Mesh2d } from '@pixi/mesh-extras'; +import { settings } from './settings'; + +// IMPORTANT: Please do NOT use this as a precedent to use `settings` after the object is created +// this was merely created to completely decouple canvas from the base Mesh class and we are +// unable to add `canvasPadding` in the constructor anymore, as the case was for PixiJS v4. + +/** + * Internal variable for `canvasPadding`. + * + * @private + * @memberof PIXI.Mesh2d + * @member {number} + * @default null + */ +Mesh2d.prototype._canvasPadding = null; + +/** + * Triangles in canvas mode are automatically antialiased, use this value to force triangles + * to overlap a bit with each other. To set the global default, set {@link PIXI.settings.MESH_CANVAS_PADDING} + * + * @see PIXI.settings.MESH_CANVAS_PADDING + * @member {number} canvasPadding + * @memberof PIXI.Mesh2d# + * @default 0 + */ +Object.defineProperty(Mesh2d.prototype, 'canvasPadding', { + get() + { + return this._canvasPadding !== null ? this._canvasPadding : settings.MESH_CANVAS_PADDING; + }, + set(value) + { + this._canvasPadding = value; + }, +}); diff --git a/packages/canvas/canvas-mesh/src/NineSlicePlane.js b/packages/canvas/canvas-mesh/src/NineSlicePlane.js index 09eaf9c..2fd5acc 100644 --- a/packages/canvas/canvas-mesh/src/NineSlicePlane.js +++ b/packages/canvas/canvas-mesh/src/NineSlicePlane.js @@ -1,4 +1,4 @@ -import { NineSlicePlane } from '@pixi/mesh'; +import { NineSlicePlane } from '@pixi/mesh-extras'; /** * Renders the object using the Canvas renderer diff --git a/packages/canvas/canvas-mesh/src/RawMesh.js b/packages/canvas/canvas-mesh/src/RawMesh.js deleted file mode 100644 index bf40184..0000000 --- a/packages/canvas/canvas-mesh/src/RawMesh.js +++ /dev/null @@ -1,14 +0,0 @@ -import { RawMesh } from '@pixi/mesh'; - -/** - * Renders the object using the Canvas renderer - * - * @private - * @method _renderCanvas - * @memberof PIXI.RawMesh# - * @param {PIXI.CanvasRenderer} renderer - The canvas renderer. - */ -RawMesh.prototype._renderCanvas = function _renderCanvas(renderer) -{ - renderer.plugins[this.pluginName].render(this); -}; diff --git a/packages/canvas/canvas-mesh/src/index.js b/packages/canvas/canvas-mesh/src/index.js index 2295016..f4fa31d 100644 --- a/packages/canvas/canvas-mesh/src/index.js +++ b/packages/canvas/canvas-mesh/src/index.js @@ -1,6 +1,6 @@ export { default as CanvasMeshRenderer } from './CanvasMeshRenderer'; import './settings'; -import './Mesh'; +import './Mesh2d'; import './NineSlicePlane'; -import './RawMesh'; +import './Mesh'; diff --git a/packages/canvas/canvas-mesh/src/settings.js b/packages/canvas/canvas-mesh/src/settings.js index 4cefb4c..e81b8e0 100644 --- a/packages/canvas/canvas-mesh/src/settings.js +++ b/packages/canvas/canvas-mesh/src/settings.js @@ -3,7 +3,7 @@ /** * Default `canvasPadding` for canvas-based Mesh rendering. * - * @see PIXI.Mesh#canvasPadding + * @see PIXI.Mesh2d#canvasPadding * @static * @constant * @memberof PIXI.settings diff --git a/packages/mesh-extras/LICENSE b/packages/mesh-extras/LICENSE new file mode 100644 index 0000000..148e3eb --- /dev/null +++ b/packages/mesh-extras/LICENSE @@ -0,0 +1,21 @@ +The MIT License + +Copyright (c) 2013-2018 Mathew Groves, Chad Engler + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/packages/mesh-extras/README.md b/packages/mesh-extras/README.md new file mode 100644 index 0000000..1d9b0e1 --- /dev/null +++ b/packages/mesh-extras/README.md @@ -0,0 +1,19 @@ +# @pixi/mesh-extras + +## Installation + +```bash +npm install @pixi/mesh-extras +``` + +## Usage + +```js +import { MeshRenderer } from '@pixi/mesh'; +import { Renderer } from '@pixi/core'; +import { Rope } from '@pixi/mesh-extras'; + +Renderer.registerPlugin('mesh', MeshRenderer); + +const rope = new Rope(); +``` \ No newline at end of file diff --git a/packages/mesh-extras/package.json b/packages/mesh-extras/package.json new file mode 100644 index 0000000..d134f64 --- /dev/null +++ b/packages/mesh-extras/package.json @@ -0,0 +1,38 @@ +{ + "name": "@pixi/mesh-extras", + "version": "5.0.0-alpha.2", + "main": "lib/mesh-extras.js", + "module": "lib/mesh-extras.es.js", + "description": "Custom Mesh display objects, like Rope and Plane", + "author": "Mat Groves", + "contributors": [ + "Matt Karl " + ], + "homepage": "http://pixijs.com/", + "bugs": "https://github.com/pixijs/pixi.js/issues", + "license": "MIT", + "repository": { + "type": "git", + "url": "https://github.com/pixijs/pixi.js.git" + }, + "publishConfig": { + "access": "public" + }, + "scripts": { + "test": "floss --path test" + }, + "files": [ + "lib" + ], + "dependencies": { + "@pixi/constants": "^5.0.0-alpha.2", + "@pixi/core": "^5.0.0-alpha.2", + "@pixi/math": "^5.0.0-alpha.2", + "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/utils": "^5.0.0-alpha.2" + }, + "devDependencies": { + "@pixi/loaders": "^5.0.0-alpha.2", + "floss": "^2.1.3" + } +} diff --git a/packages/mesh-extras/src/Mesh2d.js b/packages/mesh-extras/src/Mesh2d.js new file mode 100644 index 0000000..d113a5e --- /dev/null +++ b/packages/mesh-extras/src/Mesh2d.js @@ -0,0 +1,263 @@ +import { Mesh } from '@pixi/mesh'; +import { Geometry, Program, Shader, Texture, TextureMatrix } from '@pixi/core'; +import { Matrix } from '@pixi/math'; +import { BLEND_MODES } from '@pixi/constants'; +import { hex2rgb, premultiplyRgba } from '@pixi/utils'; +import vertex from './mesh.vert'; +import fragment from './mesh.frag'; + +let meshProgram; + +/** + * Base mesh class + * @class + * @extends PIXI.Container + * @memberof PIXI + */ +export default class Mesh2d extends Mesh +{ + /** + * @param {PIXI.Texture} [texture=Texture.EMPTY] - The texture to use + * @param {Float32Array} [vertices] - if you want to specify the vertices + * @param {Float32Array} [uvs] - if you want to specify the uvs + * @param {Uint16Array} [indices] - if you want to specify the indices + * @param {number} [drawMode] - the drawMode, can be any of the Mesh.DRAW_MODES consts + */ + constructor(texture = Texture.EMPTY, vertices, uvs, indices, drawMode) + { + const geometry = new Geometry(); + + if (!meshProgram) + { + meshProgram = new Program(vertex, fragment); + } + + geometry.addAttribute('aVertexPosition', vertices) + .addAttribute('aTextureCoord', uvs) + .addIndex(indices); + + geometry.getAttribute('aVertexPosition').static = false; + + const uniforms = { + uSampler: texture, + uTextureMatrix: Matrix.IDENTITY, + alpha: 1, + uColor: new Float32Array([1, 1, 1, 1]), + }; + + super(geometry, new Shader(meshProgram, uniforms), null, drawMode); + + /** + * The Uvs of the Mesh + * + * @member {Float32Array} + */ + this.uvs = geometry.getAttribute('aTextureCoord').data; + + /** + * An array of vertices + * + * @member {Float32Array} + */ + this.vertices = geometry.getAttribute('aVertexPosition').data; + + this.uniforms = uniforms; + + /** + * The texture of the Mesh + * + * @member {PIXI.Texture} + * @default PIXI.Texture.EMPTY + * @private + */ + this.texture = texture; + + /** + * The tint applied to the mesh. This is a [r,g,b] value. A value of [1,1,1] will remove any + * tint effect. + * + * @member {number} + * @private + */ + this._tintRGB = new Float32Array([1, 1, 1]); + + // Set default tint + this.tint = 0xFFFFFF; + + this.blendMode = BLEND_MODES.NORMAL; + + /** + * TextureMatrix instance for this Mesh, used to track Texture changes + * + * @member {PIXI.TextureMatrix} + * @readonly + */ + this.uvMatrix = new TextureMatrix(this._texture); + + /** + * whether or not upload uvMatrix to shader + * if its false, then uvs should be pre-multiplied + * if you change it for generated mesh, please call 'refresh(true)' + * @member {boolean} + * @default false + */ + this.uploadUvMatrix = false; + + /** + * Uploads vertices buffer every frame, like in PixiJS V3 and V4. + * + * @member {boolean} + * @default true + */ + this.autoUpdate = true; + } + + /** + * The tint applied to the Rope. This is a hex value. A value of + * 0xFFFFFF will remove any tint effect. + * + * @member {number} + * @memberof PIXI.Sprite# + * @default 0xFFFFFF + */ + get tint() + { + return this._tint; + } + + /** + * Sets the tint of the rope. + * + * @param {number} value - The value to set to. + */ + set tint(value) + { + this._tint = value; + + hex2rgb(this._tint, this._tintRGB); + } + + /** + * The blend mode to be applied to the sprite. Set to `PIXI.BLEND_MODES.NORMAL` to remove any blend mode. + * + * @member {number} + * @default PIXI.BLEND_MODES.NORMAL + * @see PIXI.BLEND_MODES + */ + get blendMode() + { + return this.state.blendMode; + } + + set blendMode(value) // eslint-disable-line require-jsdoc + { + this.state.blendMode = value; + } + + /** + * The texture that the mesh uses. + * + * @member {PIXI.Texture} + */ + get texture() + { + return this._texture; + } + + set texture(value) // eslint-disable-line require-jsdoc + { + if (this._texture === value) + { + return; + } + + this._texture = value; + this.uniforms.uSampler = this.texture; + + if (value) + { + // wait for the texture to load + if (value.baseTexture.valid) + { + this._onTextureUpdate(); + } + else + { + value.once('update', this._onTextureUpdate, this); + } + } + } + + _render(renderer) + { + const baseTex = this._texture.baseTexture; + + premultiplyRgba(this._tintRGB, this.worldAlpha, this.uniforms.uColor, baseTex.premultiplyAlpha); + super._render(renderer); + } + /** + * When the texture is updated, this event will fire to update the scale and frame + * + * @private + */ + _onTextureUpdate() + { + // constructor texture update stop + if (!this.uvMatrix) + { + return; + } + this.uvMatrix.texture = this._texture; + this.refresh(); + } + + /** + * multiplies uvs only if uploadUvMatrix is false + * call it after you change uvs manually + * make sure that texture is valid + */ + multiplyUvs() + { + if (!this.uploadUvMatrix) + { + this.uvMatrix.multiplyUvs(this.uvs); + } + } + + /** + * Refreshes uvs for generated meshes (rope, plane) + * sometimes refreshes vertices too + * + * @param {boolean} [forceUpdate=false] if true, matrices will be updated any case + */ + refresh(forceUpdate) + { + if (this.uvMatrix.update(forceUpdate)) + { + this._refresh(); + } + } + + /** + * Updates the object transform for rendering + * + * @private + */ + updateTransform() + { + if (this.autoUpdate) + { + this.geometry.buffers[0].update(); + } + this.containerUpdateTransform(); + } + + /** + * re-calculates mesh coords + * @private + */ + _refresh() + { + /* empty */ + } +} diff --git a/packages/mesh-extras/src/NineSlicePlane.js b/packages/mesh-extras/src/NineSlicePlane.js new file mode 100644 index 0000000..0bae92c --- /dev/null +++ b/packages/mesh-extras/src/NineSlicePlane.js @@ -0,0 +1,270 @@ +import Plane from './Plane'; + +const DEFAULT_BORDER_SIZE = 10; + +/** + * The NineSlicePlane allows you to stretch a texture using 9-slice scaling. The corners will remain unscaled (useful + * for buttons with rounded corners for example) and the other areas will be scaled horizontally and or vertically + * + *```js + * let Plane9 = new PIXI.NineSlicePlane(PIXI.Texture.from('BoxWithRoundedCorners.png'), 15, 15, 15, 15); + * ``` + *
+ *      A                          B
+ *    +---+----------------------+---+
+ *  C | 1 |          2           | 3 |
+ *    +---+----------------------+---+
+ *    |   |                      |   |
+ *    | 4 |          5           | 6 |
+ *    |   |                      |   |
+ *    +---+----------------------+---+
+ *  D | 7 |          8           | 9 |
+ *    +---+----------------------+---+
+
+ *  When changing this objects width and/or height:
+ *     areas 1 3 7 and 9 will remain unscaled.
+ *     areas 2 and 8 will be stretched horizontally
+ *     areas 4 and 6 will be stretched vertically
+ *     area 5 will be stretched both horizontally and vertically
+ * 
+ * + * @class + * @extends PIXI.Plane + * @memberof PIXI + * + */ +export default class NineSlicePlane extends Plane +{ + /** + * @param {PIXI.Texture} texture - The texture to use on the NineSlicePlane. + * @param {int} [leftWidth=10] size of the left vertical bar (A) + * @param {int} [topHeight=10] size of the top horizontal bar (C) + * @param {int} [rightWidth=10] size of the right vertical bar (B) + * @param {int} [bottomHeight=10] size of the bottom horizontal bar (D) + */ + constructor(texture, leftWidth, topHeight, rightWidth, bottomHeight) + { + super(texture, 4, 4); + + this._origWidth = texture.orig.width; + this._origHeight = texture.orig.height; + + /** + * The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._width = this._origWidth; + + /** + * The height of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._height = this._origHeight; + + /** + * The width of the left column (a) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._leftWidth = typeof leftWidth !== 'undefined' ? leftWidth : DEFAULT_BORDER_SIZE; + + /** + * The width of the right column (b) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._rightWidth = typeof rightWidth !== 'undefined' ? rightWidth : DEFAULT_BORDER_SIZE; + + /** + * The height of the top row (c) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._topHeight = typeof topHeight !== 'undefined' ? topHeight : DEFAULT_BORDER_SIZE; + + /** + * The height of the bottom row (d) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._bottomHeight = typeof bottomHeight !== 'undefined' ? bottomHeight : DEFAULT_BORDER_SIZE; + + this.refresh(true); + } + + /** + * Updates the horizontal vertices. + * + */ + updateHorizontalVertices() + { + const vertices = this.vertices; + + const h = this._topHeight + this._bottomHeight; + const scale = this._height > h ? 1.0 : this._height / h; + + vertices[9] = vertices[11] = vertices[13] = vertices[15] = this._topHeight * scale; + vertices[17] = vertices[19] = vertices[21] = vertices[23] = this._height - (this._bottomHeight * scale); + vertices[25] = vertices[27] = vertices[29] = vertices[31] = this._height; + } + + /** + * Updates the vertical vertices. + * + */ + updateVerticalVertices() + { + const vertices = this.vertices; + + const w = this._leftWidth + this._rightWidth; + const scale = this._width > w ? 1.0 : this._width / w; + + vertices[2] = vertices[10] = vertices[18] = vertices[26] = this._leftWidth * scale; + vertices[4] = vertices[12] = vertices[20] = vertices[28] = this._width - (this._rightWidth * scale); + vertices[6] = vertices[14] = vertices[22] = vertices[30] = this._width; + } + + /** + * The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + */ + get width() + { + return this._width; + } + + set width(value) // eslint-disable-line require-jsdoc + { + this._width = value; + this._refresh(); + } + + /** + * The height of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + */ + get height() + { + return this._height; + } + + set height(value) // eslint-disable-line require-jsdoc + { + this._height = value; + this._refresh(); + } + + /** + * The width of the left column + * + * @member {number} + */ + get leftWidth() + { + return this._leftWidth; + } + + set leftWidth(value) // eslint-disable-line require-jsdoc + { + this._leftWidth = value; + this._refresh(); + } + + /** + * The width of the right column + * + * @member {number} + */ + get rightWidth() + { + return this._rightWidth; + } + + set rightWidth(value) // eslint-disable-line require-jsdoc + { + this._rightWidth = value; + this._refresh(); + } + + /** + * The height of the top row + * + * @member {number} + */ + get topHeight() + { + return this._topHeight; + } + + set topHeight(value) // eslint-disable-line require-jsdoc + { + this._topHeight = value; + this._refresh(); + } + + /** + * The height of the bottom row + * + * @member {number} + */ + get bottomHeight() + { + return this._bottomHeight; + } + + set bottomHeight(value) // eslint-disable-line require-jsdoc + { + this._bottomHeight = value; + this._refresh(); + } + + /** + * Refreshes NineSlicePlane coords. All of them. + */ + _refresh() + { + super._refresh(); + + const uvs = this.uvs; + const texture = this._texture; + + this._origWidth = texture.orig.width; + this._origHeight = texture.orig.height; + + const _uvw = 1.0 / this._origWidth; + const _uvh = 1.0 / this._origHeight; + + uvs[0] = uvs[8] = uvs[16] = uvs[24] = 0; + uvs[1] = uvs[3] = uvs[5] = uvs[7] = 0; + uvs[6] = uvs[14] = uvs[22] = uvs[30] = 1; + uvs[25] = uvs[27] = uvs[29] = uvs[31] = 1; + + uvs[2] = uvs[10] = uvs[18] = uvs[26] = _uvw * this._leftWidth; + uvs[4] = uvs[12] = uvs[20] = uvs[28] = 1 - (_uvw * this._rightWidth); + uvs[9] = uvs[11] = uvs[13] = uvs[15] = _uvh * this._topHeight; + uvs[17] = uvs[19] = uvs[21] = uvs[23] = 1 - (_uvh * this._bottomHeight); + + this.updateHorizontalVertices(); + this.updateVerticalVertices(); + + this.geometry.buffers[1].update(); + + this.multiplyUvs(); + } +} diff --git a/packages/mesh-extras/src/Plane.js b/packages/mesh-extras/src/Plane.js new file mode 100644 index 0000000..1c240c4 --- /dev/null +++ b/packages/mesh-extras/src/Plane.js @@ -0,0 +1,100 @@ +import Mesh2d from './Mesh2d'; + +/** + * The Plane allows you to draw a texture across several points and them manipulate these points + * + *```js + * for (let i = 0; i < 20; i++) { + * points.push(new PIXI.Point(i * 50, 0)); + * }; + * let Plane = new PIXI.Plane(PIXI.Texture.from("snake.png"), points); + * ``` + * + * @class + * @extends PIXI.Mesh + * @memberof PIXI + * + */ +export default class Plane extends Mesh2d +{ + /** + * @param {PIXI.Texture} texture - The texture to use on the Plane. + * @param {number} verticesX - The number of vertices in the x-axis + * @param {number} verticesY - The number of vertices in the y-axis + * @param {object} [opts] - an options object - add meshWidth and meshHeight, temporary object for PixiJS v5 alpha + */ + constructor(texture, verticesX, verticesY, opts = {}) + { + super(texture, new Float32Array(1), new Float32Array(1), new Uint16Array(1), 4); + + this.verticesX = verticesX || 10; + this.verticesY = verticesY || 10; + + this.meshWidth = opts.meshWidth || 0; + this.meshHeight = opts.meshHeight || 0; + + this.refresh(); + } + + /** + * Refreshes plane coordinates + * @private + */ + _refresh() + { + const texture = this._texture; + const total = this.verticesX * this.verticesY; + const verts = []; + const uvs = []; + const indices = []; + + const segmentsX = this.verticesX - 1; + const segmentsY = this.verticesY - 1; + + const sizeX = (this.meshWidth || texture.width) / segmentsX; + const sizeY = (this.meshHeight || texture.height) / segmentsY; + + for (let i = 0; i < total; i++) + { + const x = (i % this.verticesX); + const y = ((i / this.verticesX) | 0); + + verts.push(x * sizeX, y * sizeY); + + uvs.push(x / segmentsX, y / segmentsY); + } + + // cons + + const totalSub = segmentsX * segmentsY; + + for (let i = 0; i < totalSub; i++) + { + const xpos = i % segmentsX; + const ypos = (i / segmentsX) | 0; + + const value = (ypos * this.verticesX) + xpos; + const value2 = (ypos * this.verticesX) + xpos + 1; + const value3 = ((ypos + 1) * this.verticesX) + xpos; + const value4 = ((ypos + 1) * this.verticesX) + xpos + 1; + + indices.push(value, value2, value3); + indices.push(value2, value4, value3); + } + + this.vertices = new Float32Array(verts); + this.uvs = new Float32Array(uvs); + this.indices = new Uint16Array(indices); + + this.geometry.buffers[0].data = this.vertices; + this.geometry.buffers[1].data = this.uvs; + this.geometry.indexBuffer.data = this.indices; + + // ensure that the changes are uploaded + this.geometry.buffers[0].update(); + this.geometry.buffers[1].update(); + this.geometry.indexBuffer.update(); + + this.multiplyUvs(); + } +} diff --git a/packages/mesh-extras/src/Rope.js b/packages/mesh-extras/src/Rope.js new file mode 100644 index 0000000..9cfde38 --- /dev/null +++ b/packages/mesh-extras/src/Rope.js @@ -0,0 +1,182 @@ +import Mesh2d from './Mesh2d'; + +/** + * The rope allows you to draw a texture across several points and them manipulate these points + * + *```js + * for (let i = 0; i < 20; i++) { + * points.push(new PIXI.Point(i * 50, 0)); + * }; + * let rope = new PIXI.Rope(PIXI.Texture.from("snake.png"), points); + * ``` + * + * @class + * @extends PIXI.Mesh + * @memberof PIXI + * + */ +export default class Rope extends Mesh2d +{ + /** + * @param {PIXI.Texture} texture - The texture to use on the rope. + * @param {PIXI.Point[]} points - An array of {@link PIXI.Point} objects to construct this rope. + */ + constructor(texture, points) + { + super(texture, new Float32Array(points.length * 4), + new Float32Array(points.length * 4), + new Uint16Array(points.length * 2), + 5); + + /* + * @member {PIXI.Point[]} An array of points that determine the rope + */ + this.points = points; + this.refresh(); + } + /** + * Refreshes Rope indices and uvs + * @private + */ + _refresh() + { + const points = this.points; + + if (!points) return; + + const vertexBuffer = this.geometry.getAttribute('aVertexPosition'); + const uvBuffer = this.geometry.getAttribute('aTextureCoord'); + const indexBuffer = this.geometry.getIndex(); + + // if too little points, or texture hasn't got UVs set yet just move on. + if (points.length < 1 || !this.texture._uvs) + { + return; + } + + // if the number of points has changed we will need to recreate the arraybuffers + if (vertexBuffer.data.length / 4 !== points.length) + { + vertexBuffer.data = new Float32Array(points.length * 4); + uvBuffer.data = new Float32Array(points.length * 4); + indexBuffer.data = new Uint16Array(points.length * 2); + } + + const uvs = uvBuffer.data; + const indices = indexBuffer.data; + + uvs[0] = 0; + uvs[1] = 0; + uvs[2] = 0; + uvs[3] = 1; + + indices[0] = 0; + indices[1] = 1; + + const total = points.length; + + for (let i = 1; i < total; i++) + { + // time to do some smart drawing! + let index = i * 4; + const amount = i / (total - 1); + + uvs[index] = amount; + uvs[index + 1] = 0; + + uvs[index + 2] = amount; + uvs[index + 3] = 1; + + index = i * 2; + indices[index] = index; + indices[index + 1] = index + 1; + } + + // ensure that the changes are uploaded + uvBuffer.update(); + indexBuffer.update(); + + this.multiplyUvs(); + this.refreshVertices(); + } + + /** + * refreshes vertices of Rope mesh + */ + refreshVertices() + { + const points = this.points; + + if (points.length < 1) + { + return; + } + + let lastPoint = points[0]; + let nextPoint; + let perpX = 0; + let perpY = 0; + + // this.count -= 0.2; + + const vertices = this.vertices; + const total = points.length; + + for (let i = 0; i < total; i++) + { + const point = points[i]; + const index = i * 4; + + if (i < points.length - 1) + { + nextPoint = points[i + 1]; + } + else + { + nextPoint = point; + } + + perpY = -(nextPoint.x - lastPoint.x); + perpX = nextPoint.y - lastPoint.y; + + let ratio = (1 - (i / (total - 1))) * 10; + + if (ratio > 1) + { + ratio = 1; + } + + const perpLength = Math.sqrt((perpX * perpX) + (perpY * perpY)); + const num = this._texture.height / 2; // (20 + Math.abs(Math.sin((i + this.count) * 0.3) * 50) )* ratio; + + perpX /= perpLength; + perpY /= perpLength; + + perpX *= num; + perpY *= num; + + vertices[index] = point.x + perpX; + vertices[index + 1] = point.y + perpY; + vertices[index + 2] = point.x - perpX; + vertices[index + 3] = point.y - perpY; + + lastPoint = point; + } + + this.geometry.buffers[0].update(); + } + + /** + * Updates the object transform for rendering + * + * @private + */ + updateTransform() + { + if (this.autoUpdate) + { + this.refreshVertices(); + } + this.containerUpdateTransform(); + } +} diff --git a/packages/mesh-extras/src/index.js b/packages/mesh-extras/src/index.js new file mode 100644 index 0000000..decf454 --- /dev/null +++ b/packages/mesh-extras/src/index.js @@ -0,0 +1,4 @@ +export { default as Mesh2d } from './Mesh2d'; +export { default as Plane } from './Plane'; +export { default as NineSlicePlane } from './NineSlicePlane'; +export { default as Rope } from './Rope'; diff --git a/packages/mesh-extras/src/mesh.frag b/packages/mesh-extras/src/mesh.frag new file mode 100644 index 0000000..6096983 --- /dev/null +++ b/packages/mesh-extras/src/mesh.frag @@ -0,0 +1,9 @@ +varying vec2 vTextureCoord; +uniform vec4 uColor; + +uniform sampler2D uSampler; + +void main(void) +{ + gl_FragColor = texture2D(uSampler, vTextureCoord) * uColor; +} diff --git a/packages/mesh-extras/src/mesh.vert b/packages/mesh-extras/src/mesh.vert new file mode 100644 index 0000000..0526df9 --- /dev/null +++ b/packages/mesh-extras/src/mesh.vert @@ -0,0 +1,15 @@ +attribute vec2 aVertexPosition; +attribute vec2 aTextureCoord; + +uniform mat3 projectionMatrix; +uniform mat3 translationMatrix; +uniform mat3 uTextureMatrix; + +varying vec2 vTextureCoord; + +void main(void) +{ + gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); + + vTextureCoord = (uTextureMatrix * vec3(aTextureCoord, 1.0)).xy; +} diff --git a/packages/mesh-extras/test/.eslintrc.json b/packages/mesh-extras/test/.eslintrc.json new file mode 100644 index 0000000..2ad8efb --- /dev/null +++ b/packages/mesh-extras/test/.eslintrc.json @@ -0,0 +1,12 @@ +{ + "globals": { + "expect": false, + "assert": false, + "sinon": false, + "PIXI": false + }, + "rules": { + "func-names": 0, + "no-unused-expressions": 0 + } +} \ No newline at end of file diff --git a/packages/mesh-extras/test/Plane.js b/packages/mesh-extras/test/Plane.js new file mode 100644 index 0000000..f9b1c25 --- /dev/null +++ b/packages/mesh-extras/test/Plane.js @@ -0,0 +1,60 @@ +const { Plane } = require('../'); +const { isWebGLSupported, skipHello } = require('@pixi/utils'); +const { Loader } = require('@pixi/loaders'); +const { Point } = require('@pixi/math'); +const { RenderTexture, Texture } = require('@pixi/core'); + +skipHello(); + +function withGL(fn) +{ + return isWebGLSupported() ? fn : undefined; +} + +// TODO: fix with webglrenderer +describe('PIXI.mesh.Plane', function () +{ + it.skip('should create a plane from an external image', withGL(function (done) + { + const loader = new Loader(); + + loader.add('testBitmap', `file://${__dirname}/resources/bitmap-1.png`) + .load(function (loader, resources) + { + const plane = new Plane(resources.testBitmap.texture, 100, 100); + + expect(plane.verticesX).to.equal(100); + expect(plane.verticesY).to.equal(100); + done(); + }); + })); + + it.skip('should create a new empty textured Plane', withGL(function () + { + const plane = new Plane(Texture.EMPTY, 100, 100); + + expect(plane.verticesX).to.equal(100); + expect(plane.verticesY).to.equal(100); + })); + + describe('containsPoint', function () + { + it.skip('should return true when point inside', withGL(function () + { + const point = new Point(10, 10); + const texture = new RenderTexture.create(20, 30); + const plane = new Plane(texture, 100, 100); + + expect(plane.containsPoint(point)).to.be.true; + })); + + it.skip('should return false when point outside', withGL(function () + { + const point = new Point(100, 100); + const texture = new RenderTexture.create(20, 30); + const plane = new Plane(texture, 100, 100); + + expect(plane.containsPoint(point)).to.be.false; + })); + }); +}); diff --git a/packages/mesh-extras/test/index.js b/packages/mesh-extras/test/index.js new file mode 100644 index 0000000..d767624 --- /dev/null +++ b/packages/mesh-extras/test/index.js @@ -0,0 +1 @@ +require('./Plane'); diff --git a/packages/mesh-extras/test/resources/bitmap-1.png b/packages/mesh-extras/test/resources/bitmap-1.png new file mode 100644 index 0000000..1284fb8 --- /dev/null +++ b/packages/mesh-extras/test/resources/bitmap-1.png Binary files differ diff --git a/packages/mesh/package.json b/packages/mesh/package.json index 8b1f8d9..10bd8e3 100644 --- a/packages/mesh/package.json +++ b/packages/mesh/package.json @@ -18,22 +18,16 @@ "publishConfig": { "access": "public" }, - "scripts": { - "test": "floss --path test" - }, "files": [ "lib" ], "dependencies": { - "@pixi/canvas-renderer": "^5.0.0-alpha.2", "@pixi/constants": "^5.0.0-alpha.2", "@pixi/core": "^5.0.0-alpha.2", "@pixi/display": "^5.0.0-alpha.2", - "@pixi/math": "^5.0.0-alpha.2", - "@pixi/utils": "^5.0.0-alpha.2" + "@pixi/math": "^5.0.0-alpha.2" }, "devDependencies": { - "@pixi/loaders": "^5.0.0-alpha.2", "floss": "^2.1.3" } } diff --git a/packages/mesh/src/Mesh.js b/packages/mesh/src/Mesh.js index e7c8f9e..1f35b7a 100644 --- a/packages/mesh/src/Mesh.js +++ b/packages/mesh/src/Mesh.js @@ -1,263 +1,220 @@ -import RawMesh from './RawMesh'; -import { Geometry, Program, Shader, Texture, TextureMatrix } from '@pixi/core'; -import { Matrix } from '@pixi/math'; -import { BLEND_MODES } from '@pixi/constants'; -import { hex2rgb, premultiplyRgba } from '@pixi/utils'; -import vertex from './mesh.vert'; -import fragment from './mesh.frag'; +import { State } from '@pixi/core'; +import { DRAW_MODES } from '@pixi/constants'; +import { Point, Polygon } from '@pixi/math'; +import { Container } from '@pixi/display'; -let meshProgram; +const tempPoint = new Point(); +const tempPolygon = new Polygon(); /** - * Base mesh class + * Base mesh class. + * The reason for this class is to empower you to have maximum flexibility to render any kind of webGL you can think of. + * This class assumes a certain level of webGL knowledge. + * If you know a bit this should abstract enough away to make you life easier! + * Pretty much ALL WebGL can be broken down into the following: + * Geometry - The structure and data for the mesh. This can include anything from positions, uvs, normals, colors etc.. + * Shader - This is the shader that pixi will render the geometry with. (attributes in the shader must match the geometry!) + * Uniforms - These are the values passed to the shader when the mesh is rendered. + * As a shader can be reused across multiple objects, it made sense to allow uniforms to exist outside of the shader + * State - This is the state of WebGL required to render the mesh. + * Through a combination of the above elements you can render anything you want, 2D or 3D! + * * @class * @extends PIXI.Container * @memberof PIXI */ -export default class Mesh extends RawMesh +export default class Mesh extends Container { /** - * @param {PIXI.Texture} [texture=Texture.EMPTY] - The texture to use - * @param {Float32Array} [vertices] - if you want to specify the vertices - * @param {Float32Array} [uvs] - if you want to specify the uvs - * @param {Uint16Array} [indices] - if you want to specify the indices - * @param {number} [drawMode] - the drawMode, can be any of the Mesh.DRAW_MODES consts + * @param {PIXI.Geometry} geometry the geometry the mesh will use + * @param {PIXI.Shader} shader the shader the mesh will use + * @param {PIXI.State} state the state that the webGL context is required to be in to render the mesh + * @param {number} drawMode the drawMode, can be any of the PIXI.DRAW_MODES consts */ - constructor(texture = Texture.EMPTY, vertices, uvs, indices, drawMode) + constructor(geometry, shader, state, drawMode = DRAW_MODES.TRIANGLES) { - const geometry = new Geometry(); - - if (!meshProgram) - { - meshProgram = new Program(vertex, fragment); - } - - geometry.addAttribute('aVertexPosition', vertices) - .addAttribute('aTextureCoord', uvs) - .addIndex(indices); - - geometry.getAttribute('aVertexPosition').static = false; - - const uniforms = { - uSampler: texture, - uTextureMatrix: Matrix.IDENTITY, - alpha: 1, - uColor: new Float32Array([1, 1, 1, 1]), - }; - - super(geometry, new Shader(meshProgram, uniforms), null, drawMode); + super(); /** - * The Uvs of the Mesh - * - * @member {Float32Array} + * the geometry the mesh will use + * @type {PIXI.Geometry} */ - this.uvs = geometry.getAttribute('aTextureCoord').data; + this.geometry = geometry; /** - * An array of vertices - * - * @member {Float32Array} + * the shader the mesh will use + * @type {PIXI.Shader} */ - this.vertices = geometry.getAttribute('aVertexPosition').data; - - this.uniforms = uniforms; + this.shader = shader; /** - * The texture of the Mesh - * - * @member {PIXI.Texture} - * @default PIXI.Texture.EMPTY - * @private + * the webGL state the mesh requires to render + * @type {PIXI.State} */ - this.texture = texture; + this.state = state || new State(); /** - * The tint applied to the mesh. This is a [r,g,b] value. A value of [1,1,1] will remove any - * tint effect. + * The way the Mesh should be drawn, can be any of the {@link PIXI.Mesh.DRAW_MODES} consts * * @member {number} + * @see PIXI.Mesh.DRAW_MODES + */ + this.drawMode = drawMode; + + /** + * The way uniforms that will be used by the mesh's shader. + * @member {Object} + */ + + /** + * A map of renderer IDs to webgl render data + * * @private + * @member {object} */ - this._tintRGB = new Float32Array([1, 1, 1]); - - // Set default tint - this.tint = 0xFFFFFF; - - this.blendMode = BLEND_MODES.NORMAL; + this._glDatas = {}; /** - * TextureMatrix instance for this Mesh, used to track Texture changes + * Plugin that is responsible for rendering this element. + * Allows to customize the rendering process without overriding '_render' & '_renderCanvas' methods. * - * @member {PIXI.TextureMatrix} - * @readonly + * @member {string} + * @default 'mesh' */ - this.uvMatrix = new TextureMatrix(this._texture); + this.pluginName = 'mesh'; - /** - * whether or not upload uvMatrix to shader - * if its false, then uvs should be pre-multiplied - * if you change it for generated mesh, please call 'refresh(true)' - * @member {boolean} - * @default false - */ - this.uploadUvMatrix = false; - - /** - * Uploads vertices buffer every frame, like in PixiJS V3 and V4. - * - * @member {boolean} - * @default true - */ - this.autoUpdate = true; + this.start = 0; + this.size = 0; } /** - * The tint applied to the Rope. This is a hex value. A value of - * 0xFFFFFF will remove any tint effect. + * Renders the object using the WebGL renderer * - * @member {number} - * @memberof PIXI.Sprite# - * @default 0xFFFFFF + * @param {PIXI.Renderer} renderer a reference to the WebGL renderer + * @private */ - get tint() + _render(renderer) { - return this._tint; + renderer.batch.setObjectRenderer(renderer.plugins[this.pluginName]); + renderer.plugins[this.pluginName].render(this); } /** - * Sets the tint of the rope. + * Updates the bounds of the mesh as a rectangle. The bounds calculation takes the worldTransform into account. + * there must be a aVertexPosition attribute present in the geometry for bounds to be calculated correctly. * - * @param {number} value - The value to set to. + * @private */ - set tint(value) + _calculateBounds() { - this._tint = value; - - hex2rgb(this._tint, this._tintRGB); - } - - /** - * The blend mode to be applied to the sprite. Set to `PIXI.BLEND_MODES.NORMAL` to remove any blend mode. - * - * @member {number} - * @default PIXI.BLEND_MODES.NORMAL - * @see PIXI.BLEND_MODES - */ - get blendMode() - { - return this.state.blendMode; - } - - set blendMode(value) // eslint-disable-line require-jsdoc - { - this.state.blendMode = value; - } - - /** - * The texture that the mesh uses. - * - * @member {PIXI.Texture} - */ - get texture() - { - return this._texture; - } - - set texture(value) // eslint-disable-line require-jsdoc - { - if (this._texture === value) + // The position property could be set manually? + if (this.geometry.attributes.aVertexPosition) { - return; + const vertices = this.geometry.getAttribute('aVertexPosition').data; + + // TODO - we can cache local bounds and use them if they are dirty (like graphics) + this._bounds.addVertices(this.transform, vertices, 0, vertices.length); + } + } + + /** + * Tests if a point is inside this mesh. Works only for TRIANGLE_MESH + * + * @param {PIXI.Point} point the point to test + * @return {boolean} the result of the test + */ + containsPoint(point) + { + if (!this.getBounds().contains(point.x, point.y)) + { + return false; } - this._texture = value; - this.uniforms.uSampler = this.texture; + this.worldTransform.applyInverse(point, tempPoint); - if (value) + const vertices = this.geometry.getAttribute('aVertexPosition').data; + + const points = tempPolygon.points; + const indices = this.geometry.getIndex().data; + const len = indices.length; + const step = this.drawMode === 4 ? 3 : 1; + + for (let i = 0; i + 2 < len; i += step) { - // wait for the texture to load - if (value.baseTexture.valid) + const ind0 = indices[i] * 2; + const ind1 = indices[i + 1] * 2; + const ind2 = indices[i + 2] * 2; + + points[0] = vertices[ind0]; + points[1] = vertices[ind0 + 1]; + points[2] = vertices[ind1]; + points[3] = vertices[ind1 + 1]; + points[4] = vertices[ind2]; + points[5] = vertices[ind2 + 1]; + + if (tempPolygon.contains(tempPoint.x, tempPoint.y)) { - this._onTextureUpdate(); + return true; + } + } + + return false; + } + + /** + * Destroys the Mesh object. + * + * @param {object|boolean} [options] - Options parameter. A boolean will act as if all + * options have been set to that value + * @param {boolean} [options.children=false] - if set to true, all the children will have + * their destroy method called as well. 'options' will be passed on to those calls. + * @param {boolean} [options.texture=false] - Only used for child Sprites if options.children is set to true + * Should it destroy the texture of the child sprite + * @param {boolean} [options.baseTexture=false] - Only used for child Sprites if options.children is set to true + * Should it destroy the base texture of the child sprite + */ + destroy(options) + { + // for each webgl data entry, destroy the WebGLGraphicsData + for (const id in this._glDatas) + { + const data = this._glDatas[id]; + + if (data.destroy) + { + data.destroy(); } else { - value.once('update', this._onTextureUpdate, this); + if (data.vertexBuffer) + { + data.vertexBuffer.destroy(); + data.vertexBuffer = null; + } + if (data.indexBuffer) + { + data.indexBuffer.destroy(); + data.indexBuffer = null; + } + if (data.uvBuffer) + { + data.uvBuffer.destroy(); + data.uvBuffer = null; + } + if (data.vao) + { + data.vao.destroy(); + data.vao = null; + } } } - } - _render(renderer) - { - const baseTex = this._texture.baseTexture; + this._glDatas = null; - premultiplyRgba(this._tintRGB, this.worldAlpha, this.uniforms.uColor, baseTex.premultiplyAlpha); - super._render(renderer); - } - /** - * When the texture is updated, this event will fire to update the scale and frame - * - * @private - */ - _onTextureUpdate() - { - // constructor texture update stop - if (!this.uvMatrix) - { - return; - } - this.uvMatrix.texture = this._texture; - this.refresh(); - } + this.geometry = null; + this.shader = null; + this.state = null; - /** - * multiplies uvs only if uploadUvMatrix is false - * call it after you change uvs manually - * make sure that texture is valid - */ - multiplyUvs() - { - if (!this.uploadUvMatrix) - { - this.uvMatrix.multiplyUvs(this.uvs); - } - } - - /** - * Refreshes uvs for generated meshes (rope, plane) - * sometimes refreshes vertices too - * - * @param {boolean} [forceUpdate=false] if true, matrices will be updated any case - */ - refresh(forceUpdate) - { - if (this.uvMatrix.update(forceUpdate)) - { - this._refresh(); - } - } - - /** - * Updates the object transform for rendering - * - * @private - */ - updateTransform() - { - if (this.autoUpdate) - { - this.geometry.buffers[0].update(); - } - this.containerUpdateTransform(); - } - - /** - * re-calculates mesh coords - * @private - */ - _refresh() - { - /* empty */ + super.destroy(options); } } diff --git a/packages/mesh/src/MeshRenderer.js b/packages/mesh/src/MeshRenderer.js index 12b159b..d7baf9b 100644 --- a/packages/mesh/src/MeshRenderer.js +++ b/packages/mesh/src/MeshRenderer.js @@ -36,7 +36,7 @@ /** * renders mesh * @private - * @param {PIXI.RawMesh} mesh mesh instance + * @param {PIXI.Mesh} mesh mesh instance */ render(mesh) { diff --git a/packages/mesh/src/NineSlicePlane.js b/packages/mesh/src/NineSlicePlane.js deleted file mode 100644 index 0bae92c..0000000 --- a/packages/mesh/src/NineSlicePlane.js +++ /dev/null @@ -1,270 +0,0 @@ -import Plane from './Plane'; - -const DEFAULT_BORDER_SIZE = 10; - -/** - * The NineSlicePlane allows you to stretch a texture using 9-slice scaling. The corners will remain unscaled (useful - * for buttons with rounded corners for example) and the other areas will be scaled horizontally and or vertically - * - *```js - * let Plane9 = new PIXI.NineSlicePlane(PIXI.Texture.from('BoxWithRoundedCorners.png'), 15, 15, 15, 15); - * ``` - *
- *      A                          B
- *    +---+----------------------+---+
- *  C | 1 |          2           | 3 |
- *    +---+----------------------+---+
- *    |   |                      |   |
- *    | 4 |          5           | 6 |
- *    |   |                      |   |
- *    +---+----------------------+---+
- *  D | 7 |          8           | 9 |
- *    +---+----------------------+---+
-
- *  When changing this objects width and/or height:
- *     areas 1 3 7 and 9 will remain unscaled.
- *     areas 2 and 8 will be stretched horizontally
- *     areas 4 and 6 will be stretched vertically
- *     area 5 will be stretched both horizontally and vertically
- * 
- * - * @class - * @extends PIXI.Plane - * @memberof PIXI - * - */ -export default class NineSlicePlane extends Plane -{ - /** - * @param {PIXI.Texture} texture - The texture to use on the NineSlicePlane. - * @param {int} [leftWidth=10] size of the left vertical bar (A) - * @param {int} [topHeight=10] size of the top horizontal bar (C) - * @param {int} [rightWidth=10] size of the right vertical bar (B) - * @param {int} [bottomHeight=10] size of the bottom horizontal bar (D) - */ - constructor(texture, leftWidth, topHeight, rightWidth, bottomHeight) - { - super(texture, 4, 4); - - this._origWidth = texture.orig.width; - this._origHeight = texture.orig.height; - - /** - * The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane - * - * @member {number} - * @memberof PIXI.NineSlicePlane# - * @override - */ - this._width = this._origWidth; - - /** - * The height of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane - * - * @member {number} - * @memberof PIXI.NineSlicePlane# - * @override - */ - this._height = this._origHeight; - - /** - * The width of the left column (a) - * - * @member {number} - * @memberof PIXI.NineSlicePlane# - * @override - */ - this._leftWidth = typeof leftWidth !== 'undefined' ? leftWidth : DEFAULT_BORDER_SIZE; - - /** - * The width of the right column (b) - * - * @member {number} - * @memberof PIXI.NineSlicePlane# - * @override - */ - this._rightWidth = typeof rightWidth !== 'undefined' ? rightWidth : DEFAULT_BORDER_SIZE; - - /** - * The height of the top row (c) - * - * @member {number} - * @memberof PIXI.NineSlicePlane# - * @override - */ - this._topHeight = typeof topHeight !== 'undefined' ? topHeight : DEFAULT_BORDER_SIZE; - - /** - * The height of the bottom row (d) - * - * @member {number} - * @memberof PIXI.NineSlicePlane# - * @override - */ - this._bottomHeight = typeof bottomHeight !== 'undefined' ? bottomHeight : DEFAULT_BORDER_SIZE; - - this.refresh(true); - } - - /** - * Updates the horizontal vertices. - * - */ - updateHorizontalVertices() - { - const vertices = this.vertices; - - const h = this._topHeight + this._bottomHeight; - const scale = this._height > h ? 1.0 : this._height / h; - - vertices[9] = vertices[11] = vertices[13] = vertices[15] = this._topHeight * scale; - vertices[17] = vertices[19] = vertices[21] = vertices[23] = this._height - (this._bottomHeight * scale); - vertices[25] = vertices[27] = vertices[29] = vertices[31] = this._height; - } - - /** - * Updates the vertical vertices. - * - */ - updateVerticalVertices() - { - const vertices = this.vertices; - - const w = this._leftWidth + this._rightWidth; - const scale = this._width > w ? 1.0 : this._width / w; - - vertices[2] = vertices[10] = vertices[18] = vertices[26] = this._leftWidth * scale; - vertices[4] = vertices[12] = vertices[20] = vertices[28] = this._width - (this._rightWidth * scale); - vertices[6] = vertices[14] = vertices[22] = vertices[30] = this._width; - } - - /** - * The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane - * - * @member {number} - */ - get width() - { - return this._width; - } - - set width(value) // eslint-disable-line require-jsdoc - { - this._width = value; - this._refresh(); - } - - /** - * The height of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane - * - * @member {number} - */ - get height() - { - return this._height; - } - - set height(value) // eslint-disable-line require-jsdoc - { - this._height = value; - this._refresh(); - } - - /** - * The width of the left column - * - * @member {number} - */ - get leftWidth() - { - return this._leftWidth; - } - - set leftWidth(value) // eslint-disable-line require-jsdoc - { - this._leftWidth = value; - this._refresh(); - } - - /** - * The width of the right column - * - * @member {number} - */ - get rightWidth() - { - return this._rightWidth; - } - - set rightWidth(value) // eslint-disable-line require-jsdoc - { - this._rightWidth = value; - this._refresh(); - } - - /** - * The height of the top row - * - * @member {number} - */ - get topHeight() - { - return this._topHeight; - } - - set topHeight(value) // eslint-disable-line require-jsdoc - { - this._topHeight = value; - this._refresh(); - } - - /** - * The height of the bottom row - * - * @member {number} - */ - get bottomHeight() - { - return this._bottomHeight; - } - - set bottomHeight(value) // eslint-disable-line require-jsdoc - { - this._bottomHeight = value; - this._refresh(); - } - - /** - * Refreshes NineSlicePlane coords. All of them. - */ - _refresh() - { - super._refresh(); - - const uvs = this.uvs; - const texture = this._texture; - - this._origWidth = texture.orig.width; - this._origHeight = texture.orig.height; - - const _uvw = 1.0 / this._origWidth; - const _uvh = 1.0 / this._origHeight; - - uvs[0] = uvs[8] = uvs[16] = uvs[24] = 0; - uvs[1] = uvs[3] = uvs[5] = uvs[7] = 0; - uvs[6] = uvs[14] = uvs[22] = uvs[30] = 1; - uvs[25] = uvs[27] = uvs[29] = uvs[31] = 1; - - uvs[2] = uvs[10] = uvs[18] = uvs[26] = _uvw * this._leftWidth; - uvs[4] = uvs[12] = uvs[20] = uvs[28] = 1 - (_uvw * this._rightWidth); - uvs[9] = uvs[11] = uvs[13] = uvs[15] = _uvh * this._topHeight; - uvs[17] = uvs[19] = uvs[21] = uvs[23] = 1 - (_uvh * this._bottomHeight); - - this.updateHorizontalVertices(); - this.updateVerticalVertices(); - - this.geometry.buffers[1].update(); - - this.multiplyUvs(); - } -} diff --git a/packages/mesh/src/Plane.js b/packages/mesh/src/Plane.js deleted file mode 100644 index c416b4c..0000000 --- a/packages/mesh/src/Plane.js +++ /dev/null @@ -1,100 +0,0 @@ -import Mesh from './Mesh'; - -/** - * The Plane allows you to draw a texture across several points and them manipulate these points - * - *```js - * for (let i = 0; i < 20; i++) { - * points.push(new PIXI.Point(i * 50, 0)); - * }; - * let Plane = new PIXI.Plane(PIXI.Texture.from("snake.png"), points); - * ``` - * - * @class - * @extends PIXI.Mesh - * @memberof PIXI - * - */ -export default class Plane extends Mesh -{ - /** - * @param {PIXI.Texture} texture - The texture to use on the Plane. - * @param {number} verticesX - The number of vertices in the x-axis - * @param {number} verticesY - The number of vertices in the y-axis - * @param {object} [opts] - an options object - add meshWidth and meshHeight, temporary object for PixiJS v5 alpha - */ - constructor(texture, verticesX, verticesY, opts = {}) - { - super(texture, new Float32Array(1), new Float32Array(1), new Uint16Array(1), 4); - - this.verticesX = verticesX || 10; - this.verticesY = verticesY || 10; - - this.meshWidth = opts.meshWidth || 0; - this.meshHeight = opts.meshHeight || 0; - - this.refresh(); - } - - /** - * Refreshes plane coordinates - * @private - */ - _refresh() - { - const texture = this._texture; - const total = this.verticesX * this.verticesY; - const verts = []; - const uvs = []; - const indices = []; - - const segmentsX = this.verticesX - 1; - const segmentsY = this.verticesY - 1; - - const sizeX = (this.meshWidth || texture.width) / segmentsX; - const sizeY = (this.meshHeight || texture.height) / segmentsY; - - for (let i = 0; i < total; i++) - { - const x = (i % this.verticesX); - const y = ((i / this.verticesX) | 0); - - verts.push(x * sizeX, y * sizeY); - - uvs.push(x / segmentsX, y / segmentsY); - } - - // cons - - const totalSub = segmentsX * segmentsY; - - for (let i = 0; i < totalSub; i++) - { - const xpos = i % segmentsX; - const ypos = (i / segmentsX) | 0; - - const value = (ypos * this.verticesX) + xpos; - const value2 = (ypos * this.verticesX) + xpos + 1; - const value3 = ((ypos + 1) * this.verticesX) + xpos; - const value4 = ((ypos + 1) * this.verticesX) + xpos + 1; - - indices.push(value, value2, value3); - indices.push(value2, value4, value3); - } - - this.vertices = new Float32Array(verts); - this.uvs = new Float32Array(uvs); - this.indices = new Uint16Array(indices); - - this.geometry.buffers[0].data = this.vertices; - this.geometry.buffers[1].data = this.uvs; - this.geometry.indexBuffer.data = this.indices; - - // ensure that the changes are uploaded - this.geometry.buffers[0].update(); - this.geometry.buffers[1].update(); - this.geometry.indexBuffer.update(); - - this.multiplyUvs(); - } -} diff --git a/packages/mesh/src/RawMesh.js b/packages/mesh/src/RawMesh.js deleted file mode 100644 index 7297e94..0000000 --- a/packages/mesh/src/RawMesh.js +++ /dev/null @@ -1,220 +0,0 @@ -import { State } from '@pixi/core'; -import { DRAW_MODES } from '@pixi/constants'; -import { Point, Polygon } from '@pixi/math'; -import { Container } from '@pixi/display'; - -const tempPoint = new Point(); -const tempPolygon = new Polygon(); - -/** - * Base mesh class. - * The reason for this class is to empower you to have maximum flexibility to render any kind of webGL you can think of. - * This class assumes a certain level of webGL knowledge. - * If you know a bit this should abstract enough away to make you life easier! - * Pretty much ALL WebGL can be broken down into the following: - * Geometry - The structure and data for the mesh. This can include anything from positions, uvs, normals, colors etc.. - * Shader - This is the shader that pixi will render the geometry with. (attributes in the shader must match the geometry!) - * Uniforms - These are the values passed to the shader when the mesh is rendered. - * As a shader can be reused across multiple objects, it made sense to allow uniforms to exist outside of the shader - * State - This is the state of WebGL required to render the mesh. - * Through a combination of the above elements you can render anything you want, 2D or 3D! - * - * @class - * @extends PIXI.Container - * @memberof PIXI - */ -export default class RawMesh extends Container -{ - /** - * @param {PIXI.Geometry} geometry the geometry the mesh will use - * @param {PIXI.Shader} shader the shader the mesh will use - * @param {PIXI.State} state the state that the webGL context is required to be in to render the mesh - * @param {number} drawMode the drawMode, can be any of the PIXI.DRAW_MODES consts - */ - constructor(geometry, shader, state, drawMode = DRAW_MODES.TRIANGLES) - { - super(); - - /** - * the geometry the mesh will use - * @type {PIXI.Geometry} - */ - this.geometry = geometry; - - /** - * the shader the mesh will use - * @type {PIXI.Shader} - */ - this.shader = shader; - - /** - * the webGL state the mesh requires to render - * @type {PIXI.State} - */ - this.state = state || new State(); - - /** - * The way the Mesh should be drawn, can be any of the {@link PIXI.RawMesh.DRAW_MODES} consts - * - * @member {number} - * @see PIXI.RawMesh.DRAW_MODES - */ - this.drawMode = drawMode; - - /** - * The way uniforms that will be used by the mesh's shader. - * @member {Object} - */ - - /** - * A map of renderer IDs to webgl render data - * - * @private - * @member {object} - */ - this._glDatas = {}; - - /** - * Plugin that is responsible for rendering this element. - * Allows to customize the rendering process without overriding '_render' & '_renderCanvas' methods. - * - * @member {string} - * @default 'mesh' - */ - this.pluginName = 'mesh'; - - this.start = 0; - this.size = 0; - } - - /** - * Renders the object using the WebGL renderer - * - * @param {PIXI.Renderer} renderer a reference to the WebGL renderer - * @private - */ - _render(renderer) - { - renderer.batch.setObjectRenderer(renderer.plugins[this.pluginName]); - renderer.plugins[this.pluginName].render(this); - } - - /** - * Updates the bounds of the mesh as a rectangle. The bounds calculation takes the worldTransform into account. - * there must be a aVertexPosition attribute present in the geometry for bounds to be calculated correctly. - * - * @private - */ - _calculateBounds() - { - // The position property could be set manually? - if (this.geometry.attributes.aVertexPosition) - { - const vertices = this.geometry.getAttribute('aVertexPosition').data; - - // TODO - we can cache local bounds and use them if they are dirty (like graphics) - this._bounds.addVertices(this.transform, vertices, 0, vertices.length); - } - } - - /** - * Tests if a point is inside this mesh. Works only for TRIANGLE_MESH - * - * @param {PIXI.Point} point the point to test - * @return {boolean} the result of the test - */ - containsPoint(point) - { - if (!this.getBounds().contains(point.x, point.y)) - { - return false; - } - - this.worldTransform.applyInverse(point, tempPoint); - - const vertices = this.geometry.getAttribute('aVertexPosition').data; - - const points = tempPolygon.points; - const indices = this.geometry.getIndex().data; - const len = indices.length; - const step = this.drawMode === 4 ? 3 : 1; - - for (let i = 0; i + 2 < len; i += step) - { - const ind0 = indices[i] * 2; - const ind1 = indices[i + 1] * 2; - const ind2 = indices[i + 2] * 2; - - points[0] = vertices[ind0]; - points[1] = vertices[ind0 + 1]; - points[2] = vertices[ind1]; - points[3] = vertices[ind1 + 1]; - points[4] = vertices[ind2]; - points[5] = vertices[ind2 + 1]; - - if (tempPolygon.contains(tempPoint.x, tempPoint.y)) - { - return true; - } - } - - return false; - } - - /** - * Destroys the RawMesh object. - * - * @param {object|boolean} [options] - Options parameter. A boolean will act as if all - * options have been set to that value - * @param {boolean} [options.children=false] - if set to true, all the children will have - * their destroy method called as well. 'options' will be passed on to those calls. - * @param {boolean} [options.texture=false] - Only used for child Sprites if options.children is set to true - * Should it destroy the texture of the child sprite - * @param {boolean} [options.baseTexture=false] - Only used for child Sprites if options.children is set to true - * Should it destroy the base texture of the child sprite - */ - destroy(options) - { - // for each webgl data entry, destroy the WebGLGraphicsData - for (const id in this._glDatas) - { - const data = this._glDatas[id]; - - if (data.destroy) - { - data.destroy(); - } - else - { - if (data.vertexBuffer) - { - data.vertexBuffer.destroy(); - data.vertexBuffer = null; - } - if (data.indexBuffer) - { - data.indexBuffer.destroy(); - data.indexBuffer = null; - } - if (data.uvBuffer) - { - data.uvBuffer.destroy(); - data.uvBuffer = null; - } - if (data.vao) - { - data.vao.destroy(); - data.vao = null; - } - } - } - - this._glDatas = null; - - this.geometry = null; - this.shader = null; - this.state = null; - - super.destroy(options); - } -} diff --git a/bundles/pixi.js/package.json b/bundles/pixi.js/package.json index 49c7276..177e059 100644 --- a/bundles/pixi.js/package.json +++ b/bundles/pixi.js/package.json @@ -49,6 +49,7 @@ "@pixi/loaders": "^5.0.0-alpha.2", "@pixi/math": "^5.0.0-alpha.2", "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/mesh-extras": "^5.0.0-alpha.2", "@pixi/mixin-cache-as-bitmap": "^5.0.0-alpha.2", "@pixi/mixin-get-child-by-name": "^5.0.0-alpha.2", "@pixi/mixin-get-global-position": "^5.0.0-alpha.2", diff --git a/bundles/pixi.js/src/deprecated.js b/bundles/pixi.js/src/deprecated.js index 147617c..dbebeb0 100644 --- a/bundles/pixi.js/src/deprecated.js +++ b/bundles/pixi.js/src/deprecated.js @@ -263,15 +263,15 @@ Object.defineProperties(PIXI.mesh, { /** * @class PIXI.mesh.Mesh - * @see PIXI.Mesh + * @see PIXI.Mesh2d * @deprecated since 5.0.0 */ Mesh: { get() { - warn('PIXI.mesh.Mesh has moved to PIXI.Mesh'); + warn('PIXI.mesh.Mesh has moved to PIXI.Mesh2d'); - return PIXI.Mesh; + return PIXI.Mesh2d; }, }, /** @@ -315,15 +315,15 @@ }, /** * @class PIXI.mesh.RawMesh - * @see PIXI.RawMesh + * @see PIXI.Mesh * @deprecated since 5.0.0 */ RawMesh: { get() { - warn('PIXI.mesh.RawMesh has moved to PIXI.RawMesh'); + warn('PIXI.mesh.RawMesh has moved to PIXI.Mesh'); - return PIXI.RawMesh; + return PIXI.Mesh; }, }, /** diff --git a/bundles/pixi.js/src/index.js b/bundles/pixi.js/src/index.js index a3a0d1b..6fdabf0 100644 --- a/bundles/pixi.js/src/index.js +++ b/bundles/pixi.js/src/index.js @@ -9,6 +9,7 @@ import * as loaders from '@pixi/loaders'; import * as math from '@pixi/math'; import * as mesh from '@pixi/mesh'; +import * as meshExtras from '@pixi/mesh-extras'; import * as particles from '@pixi/particles'; import * as prepare from '@pixi/prepare'; import * as sprite from '@pixi/sprite'; @@ -128,6 +129,7 @@ loaders, math, mesh, + meshExtras, particles, sprite, spriteAnimated, @@ -152,6 +154,7 @@ export * from '@pixi/loaders'; export * from '@pixi/math'; export * from '@pixi/mesh'; +export * from '@pixi/mesh-extras'; export * from '@pixi/particles'; export * from '@pixi/sprite'; export * from '@pixi/spritesheet'; diff --git a/package-lock.json b/package-lock.json index 7fe6db7..0814729 100644 --- a/package-lock.json +++ b/package-lock.json @@ -209,7 +209,7 @@ "argparse": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", - "integrity": "sha1-vNZ5HqWuCXJeF+WtmIE0zUCz2RE=", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", "dev": true, "requires": { "sprintf-js": "1.0.3" @@ -228,7 +228,7 @@ "arr-flatten": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz", - "integrity": "sha1-NgSLv/TntH4TZkQxbJlmnqWukfE=", + "integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==", "dev": true }, "arr-union": { @@ -297,7 +297,7 @@ "assertion-error": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", - "integrity": "sha1-5gtrDo8wG9l+U3UhW9pAbIURjAs=", + "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", "dev": true }, "async": { @@ -396,7 +396,7 @@ "brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha1-PH/L9SnYcibz0vUrlm/1Jx60Qd0=", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, "requires": { "balanced-match": "1.0.0", @@ -568,7 +568,7 @@ "circular-json": { "version": "0.3.3", "resolved": "https://registry.npmjs.org/circular-json/-/circular-json-0.3.3.tgz", - "integrity": "sha1-gVyZ6oT2gJUp0vRXkb34JxE1LWY=", + "integrity": "sha512-UZK3NBx2Mca+b5LsG7bY183pHWt5Y1xts4P3Pz7ENTwGVnJOUWbRb3ocjvX7hx9tq/yTAdclXm9sZ38gNuem4A==", "dev": true }, "cli-cursor": { @@ -638,7 +638,7 @@ "color-convert": { "version": "1.9.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.1.tgz", - "integrity": "sha1-wSYRB66y8pTr/+ye2eytUppgl+0=", + "integrity": "sha512-mjGanIiwQJskCC18rPR6OmrZ6fm2Lc7PeGFYwCmy5J34wC6F1PzdGL6xeMfmgicfYcNLGuVFA3WzXtIDCQSZxQ==", "dev": true, "requires": { "color-name": "1.1.3" @@ -1427,7 +1427,7 @@ "boom": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/boom/-/boom-5.2.0.tgz", - "integrity": "sha1-XdnabuOl8wIHdDYpDLcX0/SlTgI=", + "integrity": "sha512-Z5BTk6ZRe4tXXQlkqftmsAUANpXmuwlsF5Oov8ThoMbQRzdGTA1ngYRW160GexgOgjsFOKJz0LYhoNi+2AMBUw==", "dev": true, "requires": { "hoek": "4.2.1" @@ -1471,7 +1471,7 @@ "debug": { "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha1-XRKFFd8TT/Mn6QpMk/Tgd6U2NB8=", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", "dev": true, "requires": { "ms": "2.0.0" @@ -1585,7 +1585,7 @@ "doctrine": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", - "integrity": "sha1-XNAfwQFiG0LEzX9dGmYkNxbT850=", + "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", "dev": true, "requires": { "esutils": "2.0.2" @@ -1662,7 +1662,7 @@ "es6-promise": { "version": "4.2.4", "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.4.tgz", - "integrity": "sha1-3EIhwrFlGHYL2MOaUtjzVvwA7Sk=", + "integrity": "sha512-/NdNZVJg+uZgtm9eS3O6lrOLYmQag2DjdEXuPaHlZ6RuVqgqaVZfgYCepEIKsLqwdQArOPtC3XzRLqGGfT8KQQ==", "dev": true }, "escape-string-regexp": { @@ -1788,7 +1788,7 @@ "espree": { "version": "3.5.4", "resolved": "https://registry.npmjs.org/espree/-/espree-3.5.4.tgz", - "integrity": "sha1-sPRHGHyKi+2US4FaZgvd9d610ac=", + "integrity": "sha512-yAcIQxtmMiB/jL32dzEp2enBeidsB7xWPLNiw3IIkpVds1P+h7qF9YwJq1yUNzp2OKXgAprs4F61ih66UsoD1A==", "dev": true, "requires": { "acorn": "5.5.0", @@ -1798,7 +1798,7 @@ "esprima": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.0.tgz", - "integrity": "sha1-RJnt3NERDgshi6zy+n9/WfVcqAQ=", + "integrity": "sha512-oftTcaMu/EGrEIu904mWteKIv8vMuOgGYo7EhVJJN00R/EED9DCua/xxHRdYnKtcECzVg7xOWhflvJMnqcFZjw==", "dev": true }, "esquery": { @@ -1813,7 +1813,7 @@ "esrecurse": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.2.1.tgz", - "integrity": "sha1-AHo7n9vCs7uH5IeeoZyS/b05Qs8=", + "integrity": "sha512-64RBB++fIOAXPw3P9cy89qfMlvZEXZkqqJkjqqXIvzP5ezRZjW+lPWjw35UX/3EhUPFYbg5ER4JYgDw4007/DQ==", "dev": true, "requires": { "estraverse": "4.2.0" @@ -2024,7 +2024,7 @@ "find-root": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/find-root/-/find-root-1.1.0.tgz", - "integrity": "sha1-q8/Iunb3CMQql7PWhbfpRQv7nOQ=", + "integrity": "sha512-NKfW6bec6GfKc0SGx1e07QZY9PE99u0Bft/0rzSD5k3sO/vwkVUpDUKVm5Gpp5Ue3YfShPFTX2070tDs5kB9Ng==", "dev": true }, "find-up": { @@ -2103,7 +2103,7 @@ "supports-color": { "version": "5.3.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.3.0.tgz", - "integrity": "sha1-WySsFduA+pJ89SJ6SjP9PEx2dsA=", + "integrity": "sha512-0aP01LLIskjKs3lq52EC0aGBAJhLq7B2Rd8HC/DR/PtNNpcLilNmHC12O+hu0usQpo7wtHNRqtrhBwtDb0+dNg==", "dev": true, "requires": { "has-flag": "3.0.0" @@ -2567,7 +2567,7 @@ "glob": { "version": "7.1.2", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", - "integrity": "sha1-wZyd+aAocC1nhhI4SmVSQExjbRU=", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", "dev": true, "requires": { "fs.realpath": "1.0.0", @@ -2672,7 +2672,7 @@ "growl": { "version": "1.10.3", "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.3.tgz", - "integrity": "sha1-GSa6kM8+3+KttJJ/WIC8IsZseQ8=", + "integrity": "sha512-hKlsbA5Vu3xsh1Cg3J7jSmX/WaW6A5oBeqzM88oNbCRQFz+zUaXm6yxS4RVytp1scBoJzSYl4YAEOQIt6O8V1Q==", "dev": true }, "handlebars": { @@ -2738,7 +2738,7 @@ "hawk": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/hawk/-/hawk-6.0.2.tgz", - "integrity": "sha1-r02RTrBl+bXOTZ0RwcshJu7MMDg=", + "integrity": "sha512-miowhl2+U7Qle4vdLqDdPt9m09K6yZhkLDTWGoUiUzrQCn+mHHSmfJgAyGaLRZbPmTqfFFjRV1QWCW0VWUJBbQ==", "dev": true, "requires": { "boom": "4.3.1", @@ -2756,7 +2756,7 @@ "hoek": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/hoek/-/hoek-4.2.1.tgz", - "integrity": "sha1-ljRQKqEsRF3Vp8VzS1cruHOKrLs=", + "integrity": "sha512-QLg82fGkfnJ/4iy1xZ81/9SIJiq1NGFUMGs6ParyjBZr6jW2Ufj/snDqTHixNlHdPNwN2RLVD0Pi3igeK9+JfA==", "dev": true }, "home-path": { @@ -2791,7 +2791,7 @@ "ignore": { "version": "3.3.7", "resolved": "https://registry.npmjs.org/ignore/-/ignore-3.3.7.tgz", - "integrity": "sha1-YSKJv7PCIOGGpYEYYY1b6MG6sCE=", + "integrity": "sha512-YGG3ejvBNHRqu0559EOxxNFihD0AjpvHlC/pdGKd3X3ofe+CoJkYazwNJYTNebqpPKN+VVQbh4ZFn1DivMNuHA==", "dev": true }, "imurmurhash": { @@ -2828,7 +2828,7 @@ "ini": { "version": "1.3.5", "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", - "integrity": "sha1-7uJfVtscnsYIXgwid4CD9Zar+Sc=", + "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==", "dev": true }, "inquirer": { @@ -2901,7 +2901,7 @@ "is-buffer": { "version": "1.1.6", "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", - "integrity": "sha1-76ouqdqg16suoTqXsritUf776L4=", + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", "dev": true }, "is-builtin-module": { @@ -3054,7 +3054,7 @@ "is-resolvable": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/is-resolvable/-/is-resolvable-1.1.0.tgz", - "integrity": "sha1-+xj4fOH+uSUWnJpAfBkxijIG7Yg=", + "integrity": "sha512-qgDYXFSR5WvEfuS5dMj6oTMEbrrSaM0CrFk2Yiq/gXnBvD9pMa2jGXxyhGLfvhZpuMZe18CJpFxAt3CRs42NMg==", "dev": true }, "is-retry-allowed": { @@ -3204,7 +3204,7 @@ "js-yaml": { "version": "3.11.0", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.11.0.tgz", - "integrity": "sha1-WXwai9VxUvJtYizkEXhRpR9euu8=", + "integrity": "sha512-saJstZWv7oNeOyBh3+Dx1qWzhW0+e6/8eDzo7p5rDFqxntSztloLtuKu+Ejhtq82jsilwOIZYsCz+lIjthg1Hw==", "dev": true, "requires": { "argparse": "1.0.10", @@ -3324,7 +3324,7 @@ "just-extend": { "version": "1.1.27", "resolved": "https://registry.npmjs.org/just-extend/-/just-extend-1.1.27.tgz", - "integrity": "sha1-7G55QQ/5FORyZSq/oOYDwD1g6QU=", + "integrity": "sha512-mJVp13Ix6gFo3SBAy9U/kL+oeZqzlYYYLQBwXVBlVzIsZwBqGREnOro24oC/8s8aox+rJhtZ2DiQof++IrkA+g==", "dev": true }, "kind-of": { @@ -3703,7 +3703,7 @@ "lodash": { "version": "4.17.5", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.5.tgz", - "integrity": "sha1-maktZcAnLevoyWtgV7yPv6O+1RE=", + "integrity": "sha512-svL3uiZf1RwhH+cWrfZn3A4+U58wbP0tGVTLQPbjplZxZ8ROD9VLuNgsRniTlLe7OlSqR79RUehXgpBW/s0IQw==", "dev": true }, "lodash._reinterpolate": { @@ -3740,7 +3740,7 @@ "lolex": { "version": "2.3.2", "resolved": "https://registry.npmjs.org/lolex/-/lolex-2.3.2.tgz", - "integrity": "sha1-hflFBCUQO/nnpgZo6iXcQydMqAc=", + "integrity": "sha512-A5pN2tkFj7H0dGIAM6MFvHKMJcPnjZsOMvR7ujCjfgW5TbV6H9vb1PgxLtHvjqNZTHsUolz+6/WEO0N1xNx2ng==", "dev": true }, "longest": { @@ -3816,7 +3816,7 @@ "marked": { "version": "0.3.17", "resolved": "https://registry.npmjs.org/marked/-/marked-0.3.17.tgz", - "integrity": "sha1-YH8GZos8axJGso8T2nYRasGqLSs=", + "integrity": "sha512-+AKbNsjZl6jFfLPwHhWmGTqE009wTKn3RTmn9K8oUKHrX/abPJjtcRtXpYB/FFrwPJRUA86LX/de3T0knkPCmQ==", "dev": true }, "mem": { @@ -3896,13 +3896,13 @@ "mime-db": { "version": "1.33.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.33.0.tgz", - "integrity": "sha1-o0kgUKXLm2NFBUHjnZeI0icng9s=", + "integrity": "sha512-BHJ/EKruNIqJf/QahvxwQZXKygOQ256myeN/Ew+THcAa5q+PjyTTMMeNQC4DZw5AwfvelsUrA6B67NKMqXDbzQ==", "dev": true }, "mime-types": { "version": "2.1.18", "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.18.tgz", - "integrity": "sha1-bzI/YKg9ERRvgx/xH9ZuL+VQO7g=", + "integrity": "sha512-lc/aahn+t4/SWV/qcmumYjymLsWfN3ELhpmVuUFjgsORruuZPVSwAQryq+HHGvO/SI2KVX26bx+En+zhM8g8hQ==", "dev": true, "requires": { "mime-db": "1.33.0" @@ -3917,7 +3917,7 @@ "minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha1-UWbihkV/AzBgZL5Ul+jbsMPTIIM=", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "dev": true, "requires": { "brace-expansion": "1.1.11" @@ -4071,7 +4071,7 @@ "normalize-package-data": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.4.0.tgz", - "integrity": "sha1-EvlaMH1YNSB1oEkHuErIvpisAS8=", + "integrity": "sha512-9jjUFbTPfEy3R/ad/2oNbKtW9Hgovl5O1FvFWKkKblNXoN/Oou6+9+KKohPK13Yc3/TyunyWhJp6gvRNR/PPAw==", "dev": true, "requires": { "hosted-git-info": "2.5.0", @@ -4511,7 +4511,7 @@ "process-nextick-args": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", - "integrity": "sha1-o31zL0JxtKsa0HDTVQjoKQeI/6o=", + "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==", "dev": true }, "progress": { @@ -4584,7 +4584,7 @@ "qs": { "version": "6.5.1", "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.1.tgz", - "integrity": "sha1-NJzfbu+J7EXBLX1es/wMhwNDptg=", + "integrity": "sha512-eRzhrN1WSINYCDCbrz796z37LOe3m5tmW7RQf6oBntukAG1nmovJvhnwHHRMAfeoItc1m2Hk02WER2aQ/iqs+A==", "dev": true }, "quick-lru": { @@ -4596,7 +4596,7 @@ "randomatic": { "version": "1.1.7", "resolved": "https://registry.npmjs.org/randomatic/-/randomatic-1.1.7.tgz", - "integrity": "sha1-x6vpzIuHwLqodrGf3oP9RkeX44w=", + "integrity": "sha512-D5JUjPyJbaJDkuAazpVnSfVkLlpeO3wDlPROTMLGKG1zMFNFRgrciKo1ltz/AzNTkqE0HzDx655QOL51N06how==", "dev": true, "requires": { "is-number": "3.0.0", @@ -4701,7 +4701,7 @@ "regex-cache": { "version": "0.4.4", "resolved": "https://registry.npmjs.org/regex-cache/-/regex-cache-0.4.4.tgz", - "integrity": "sha1-db3FiioUls7EihKDW8VMjVYjNt0=", + "integrity": "sha512-nVIZwtCjkC9YgvWkpM55B5rBhBYRZhAaJbgcFYXXsHnbZ9UZI9nnVWYZpBlCqv9ho2eZryPnWrZGsOdPwVWXWQ==", "dev": true, "requires": { "is-equal-shallow": "0.1.3" @@ -4729,7 +4729,7 @@ "remap-istanbul": { "version": "0.10.1", "resolved": "https://registry.npmjs.org/remap-istanbul/-/remap-istanbul-0.10.1.tgz", - "integrity": "sha1-OqWN1QIdSZ8zbTulvzu7kcG4jjc=", + "integrity": "sha512-gsNQXs5kJLhErICSyYhzVZ++C8LBW8dgwr874Y2QvzAUS75zBlD/juZgXs39nbYJ09fZDlX2AVLVJAY2jbFJoQ==", "dev": true, "requires": { "amdefine": "1.0.1", @@ -4769,7 +4769,7 @@ "source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha1-dHIq8y6WFOnCh6jQu95IteLxomM=", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", "dev": true }, "through2": { @@ -4883,7 +4883,7 @@ "resolve": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.5.0.tgz", - "integrity": "sha1-HwmsznlsmnYlefMbLBzEw83fnzY=", + "integrity": "sha512-hgoSGrc3pjzAPHNBg+KnFcK2HwlHTs/YrAGUr6qgTVUZmXv1UEXXl0bZNBKMA9fud6lRYFdPGz0xXxycPzmmiw==", "dev": true, "requires": { "path-parse": "1.0.5" @@ -4924,7 +4924,7 @@ "rimraf": { "version": "2.6.2", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", - "integrity": "sha1-LtgVDSShbqhlHm1u8PR8QVjOejY=", + "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", "dev": true, "requires": { "glob": "7.1.2" @@ -5063,19 +5063,19 @@ "safe-buffer": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", - "integrity": "sha1-iTMSr2myEj3vcfV4iQAWce6yyFM=", + "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", "dev": true }, "samsam": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/samsam/-/samsam-1.3.0.tgz", - "integrity": "sha1-jR2TUOJWItow3j5EumkrUiGrfFA=", + "integrity": "sha512-1HwIYD/8UlOtFS3QO3w7ey+SdSDFE4HRNLZoZRYVQefrOY3l17epswImeB1ijgJFQJodIaHcwkp3r/myBjFVbg==", "dev": true }, "semver": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz", - "integrity": "sha1-3Eu8emyp2Rbe5dQ1FvAJK1j3uKs=", + "integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==", "dev": true }, "set-blocking": { @@ -5117,7 +5117,7 @@ "sinon-chai": { "version": "2.14.0", "resolved": "https://registry.npmjs.org/sinon-chai/-/sinon-chai-2.14.0.tgz", - "integrity": "sha1-2n3UzIPNaiYLZ8yg96n9riahIF0=", + "integrity": "sha512-9stIF1utB0ywNHNT7RgiXbdmen8QDCRsrTjw+G9TgKt1Yexjiv8TOWZ6WHsTPz57Yky3DIswZvEqX8fpuHNDtQ==", "dev": true }, "slash": { @@ -5146,7 +5146,7 @@ "sntp": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/sntp/-/sntp-2.1.0.tgz", - "integrity": "sha1-LGzsFP7cIiJznK+bXD2F0cxaLMg=", + "integrity": "sha512-FL1b58BDrqS3A11lJ0zEdnJ3UOKqVxawAkF3k7F0CVN7VQ34aZrV+G8BZ1WC9ZL7NyrwsW0oviwsWDgRuVYtJg==", "dev": true, "requires": { "hoek": "4.2.1" @@ -5203,7 +5203,7 @@ "spdx-correct": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.0.0.tgz", - "integrity": "sha1-BaW01xU6GVvJLDxCW2nzsqlSTII=", + "integrity": "sha512-N19o9z5cEyc8yQQPukRCZ9EUmb4HUpnrmaL/fxS2pBo2jbfcFRVuFZ/oFC+vZz0MNNk0h80iMn5/S6qGZOL5+g==", "dev": true, "requires": { "spdx-expression-parse": "3.0.0", @@ -5213,13 +5213,13 @@ "spdx-exceptions": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.1.0.tgz", - "integrity": "sha1-LHrmEFbHFKW5ubKyr30xHvXHj+k=", + "integrity": "sha512-4K1NsmrlCU1JJgUrtgEeTVyfx8VaYea9J9LvARxhbHtVtohPs/gFGG5yy49beySjlIMhhXZ4QqujIZEfS4l6Cg==", "dev": true }, "spdx-expression-parse": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.0.tgz", - "integrity": "sha1-meEZt6XaAOBUkcn6M4t5BII7QdA=", + "integrity": "sha512-Yg6D3XpRD4kkOmTpdgbUiEJFKghJH03fiC1OPll5h/0sO6neh2jqRDVHOQ4o/LMea0tgCkbMgea5ip/e+MkWyg==", "dev": true, "requires": { "spdx-exceptions": "2.1.0", @@ -5229,7 +5229,7 @@ "spdx-license-ids": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.0.tgz", - "integrity": "sha1-enzShHDMbToc/m1miG9rxDDTrIc=", + "integrity": "sha512-2+EPwgbnmOIl8HjGBXXMd9NAu02vLjOO1nWw4kmeRDFyHn+M/ETfHxQUK0oXg8ctgVnl9t3rosNVsZ1jG61nDA==", "dev": true }, "speedometer": { @@ -5566,7 +5566,7 @@ "tough-cookie": { "version": "2.3.4", "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.4.tgz", - "integrity": "sha1-7GDO44rGdQY//JelwYlwV47oNlU=", + "integrity": "sha512-TZ6TTfI5NtZnuyy/Kecv+CnoROnyXn2DN97LontgQpCwsX2XyLYCC0ENhYkehSOwAp8rTQKc/NUIF7BkQ5rKLA==", "dev": true, "requires": { "punycode": "1.4.1" @@ -5708,13 +5708,13 @@ "uuid": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.2.1.tgz", - "integrity": "sha1-EsUou51Y0LkmXZovbw/ovhf/HxQ=", + "integrity": "sha512-jZnMwlb9Iku/O3smGWvZhauCf6cvvpKi4BKRiliS3cxnI+Gz9j5MEpTz2UFuXiKPJocb7gnsLHwiS05ige5BEA==", "dev": true }, "validate-npm-package-license": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.3.tgz", - "integrity": "sha1-gWQ7y+8b3+zUYjeT3EZIlIupgzg=", + "integrity": "sha512-63ZOUnL4SIXj4L0NixR3L1lcjO38crAbgrTpl28t8jjrfuiOBL5Iygm+60qPs/KsZGzPNg6Smnc/oY16QTjF0g==", "dev": true, "requires": { "spdx-correct": "3.0.0", @@ -5750,7 +5750,7 @@ "which": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/which/-/which-1.3.0.tgz", - "integrity": "sha1-/wS9/AEO5UfXgL7DjhrBwnd9JTo=", + "integrity": "sha512-xcJpopdamTuY5duC/KnTTNBraPK54YwpenP4lzxU8H91GudWpFv38u0CKjclE1Wi2EH2EDz5LRcHcKbCIzqGyg==", "dev": true, "requires": { "isexe": "2.0.0" diff --git a/packages/canvas/canvas-mesh/package.json b/packages/canvas/canvas-mesh/package.json index 691cd2c..6744a17 100644 --- a/packages/canvas/canvas-mesh/package.json +++ b/packages/canvas/canvas-mesh/package.json @@ -24,6 +24,7 @@ "dependencies": { "@pixi/constants": "^5.0.0-alpha.2", "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/mesh-extras": "^5.0.0-alpha.2", "@pixi/settings": "^5.0.0-alpha.2" }, "devDependencies": { diff --git a/packages/canvas/canvas-mesh/src/Mesh.js b/packages/canvas/canvas-mesh/src/Mesh.js index 900a872..c43a74b 100644 --- a/packages/canvas/canvas-mesh/src/Mesh.js +++ b/packages/canvas/canvas-mesh/src/Mesh.js @@ -1,36 +1,14 @@ import { Mesh } from '@pixi/mesh'; -import { settings } from './settings'; - -// IMPORTANT: Please do NOT use this as a precedent to use `settings` after the object is created -// this was merely created to completely decouple canvas from the base Mesh class and we are -// unable to add `canvasPadding` in the constructor anymore, as the case was for PixiJS v4. /** - * Internal variable for `canvasPadding`. + * Renders the object using the Canvas renderer * * @private - * @memberof PIXI.Mesh - * @member {number} - * @default null - */ -Mesh.prototype._canvasPadding = null; - -/** - * Triangles in canvas mode are automatically antialiased, use this value to force triangles - * to overlap a bit with each other. To set the global default, set {@link PIXI.settings.MESH_CANVAS_PADDING} - * - * @see PIXI.settings.MESH_CANVAS_PADDING - * @member {number} canvasPadding + * @method _renderCanvas * @memberof PIXI.Mesh# - * @default 0 + * @param {PIXI.CanvasRenderer} renderer - The canvas renderer. */ -Object.defineProperty(Mesh.prototype, 'canvasPadding', { - get() - { - return this._canvasPadding !== null ? this._canvasPadding : settings.MESH_CANVAS_PADDING; - }, - set(value) - { - this._canvasPadding = value; - }, -}); +Mesh.prototype._renderCanvas = function _renderCanvas(renderer) +{ + renderer.plugins[this.pluginName].render(this); +}; diff --git a/packages/canvas/canvas-mesh/src/Mesh2d.js b/packages/canvas/canvas-mesh/src/Mesh2d.js new file mode 100644 index 0000000..d0bd80f --- /dev/null +++ b/packages/canvas/canvas-mesh/src/Mesh2d.js @@ -0,0 +1,36 @@ +import { Mesh2d } from '@pixi/mesh-extras'; +import { settings } from './settings'; + +// IMPORTANT: Please do NOT use this as a precedent to use `settings` after the object is created +// this was merely created to completely decouple canvas from the base Mesh class and we are +// unable to add `canvasPadding` in the constructor anymore, as the case was for PixiJS v4. + +/** + * Internal variable for `canvasPadding`. + * + * @private + * @memberof PIXI.Mesh2d + * @member {number} + * @default null + */ +Mesh2d.prototype._canvasPadding = null; + +/** + * Triangles in canvas mode are automatically antialiased, use this value to force triangles + * to overlap a bit with each other. To set the global default, set {@link PIXI.settings.MESH_CANVAS_PADDING} + * + * @see PIXI.settings.MESH_CANVAS_PADDING + * @member {number} canvasPadding + * @memberof PIXI.Mesh2d# + * @default 0 + */ +Object.defineProperty(Mesh2d.prototype, 'canvasPadding', { + get() + { + return this._canvasPadding !== null ? this._canvasPadding : settings.MESH_CANVAS_PADDING; + }, + set(value) + { + this._canvasPadding = value; + }, +}); diff --git a/packages/canvas/canvas-mesh/src/NineSlicePlane.js b/packages/canvas/canvas-mesh/src/NineSlicePlane.js index 09eaf9c..2fd5acc 100644 --- a/packages/canvas/canvas-mesh/src/NineSlicePlane.js +++ b/packages/canvas/canvas-mesh/src/NineSlicePlane.js @@ -1,4 +1,4 @@ -import { NineSlicePlane } from '@pixi/mesh'; +import { NineSlicePlane } from '@pixi/mesh-extras'; /** * Renders the object using the Canvas renderer diff --git a/packages/canvas/canvas-mesh/src/RawMesh.js b/packages/canvas/canvas-mesh/src/RawMesh.js deleted file mode 100644 index bf40184..0000000 --- a/packages/canvas/canvas-mesh/src/RawMesh.js +++ /dev/null @@ -1,14 +0,0 @@ -import { RawMesh } from '@pixi/mesh'; - -/** - * Renders the object using the Canvas renderer - * - * @private - * @method _renderCanvas - * @memberof PIXI.RawMesh# - * @param {PIXI.CanvasRenderer} renderer - The canvas renderer. - */ -RawMesh.prototype._renderCanvas = function _renderCanvas(renderer) -{ - renderer.plugins[this.pluginName].render(this); -}; diff --git a/packages/canvas/canvas-mesh/src/index.js b/packages/canvas/canvas-mesh/src/index.js index 2295016..f4fa31d 100644 --- a/packages/canvas/canvas-mesh/src/index.js +++ b/packages/canvas/canvas-mesh/src/index.js @@ -1,6 +1,6 @@ export { default as CanvasMeshRenderer } from './CanvasMeshRenderer'; import './settings'; -import './Mesh'; +import './Mesh2d'; import './NineSlicePlane'; -import './RawMesh'; +import './Mesh'; diff --git a/packages/canvas/canvas-mesh/src/settings.js b/packages/canvas/canvas-mesh/src/settings.js index 4cefb4c..e81b8e0 100644 --- a/packages/canvas/canvas-mesh/src/settings.js +++ b/packages/canvas/canvas-mesh/src/settings.js @@ -3,7 +3,7 @@ /** * Default `canvasPadding` for canvas-based Mesh rendering. * - * @see PIXI.Mesh#canvasPadding + * @see PIXI.Mesh2d#canvasPadding * @static * @constant * @memberof PIXI.settings diff --git a/packages/mesh-extras/LICENSE b/packages/mesh-extras/LICENSE new file mode 100644 index 0000000..148e3eb --- /dev/null +++ b/packages/mesh-extras/LICENSE @@ -0,0 +1,21 @@ +The MIT License + +Copyright (c) 2013-2018 Mathew Groves, Chad Engler + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/packages/mesh-extras/README.md b/packages/mesh-extras/README.md new file mode 100644 index 0000000..1d9b0e1 --- /dev/null +++ b/packages/mesh-extras/README.md @@ -0,0 +1,19 @@ +# @pixi/mesh-extras + +## Installation + +```bash +npm install @pixi/mesh-extras +``` + +## Usage + +```js +import { MeshRenderer } from '@pixi/mesh'; +import { Renderer } from '@pixi/core'; +import { Rope } from '@pixi/mesh-extras'; + +Renderer.registerPlugin('mesh', MeshRenderer); + +const rope = new Rope(); +``` \ No newline at end of file diff --git a/packages/mesh-extras/package.json b/packages/mesh-extras/package.json new file mode 100644 index 0000000..d134f64 --- /dev/null +++ b/packages/mesh-extras/package.json @@ -0,0 +1,38 @@ +{ + "name": "@pixi/mesh-extras", + "version": "5.0.0-alpha.2", + "main": "lib/mesh-extras.js", + "module": "lib/mesh-extras.es.js", + "description": "Custom Mesh display objects, like Rope and Plane", + "author": "Mat Groves", + "contributors": [ + "Matt Karl " + ], + "homepage": "http://pixijs.com/", + "bugs": "https://github.com/pixijs/pixi.js/issues", + "license": "MIT", + "repository": { + "type": "git", + "url": "https://github.com/pixijs/pixi.js.git" + }, + "publishConfig": { + "access": "public" + }, + "scripts": { + "test": "floss --path test" + }, + "files": [ + "lib" + ], + "dependencies": { + "@pixi/constants": "^5.0.0-alpha.2", + "@pixi/core": "^5.0.0-alpha.2", + "@pixi/math": "^5.0.0-alpha.2", + "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/utils": "^5.0.0-alpha.2" + }, + "devDependencies": { + "@pixi/loaders": "^5.0.0-alpha.2", + "floss": "^2.1.3" + } +} diff --git a/packages/mesh-extras/src/Mesh2d.js b/packages/mesh-extras/src/Mesh2d.js new file mode 100644 index 0000000..d113a5e --- /dev/null +++ b/packages/mesh-extras/src/Mesh2d.js @@ -0,0 +1,263 @@ +import { Mesh } from '@pixi/mesh'; +import { Geometry, Program, Shader, Texture, TextureMatrix } from '@pixi/core'; +import { Matrix } from '@pixi/math'; +import { BLEND_MODES } from '@pixi/constants'; +import { hex2rgb, premultiplyRgba } from '@pixi/utils'; +import vertex from './mesh.vert'; +import fragment from './mesh.frag'; + +let meshProgram; + +/** + * Base mesh class + * @class + * @extends PIXI.Container + * @memberof PIXI + */ +export default class Mesh2d extends Mesh +{ + /** + * @param {PIXI.Texture} [texture=Texture.EMPTY] - The texture to use + * @param {Float32Array} [vertices] - if you want to specify the vertices + * @param {Float32Array} [uvs] - if you want to specify the uvs + * @param {Uint16Array} [indices] - if you want to specify the indices + * @param {number} [drawMode] - the drawMode, can be any of the Mesh.DRAW_MODES consts + */ + constructor(texture = Texture.EMPTY, vertices, uvs, indices, drawMode) + { + const geometry = new Geometry(); + + if (!meshProgram) + { + meshProgram = new Program(vertex, fragment); + } + + geometry.addAttribute('aVertexPosition', vertices) + .addAttribute('aTextureCoord', uvs) + .addIndex(indices); + + geometry.getAttribute('aVertexPosition').static = false; + + const uniforms = { + uSampler: texture, + uTextureMatrix: Matrix.IDENTITY, + alpha: 1, + uColor: new Float32Array([1, 1, 1, 1]), + }; + + super(geometry, new Shader(meshProgram, uniforms), null, drawMode); + + /** + * The Uvs of the Mesh + * + * @member {Float32Array} + */ + this.uvs = geometry.getAttribute('aTextureCoord').data; + + /** + * An array of vertices + * + * @member {Float32Array} + */ + this.vertices = geometry.getAttribute('aVertexPosition').data; + + this.uniforms = uniforms; + + /** + * The texture of the Mesh + * + * @member {PIXI.Texture} + * @default PIXI.Texture.EMPTY + * @private + */ + this.texture = texture; + + /** + * The tint applied to the mesh. This is a [r,g,b] value. A value of [1,1,1] will remove any + * tint effect. + * + * @member {number} + * @private + */ + this._tintRGB = new Float32Array([1, 1, 1]); + + // Set default tint + this.tint = 0xFFFFFF; + + this.blendMode = BLEND_MODES.NORMAL; + + /** + * TextureMatrix instance for this Mesh, used to track Texture changes + * + * @member {PIXI.TextureMatrix} + * @readonly + */ + this.uvMatrix = new TextureMatrix(this._texture); + + /** + * whether or not upload uvMatrix to shader + * if its false, then uvs should be pre-multiplied + * if you change it for generated mesh, please call 'refresh(true)' + * @member {boolean} + * @default false + */ + this.uploadUvMatrix = false; + + /** + * Uploads vertices buffer every frame, like in PixiJS V3 and V4. + * + * @member {boolean} + * @default true + */ + this.autoUpdate = true; + } + + /** + * The tint applied to the Rope. This is a hex value. A value of + * 0xFFFFFF will remove any tint effect. + * + * @member {number} + * @memberof PIXI.Sprite# + * @default 0xFFFFFF + */ + get tint() + { + return this._tint; + } + + /** + * Sets the tint of the rope. + * + * @param {number} value - The value to set to. + */ + set tint(value) + { + this._tint = value; + + hex2rgb(this._tint, this._tintRGB); + } + + /** + * The blend mode to be applied to the sprite. Set to `PIXI.BLEND_MODES.NORMAL` to remove any blend mode. + * + * @member {number} + * @default PIXI.BLEND_MODES.NORMAL + * @see PIXI.BLEND_MODES + */ + get blendMode() + { + return this.state.blendMode; + } + + set blendMode(value) // eslint-disable-line require-jsdoc + { + this.state.blendMode = value; + } + + /** + * The texture that the mesh uses. + * + * @member {PIXI.Texture} + */ + get texture() + { + return this._texture; + } + + set texture(value) // eslint-disable-line require-jsdoc + { + if (this._texture === value) + { + return; + } + + this._texture = value; + this.uniforms.uSampler = this.texture; + + if (value) + { + // wait for the texture to load + if (value.baseTexture.valid) + { + this._onTextureUpdate(); + } + else + { + value.once('update', this._onTextureUpdate, this); + } + } + } + + _render(renderer) + { + const baseTex = this._texture.baseTexture; + + premultiplyRgba(this._tintRGB, this.worldAlpha, this.uniforms.uColor, baseTex.premultiplyAlpha); + super._render(renderer); + } + /** + * When the texture is updated, this event will fire to update the scale and frame + * + * @private + */ + _onTextureUpdate() + { + // constructor texture update stop + if (!this.uvMatrix) + { + return; + } + this.uvMatrix.texture = this._texture; + this.refresh(); + } + + /** + * multiplies uvs only if uploadUvMatrix is false + * call it after you change uvs manually + * make sure that texture is valid + */ + multiplyUvs() + { + if (!this.uploadUvMatrix) + { + this.uvMatrix.multiplyUvs(this.uvs); + } + } + + /** + * Refreshes uvs for generated meshes (rope, plane) + * sometimes refreshes vertices too + * + * @param {boolean} [forceUpdate=false] if true, matrices will be updated any case + */ + refresh(forceUpdate) + { + if (this.uvMatrix.update(forceUpdate)) + { + this._refresh(); + } + } + + /** + * Updates the object transform for rendering + * + * @private + */ + updateTransform() + { + if (this.autoUpdate) + { + this.geometry.buffers[0].update(); + } + this.containerUpdateTransform(); + } + + /** + * re-calculates mesh coords + * @private + */ + _refresh() + { + /* empty */ + } +} diff --git a/packages/mesh-extras/src/NineSlicePlane.js b/packages/mesh-extras/src/NineSlicePlane.js new file mode 100644 index 0000000..0bae92c --- /dev/null +++ b/packages/mesh-extras/src/NineSlicePlane.js @@ -0,0 +1,270 @@ +import Plane from './Plane'; + +const DEFAULT_BORDER_SIZE = 10; + +/** + * The NineSlicePlane allows you to stretch a texture using 9-slice scaling. The corners will remain unscaled (useful + * for buttons with rounded corners for example) and the other areas will be scaled horizontally and or vertically + * + *```js + * let Plane9 = new PIXI.NineSlicePlane(PIXI.Texture.from('BoxWithRoundedCorners.png'), 15, 15, 15, 15); + * ``` + *
+ *      A                          B
+ *    +---+----------------------+---+
+ *  C | 1 |          2           | 3 |
+ *    +---+----------------------+---+
+ *    |   |                      |   |
+ *    | 4 |          5           | 6 |
+ *    |   |                      |   |
+ *    +---+----------------------+---+
+ *  D | 7 |          8           | 9 |
+ *    +---+----------------------+---+
+
+ *  When changing this objects width and/or height:
+ *     areas 1 3 7 and 9 will remain unscaled.
+ *     areas 2 and 8 will be stretched horizontally
+ *     areas 4 and 6 will be stretched vertically
+ *     area 5 will be stretched both horizontally and vertically
+ * 
+ * + * @class + * @extends PIXI.Plane + * @memberof PIXI + * + */ +export default class NineSlicePlane extends Plane +{ + /** + * @param {PIXI.Texture} texture - The texture to use on the NineSlicePlane. + * @param {int} [leftWidth=10] size of the left vertical bar (A) + * @param {int} [topHeight=10] size of the top horizontal bar (C) + * @param {int} [rightWidth=10] size of the right vertical bar (B) + * @param {int} [bottomHeight=10] size of the bottom horizontal bar (D) + */ + constructor(texture, leftWidth, topHeight, rightWidth, bottomHeight) + { + super(texture, 4, 4); + + this._origWidth = texture.orig.width; + this._origHeight = texture.orig.height; + + /** + * The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._width = this._origWidth; + + /** + * The height of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._height = this._origHeight; + + /** + * The width of the left column (a) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._leftWidth = typeof leftWidth !== 'undefined' ? leftWidth : DEFAULT_BORDER_SIZE; + + /** + * The width of the right column (b) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._rightWidth = typeof rightWidth !== 'undefined' ? rightWidth : DEFAULT_BORDER_SIZE; + + /** + * The height of the top row (c) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._topHeight = typeof topHeight !== 'undefined' ? topHeight : DEFAULT_BORDER_SIZE; + + /** + * The height of the bottom row (d) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._bottomHeight = typeof bottomHeight !== 'undefined' ? bottomHeight : DEFAULT_BORDER_SIZE; + + this.refresh(true); + } + + /** + * Updates the horizontal vertices. + * + */ + updateHorizontalVertices() + { + const vertices = this.vertices; + + const h = this._topHeight + this._bottomHeight; + const scale = this._height > h ? 1.0 : this._height / h; + + vertices[9] = vertices[11] = vertices[13] = vertices[15] = this._topHeight * scale; + vertices[17] = vertices[19] = vertices[21] = vertices[23] = this._height - (this._bottomHeight * scale); + vertices[25] = vertices[27] = vertices[29] = vertices[31] = this._height; + } + + /** + * Updates the vertical vertices. + * + */ + updateVerticalVertices() + { + const vertices = this.vertices; + + const w = this._leftWidth + this._rightWidth; + const scale = this._width > w ? 1.0 : this._width / w; + + vertices[2] = vertices[10] = vertices[18] = vertices[26] = this._leftWidth * scale; + vertices[4] = vertices[12] = vertices[20] = vertices[28] = this._width - (this._rightWidth * scale); + vertices[6] = vertices[14] = vertices[22] = vertices[30] = this._width; + } + + /** + * The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + */ + get width() + { + return this._width; + } + + set width(value) // eslint-disable-line require-jsdoc + { + this._width = value; + this._refresh(); + } + + /** + * The height of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + */ + get height() + { + return this._height; + } + + set height(value) // eslint-disable-line require-jsdoc + { + this._height = value; + this._refresh(); + } + + /** + * The width of the left column + * + * @member {number} + */ + get leftWidth() + { + return this._leftWidth; + } + + set leftWidth(value) // eslint-disable-line require-jsdoc + { + this._leftWidth = value; + this._refresh(); + } + + /** + * The width of the right column + * + * @member {number} + */ + get rightWidth() + { + return this._rightWidth; + } + + set rightWidth(value) // eslint-disable-line require-jsdoc + { + this._rightWidth = value; + this._refresh(); + } + + /** + * The height of the top row + * + * @member {number} + */ + get topHeight() + { + return this._topHeight; + } + + set topHeight(value) // eslint-disable-line require-jsdoc + { + this._topHeight = value; + this._refresh(); + } + + /** + * The height of the bottom row + * + * @member {number} + */ + get bottomHeight() + { + return this._bottomHeight; + } + + set bottomHeight(value) // eslint-disable-line require-jsdoc + { + this._bottomHeight = value; + this._refresh(); + } + + /** + * Refreshes NineSlicePlane coords. All of them. + */ + _refresh() + { + super._refresh(); + + const uvs = this.uvs; + const texture = this._texture; + + this._origWidth = texture.orig.width; + this._origHeight = texture.orig.height; + + const _uvw = 1.0 / this._origWidth; + const _uvh = 1.0 / this._origHeight; + + uvs[0] = uvs[8] = uvs[16] = uvs[24] = 0; + uvs[1] = uvs[3] = uvs[5] = uvs[7] = 0; + uvs[6] = uvs[14] = uvs[22] = uvs[30] = 1; + uvs[25] = uvs[27] = uvs[29] = uvs[31] = 1; + + uvs[2] = uvs[10] = uvs[18] = uvs[26] = _uvw * this._leftWidth; + uvs[4] = uvs[12] = uvs[20] = uvs[28] = 1 - (_uvw * this._rightWidth); + uvs[9] = uvs[11] = uvs[13] = uvs[15] = _uvh * this._topHeight; + uvs[17] = uvs[19] = uvs[21] = uvs[23] = 1 - (_uvh * this._bottomHeight); + + this.updateHorizontalVertices(); + this.updateVerticalVertices(); + + this.geometry.buffers[1].update(); + + this.multiplyUvs(); + } +} diff --git a/packages/mesh-extras/src/Plane.js b/packages/mesh-extras/src/Plane.js new file mode 100644 index 0000000..1c240c4 --- /dev/null +++ b/packages/mesh-extras/src/Plane.js @@ -0,0 +1,100 @@ +import Mesh2d from './Mesh2d'; + +/** + * The Plane allows you to draw a texture across several points and them manipulate these points + * + *```js + * for (let i = 0; i < 20; i++) { + * points.push(new PIXI.Point(i * 50, 0)); + * }; + * let Plane = new PIXI.Plane(PIXI.Texture.from("snake.png"), points); + * ``` + * + * @class + * @extends PIXI.Mesh + * @memberof PIXI + * + */ +export default class Plane extends Mesh2d +{ + /** + * @param {PIXI.Texture} texture - The texture to use on the Plane. + * @param {number} verticesX - The number of vertices in the x-axis + * @param {number} verticesY - The number of vertices in the y-axis + * @param {object} [opts] - an options object - add meshWidth and meshHeight, temporary object for PixiJS v5 alpha + */ + constructor(texture, verticesX, verticesY, opts = {}) + { + super(texture, new Float32Array(1), new Float32Array(1), new Uint16Array(1), 4); + + this.verticesX = verticesX || 10; + this.verticesY = verticesY || 10; + + this.meshWidth = opts.meshWidth || 0; + this.meshHeight = opts.meshHeight || 0; + + this.refresh(); + } + + /** + * Refreshes plane coordinates + * @private + */ + _refresh() + { + const texture = this._texture; + const total = this.verticesX * this.verticesY; + const verts = []; + const uvs = []; + const indices = []; + + const segmentsX = this.verticesX - 1; + const segmentsY = this.verticesY - 1; + + const sizeX = (this.meshWidth || texture.width) / segmentsX; + const sizeY = (this.meshHeight || texture.height) / segmentsY; + + for (let i = 0; i < total; i++) + { + const x = (i % this.verticesX); + const y = ((i / this.verticesX) | 0); + + verts.push(x * sizeX, y * sizeY); + + uvs.push(x / segmentsX, y / segmentsY); + } + + // cons + + const totalSub = segmentsX * segmentsY; + + for (let i = 0; i < totalSub; i++) + { + const xpos = i % segmentsX; + const ypos = (i / segmentsX) | 0; + + const value = (ypos * this.verticesX) + xpos; + const value2 = (ypos * this.verticesX) + xpos + 1; + const value3 = ((ypos + 1) * this.verticesX) + xpos; + const value4 = ((ypos + 1) * this.verticesX) + xpos + 1; + + indices.push(value, value2, value3); + indices.push(value2, value4, value3); + } + + this.vertices = new Float32Array(verts); + this.uvs = new Float32Array(uvs); + this.indices = new Uint16Array(indices); + + this.geometry.buffers[0].data = this.vertices; + this.geometry.buffers[1].data = this.uvs; + this.geometry.indexBuffer.data = this.indices; + + // ensure that the changes are uploaded + this.geometry.buffers[0].update(); + this.geometry.buffers[1].update(); + this.geometry.indexBuffer.update(); + + this.multiplyUvs(); + } +} diff --git a/packages/mesh-extras/src/Rope.js b/packages/mesh-extras/src/Rope.js new file mode 100644 index 0000000..9cfde38 --- /dev/null +++ b/packages/mesh-extras/src/Rope.js @@ -0,0 +1,182 @@ +import Mesh2d from './Mesh2d'; + +/** + * The rope allows you to draw a texture across several points and them manipulate these points + * + *```js + * for (let i = 0; i < 20; i++) { + * points.push(new PIXI.Point(i * 50, 0)); + * }; + * let rope = new PIXI.Rope(PIXI.Texture.from("snake.png"), points); + * ``` + * + * @class + * @extends PIXI.Mesh + * @memberof PIXI + * + */ +export default class Rope extends Mesh2d +{ + /** + * @param {PIXI.Texture} texture - The texture to use on the rope. + * @param {PIXI.Point[]} points - An array of {@link PIXI.Point} objects to construct this rope. + */ + constructor(texture, points) + { + super(texture, new Float32Array(points.length * 4), + new Float32Array(points.length * 4), + new Uint16Array(points.length * 2), + 5); + + /* + * @member {PIXI.Point[]} An array of points that determine the rope + */ + this.points = points; + this.refresh(); + } + /** + * Refreshes Rope indices and uvs + * @private + */ + _refresh() + { + const points = this.points; + + if (!points) return; + + const vertexBuffer = this.geometry.getAttribute('aVertexPosition'); + const uvBuffer = this.geometry.getAttribute('aTextureCoord'); + const indexBuffer = this.geometry.getIndex(); + + // if too little points, or texture hasn't got UVs set yet just move on. + if (points.length < 1 || !this.texture._uvs) + { + return; + } + + // if the number of points has changed we will need to recreate the arraybuffers + if (vertexBuffer.data.length / 4 !== points.length) + { + vertexBuffer.data = new Float32Array(points.length * 4); + uvBuffer.data = new Float32Array(points.length * 4); + indexBuffer.data = new Uint16Array(points.length * 2); + } + + const uvs = uvBuffer.data; + const indices = indexBuffer.data; + + uvs[0] = 0; + uvs[1] = 0; + uvs[2] = 0; + uvs[3] = 1; + + indices[0] = 0; + indices[1] = 1; + + const total = points.length; + + for (let i = 1; i < total; i++) + { + // time to do some smart drawing! + let index = i * 4; + const amount = i / (total - 1); + + uvs[index] = amount; + uvs[index + 1] = 0; + + uvs[index + 2] = amount; + uvs[index + 3] = 1; + + index = i * 2; + indices[index] = index; + indices[index + 1] = index + 1; + } + + // ensure that the changes are uploaded + uvBuffer.update(); + indexBuffer.update(); + + this.multiplyUvs(); + this.refreshVertices(); + } + + /** + * refreshes vertices of Rope mesh + */ + refreshVertices() + { + const points = this.points; + + if (points.length < 1) + { + return; + } + + let lastPoint = points[0]; + let nextPoint; + let perpX = 0; + let perpY = 0; + + // this.count -= 0.2; + + const vertices = this.vertices; + const total = points.length; + + for (let i = 0; i < total; i++) + { + const point = points[i]; + const index = i * 4; + + if (i < points.length - 1) + { + nextPoint = points[i + 1]; + } + else + { + nextPoint = point; + } + + perpY = -(nextPoint.x - lastPoint.x); + perpX = nextPoint.y - lastPoint.y; + + let ratio = (1 - (i / (total - 1))) * 10; + + if (ratio > 1) + { + ratio = 1; + } + + const perpLength = Math.sqrt((perpX * perpX) + (perpY * perpY)); + const num = this._texture.height / 2; // (20 + Math.abs(Math.sin((i + this.count) * 0.3) * 50) )* ratio; + + perpX /= perpLength; + perpY /= perpLength; + + perpX *= num; + perpY *= num; + + vertices[index] = point.x + perpX; + vertices[index + 1] = point.y + perpY; + vertices[index + 2] = point.x - perpX; + vertices[index + 3] = point.y - perpY; + + lastPoint = point; + } + + this.geometry.buffers[0].update(); + } + + /** + * Updates the object transform for rendering + * + * @private + */ + updateTransform() + { + if (this.autoUpdate) + { + this.refreshVertices(); + } + this.containerUpdateTransform(); + } +} diff --git a/packages/mesh-extras/src/index.js b/packages/mesh-extras/src/index.js new file mode 100644 index 0000000..decf454 --- /dev/null +++ b/packages/mesh-extras/src/index.js @@ -0,0 +1,4 @@ +export { default as Mesh2d } from './Mesh2d'; +export { default as Plane } from './Plane'; +export { default as NineSlicePlane } from './NineSlicePlane'; +export { default as Rope } from './Rope'; diff --git a/packages/mesh-extras/src/mesh.frag b/packages/mesh-extras/src/mesh.frag new file mode 100644 index 0000000..6096983 --- /dev/null +++ b/packages/mesh-extras/src/mesh.frag @@ -0,0 +1,9 @@ +varying vec2 vTextureCoord; +uniform vec4 uColor; + +uniform sampler2D uSampler; + +void main(void) +{ + gl_FragColor = texture2D(uSampler, vTextureCoord) * uColor; +} diff --git a/packages/mesh-extras/src/mesh.vert b/packages/mesh-extras/src/mesh.vert new file mode 100644 index 0000000..0526df9 --- /dev/null +++ b/packages/mesh-extras/src/mesh.vert @@ -0,0 +1,15 @@ +attribute vec2 aVertexPosition; +attribute vec2 aTextureCoord; + +uniform mat3 projectionMatrix; +uniform mat3 translationMatrix; +uniform mat3 uTextureMatrix; + +varying vec2 vTextureCoord; + +void main(void) +{ + gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); + + vTextureCoord = (uTextureMatrix * vec3(aTextureCoord, 1.0)).xy; +} diff --git a/packages/mesh-extras/test/.eslintrc.json b/packages/mesh-extras/test/.eslintrc.json new file mode 100644 index 0000000..2ad8efb --- /dev/null +++ b/packages/mesh-extras/test/.eslintrc.json @@ -0,0 +1,12 @@ +{ + "globals": { + "expect": false, + "assert": false, + "sinon": false, + "PIXI": false + }, + "rules": { + "func-names": 0, + "no-unused-expressions": 0 + } +} \ No newline at end of file diff --git a/packages/mesh-extras/test/Plane.js b/packages/mesh-extras/test/Plane.js new file mode 100644 index 0000000..f9b1c25 --- /dev/null +++ b/packages/mesh-extras/test/Plane.js @@ -0,0 +1,60 @@ +const { Plane } = require('../'); +const { isWebGLSupported, skipHello } = require('@pixi/utils'); +const { Loader } = require('@pixi/loaders'); +const { Point } = require('@pixi/math'); +const { RenderTexture, Texture } = require('@pixi/core'); + +skipHello(); + +function withGL(fn) +{ + return isWebGLSupported() ? fn : undefined; +} + +// TODO: fix with webglrenderer +describe('PIXI.mesh.Plane', function () +{ + it.skip('should create a plane from an external image', withGL(function (done) + { + const loader = new Loader(); + + loader.add('testBitmap', `file://${__dirname}/resources/bitmap-1.png`) + .load(function (loader, resources) + { + const plane = new Plane(resources.testBitmap.texture, 100, 100); + + expect(plane.verticesX).to.equal(100); + expect(plane.verticesY).to.equal(100); + done(); + }); + })); + + it.skip('should create a new empty textured Plane', withGL(function () + { + const plane = new Plane(Texture.EMPTY, 100, 100); + + expect(plane.verticesX).to.equal(100); + expect(plane.verticesY).to.equal(100); + })); + + describe('containsPoint', function () + { + it.skip('should return true when point inside', withGL(function () + { + const point = new Point(10, 10); + const texture = new RenderTexture.create(20, 30); + const plane = new Plane(texture, 100, 100); + + expect(plane.containsPoint(point)).to.be.true; + })); + + it.skip('should return false when point outside', withGL(function () + { + const point = new Point(100, 100); + const texture = new RenderTexture.create(20, 30); + const plane = new Plane(texture, 100, 100); + + expect(plane.containsPoint(point)).to.be.false; + })); + }); +}); diff --git a/packages/mesh-extras/test/index.js b/packages/mesh-extras/test/index.js new file mode 100644 index 0000000..d767624 --- /dev/null +++ b/packages/mesh-extras/test/index.js @@ -0,0 +1 @@ +require('./Plane'); diff --git a/packages/mesh-extras/test/resources/bitmap-1.png b/packages/mesh-extras/test/resources/bitmap-1.png new file mode 100644 index 0000000..1284fb8 --- /dev/null +++ b/packages/mesh-extras/test/resources/bitmap-1.png Binary files differ diff --git a/packages/mesh/package.json b/packages/mesh/package.json index 8b1f8d9..10bd8e3 100644 --- a/packages/mesh/package.json +++ b/packages/mesh/package.json @@ -18,22 +18,16 @@ "publishConfig": { "access": "public" }, - "scripts": { - "test": "floss --path test" - }, "files": [ "lib" ], "dependencies": { - "@pixi/canvas-renderer": "^5.0.0-alpha.2", "@pixi/constants": "^5.0.0-alpha.2", "@pixi/core": "^5.0.0-alpha.2", "@pixi/display": "^5.0.0-alpha.2", - "@pixi/math": "^5.0.0-alpha.2", - "@pixi/utils": "^5.0.0-alpha.2" + "@pixi/math": "^5.0.0-alpha.2" }, "devDependencies": { - "@pixi/loaders": "^5.0.0-alpha.2", "floss": "^2.1.3" } } diff --git a/packages/mesh/src/Mesh.js b/packages/mesh/src/Mesh.js index e7c8f9e..1f35b7a 100644 --- a/packages/mesh/src/Mesh.js +++ b/packages/mesh/src/Mesh.js @@ -1,263 +1,220 @@ -import RawMesh from './RawMesh'; -import { Geometry, Program, Shader, Texture, TextureMatrix } from '@pixi/core'; -import { Matrix } from '@pixi/math'; -import { BLEND_MODES } from '@pixi/constants'; -import { hex2rgb, premultiplyRgba } from '@pixi/utils'; -import vertex from './mesh.vert'; -import fragment from './mesh.frag'; +import { State } from '@pixi/core'; +import { DRAW_MODES } from '@pixi/constants'; +import { Point, Polygon } from '@pixi/math'; +import { Container } from '@pixi/display'; -let meshProgram; +const tempPoint = new Point(); +const tempPolygon = new Polygon(); /** - * Base mesh class + * Base mesh class. + * The reason for this class is to empower you to have maximum flexibility to render any kind of webGL you can think of. + * This class assumes a certain level of webGL knowledge. + * If you know a bit this should abstract enough away to make you life easier! + * Pretty much ALL WebGL can be broken down into the following: + * Geometry - The structure and data for the mesh. This can include anything from positions, uvs, normals, colors etc.. + * Shader - This is the shader that pixi will render the geometry with. (attributes in the shader must match the geometry!) + * Uniforms - These are the values passed to the shader when the mesh is rendered. + * As a shader can be reused across multiple objects, it made sense to allow uniforms to exist outside of the shader + * State - This is the state of WebGL required to render the mesh. + * Through a combination of the above elements you can render anything you want, 2D or 3D! + * * @class * @extends PIXI.Container * @memberof PIXI */ -export default class Mesh extends RawMesh +export default class Mesh extends Container { /** - * @param {PIXI.Texture} [texture=Texture.EMPTY] - The texture to use - * @param {Float32Array} [vertices] - if you want to specify the vertices - * @param {Float32Array} [uvs] - if you want to specify the uvs - * @param {Uint16Array} [indices] - if you want to specify the indices - * @param {number} [drawMode] - the drawMode, can be any of the Mesh.DRAW_MODES consts + * @param {PIXI.Geometry} geometry the geometry the mesh will use + * @param {PIXI.Shader} shader the shader the mesh will use + * @param {PIXI.State} state the state that the webGL context is required to be in to render the mesh + * @param {number} drawMode the drawMode, can be any of the PIXI.DRAW_MODES consts */ - constructor(texture = Texture.EMPTY, vertices, uvs, indices, drawMode) + constructor(geometry, shader, state, drawMode = DRAW_MODES.TRIANGLES) { - const geometry = new Geometry(); - - if (!meshProgram) - { - meshProgram = new Program(vertex, fragment); - } - - geometry.addAttribute('aVertexPosition', vertices) - .addAttribute('aTextureCoord', uvs) - .addIndex(indices); - - geometry.getAttribute('aVertexPosition').static = false; - - const uniforms = { - uSampler: texture, - uTextureMatrix: Matrix.IDENTITY, - alpha: 1, - uColor: new Float32Array([1, 1, 1, 1]), - }; - - super(geometry, new Shader(meshProgram, uniforms), null, drawMode); + super(); /** - * The Uvs of the Mesh - * - * @member {Float32Array} + * the geometry the mesh will use + * @type {PIXI.Geometry} */ - this.uvs = geometry.getAttribute('aTextureCoord').data; + this.geometry = geometry; /** - * An array of vertices - * - * @member {Float32Array} + * the shader the mesh will use + * @type {PIXI.Shader} */ - this.vertices = geometry.getAttribute('aVertexPosition').data; - - this.uniforms = uniforms; + this.shader = shader; /** - * The texture of the Mesh - * - * @member {PIXI.Texture} - * @default PIXI.Texture.EMPTY - * @private + * the webGL state the mesh requires to render + * @type {PIXI.State} */ - this.texture = texture; + this.state = state || new State(); /** - * The tint applied to the mesh. This is a [r,g,b] value. A value of [1,1,1] will remove any - * tint effect. + * The way the Mesh should be drawn, can be any of the {@link PIXI.Mesh.DRAW_MODES} consts * * @member {number} + * @see PIXI.Mesh.DRAW_MODES + */ + this.drawMode = drawMode; + + /** + * The way uniforms that will be used by the mesh's shader. + * @member {Object} + */ + + /** + * A map of renderer IDs to webgl render data + * * @private + * @member {object} */ - this._tintRGB = new Float32Array([1, 1, 1]); - - // Set default tint - this.tint = 0xFFFFFF; - - this.blendMode = BLEND_MODES.NORMAL; + this._glDatas = {}; /** - * TextureMatrix instance for this Mesh, used to track Texture changes + * Plugin that is responsible for rendering this element. + * Allows to customize the rendering process without overriding '_render' & '_renderCanvas' methods. * - * @member {PIXI.TextureMatrix} - * @readonly + * @member {string} + * @default 'mesh' */ - this.uvMatrix = new TextureMatrix(this._texture); + this.pluginName = 'mesh'; - /** - * whether or not upload uvMatrix to shader - * if its false, then uvs should be pre-multiplied - * if you change it for generated mesh, please call 'refresh(true)' - * @member {boolean} - * @default false - */ - this.uploadUvMatrix = false; - - /** - * Uploads vertices buffer every frame, like in PixiJS V3 and V4. - * - * @member {boolean} - * @default true - */ - this.autoUpdate = true; + this.start = 0; + this.size = 0; } /** - * The tint applied to the Rope. This is a hex value. A value of - * 0xFFFFFF will remove any tint effect. + * Renders the object using the WebGL renderer * - * @member {number} - * @memberof PIXI.Sprite# - * @default 0xFFFFFF + * @param {PIXI.Renderer} renderer a reference to the WebGL renderer + * @private */ - get tint() + _render(renderer) { - return this._tint; + renderer.batch.setObjectRenderer(renderer.plugins[this.pluginName]); + renderer.plugins[this.pluginName].render(this); } /** - * Sets the tint of the rope. + * Updates the bounds of the mesh as a rectangle. The bounds calculation takes the worldTransform into account. + * there must be a aVertexPosition attribute present in the geometry for bounds to be calculated correctly. * - * @param {number} value - The value to set to. + * @private */ - set tint(value) + _calculateBounds() { - this._tint = value; - - hex2rgb(this._tint, this._tintRGB); - } - - /** - * The blend mode to be applied to the sprite. Set to `PIXI.BLEND_MODES.NORMAL` to remove any blend mode. - * - * @member {number} - * @default PIXI.BLEND_MODES.NORMAL - * @see PIXI.BLEND_MODES - */ - get blendMode() - { - return this.state.blendMode; - } - - set blendMode(value) // eslint-disable-line require-jsdoc - { - this.state.blendMode = value; - } - - /** - * The texture that the mesh uses. - * - * @member {PIXI.Texture} - */ - get texture() - { - return this._texture; - } - - set texture(value) // eslint-disable-line require-jsdoc - { - if (this._texture === value) + // The position property could be set manually? + if (this.geometry.attributes.aVertexPosition) { - return; + const vertices = this.geometry.getAttribute('aVertexPosition').data; + + // TODO - we can cache local bounds and use them if they are dirty (like graphics) + this._bounds.addVertices(this.transform, vertices, 0, vertices.length); + } + } + + /** + * Tests if a point is inside this mesh. Works only for TRIANGLE_MESH + * + * @param {PIXI.Point} point the point to test + * @return {boolean} the result of the test + */ + containsPoint(point) + { + if (!this.getBounds().contains(point.x, point.y)) + { + return false; } - this._texture = value; - this.uniforms.uSampler = this.texture; + this.worldTransform.applyInverse(point, tempPoint); - if (value) + const vertices = this.geometry.getAttribute('aVertexPosition').data; + + const points = tempPolygon.points; + const indices = this.geometry.getIndex().data; + const len = indices.length; + const step = this.drawMode === 4 ? 3 : 1; + + for (let i = 0; i + 2 < len; i += step) { - // wait for the texture to load - if (value.baseTexture.valid) + const ind0 = indices[i] * 2; + const ind1 = indices[i + 1] * 2; + const ind2 = indices[i + 2] * 2; + + points[0] = vertices[ind0]; + points[1] = vertices[ind0 + 1]; + points[2] = vertices[ind1]; + points[3] = vertices[ind1 + 1]; + points[4] = vertices[ind2]; + points[5] = vertices[ind2 + 1]; + + if (tempPolygon.contains(tempPoint.x, tempPoint.y)) { - this._onTextureUpdate(); + return true; + } + } + + return false; + } + + /** + * Destroys the Mesh object. + * + * @param {object|boolean} [options] - Options parameter. A boolean will act as if all + * options have been set to that value + * @param {boolean} [options.children=false] - if set to true, all the children will have + * their destroy method called as well. 'options' will be passed on to those calls. + * @param {boolean} [options.texture=false] - Only used for child Sprites if options.children is set to true + * Should it destroy the texture of the child sprite + * @param {boolean} [options.baseTexture=false] - Only used for child Sprites if options.children is set to true + * Should it destroy the base texture of the child sprite + */ + destroy(options) + { + // for each webgl data entry, destroy the WebGLGraphicsData + for (const id in this._glDatas) + { + const data = this._glDatas[id]; + + if (data.destroy) + { + data.destroy(); } else { - value.once('update', this._onTextureUpdate, this); + if (data.vertexBuffer) + { + data.vertexBuffer.destroy(); + data.vertexBuffer = null; + } + if (data.indexBuffer) + { + data.indexBuffer.destroy(); + data.indexBuffer = null; + } + if (data.uvBuffer) + { + data.uvBuffer.destroy(); + data.uvBuffer = null; + } + if (data.vao) + { + data.vao.destroy(); + data.vao = null; + } } } - } - _render(renderer) - { - const baseTex = this._texture.baseTexture; + this._glDatas = null; - premultiplyRgba(this._tintRGB, this.worldAlpha, this.uniforms.uColor, baseTex.premultiplyAlpha); - super._render(renderer); - } - /** - * When the texture is updated, this event will fire to update the scale and frame - * - * @private - */ - _onTextureUpdate() - { - // constructor texture update stop - if (!this.uvMatrix) - { - return; - } - this.uvMatrix.texture = this._texture; - this.refresh(); - } + this.geometry = null; + this.shader = null; + this.state = null; - /** - * multiplies uvs only if uploadUvMatrix is false - * call it after you change uvs manually - * make sure that texture is valid - */ - multiplyUvs() - { - if (!this.uploadUvMatrix) - { - this.uvMatrix.multiplyUvs(this.uvs); - } - } - - /** - * Refreshes uvs for generated meshes (rope, plane) - * sometimes refreshes vertices too - * - * @param {boolean} [forceUpdate=false] if true, matrices will be updated any case - */ - refresh(forceUpdate) - { - if (this.uvMatrix.update(forceUpdate)) - { - this._refresh(); - } - } - - /** - * Updates the object transform for rendering - * - * @private - */ - updateTransform() - { - if (this.autoUpdate) - { - this.geometry.buffers[0].update(); - } - this.containerUpdateTransform(); - } - - /** - * re-calculates mesh coords - * @private - */ - _refresh() - { - /* empty */ + super.destroy(options); } } diff --git a/packages/mesh/src/MeshRenderer.js b/packages/mesh/src/MeshRenderer.js index 12b159b..d7baf9b 100644 --- a/packages/mesh/src/MeshRenderer.js +++ b/packages/mesh/src/MeshRenderer.js @@ -36,7 +36,7 @@ /** * renders mesh * @private - * @param {PIXI.RawMesh} mesh mesh instance + * @param {PIXI.Mesh} mesh mesh instance */ render(mesh) { diff --git a/packages/mesh/src/NineSlicePlane.js b/packages/mesh/src/NineSlicePlane.js deleted file mode 100644 index 0bae92c..0000000 --- a/packages/mesh/src/NineSlicePlane.js +++ /dev/null @@ -1,270 +0,0 @@ -import Plane from './Plane'; - -const DEFAULT_BORDER_SIZE = 10; - -/** - * The NineSlicePlane allows you to stretch a texture using 9-slice scaling. The corners will remain unscaled (useful - * for buttons with rounded corners for example) and the other areas will be scaled horizontally and or vertically - * - *```js - * let Plane9 = new PIXI.NineSlicePlane(PIXI.Texture.from('BoxWithRoundedCorners.png'), 15, 15, 15, 15); - * ``` - *
- *      A                          B
- *    +---+----------------------+---+
- *  C | 1 |          2           | 3 |
- *    +---+----------------------+---+
- *    |   |                      |   |
- *    | 4 |          5           | 6 |
- *    |   |                      |   |
- *    +---+----------------------+---+
- *  D | 7 |          8           | 9 |
- *    +---+----------------------+---+
-
- *  When changing this objects width and/or height:
- *     areas 1 3 7 and 9 will remain unscaled.
- *     areas 2 and 8 will be stretched horizontally
- *     areas 4 and 6 will be stretched vertically
- *     area 5 will be stretched both horizontally and vertically
- * 
- * - * @class - * @extends PIXI.Plane - * @memberof PIXI - * - */ -export default class NineSlicePlane extends Plane -{ - /** - * @param {PIXI.Texture} texture - The texture to use on the NineSlicePlane. - * @param {int} [leftWidth=10] size of the left vertical bar (A) - * @param {int} [topHeight=10] size of the top horizontal bar (C) - * @param {int} [rightWidth=10] size of the right vertical bar (B) - * @param {int} [bottomHeight=10] size of the bottom horizontal bar (D) - */ - constructor(texture, leftWidth, topHeight, rightWidth, bottomHeight) - { - super(texture, 4, 4); - - this._origWidth = texture.orig.width; - this._origHeight = texture.orig.height; - - /** - * The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane - * - * @member {number} - * @memberof PIXI.NineSlicePlane# - * @override - */ - this._width = this._origWidth; - - /** - * The height of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane - * - * @member {number} - * @memberof PIXI.NineSlicePlane# - * @override - */ - this._height = this._origHeight; - - /** - * The width of the left column (a) - * - * @member {number} - * @memberof PIXI.NineSlicePlane# - * @override - */ - this._leftWidth = typeof leftWidth !== 'undefined' ? leftWidth : DEFAULT_BORDER_SIZE; - - /** - * The width of the right column (b) - * - * @member {number} - * @memberof PIXI.NineSlicePlane# - * @override - */ - this._rightWidth = typeof rightWidth !== 'undefined' ? rightWidth : DEFAULT_BORDER_SIZE; - - /** - * The height of the top row (c) - * - * @member {number} - * @memberof PIXI.NineSlicePlane# - * @override - */ - this._topHeight = typeof topHeight !== 'undefined' ? topHeight : DEFAULT_BORDER_SIZE; - - /** - * The height of the bottom row (d) - * - * @member {number} - * @memberof PIXI.NineSlicePlane# - * @override - */ - this._bottomHeight = typeof bottomHeight !== 'undefined' ? bottomHeight : DEFAULT_BORDER_SIZE; - - this.refresh(true); - } - - /** - * Updates the horizontal vertices. - * - */ - updateHorizontalVertices() - { - const vertices = this.vertices; - - const h = this._topHeight + this._bottomHeight; - const scale = this._height > h ? 1.0 : this._height / h; - - vertices[9] = vertices[11] = vertices[13] = vertices[15] = this._topHeight * scale; - vertices[17] = vertices[19] = vertices[21] = vertices[23] = this._height - (this._bottomHeight * scale); - vertices[25] = vertices[27] = vertices[29] = vertices[31] = this._height; - } - - /** - * Updates the vertical vertices. - * - */ - updateVerticalVertices() - { - const vertices = this.vertices; - - const w = this._leftWidth + this._rightWidth; - const scale = this._width > w ? 1.0 : this._width / w; - - vertices[2] = vertices[10] = vertices[18] = vertices[26] = this._leftWidth * scale; - vertices[4] = vertices[12] = vertices[20] = vertices[28] = this._width - (this._rightWidth * scale); - vertices[6] = vertices[14] = vertices[22] = vertices[30] = this._width; - } - - /** - * The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane - * - * @member {number} - */ - get width() - { - return this._width; - } - - set width(value) // eslint-disable-line require-jsdoc - { - this._width = value; - this._refresh(); - } - - /** - * The height of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane - * - * @member {number} - */ - get height() - { - return this._height; - } - - set height(value) // eslint-disable-line require-jsdoc - { - this._height = value; - this._refresh(); - } - - /** - * The width of the left column - * - * @member {number} - */ - get leftWidth() - { - return this._leftWidth; - } - - set leftWidth(value) // eslint-disable-line require-jsdoc - { - this._leftWidth = value; - this._refresh(); - } - - /** - * The width of the right column - * - * @member {number} - */ - get rightWidth() - { - return this._rightWidth; - } - - set rightWidth(value) // eslint-disable-line require-jsdoc - { - this._rightWidth = value; - this._refresh(); - } - - /** - * The height of the top row - * - * @member {number} - */ - get topHeight() - { - return this._topHeight; - } - - set topHeight(value) // eslint-disable-line require-jsdoc - { - this._topHeight = value; - this._refresh(); - } - - /** - * The height of the bottom row - * - * @member {number} - */ - get bottomHeight() - { - return this._bottomHeight; - } - - set bottomHeight(value) // eslint-disable-line require-jsdoc - { - this._bottomHeight = value; - this._refresh(); - } - - /** - * Refreshes NineSlicePlane coords. All of them. - */ - _refresh() - { - super._refresh(); - - const uvs = this.uvs; - const texture = this._texture; - - this._origWidth = texture.orig.width; - this._origHeight = texture.orig.height; - - const _uvw = 1.0 / this._origWidth; - const _uvh = 1.0 / this._origHeight; - - uvs[0] = uvs[8] = uvs[16] = uvs[24] = 0; - uvs[1] = uvs[3] = uvs[5] = uvs[7] = 0; - uvs[6] = uvs[14] = uvs[22] = uvs[30] = 1; - uvs[25] = uvs[27] = uvs[29] = uvs[31] = 1; - - uvs[2] = uvs[10] = uvs[18] = uvs[26] = _uvw * this._leftWidth; - uvs[4] = uvs[12] = uvs[20] = uvs[28] = 1 - (_uvw * this._rightWidth); - uvs[9] = uvs[11] = uvs[13] = uvs[15] = _uvh * this._topHeight; - uvs[17] = uvs[19] = uvs[21] = uvs[23] = 1 - (_uvh * this._bottomHeight); - - this.updateHorizontalVertices(); - this.updateVerticalVertices(); - - this.geometry.buffers[1].update(); - - this.multiplyUvs(); - } -} diff --git a/packages/mesh/src/Plane.js b/packages/mesh/src/Plane.js deleted file mode 100644 index c416b4c..0000000 --- a/packages/mesh/src/Plane.js +++ /dev/null @@ -1,100 +0,0 @@ -import Mesh from './Mesh'; - -/** - * The Plane allows you to draw a texture across several points and them manipulate these points - * - *```js - * for (let i = 0; i < 20; i++) { - * points.push(new PIXI.Point(i * 50, 0)); - * }; - * let Plane = new PIXI.Plane(PIXI.Texture.from("snake.png"), points); - * ``` - * - * @class - * @extends PIXI.Mesh - * @memberof PIXI - * - */ -export default class Plane extends Mesh -{ - /** - * @param {PIXI.Texture} texture - The texture to use on the Plane. - * @param {number} verticesX - The number of vertices in the x-axis - * @param {number} verticesY - The number of vertices in the y-axis - * @param {object} [opts] - an options object - add meshWidth and meshHeight, temporary object for PixiJS v5 alpha - */ - constructor(texture, verticesX, verticesY, opts = {}) - { - super(texture, new Float32Array(1), new Float32Array(1), new Uint16Array(1), 4); - - this.verticesX = verticesX || 10; - this.verticesY = verticesY || 10; - - this.meshWidth = opts.meshWidth || 0; - this.meshHeight = opts.meshHeight || 0; - - this.refresh(); - } - - /** - * Refreshes plane coordinates - * @private - */ - _refresh() - { - const texture = this._texture; - const total = this.verticesX * this.verticesY; - const verts = []; - const uvs = []; - const indices = []; - - const segmentsX = this.verticesX - 1; - const segmentsY = this.verticesY - 1; - - const sizeX = (this.meshWidth || texture.width) / segmentsX; - const sizeY = (this.meshHeight || texture.height) / segmentsY; - - for (let i = 0; i < total; i++) - { - const x = (i % this.verticesX); - const y = ((i / this.verticesX) | 0); - - verts.push(x * sizeX, y * sizeY); - - uvs.push(x / segmentsX, y / segmentsY); - } - - // cons - - const totalSub = segmentsX * segmentsY; - - for (let i = 0; i < totalSub; i++) - { - const xpos = i % segmentsX; - const ypos = (i / segmentsX) | 0; - - const value = (ypos * this.verticesX) + xpos; - const value2 = (ypos * this.verticesX) + xpos + 1; - const value3 = ((ypos + 1) * this.verticesX) + xpos; - const value4 = ((ypos + 1) * this.verticesX) + xpos + 1; - - indices.push(value, value2, value3); - indices.push(value2, value4, value3); - } - - this.vertices = new Float32Array(verts); - this.uvs = new Float32Array(uvs); - this.indices = new Uint16Array(indices); - - this.geometry.buffers[0].data = this.vertices; - this.geometry.buffers[1].data = this.uvs; - this.geometry.indexBuffer.data = this.indices; - - // ensure that the changes are uploaded - this.geometry.buffers[0].update(); - this.geometry.buffers[1].update(); - this.geometry.indexBuffer.update(); - - this.multiplyUvs(); - } -} diff --git a/packages/mesh/src/RawMesh.js b/packages/mesh/src/RawMesh.js deleted file mode 100644 index 7297e94..0000000 --- a/packages/mesh/src/RawMesh.js +++ /dev/null @@ -1,220 +0,0 @@ -import { State } from '@pixi/core'; -import { DRAW_MODES } from '@pixi/constants'; -import { Point, Polygon } from '@pixi/math'; -import { Container } from '@pixi/display'; - -const tempPoint = new Point(); -const tempPolygon = new Polygon(); - -/** - * Base mesh class. - * The reason for this class is to empower you to have maximum flexibility to render any kind of webGL you can think of. - * This class assumes a certain level of webGL knowledge. - * If you know a bit this should abstract enough away to make you life easier! - * Pretty much ALL WebGL can be broken down into the following: - * Geometry - The structure and data for the mesh. This can include anything from positions, uvs, normals, colors etc.. - * Shader - This is the shader that pixi will render the geometry with. (attributes in the shader must match the geometry!) - * Uniforms - These are the values passed to the shader when the mesh is rendered. - * As a shader can be reused across multiple objects, it made sense to allow uniforms to exist outside of the shader - * State - This is the state of WebGL required to render the mesh. - * Through a combination of the above elements you can render anything you want, 2D or 3D! - * - * @class - * @extends PIXI.Container - * @memberof PIXI - */ -export default class RawMesh extends Container -{ - /** - * @param {PIXI.Geometry} geometry the geometry the mesh will use - * @param {PIXI.Shader} shader the shader the mesh will use - * @param {PIXI.State} state the state that the webGL context is required to be in to render the mesh - * @param {number} drawMode the drawMode, can be any of the PIXI.DRAW_MODES consts - */ - constructor(geometry, shader, state, drawMode = DRAW_MODES.TRIANGLES) - { - super(); - - /** - * the geometry the mesh will use - * @type {PIXI.Geometry} - */ - this.geometry = geometry; - - /** - * the shader the mesh will use - * @type {PIXI.Shader} - */ - this.shader = shader; - - /** - * the webGL state the mesh requires to render - * @type {PIXI.State} - */ - this.state = state || new State(); - - /** - * The way the Mesh should be drawn, can be any of the {@link PIXI.RawMesh.DRAW_MODES} consts - * - * @member {number} - * @see PIXI.RawMesh.DRAW_MODES - */ - this.drawMode = drawMode; - - /** - * The way uniforms that will be used by the mesh's shader. - * @member {Object} - */ - - /** - * A map of renderer IDs to webgl render data - * - * @private - * @member {object} - */ - this._glDatas = {}; - - /** - * Plugin that is responsible for rendering this element. - * Allows to customize the rendering process without overriding '_render' & '_renderCanvas' methods. - * - * @member {string} - * @default 'mesh' - */ - this.pluginName = 'mesh'; - - this.start = 0; - this.size = 0; - } - - /** - * Renders the object using the WebGL renderer - * - * @param {PIXI.Renderer} renderer a reference to the WebGL renderer - * @private - */ - _render(renderer) - { - renderer.batch.setObjectRenderer(renderer.plugins[this.pluginName]); - renderer.plugins[this.pluginName].render(this); - } - - /** - * Updates the bounds of the mesh as a rectangle. The bounds calculation takes the worldTransform into account. - * there must be a aVertexPosition attribute present in the geometry for bounds to be calculated correctly. - * - * @private - */ - _calculateBounds() - { - // The position property could be set manually? - if (this.geometry.attributes.aVertexPosition) - { - const vertices = this.geometry.getAttribute('aVertexPosition').data; - - // TODO - we can cache local bounds and use them if they are dirty (like graphics) - this._bounds.addVertices(this.transform, vertices, 0, vertices.length); - } - } - - /** - * Tests if a point is inside this mesh. Works only for TRIANGLE_MESH - * - * @param {PIXI.Point} point the point to test - * @return {boolean} the result of the test - */ - containsPoint(point) - { - if (!this.getBounds().contains(point.x, point.y)) - { - return false; - } - - this.worldTransform.applyInverse(point, tempPoint); - - const vertices = this.geometry.getAttribute('aVertexPosition').data; - - const points = tempPolygon.points; - const indices = this.geometry.getIndex().data; - const len = indices.length; - const step = this.drawMode === 4 ? 3 : 1; - - for (let i = 0; i + 2 < len; i += step) - { - const ind0 = indices[i] * 2; - const ind1 = indices[i + 1] * 2; - const ind2 = indices[i + 2] * 2; - - points[0] = vertices[ind0]; - points[1] = vertices[ind0 + 1]; - points[2] = vertices[ind1]; - points[3] = vertices[ind1 + 1]; - points[4] = vertices[ind2]; - points[5] = vertices[ind2 + 1]; - - if (tempPolygon.contains(tempPoint.x, tempPoint.y)) - { - return true; - } - } - - return false; - } - - /** - * Destroys the RawMesh object. - * - * @param {object|boolean} [options] - Options parameter. A boolean will act as if all - * options have been set to that value - * @param {boolean} [options.children=false] - if set to true, all the children will have - * their destroy method called as well. 'options' will be passed on to those calls. - * @param {boolean} [options.texture=false] - Only used for child Sprites if options.children is set to true - * Should it destroy the texture of the child sprite - * @param {boolean} [options.baseTexture=false] - Only used for child Sprites if options.children is set to true - * Should it destroy the base texture of the child sprite - */ - destroy(options) - { - // for each webgl data entry, destroy the WebGLGraphicsData - for (const id in this._glDatas) - { - const data = this._glDatas[id]; - - if (data.destroy) - { - data.destroy(); - } - else - { - if (data.vertexBuffer) - { - data.vertexBuffer.destroy(); - data.vertexBuffer = null; - } - if (data.indexBuffer) - { - data.indexBuffer.destroy(); - data.indexBuffer = null; - } - if (data.uvBuffer) - { - data.uvBuffer.destroy(); - data.uvBuffer = null; - } - if (data.vao) - { - data.vao.destroy(); - data.vao = null; - } - } - } - - this._glDatas = null; - - this.geometry = null; - this.shader = null; - this.state = null; - - super.destroy(options); - } -} diff --git a/packages/mesh/src/Rope.js b/packages/mesh/src/Rope.js deleted file mode 100644 index b4f85d3..0000000 --- a/packages/mesh/src/Rope.js +++ /dev/null @@ -1,182 +0,0 @@ -import Mesh from './Mesh'; - -/** - * The rope allows you to draw a texture across several points and them manipulate these points - * - *```js - * for (let i = 0; i < 20; i++) { - * points.push(new PIXI.Point(i * 50, 0)); - * }; - * let rope = new PIXI.Rope(PIXI.Texture.from("snake.png"), points); - * ``` - * - * @class - * @extends PIXI.Mesh - * @memberof PIXI - * - */ -export default class Rope extends Mesh -{ - /** - * @param {PIXI.Texture} texture - The texture to use on the rope. - * @param {PIXI.Point[]} points - An array of {@link PIXI.Point} objects to construct this rope. - */ - constructor(texture, points) - { - super(texture, new Float32Array(points.length * 4), - new Float32Array(points.length * 4), - new Uint16Array(points.length * 2), - 5); - - /* - * @member {PIXI.Point[]} An array of points that determine the rope - */ - this.points = points; - this.refresh(); - } - /** - * Refreshes Rope indices and uvs - * @private - */ - _refresh() - { - const points = this.points; - - if (!points) return; - - const vertexBuffer = this.geometry.getAttribute('aVertexPosition'); - const uvBuffer = this.geometry.getAttribute('aTextureCoord'); - const indexBuffer = this.geometry.getIndex(); - - // if too little points, or texture hasn't got UVs set yet just move on. - if (points.length < 1 || !this.texture._uvs) - { - return; - } - - // if the number of points has changed we will need to recreate the arraybuffers - if (vertexBuffer.data.length / 4 !== points.length) - { - vertexBuffer.data = new Float32Array(points.length * 4); - uvBuffer.data = new Float32Array(points.length * 4); - indexBuffer.data = new Uint16Array(points.length * 2); - } - - const uvs = uvBuffer.data; - const indices = indexBuffer.data; - - uvs[0] = 0; - uvs[1] = 0; - uvs[2] = 0; - uvs[3] = 1; - - indices[0] = 0; - indices[1] = 1; - - const total = points.length; - - for (let i = 1; i < total; i++) - { - // time to do some smart drawing! - let index = i * 4; - const amount = i / (total - 1); - - uvs[index] = amount; - uvs[index + 1] = 0; - - uvs[index + 2] = amount; - uvs[index + 3] = 1; - - index = i * 2; - indices[index] = index; - indices[index + 1] = index + 1; - } - - // ensure that the changes are uploaded - uvBuffer.update(); - indexBuffer.update(); - - this.multiplyUvs(); - this.refreshVertices(); - } - - /** - * refreshes vertices of Rope mesh - */ - refreshVertices() - { - const points = this.points; - - if (points.length < 1) - { - return; - } - - let lastPoint = points[0]; - let nextPoint; - let perpX = 0; - let perpY = 0; - - // this.count -= 0.2; - - const vertices = this.vertices; - const total = points.length; - - for (let i = 0; i < total; i++) - { - const point = points[i]; - const index = i * 4; - - if (i < points.length - 1) - { - nextPoint = points[i + 1]; - } - else - { - nextPoint = point; - } - - perpY = -(nextPoint.x - lastPoint.x); - perpX = nextPoint.y - lastPoint.y; - - let ratio = (1 - (i / (total - 1))) * 10; - - if (ratio > 1) - { - ratio = 1; - } - - const perpLength = Math.sqrt((perpX * perpX) + (perpY * perpY)); - const num = this._texture.height / 2; // (20 + Math.abs(Math.sin((i + this.count) * 0.3) * 50) )* ratio; - - perpX /= perpLength; - perpY /= perpLength; - - perpX *= num; - perpY *= num; - - vertices[index] = point.x + perpX; - vertices[index + 1] = point.y + perpY; - vertices[index + 2] = point.x - perpX; - vertices[index + 3] = point.y - perpY; - - lastPoint = point; - } - - this.geometry.buffers[0].update(); - } - - /** - * Updates the object transform for rendering - * - * @private - */ - updateTransform() - { - if (this.autoUpdate) - { - this.refreshVertices(); - } - this.containerUpdateTransform(); - } -} diff --git a/bundles/pixi.js/package.json b/bundles/pixi.js/package.json index 49c7276..177e059 100644 --- a/bundles/pixi.js/package.json +++ b/bundles/pixi.js/package.json @@ -49,6 +49,7 @@ "@pixi/loaders": "^5.0.0-alpha.2", "@pixi/math": "^5.0.0-alpha.2", "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/mesh-extras": "^5.0.0-alpha.2", "@pixi/mixin-cache-as-bitmap": "^5.0.0-alpha.2", "@pixi/mixin-get-child-by-name": "^5.0.0-alpha.2", "@pixi/mixin-get-global-position": "^5.0.0-alpha.2", diff --git a/bundles/pixi.js/src/deprecated.js b/bundles/pixi.js/src/deprecated.js index 147617c..dbebeb0 100644 --- a/bundles/pixi.js/src/deprecated.js +++ b/bundles/pixi.js/src/deprecated.js @@ -263,15 +263,15 @@ Object.defineProperties(PIXI.mesh, { /** * @class PIXI.mesh.Mesh - * @see PIXI.Mesh + * @see PIXI.Mesh2d * @deprecated since 5.0.0 */ Mesh: { get() { - warn('PIXI.mesh.Mesh has moved to PIXI.Mesh'); + warn('PIXI.mesh.Mesh has moved to PIXI.Mesh2d'); - return PIXI.Mesh; + return PIXI.Mesh2d; }, }, /** @@ -315,15 +315,15 @@ }, /** * @class PIXI.mesh.RawMesh - * @see PIXI.RawMesh + * @see PIXI.Mesh * @deprecated since 5.0.0 */ RawMesh: { get() { - warn('PIXI.mesh.RawMesh has moved to PIXI.RawMesh'); + warn('PIXI.mesh.RawMesh has moved to PIXI.Mesh'); - return PIXI.RawMesh; + return PIXI.Mesh; }, }, /** diff --git a/bundles/pixi.js/src/index.js b/bundles/pixi.js/src/index.js index a3a0d1b..6fdabf0 100644 --- a/bundles/pixi.js/src/index.js +++ b/bundles/pixi.js/src/index.js @@ -9,6 +9,7 @@ import * as loaders from '@pixi/loaders'; import * as math from '@pixi/math'; import * as mesh from '@pixi/mesh'; +import * as meshExtras from '@pixi/mesh-extras'; import * as particles from '@pixi/particles'; import * as prepare from '@pixi/prepare'; import * as sprite from '@pixi/sprite'; @@ -128,6 +129,7 @@ loaders, math, mesh, + meshExtras, particles, sprite, spriteAnimated, @@ -152,6 +154,7 @@ export * from '@pixi/loaders'; export * from '@pixi/math'; export * from '@pixi/mesh'; +export * from '@pixi/mesh-extras'; export * from '@pixi/particles'; export * from '@pixi/sprite'; export * from '@pixi/spritesheet'; diff --git a/package-lock.json b/package-lock.json index 7fe6db7..0814729 100644 --- a/package-lock.json +++ b/package-lock.json @@ -209,7 +209,7 @@ "argparse": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", - "integrity": "sha1-vNZ5HqWuCXJeF+WtmIE0zUCz2RE=", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", "dev": true, "requires": { "sprintf-js": "1.0.3" @@ -228,7 +228,7 @@ "arr-flatten": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz", - "integrity": "sha1-NgSLv/TntH4TZkQxbJlmnqWukfE=", + "integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==", "dev": true }, "arr-union": { @@ -297,7 +297,7 @@ "assertion-error": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", - "integrity": "sha1-5gtrDo8wG9l+U3UhW9pAbIURjAs=", + "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", "dev": true }, "async": { @@ -396,7 +396,7 @@ "brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha1-PH/L9SnYcibz0vUrlm/1Jx60Qd0=", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, "requires": { "balanced-match": "1.0.0", @@ -568,7 +568,7 @@ "circular-json": { "version": "0.3.3", "resolved": "https://registry.npmjs.org/circular-json/-/circular-json-0.3.3.tgz", - "integrity": "sha1-gVyZ6oT2gJUp0vRXkb34JxE1LWY=", + "integrity": "sha512-UZK3NBx2Mca+b5LsG7bY183pHWt5Y1xts4P3Pz7ENTwGVnJOUWbRb3ocjvX7hx9tq/yTAdclXm9sZ38gNuem4A==", "dev": true }, "cli-cursor": { @@ -638,7 +638,7 @@ "color-convert": { "version": "1.9.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.1.tgz", - "integrity": "sha1-wSYRB66y8pTr/+ye2eytUppgl+0=", + "integrity": "sha512-mjGanIiwQJskCC18rPR6OmrZ6fm2Lc7PeGFYwCmy5J34wC6F1PzdGL6xeMfmgicfYcNLGuVFA3WzXtIDCQSZxQ==", "dev": true, "requires": { "color-name": "1.1.3" @@ -1427,7 +1427,7 @@ "boom": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/boom/-/boom-5.2.0.tgz", - "integrity": "sha1-XdnabuOl8wIHdDYpDLcX0/SlTgI=", + "integrity": "sha512-Z5BTk6ZRe4tXXQlkqftmsAUANpXmuwlsF5Oov8ThoMbQRzdGTA1ngYRW160GexgOgjsFOKJz0LYhoNi+2AMBUw==", "dev": true, "requires": { "hoek": "4.2.1" @@ -1471,7 +1471,7 @@ "debug": { "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha1-XRKFFd8TT/Mn6QpMk/Tgd6U2NB8=", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", "dev": true, "requires": { "ms": "2.0.0" @@ -1585,7 +1585,7 @@ "doctrine": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", - "integrity": "sha1-XNAfwQFiG0LEzX9dGmYkNxbT850=", + "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", "dev": true, "requires": { "esutils": "2.0.2" @@ -1662,7 +1662,7 @@ "es6-promise": { "version": "4.2.4", "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.4.tgz", - "integrity": "sha1-3EIhwrFlGHYL2MOaUtjzVvwA7Sk=", + "integrity": "sha512-/NdNZVJg+uZgtm9eS3O6lrOLYmQag2DjdEXuPaHlZ6RuVqgqaVZfgYCepEIKsLqwdQArOPtC3XzRLqGGfT8KQQ==", "dev": true }, "escape-string-regexp": { @@ -1788,7 +1788,7 @@ "espree": { "version": "3.5.4", "resolved": "https://registry.npmjs.org/espree/-/espree-3.5.4.tgz", - "integrity": "sha1-sPRHGHyKi+2US4FaZgvd9d610ac=", + "integrity": "sha512-yAcIQxtmMiB/jL32dzEp2enBeidsB7xWPLNiw3IIkpVds1P+h7qF9YwJq1yUNzp2OKXgAprs4F61ih66UsoD1A==", "dev": true, "requires": { "acorn": "5.5.0", @@ -1798,7 +1798,7 @@ "esprima": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.0.tgz", - "integrity": "sha1-RJnt3NERDgshi6zy+n9/WfVcqAQ=", + "integrity": "sha512-oftTcaMu/EGrEIu904mWteKIv8vMuOgGYo7EhVJJN00R/EED9DCua/xxHRdYnKtcECzVg7xOWhflvJMnqcFZjw==", "dev": true }, "esquery": { @@ -1813,7 +1813,7 @@ "esrecurse": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.2.1.tgz", - "integrity": "sha1-AHo7n9vCs7uH5IeeoZyS/b05Qs8=", + "integrity": "sha512-64RBB++fIOAXPw3P9cy89qfMlvZEXZkqqJkjqqXIvzP5ezRZjW+lPWjw35UX/3EhUPFYbg5ER4JYgDw4007/DQ==", "dev": true, "requires": { "estraverse": "4.2.0" @@ -2024,7 +2024,7 @@ "find-root": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/find-root/-/find-root-1.1.0.tgz", - "integrity": "sha1-q8/Iunb3CMQql7PWhbfpRQv7nOQ=", + "integrity": "sha512-NKfW6bec6GfKc0SGx1e07QZY9PE99u0Bft/0rzSD5k3sO/vwkVUpDUKVm5Gpp5Ue3YfShPFTX2070tDs5kB9Ng==", "dev": true }, "find-up": { @@ -2103,7 +2103,7 @@ "supports-color": { "version": "5.3.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.3.0.tgz", - "integrity": "sha1-WySsFduA+pJ89SJ6SjP9PEx2dsA=", + "integrity": "sha512-0aP01LLIskjKs3lq52EC0aGBAJhLq7B2Rd8HC/DR/PtNNpcLilNmHC12O+hu0usQpo7wtHNRqtrhBwtDb0+dNg==", "dev": true, "requires": { "has-flag": "3.0.0" @@ -2567,7 +2567,7 @@ "glob": { "version": "7.1.2", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", - "integrity": "sha1-wZyd+aAocC1nhhI4SmVSQExjbRU=", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", "dev": true, "requires": { "fs.realpath": "1.0.0", @@ -2672,7 +2672,7 @@ "growl": { "version": "1.10.3", "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.3.tgz", - "integrity": "sha1-GSa6kM8+3+KttJJ/WIC8IsZseQ8=", + "integrity": "sha512-hKlsbA5Vu3xsh1Cg3J7jSmX/WaW6A5oBeqzM88oNbCRQFz+zUaXm6yxS4RVytp1scBoJzSYl4YAEOQIt6O8V1Q==", "dev": true }, "handlebars": { @@ -2738,7 +2738,7 @@ "hawk": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/hawk/-/hawk-6.0.2.tgz", - "integrity": "sha1-r02RTrBl+bXOTZ0RwcshJu7MMDg=", + "integrity": "sha512-miowhl2+U7Qle4vdLqDdPt9m09K6yZhkLDTWGoUiUzrQCn+mHHSmfJgAyGaLRZbPmTqfFFjRV1QWCW0VWUJBbQ==", "dev": true, "requires": { "boom": "4.3.1", @@ -2756,7 +2756,7 @@ "hoek": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/hoek/-/hoek-4.2.1.tgz", - "integrity": "sha1-ljRQKqEsRF3Vp8VzS1cruHOKrLs=", + "integrity": "sha512-QLg82fGkfnJ/4iy1xZ81/9SIJiq1NGFUMGs6ParyjBZr6jW2Ufj/snDqTHixNlHdPNwN2RLVD0Pi3igeK9+JfA==", "dev": true }, "home-path": { @@ -2791,7 +2791,7 @@ "ignore": { "version": "3.3.7", "resolved": "https://registry.npmjs.org/ignore/-/ignore-3.3.7.tgz", - "integrity": "sha1-YSKJv7PCIOGGpYEYYY1b6MG6sCE=", + "integrity": "sha512-YGG3ejvBNHRqu0559EOxxNFihD0AjpvHlC/pdGKd3X3ofe+CoJkYazwNJYTNebqpPKN+VVQbh4ZFn1DivMNuHA==", "dev": true }, "imurmurhash": { @@ -2828,7 +2828,7 @@ "ini": { "version": "1.3.5", "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", - "integrity": "sha1-7uJfVtscnsYIXgwid4CD9Zar+Sc=", + "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==", "dev": true }, "inquirer": { @@ -2901,7 +2901,7 @@ "is-buffer": { "version": "1.1.6", "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", - "integrity": "sha1-76ouqdqg16suoTqXsritUf776L4=", + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", "dev": true }, "is-builtin-module": { @@ -3054,7 +3054,7 @@ "is-resolvable": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/is-resolvable/-/is-resolvable-1.1.0.tgz", - "integrity": "sha1-+xj4fOH+uSUWnJpAfBkxijIG7Yg=", + "integrity": "sha512-qgDYXFSR5WvEfuS5dMj6oTMEbrrSaM0CrFk2Yiq/gXnBvD9pMa2jGXxyhGLfvhZpuMZe18CJpFxAt3CRs42NMg==", "dev": true }, "is-retry-allowed": { @@ -3204,7 +3204,7 @@ "js-yaml": { "version": "3.11.0", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.11.0.tgz", - "integrity": "sha1-WXwai9VxUvJtYizkEXhRpR9euu8=", + "integrity": "sha512-saJstZWv7oNeOyBh3+Dx1qWzhW0+e6/8eDzo7p5rDFqxntSztloLtuKu+Ejhtq82jsilwOIZYsCz+lIjthg1Hw==", "dev": true, "requires": { "argparse": "1.0.10", @@ -3324,7 +3324,7 @@ "just-extend": { "version": "1.1.27", "resolved": "https://registry.npmjs.org/just-extend/-/just-extend-1.1.27.tgz", - "integrity": "sha1-7G55QQ/5FORyZSq/oOYDwD1g6QU=", + "integrity": "sha512-mJVp13Ix6gFo3SBAy9U/kL+oeZqzlYYYLQBwXVBlVzIsZwBqGREnOro24oC/8s8aox+rJhtZ2DiQof++IrkA+g==", "dev": true }, "kind-of": { @@ -3703,7 +3703,7 @@ "lodash": { "version": "4.17.5", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.5.tgz", - "integrity": "sha1-maktZcAnLevoyWtgV7yPv6O+1RE=", + "integrity": "sha512-svL3uiZf1RwhH+cWrfZn3A4+U58wbP0tGVTLQPbjplZxZ8ROD9VLuNgsRniTlLe7OlSqR79RUehXgpBW/s0IQw==", "dev": true }, "lodash._reinterpolate": { @@ -3740,7 +3740,7 @@ "lolex": { "version": "2.3.2", "resolved": "https://registry.npmjs.org/lolex/-/lolex-2.3.2.tgz", - "integrity": "sha1-hflFBCUQO/nnpgZo6iXcQydMqAc=", + "integrity": "sha512-A5pN2tkFj7H0dGIAM6MFvHKMJcPnjZsOMvR7ujCjfgW5TbV6H9vb1PgxLtHvjqNZTHsUolz+6/WEO0N1xNx2ng==", "dev": true }, "longest": { @@ -3816,7 +3816,7 @@ "marked": { "version": "0.3.17", "resolved": "https://registry.npmjs.org/marked/-/marked-0.3.17.tgz", - "integrity": "sha1-YH8GZos8axJGso8T2nYRasGqLSs=", + "integrity": "sha512-+AKbNsjZl6jFfLPwHhWmGTqE009wTKn3RTmn9K8oUKHrX/abPJjtcRtXpYB/FFrwPJRUA86LX/de3T0knkPCmQ==", "dev": true }, "mem": { @@ -3896,13 +3896,13 @@ "mime-db": { "version": "1.33.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.33.0.tgz", - "integrity": "sha1-o0kgUKXLm2NFBUHjnZeI0icng9s=", + "integrity": "sha512-BHJ/EKruNIqJf/QahvxwQZXKygOQ256myeN/Ew+THcAa5q+PjyTTMMeNQC4DZw5AwfvelsUrA6B67NKMqXDbzQ==", "dev": true }, "mime-types": { "version": "2.1.18", "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.18.tgz", - "integrity": "sha1-bzI/YKg9ERRvgx/xH9ZuL+VQO7g=", + "integrity": "sha512-lc/aahn+t4/SWV/qcmumYjymLsWfN3ELhpmVuUFjgsORruuZPVSwAQryq+HHGvO/SI2KVX26bx+En+zhM8g8hQ==", "dev": true, "requires": { "mime-db": "1.33.0" @@ -3917,7 +3917,7 @@ "minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha1-UWbihkV/AzBgZL5Ul+jbsMPTIIM=", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "dev": true, "requires": { "brace-expansion": "1.1.11" @@ -4071,7 +4071,7 @@ "normalize-package-data": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.4.0.tgz", - "integrity": "sha1-EvlaMH1YNSB1oEkHuErIvpisAS8=", + "integrity": "sha512-9jjUFbTPfEy3R/ad/2oNbKtW9Hgovl5O1FvFWKkKblNXoN/Oou6+9+KKohPK13Yc3/TyunyWhJp6gvRNR/PPAw==", "dev": true, "requires": { "hosted-git-info": "2.5.0", @@ -4511,7 +4511,7 @@ "process-nextick-args": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", - "integrity": "sha1-o31zL0JxtKsa0HDTVQjoKQeI/6o=", + "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==", "dev": true }, "progress": { @@ -4584,7 +4584,7 @@ "qs": { "version": "6.5.1", "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.1.tgz", - "integrity": "sha1-NJzfbu+J7EXBLX1es/wMhwNDptg=", + "integrity": "sha512-eRzhrN1WSINYCDCbrz796z37LOe3m5tmW7RQf6oBntukAG1nmovJvhnwHHRMAfeoItc1m2Hk02WER2aQ/iqs+A==", "dev": true }, "quick-lru": { @@ -4596,7 +4596,7 @@ "randomatic": { "version": "1.1.7", "resolved": "https://registry.npmjs.org/randomatic/-/randomatic-1.1.7.tgz", - "integrity": "sha1-x6vpzIuHwLqodrGf3oP9RkeX44w=", + "integrity": "sha512-D5JUjPyJbaJDkuAazpVnSfVkLlpeO3wDlPROTMLGKG1zMFNFRgrciKo1ltz/AzNTkqE0HzDx655QOL51N06how==", "dev": true, "requires": { "is-number": "3.0.0", @@ -4701,7 +4701,7 @@ "regex-cache": { "version": "0.4.4", "resolved": "https://registry.npmjs.org/regex-cache/-/regex-cache-0.4.4.tgz", - "integrity": "sha1-db3FiioUls7EihKDW8VMjVYjNt0=", + "integrity": "sha512-nVIZwtCjkC9YgvWkpM55B5rBhBYRZhAaJbgcFYXXsHnbZ9UZI9nnVWYZpBlCqv9ho2eZryPnWrZGsOdPwVWXWQ==", "dev": true, "requires": { "is-equal-shallow": "0.1.3" @@ -4729,7 +4729,7 @@ "remap-istanbul": { "version": "0.10.1", "resolved": "https://registry.npmjs.org/remap-istanbul/-/remap-istanbul-0.10.1.tgz", - "integrity": "sha1-OqWN1QIdSZ8zbTulvzu7kcG4jjc=", + "integrity": "sha512-gsNQXs5kJLhErICSyYhzVZ++C8LBW8dgwr874Y2QvzAUS75zBlD/juZgXs39nbYJ09fZDlX2AVLVJAY2jbFJoQ==", "dev": true, "requires": { "amdefine": "1.0.1", @@ -4769,7 +4769,7 @@ "source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha1-dHIq8y6WFOnCh6jQu95IteLxomM=", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", "dev": true }, "through2": { @@ -4883,7 +4883,7 @@ "resolve": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.5.0.tgz", - "integrity": "sha1-HwmsznlsmnYlefMbLBzEw83fnzY=", + "integrity": "sha512-hgoSGrc3pjzAPHNBg+KnFcK2HwlHTs/YrAGUr6qgTVUZmXv1UEXXl0bZNBKMA9fud6lRYFdPGz0xXxycPzmmiw==", "dev": true, "requires": { "path-parse": "1.0.5" @@ -4924,7 +4924,7 @@ "rimraf": { "version": "2.6.2", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", - "integrity": "sha1-LtgVDSShbqhlHm1u8PR8QVjOejY=", + "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", "dev": true, "requires": { "glob": "7.1.2" @@ -5063,19 +5063,19 @@ "safe-buffer": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", - "integrity": "sha1-iTMSr2myEj3vcfV4iQAWce6yyFM=", + "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", "dev": true }, "samsam": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/samsam/-/samsam-1.3.0.tgz", - "integrity": "sha1-jR2TUOJWItow3j5EumkrUiGrfFA=", + "integrity": "sha512-1HwIYD/8UlOtFS3QO3w7ey+SdSDFE4HRNLZoZRYVQefrOY3l17epswImeB1ijgJFQJodIaHcwkp3r/myBjFVbg==", "dev": true }, "semver": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz", - "integrity": "sha1-3Eu8emyp2Rbe5dQ1FvAJK1j3uKs=", + "integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==", "dev": true }, "set-blocking": { @@ -5117,7 +5117,7 @@ "sinon-chai": { "version": "2.14.0", "resolved": "https://registry.npmjs.org/sinon-chai/-/sinon-chai-2.14.0.tgz", - "integrity": "sha1-2n3UzIPNaiYLZ8yg96n9riahIF0=", + "integrity": "sha512-9stIF1utB0ywNHNT7RgiXbdmen8QDCRsrTjw+G9TgKt1Yexjiv8TOWZ6WHsTPz57Yky3DIswZvEqX8fpuHNDtQ==", "dev": true }, "slash": { @@ -5146,7 +5146,7 @@ "sntp": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/sntp/-/sntp-2.1.0.tgz", - "integrity": "sha1-LGzsFP7cIiJznK+bXD2F0cxaLMg=", + "integrity": "sha512-FL1b58BDrqS3A11lJ0zEdnJ3UOKqVxawAkF3k7F0CVN7VQ34aZrV+G8BZ1WC9ZL7NyrwsW0oviwsWDgRuVYtJg==", "dev": true, "requires": { "hoek": "4.2.1" @@ -5203,7 +5203,7 @@ "spdx-correct": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.0.0.tgz", - "integrity": "sha1-BaW01xU6GVvJLDxCW2nzsqlSTII=", + "integrity": "sha512-N19o9z5cEyc8yQQPukRCZ9EUmb4HUpnrmaL/fxS2pBo2jbfcFRVuFZ/oFC+vZz0MNNk0h80iMn5/S6qGZOL5+g==", "dev": true, "requires": { "spdx-expression-parse": "3.0.0", @@ -5213,13 +5213,13 @@ "spdx-exceptions": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.1.0.tgz", - "integrity": "sha1-LHrmEFbHFKW5ubKyr30xHvXHj+k=", + "integrity": "sha512-4K1NsmrlCU1JJgUrtgEeTVyfx8VaYea9J9LvARxhbHtVtohPs/gFGG5yy49beySjlIMhhXZ4QqujIZEfS4l6Cg==", "dev": true }, "spdx-expression-parse": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.0.tgz", - "integrity": "sha1-meEZt6XaAOBUkcn6M4t5BII7QdA=", + "integrity": "sha512-Yg6D3XpRD4kkOmTpdgbUiEJFKghJH03fiC1OPll5h/0sO6neh2jqRDVHOQ4o/LMea0tgCkbMgea5ip/e+MkWyg==", "dev": true, "requires": { "spdx-exceptions": "2.1.0", @@ -5229,7 +5229,7 @@ "spdx-license-ids": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.0.tgz", - "integrity": "sha1-enzShHDMbToc/m1miG9rxDDTrIc=", + "integrity": "sha512-2+EPwgbnmOIl8HjGBXXMd9NAu02vLjOO1nWw4kmeRDFyHn+M/ETfHxQUK0oXg8ctgVnl9t3rosNVsZ1jG61nDA==", "dev": true }, "speedometer": { @@ -5566,7 +5566,7 @@ "tough-cookie": { "version": "2.3.4", "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.4.tgz", - "integrity": "sha1-7GDO44rGdQY//JelwYlwV47oNlU=", + "integrity": "sha512-TZ6TTfI5NtZnuyy/Kecv+CnoROnyXn2DN97LontgQpCwsX2XyLYCC0ENhYkehSOwAp8rTQKc/NUIF7BkQ5rKLA==", "dev": true, "requires": { "punycode": "1.4.1" @@ -5708,13 +5708,13 @@ "uuid": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.2.1.tgz", - "integrity": "sha1-EsUou51Y0LkmXZovbw/ovhf/HxQ=", + "integrity": "sha512-jZnMwlb9Iku/O3smGWvZhauCf6cvvpKi4BKRiliS3cxnI+Gz9j5MEpTz2UFuXiKPJocb7gnsLHwiS05ige5BEA==", "dev": true }, "validate-npm-package-license": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.3.tgz", - "integrity": "sha1-gWQ7y+8b3+zUYjeT3EZIlIupgzg=", + "integrity": "sha512-63ZOUnL4SIXj4L0NixR3L1lcjO38crAbgrTpl28t8jjrfuiOBL5Iygm+60qPs/KsZGzPNg6Smnc/oY16QTjF0g==", "dev": true, "requires": { "spdx-correct": "3.0.0", @@ -5750,7 +5750,7 @@ "which": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/which/-/which-1.3.0.tgz", - "integrity": "sha1-/wS9/AEO5UfXgL7DjhrBwnd9JTo=", + "integrity": "sha512-xcJpopdamTuY5duC/KnTTNBraPK54YwpenP4lzxU8H91GudWpFv38u0CKjclE1Wi2EH2EDz5LRcHcKbCIzqGyg==", "dev": true, "requires": { "isexe": "2.0.0" diff --git a/packages/canvas/canvas-mesh/package.json b/packages/canvas/canvas-mesh/package.json index 691cd2c..6744a17 100644 --- a/packages/canvas/canvas-mesh/package.json +++ b/packages/canvas/canvas-mesh/package.json @@ -24,6 +24,7 @@ "dependencies": { "@pixi/constants": "^5.0.0-alpha.2", "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/mesh-extras": "^5.0.0-alpha.2", "@pixi/settings": "^5.0.0-alpha.2" }, "devDependencies": { diff --git a/packages/canvas/canvas-mesh/src/Mesh.js b/packages/canvas/canvas-mesh/src/Mesh.js index 900a872..c43a74b 100644 --- a/packages/canvas/canvas-mesh/src/Mesh.js +++ b/packages/canvas/canvas-mesh/src/Mesh.js @@ -1,36 +1,14 @@ import { Mesh } from '@pixi/mesh'; -import { settings } from './settings'; - -// IMPORTANT: Please do NOT use this as a precedent to use `settings` after the object is created -// this was merely created to completely decouple canvas from the base Mesh class and we are -// unable to add `canvasPadding` in the constructor anymore, as the case was for PixiJS v4. /** - * Internal variable for `canvasPadding`. + * Renders the object using the Canvas renderer * * @private - * @memberof PIXI.Mesh - * @member {number} - * @default null - */ -Mesh.prototype._canvasPadding = null; - -/** - * Triangles in canvas mode are automatically antialiased, use this value to force triangles - * to overlap a bit with each other. To set the global default, set {@link PIXI.settings.MESH_CANVAS_PADDING} - * - * @see PIXI.settings.MESH_CANVAS_PADDING - * @member {number} canvasPadding + * @method _renderCanvas * @memberof PIXI.Mesh# - * @default 0 + * @param {PIXI.CanvasRenderer} renderer - The canvas renderer. */ -Object.defineProperty(Mesh.prototype, 'canvasPadding', { - get() - { - return this._canvasPadding !== null ? this._canvasPadding : settings.MESH_CANVAS_PADDING; - }, - set(value) - { - this._canvasPadding = value; - }, -}); +Mesh.prototype._renderCanvas = function _renderCanvas(renderer) +{ + renderer.plugins[this.pluginName].render(this); +}; diff --git a/packages/canvas/canvas-mesh/src/Mesh2d.js b/packages/canvas/canvas-mesh/src/Mesh2d.js new file mode 100644 index 0000000..d0bd80f --- /dev/null +++ b/packages/canvas/canvas-mesh/src/Mesh2d.js @@ -0,0 +1,36 @@ +import { Mesh2d } from '@pixi/mesh-extras'; +import { settings } from './settings'; + +// IMPORTANT: Please do NOT use this as a precedent to use `settings` after the object is created +// this was merely created to completely decouple canvas from the base Mesh class and we are +// unable to add `canvasPadding` in the constructor anymore, as the case was for PixiJS v4. + +/** + * Internal variable for `canvasPadding`. + * + * @private + * @memberof PIXI.Mesh2d + * @member {number} + * @default null + */ +Mesh2d.prototype._canvasPadding = null; + +/** + * Triangles in canvas mode are automatically antialiased, use this value to force triangles + * to overlap a bit with each other. To set the global default, set {@link PIXI.settings.MESH_CANVAS_PADDING} + * + * @see PIXI.settings.MESH_CANVAS_PADDING + * @member {number} canvasPadding + * @memberof PIXI.Mesh2d# + * @default 0 + */ +Object.defineProperty(Mesh2d.prototype, 'canvasPadding', { + get() + { + return this._canvasPadding !== null ? this._canvasPadding : settings.MESH_CANVAS_PADDING; + }, + set(value) + { + this._canvasPadding = value; + }, +}); diff --git a/packages/canvas/canvas-mesh/src/NineSlicePlane.js b/packages/canvas/canvas-mesh/src/NineSlicePlane.js index 09eaf9c..2fd5acc 100644 --- a/packages/canvas/canvas-mesh/src/NineSlicePlane.js +++ b/packages/canvas/canvas-mesh/src/NineSlicePlane.js @@ -1,4 +1,4 @@ -import { NineSlicePlane } from '@pixi/mesh'; +import { NineSlicePlane } from '@pixi/mesh-extras'; /** * Renders the object using the Canvas renderer diff --git a/packages/canvas/canvas-mesh/src/RawMesh.js b/packages/canvas/canvas-mesh/src/RawMesh.js deleted file mode 100644 index bf40184..0000000 --- a/packages/canvas/canvas-mesh/src/RawMesh.js +++ /dev/null @@ -1,14 +0,0 @@ -import { RawMesh } from '@pixi/mesh'; - -/** - * Renders the object using the Canvas renderer - * - * @private - * @method _renderCanvas - * @memberof PIXI.RawMesh# - * @param {PIXI.CanvasRenderer} renderer - The canvas renderer. - */ -RawMesh.prototype._renderCanvas = function _renderCanvas(renderer) -{ - renderer.plugins[this.pluginName].render(this); -}; diff --git a/packages/canvas/canvas-mesh/src/index.js b/packages/canvas/canvas-mesh/src/index.js index 2295016..f4fa31d 100644 --- a/packages/canvas/canvas-mesh/src/index.js +++ b/packages/canvas/canvas-mesh/src/index.js @@ -1,6 +1,6 @@ export { default as CanvasMeshRenderer } from './CanvasMeshRenderer'; import './settings'; -import './Mesh'; +import './Mesh2d'; import './NineSlicePlane'; -import './RawMesh'; +import './Mesh'; diff --git a/packages/canvas/canvas-mesh/src/settings.js b/packages/canvas/canvas-mesh/src/settings.js index 4cefb4c..e81b8e0 100644 --- a/packages/canvas/canvas-mesh/src/settings.js +++ b/packages/canvas/canvas-mesh/src/settings.js @@ -3,7 +3,7 @@ /** * Default `canvasPadding` for canvas-based Mesh rendering. * - * @see PIXI.Mesh#canvasPadding + * @see PIXI.Mesh2d#canvasPadding * @static * @constant * @memberof PIXI.settings diff --git a/packages/mesh-extras/LICENSE b/packages/mesh-extras/LICENSE new file mode 100644 index 0000000..148e3eb --- /dev/null +++ b/packages/mesh-extras/LICENSE @@ -0,0 +1,21 @@ +The MIT License + +Copyright (c) 2013-2018 Mathew Groves, Chad Engler + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/packages/mesh-extras/README.md b/packages/mesh-extras/README.md new file mode 100644 index 0000000..1d9b0e1 --- /dev/null +++ b/packages/mesh-extras/README.md @@ -0,0 +1,19 @@ +# @pixi/mesh-extras + +## Installation + +```bash +npm install @pixi/mesh-extras +``` + +## Usage + +```js +import { MeshRenderer } from '@pixi/mesh'; +import { Renderer } from '@pixi/core'; +import { Rope } from '@pixi/mesh-extras'; + +Renderer.registerPlugin('mesh', MeshRenderer); + +const rope = new Rope(); +``` \ No newline at end of file diff --git a/packages/mesh-extras/package.json b/packages/mesh-extras/package.json new file mode 100644 index 0000000..d134f64 --- /dev/null +++ b/packages/mesh-extras/package.json @@ -0,0 +1,38 @@ +{ + "name": "@pixi/mesh-extras", + "version": "5.0.0-alpha.2", + "main": "lib/mesh-extras.js", + "module": "lib/mesh-extras.es.js", + "description": "Custom Mesh display objects, like Rope and Plane", + "author": "Mat Groves", + "contributors": [ + "Matt Karl " + ], + "homepage": "http://pixijs.com/", + "bugs": "https://github.com/pixijs/pixi.js/issues", + "license": "MIT", + "repository": { + "type": "git", + "url": "https://github.com/pixijs/pixi.js.git" + }, + "publishConfig": { + "access": "public" + }, + "scripts": { + "test": "floss --path test" + }, + "files": [ + "lib" + ], + "dependencies": { + "@pixi/constants": "^5.0.0-alpha.2", + "@pixi/core": "^5.0.0-alpha.2", + "@pixi/math": "^5.0.0-alpha.2", + "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/utils": "^5.0.0-alpha.2" + }, + "devDependencies": { + "@pixi/loaders": "^5.0.0-alpha.2", + "floss": "^2.1.3" + } +} diff --git a/packages/mesh-extras/src/Mesh2d.js b/packages/mesh-extras/src/Mesh2d.js new file mode 100644 index 0000000..d113a5e --- /dev/null +++ b/packages/mesh-extras/src/Mesh2d.js @@ -0,0 +1,263 @@ +import { Mesh } from '@pixi/mesh'; +import { Geometry, Program, Shader, Texture, TextureMatrix } from '@pixi/core'; +import { Matrix } from '@pixi/math'; +import { BLEND_MODES } from '@pixi/constants'; +import { hex2rgb, premultiplyRgba } from '@pixi/utils'; +import vertex from './mesh.vert'; +import fragment from './mesh.frag'; + +let meshProgram; + +/** + * Base mesh class + * @class + * @extends PIXI.Container + * @memberof PIXI + */ +export default class Mesh2d extends Mesh +{ + /** + * @param {PIXI.Texture} [texture=Texture.EMPTY] - The texture to use + * @param {Float32Array} [vertices] - if you want to specify the vertices + * @param {Float32Array} [uvs] - if you want to specify the uvs + * @param {Uint16Array} [indices] - if you want to specify the indices + * @param {number} [drawMode] - the drawMode, can be any of the Mesh.DRAW_MODES consts + */ + constructor(texture = Texture.EMPTY, vertices, uvs, indices, drawMode) + { + const geometry = new Geometry(); + + if (!meshProgram) + { + meshProgram = new Program(vertex, fragment); + } + + geometry.addAttribute('aVertexPosition', vertices) + .addAttribute('aTextureCoord', uvs) + .addIndex(indices); + + geometry.getAttribute('aVertexPosition').static = false; + + const uniforms = { + uSampler: texture, + uTextureMatrix: Matrix.IDENTITY, + alpha: 1, + uColor: new Float32Array([1, 1, 1, 1]), + }; + + super(geometry, new Shader(meshProgram, uniforms), null, drawMode); + + /** + * The Uvs of the Mesh + * + * @member {Float32Array} + */ + this.uvs = geometry.getAttribute('aTextureCoord').data; + + /** + * An array of vertices + * + * @member {Float32Array} + */ + this.vertices = geometry.getAttribute('aVertexPosition').data; + + this.uniforms = uniforms; + + /** + * The texture of the Mesh + * + * @member {PIXI.Texture} + * @default PIXI.Texture.EMPTY + * @private + */ + this.texture = texture; + + /** + * The tint applied to the mesh. This is a [r,g,b] value. A value of [1,1,1] will remove any + * tint effect. + * + * @member {number} + * @private + */ + this._tintRGB = new Float32Array([1, 1, 1]); + + // Set default tint + this.tint = 0xFFFFFF; + + this.blendMode = BLEND_MODES.NORMAL; + + /** + * TextureMatrix instance for this Mesh, used to track Texture changes + * + * @member {PIXI.TextureMatrix} + * @readonly + */ + this.uvMatrix = new TextureMatrix(this._texture); + + /** + * whether or not upload uvMatrix to shader + * if its false, then uvs should be pre-multiplied + * if you change it for generated mesh, please call 'refresh(true)' + * @member {boolean} + * @default false + */ + this.uploadUvMatrix = false; + + /** + * Uploads vertices buffer every frame, like in PixiJS V3 and V4. + * + * @member {boolean} + * @default true + */ + this.autoUpdate = true; + } + + /** + * The tint applied to the Rope. This is a hex value. A value of + * 0xFFFFFF will remove any tint effect. + * + * @member {number} + * @memberof PIXI.Sprite# + * @default 0xFFFFFF + */ + get tint() + { + return this._tint; + } + + /** + * Sets the tint of the rope. + * + * @param {number} value - The value to set to. + */ + set tint(value) + { + this._tint = value; + + hex2rgb(this._tint, this._tintRGB); + } + + /** + * The blend mode to be applied to the sprite. Set to `PIXI.BLEND_MODES.NORMAL` to remove any blend mode. + * + * @member {number} + * @default PIXI.BLEND_MODES.NORMAL + * @see PIXI.BLEND_MODES + */ + get blendMode() + { + return this.state.blendMode; + } + + set blendMode(value) // eslint-disable-line require-jsdoc + { + this.state.blendMode = value; + } + + /** + * The texture that the mesh uses. + * + * @member {PIXI.Texture} + */ + get texture() + { + return this._texture; + } + + set texture(value) // eslint-disable-line require-jsdoc + { + if (this._texture === value) + { + return; + } + + this._texture = value; + this.uniforms.uSampler = this.texture; + + if (value) + { + // wait for the texture to load + if (value.baseTexture.valid) + { + this._onTextureUpdate(); + } + else + { + value.once('update', this._onTextureUpdate, this); + } + } + } + + _render(renderer) + { + const baseTex = this._texture.baseTexture; + + premultiplyRgba(this._tintRGB, this.worldAlpha, this.uniforms.uColor, baseTex.premultiplyAlpha); + super._render(renderer); + } + /** + * When the texture is updated, this event will fire to update the scale and frame + * + * @private + */ + _onTextureUpdate() + { + // constructor texture update stop + if (!this.uvMatrix) + { + return; + } + this.uvMatrix.texture = this._texture; + this.refresh(); + } + + /** + * multiplies uvs only if uploadUvMatrix is false + * call it after you change uvs manually + * make sure that texture is valid + */ + multiplyUvs() + { + if (!this.uploadUvMatrix) + { + this.uvMatrix.multiplyUvs(this.uvs); + } + } + + /** + * Refreshes uvs for generated meshes (rope, plane) + * sometimes refreshes vertices too + * + * @param {boolean} [forceUpdate=false] if true, matrices will be updated any case + */ + refresh(forceUpdate) + { + if (this.uvMatrix.update(forceUpdate)) + { + this._refresh(); + } + } + + /** + * Updates the object transform for rendering + * + * @private + */ + updateTransform() + { + if (this.autoUpdate) + { + this.geometry.buffers[0].update(); + } + this.containerUpdateTransform(); + } + + /** + * re-calculates mesh coords + * @private + */ + _refresh() + { + /* empty */ + } +} diff --git a/packages/mesh-extras/src/NineSlicePlane.js b/packages/mesh-extras/src/NineSlicePlane.js new file mode 100644 index 0000000..0bae92c --- /dev/null +++ b/packages/mesh-extras/src/NineSlicePlane.js @@ -0,0 +1,270 @@ +import Plane from './Plane'; + +const DEFAULT_BORDER_SIZE = 10; + +/** + * The NineSlicePlane allows you to stretch a texture using 9-slice scaling. The corners will remain unscaled (useful + * for buttons with rounded corners for example) and the other areas will be scaled horizontally and or vertically + * + *```js + * let Plane9 = new PIXI.NineSlicePlane(PIXI.Texture.from('BoxWithRoundedCorners.png'), 15, 15, 15, 15); + * ``` + *
+ *      A                          B
+ *    +---+----------------------+---+
+ *  C | 1 |          2           | 3 |
+ *    +---+----------------------+---+
+ *    |   |                      |   |
+ *    | 4 |          5           | 6 |
+ *    |   |                      |   |
+ *    +---+----------------------+---+
+ *  D | 7 |          8           | 9 |
+ *    +---+----------------------+---+
+
+ *  When changing this objects width and/or height:
+ *     areas 1 3 7 and 9 will remain unscaled.
+ *     areas 2 and 8 will be stretched horizontally
+ *     areas 4 and 6 will be stretched vertically
+ *     area 5 will be stretched both horizontally and vertically
+ * 
+ * + * @class + * @extends PIXI.Plane + * @memberof PIXI + * + */ +export default class NineSlicePlane extends Plane +{ + /** + * @param {PIXI.Texture} texture - The texture to use on the NineSlicePlane. + * @param {int} [leftWidth=10] size of the left vertical bar (A) + * @param {int} [topHeight=10] size of the top horizontal bar (C) + * @param {int} [rightWidth=10] size of the right vertical bar (B) + * @param {int} [bottomHeight=10] size of the bottom horizontal bar (D) + */ + constructor(texture, leftWidth, topHeight, rightWidth, bottomHeight) + { + super(texture, 4, 4); + + this._origWidth = texture.orig.width; + this._origHeight = texture.orig.height; + + /** + * The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._width = this._origWidth; + + /** + * The height of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._height = this._origHeight; + + /** + * The width of the left column (a) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._leftWidth = typeof leftWidth !== 'undefined' ? leftWidth : DEFAULT_BORDER_SIZE; + + /** + * The width of the right column (b) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._rightWidth = typeof rightWidth !== 'undefined' ? rightWidth : DEFAULT_BORDER_SIZE; + + /** + * The height of the top row (c) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._topHeight = typeof topHeight !== 'undefined' ? topHeight : DEFAULT_BORDER_SIZE; + + /** + * The height of the bottom row (d) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._bottomHeight = typeof bottomHeight !== 'undefined' ? bottomHeight : DEFAULT_BORDER_SIZE; + + this.refresh(true); + } + + /** + * Updates the horizontal vertices. + * + */ + updateHorizontalVertices() + { + const vertices = this.vertices; + + const h = this._topHeight + this._bottomHeight; + const scale = this._height > h ? 1.0 : this._height / h; + + vertices[9] = vertices[11] = vertices[13] = vertices[15] = this._topHeight * scale; + vertices[17] = vertices[19] = vertices[21] = vertices[23] = this._height - (this._bottomHeight * scale); + vertices[25] = vertices[27] = vertices[29] = vertices[31] = this._height; + } + + /** + * Updates the vertical vertices. + * + */ + updateVerticalVertices() + { + const vertices = this.vertices; + + const w = this._leftWidth + this._rightWidth; + const scale = this._width > w ? 1.0 : this._width / w; + + vertices[2] = vertices[10] = vertices[18] = vertices[26] = this._leftWidth * scale; + vertices[4] = vertices[12] = vertices[20] = vertices[28] = this._width - (this._rightWidth * scale); + vertices[6] = vertices[14] = vertices[22] = vertices[30] = this._width; + } + + /** + * The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + */ + get width() + { + return this._width; + } + + set width(value) // eslint-disable-line require-jsdoc + { + this._width = value; + this._refresh(); + } + + /** + * The height of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + */ + get height() + { + return this._height; + } + + set height(value) // eslint-disable-line require-jsdoc + { + this._height = value; + this._refresh(); + } + + /** + * The width of the left column + * + * @member {number} + */ + get leftWidth() + { + return this._leftWidth; + } + + set leftWidth(value) // eslint-disable-line require-jsdoc + { + this._leftWidth = value; + this._refresh(); + } + + /** + * The width of the right column + * + * @member {number} + */ + get rightWidth() + { + return this._rightWidth; + } + + set rightWidth(value) // eslint-disable-line require-jsdoc + { + this._rightWidth = value; + this._refresh(); + } + + /** + * The height of the top row + * + * @member {number} + */ + get topHeight() + { + return this._topHeight; + } + + set topHeight(value) // eslint-disable-line require-jsdoc + { + this._topHeight = value; + this._refresh(); + } + + /** + * The height of the bottom row + * + * @member {number} + */ + get bottomHeight() + { + return this._bottomHeight; + } + + set bottomHeight(value) // eslint-disable-line require-jsdoc + { + this._bottomHeight = value; + this._refresh(); + } + + /** + * Refreshes NineSlicePlane coords. All of them. + */ + _refresh() + { + super._refresh(); + + const uvs = this.uvs; + const texture = this._texture; + + this._origWidth = texture.orig.width; + this._origHeight = texture.orig.height; + + const _uvw = 1.0 / this._origWidth; + const _uvh = 1.0 / this._origHeight; + + uvs[0] = uvs[8] = uvs[16] = uvs[24] = 0; + uvs[1] = uvs[3] = uvs[5] = uvs[7] = 0; + uvs[6] = uvs[14] = uvs[22] = uvs[30] = 1; + uvs[25] = uvs[27] = uvs[29] = uvs[31] = 1; + + uvs[2] = uvs[10] = uvs[18] = uvs[26] = _uvw * this._leftWidth; + uvs[4] = uvs[12] = uvs[20] = uvs[28] = 1 - (_uvw * this._rightWidth); + uvs[9] = uvs[11] = uvs[13] = uvs[15] = _uvh * this._topHeight; + uvs[17] = uvs[19] = uvs[21] = uvs[23] = 1 - (_uvh * this._bottomHeight); + + this.updateHorizontalVertices(); + this.updateVerticalVertices(); + + this.geometry.buffers[1].update(); + + this.multiplyUvs(); + } +} diff --git a/packages/mesh-extras/src/Plane.js b/packages/mesh-extras/src/Plane.js new file mode 100644 index 0000000..1c240c4 --- /dev/null +++ b/packages/mesh-extras/src/Plane.js @@ -0,0 +1,100 @@ +import Mesh2d from './Mesh2d'; + +/** + * The Plane allows you to draw a texture across several points and them manipulate these points + * + *```js + * for (let i = 0; i < 20; i++) { + * points.push(new PIXI.Point(i * 50, 0)); + * }; + * let Plane = new PIXI.Plane(PIXI.Texture.from("snake.png"), points); + * ``` + * + * @class + * @extends PIXI.Mesh + * @memberof PIXI + * + */ +export default class Plane extends Mesh2d +{ + /** + * @param {PIXI.Texture} texture - The texture to use on the Plane. + * @param {number} verticesX - The number of vertices in the x-axis + * @param {number} verticesY - The number of vertices in the y-axis + * @param {object} [opts] - an options object - add meshWidth and meshHeight, temporary object for PixiJS v5 alpha + */ + constructor(texture, verticesX, verticesY, opts = {}) + { + super(texture, new Float32Array(1), new Float32Array(1), new Uint16Array(1), 4); + + this.verticesX = verticesX || 10; + this.verticesY = verticesY || 10; + + this.meshWidth = opts.meshWidth || 0; + this.meshHeight = opts.meshHeight || 0; + + this.refresh(); + } + + /** + * Refreshes plane coordinates + * @private + */ + _refresh() + { + const texture = this._texture; + const total = this.verticesX * this.verticesY; + const verts = []; + const uvs = []; + const indices = []; + + const segmentsX = this.verticesX - 1; + const segmentsY = this.verticesY - 1; + + const sizeX = (this.meshWidth || texture.width) / segmentsX; + const sizeY = (this.meshHeight || texture.height) / segmentsY; + + for (let i = 0; i < total; i++) + { + const x = (i % this.verticesX); + const y = ((i / this.verticesX) | 0); + + verts.push(x * sizeX, y * sizeY); + + uvs.push(x / segmentsX, y / segmentsY); + } + + // cons + + const totalSub = segmentsX * segmentsY; + + for (let i = 0; i < totalSub; i++) + { + const xpos = i % segmentsX; + const ypos = (i / segmentsX) | 0; + + const value = (ypos * this.verticesX) + xpos; + const value2 = (ypos * this.verticesX) + xpos + 1; + const value3 = ((ypos + 1) * this.verticesX) + xpos; + const value4 = ((ypos + 1) * this.verticesX) + xpos + 1; + + indices.push(value, value2, value3); + indices.push(value2, value4, value3); + } + + this.vertices = new Float32Array(verts); + this.uvs = new Float32Array(uvs); + this.indices = new Uint16Array(indices); + + this.geometry.buffers[0].data = this.vertices; + this.geometry.buffers[1].data = this.uvs; + this.geometry.indexBuffer.data = this.indices; + + // ensure that the changes are uploaded + this.geometry.buffers[0].update(); + this.geometry.buffers[1].update(); + this.geometry.indexBuffer.update(); + + this.multiplyUvs(); + } +} diff --git a/packages/mesh-extras/src/Rope.js b/packages/mesh-extras/src/Rope.js new file mode 100644 index 0000000..9cfde38 --- /dev/null +++ b/packages/mesh-extras/src/Rope.js @@ -0,0 +1,182 @@ +import Mesh2d from './Mesh2d'; + +/** + * The rope allows you to draw a texture across several points and them manipulate these points + * + *```js + * for (let i = 0; i < 20; i++) { + * points.push(new PIXI.Point(i * 50, 0)); + * }; + * let rope = new PIXI.Rope(PIXI.Texture.from("snake.png"), points); + * ``` + * + * @class + * @extends PIXI.Mesh + * @memberof PIXI + * + */ +export default class Rope extends Mesh2d +{ + /** + * @param {PIXI.Texture} texture - The texture to use on the rope. + * @param {PIXI.Point[]} points - An array of {@link PIXI.Point} objects to construct this rope. + */ + constructor(texture, points) + { + super(texture, new Float32Array(points.length * 4), + new Float32Array(points.length * 4), + new Uint16Array(points.length * 2), + 5); + + /* + * @member {PIXI.Point[]} An array of points that determine the rope + */ + this.points = points; + this.refresh(); + } + /** + * Refreshes Rope indices and uvs + * @private + */ + _refresh() + { + const points = this.points; + + if (!points) return; + + const vertexBuffer = this.geometry.getAttribute('aVertexPosition'); + const uvBuffer = this.geometry.getAttribute('aTextureCoord'); + const indexBuffer = this.geometry.getIndex(); + + // if too little points, or texture hasn't got UVs set yet just move on. + if (points.length < 1 || !this.texture._uvs) + { + return; + } + + // if the number of points has changed we will need to recreate the arraybuffers + if (vertexBuffer.data.length / 4 !== points.length) + { + vertexBuffer.data = new Float32Array(points.length * 4); + uvBuffer.data = new Float32Array(points.length * 4); + indexBuffer.data = new Uint16Array(points.length * 2); + } + + const uvs = uvBuffer.data; + const indices = indexBuffer.data; + + uvs[0] = 0; + uvs[1] = 0; + uvs[2] = 0; + uvs[3] = 1; + + indices[0] = 0; + indices[1] = 1; + + const total = points.length; + + for (let i = 1; i < total; i++) + { + // time to do some smart drawing! + let index = i * 4; + const amount = i / (total - 1); + + uvs[index] = amount; + uvs[index + 1] = 0; + + uvs[index + 2] = amount; + uvs[index + 3] = 1; + + index = i * 2; + indices[index] = index; + indices[index + 1] = index + 1; + } + + // ensure that the changes are uploaded + uvBuffer.update(); + indexBuffer.update(); + + this.multiplyUvs(); + this.refreshVertices(); + } + + /** + * refreshes vertices of Rope mesh + */ + refreshVertices() + { + const points = this.points; + + if (points.length < 1) + { + return; + } + + let lastPoint = points[0]; + let nextPoint; + let perpX = 0; + let perpY = 0; + + // this.count -= 0.2; + + const vertices = this.vertices; + const total = points.length; + + for (let i = 0; i < total; i++) + { + const point = points[i]; + const index = i * 4; + + if (i < points.length - 1) + { + nextPoint = points[i + 1]; + } + else + { + nextPoint = point; + } + + perpY = -(nextPoint.x - lastPoint.x); + perpX = nextPoint.y - lastPoint.y; + + let ratio = (1 - (i / (total - 1))) * 10; + + if (ratio > 1) + { + ratio = 1; + } + + const perpLength = Math.sqrt((perpX * perpX) + (perpY * perpY)); + const num = this._texture.height / 2; // (20 + Math.abs(Math.sin((i + this.count) * 0.3) * 50) )* ratio; + + perpX /= perpLength; + perpY /= perpLength; + + perpX *= num; + perpY *= num; + + vertices[index] = point.x + perpX; + vertices[index + 1] = point.y + perpY; + vertices[index + 2] = point.x - perpX; + vertices[index + 3] = point.y - perpY; + + lastPoint = point; + } + + this.geometry.buffers[0].update(); + } + + /** + * Updates the object transform for rendering + * + * @private + */ + updateTransform() + { + if (this.autoUpdate) + { + this.refreshVertices(); + } + this.containerUpdateTransform(); + } +} diff --git a/packages/mesh-extras/src/index.js b/packages/mesh-extras/src/index.js new file mode 100644 index 0000000..decf454 --- /dev/null +++ b/packages/mesh-extras/src/index.js @@ -0,0 +1,4 @@ +export { default as Mesh2d } from './Mesh2d'; +export { default as Plane } from './Plane'; +export { default as NineSlicePlane } from './NineSlicePlane'; +export { default as Rope } from './Rope'; diff --git a/packages/mesh-extras/src/mesh.frag b/packages/mesh-extras/src/mesh.frag new file mode 100644 index 0000000..6096983 --- /dev/null +++ b/packages/mesh-extras/src/mesh.frag @@ -0,0 +1,9 @@ +varying vec2 vTextureCoord; +uniform vec4 uColor; + +uniform sampler2D uSampler; + +void main(void) +{ + gl_FragColor = texture2D(uSampler, vTextureCoord) * uColor; +} diff --git a/packages/mesh-extras/src/mesh.vert b/packages/mesh-extras/src/mesh.vert new file mode 100644 index 0000000..0526df9 --- /dev/null +++ b/packages/mesh-extras/src/mesh.vert @@ -0,0 +1,15 @@ +attribute vec2 aVertexPosition; +attribute vec2 aTextureCoord; + +uniform mat3 projectionMatrix; +uniform mat3 translationMatrix; +uniform mat3 uTextureMatrix; + +varying vec2 vTextureCoord; + +void main(void) +{ + gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); + + vTextureCoord = (uTextureMatrix * vec3(aTextureCoord, 1.0)).xy; +} diff --git a/packages/mesh-extras/test/.eslintrc.json b/packages/mesh-extras/test/.eslintrc.json new file mode 100644 index 0000000..2ad8efb --- /dev/null +++ b/packages/mesh-extras/test/.eslintrc.json @@ -0,0 +1,12 @@ +{ + "globals": { + "expect": false, + "assert": false, + "sinon": false, + "PIXI": false + }, + "rules": { + "func-names": 0, + "no-unused-expressions": 0 + } +} \ No newline at end of file diff --git a/packages/mesh-extras/test/Plane.js b/packages/mesh-extras/test/Plane.js new file mode 100644 index 0000000..f9b1c25 --- /dev/null +++ b/packages/mesh-extras/test/Plane.js @@ -0,0 +1,60 @@ +const { Plane } = require('../'); +const { isWebGLSupported, skipHello } = require('@pixi/utils'); +const { Loader } = require('@pixi/loaders'); +const { Point } = require('@pixi/math'); +const { RenderTexture, Texture } = require('@pixi/core'); + +skipHello(); + +function withGL(fn) +{ + return isWebGLSupported() ? fn : undefined; +} + +// TODO: fix with webglrenderer +describe('PIXI.mesh.Plane', function () +{ + it.skip('should create a plane from an external image', withGL(function (done) + { + const loader = new Loader(); + + loader.add('testBitmap', `file://${__dirname}/resources/bitmap-1.png`) + .load(function (loader, resources) + { + const plane = new Plane(resources.testBitmap.texture, 100, 100); + + expect(plane.verticesX).to.equal(100); + expect(plane.verticesY).to.equal(100); + done(); + }); + })); + + it.skip('should create a new empty textured Plane', withGL(function () + { + const plane = new Plane(Texture.EMPTY, 100, 100); + + expect(plane.verticesX).to.equal(100); + expect(plane.verticesY).to.equal(100); + })); + + describe('containsPoint', function () + { + it.skip('should return true when point inside', withGL(function () + { + const point = new Point(10, 10); + const texture = new RenderTexture.create(20, 30); + const plane = new Plane(texture, 100, 100); + + expect(plane.containsPoint(point)).to.be.true; + })); + + it.skip('should return false when point outside', withGL(function () + { + const point = new Point(100, 100); + const texture = new RenderTexture.create(20, 30); + const plane = new Plane(texture, 100, 100); + + expect(plane.containsPoint(point)).to.be.false; + })); + }); +}); diff --git a/packages/mesh-extras/test/index.js b/packages/mesh-extras/test/index.js new file mode 100644 index 0000000..d767624 --- /dev/null +++ b/packages/mesh-extras/test/index.js @@ -0,0 +1 @@ +require('./Plane'); diff --git a/packages/mesh-extras/test/resources/bitmap-1.png b/packages/mesh-extras/test/resources/bitmap-1.png new file mode 100644 index 0000000..1284fb8 --- /dev/null +++ b/packages/mesh-extras/test/resources/bitmap-1.png Binary files differ diff --git a/packages/mesh/package.json b/packages/mesh/package.json index 8b1f8d9..10bd8e3 100644 --- a/packages/mesh/package.json +++ b/packages/mesh/package.json @@ -18,22 +18,16 @@ "publishConfig": { "access": "public" }, - "scripts": { - "test": "floss --path test" - }, "files": [ "lib" ], "dependencies": { - "@pixi/canvas-renderer": "^5.0.0-alpha.2", "@pixi/constants": "^5.0.0-alpha.2", "@pixi/core": "^5.0.0-alpha.2", "@pixi/display": "^5.0.0-alpha.2", - "@pixi/math": "^5.0.0-alpha.2", - "@pixi/utils": "^5.0.0-alpha.2" + "@pixi/math": "^5.0.0-alpha.2" }, "devDependencies": { - "@pixi/loaders": "^5.0.0-alpha.2", "floss": "^2.1.3" } } diff --git a/packages/mesh/src/Mesh.js b/packages/mesh/src/Mesh.js index e7c8f9e..1f35b7a 100644 --- a/packages/mesh/src/Mesh.js +++ b/packages/mesh/src/Mesh.js @@ -1,263 +1,220 @@ -import RawMesh from './RawMesh'; -import { Geometry, Program, Shader, Texture, TextureMatrix } from '@pixi/core'; -import { Matrix } from '@pixi/math'; -import { BLEND_MODES } from '@pixi/constants'; -import { hex2rgb, premultiplyRgba } from '@pixi/utils'; -import vertex from './mesh.vert'; -import fragment from './mesh.frag'; +import { State } from '@pixi/core'; +import { DRAW_MODES } from '@pixi/constants'; +import { Point, Polygon } from '@pixi/math'; +import { Container } from '@pixi/display'; -let meshProgram; +const tempPoint = new Point(); +const tempPolygon = new Polygon(); /** - * Base mesh class + * Base mesh class. + * The reason for this class is to empower you to have maximum flexibility to render any kind of webGL you can think of. + * This class assumes a certain level of webGL knowledge. + * If you know a bit this should abstract enough away to make you life easier! + * Pretty much ALL WebGL can be broken down into the following: + * Geometry - The structure and data for the mesh. This can include anything from positions, uvs, normals, colors etc.. + * Shader - This is the shader that pixi will render the geometry with. (attributes in the shader must match the geometry!) + * Uniforms - These are the values passed to the shader when the mesh is rendered. + * As a shader can be reused across multiple objects, it made sense to allow uniforms to exist outside of the shader + * State - This is the state of WebGL required to render the mesh. + * Through a combination of the above elements you can render anything you want, 2D or 3D! + * * @class * @extends PIXI.Container * @memberof PIXI */ -export default class Mesh extends RawMesh +export default class Mesh extends Container { /** - * @param {PIXI.Texture} [texture=Texture.EMPTY] - The texture to use - * @param {Float32Array} [vertices] - if you want to specify the vertices - * @param {Float32Array} [uvs] - if you want to specify the uvs - * @param {Uint16Array} [indices] - if you want to specify the indices - * @param {number} [drawMode] - the drawMode, can be any of the Mesh.DRAW_MODES consts + * @param {PIXI.Geometry} geometry the geometry the mesh will use + * @param {PIXI.Shader} shader the shader the mesh will use + * @param {PIXI.State} state the state that the webGL context is required to be in to render the mesh + * @param {number} drawMode the drawMode, can be any of the PIXI.DRAW_MODES consts */ - constructor(texture = Texture.EMPTY, vertices, uvs, indices, drawMode) + constructor(geometry, shader, state, drawMode = DRAW_MODES.TRIANGLES) { - const geometry = new Geometry(); - - if (!meshProgram) - { - meshProgram = new Program(vertex, fragment); - } - - geometry.addAttribute('aVertexPosition', vertices) - .addAttribute('aTextureCoord', uvs) - .addIndex(indices); - - geometry.getAttribute('aVertexPosition').static = false; - - const uniforms = { - uSampler: texture, - uTextureMatrix: Matrix.IDENTITY, - alpha: 1, - uColor: new Float32Array([1, 1, 1, 1]), - }; - - super(geometry, new Shader(meshProgram, uniforms), null, drawMode); + super(); /** - * The Uvs of the Mesh - * - * @member {Float32Array} + * the geometry the mesh will use + * @type {PIXI.Geometry} */ - this.uvs = geometry.getAttribute('aTextureCoord').data; + this.geometry = geometry; /** - * An array of vertices - * - * @member {Float32Array} + * the shader the mesh will use + * @type {PIXI.Shader} */ - this.vertices = geometry.getAttribute('aVertexPosition').data; - - this.uniforms = uniforms; + this.shader = shader; /** - * The texture of the Mesh - * - * @member {PIXI.Texture} - * @default PIXI.Texture.EMPTY - * @private + * the webGL state the mesh requires to render + * @type {PIXI.State} */ - this.texture = texture; + this.state = state || new State(); /** - * The tint applied to the mesh. This is a [r,g,b] value. A value of [1,1,1] will remove any - * tint effect. + * The way the Mesh should be drawn, can be any of the {@link PIXI.Mesh.DRAW_MODES} consts * * @member {number} + * @see PIXI.Mesh.DRAW_MODES + */ + this.drawMode = drawMode; + + /** + * The way uniforms that will be used by the mesh's shader. + * @member {Object} + */ + + /** + * A map of renderer IDs to webgl render data + * * @private + * @member {object} */ - this._tintRGB = new Float32Array([1, 1, 1]); - - // Set default tint - this.tint = 0xFFFFFF; - - this.blendMode = BLEND_MODES.NORMAL; + this._glDatas = {}; /** - * TextureMatrix instance for this Mesh, used to track Texture changes + * Plugin that is responsible for rendering this element. + * Allows to customize the rendering process without overriding '_render' & '_renderCanvas' methods. * - * @member {PIXI.TextureMatrix} - * @readonly + * @member {string} + * @default 'mesh' */ - this.uvMatrix = new TextureMatrix(this._texture); + this.pluginName = 'mesh'; - /** - * whether or not upload uvMatrix to shader - * if its false, then uvs should be pre-multiplied - * if you change it for generated mesh, please call 'refresh(true)' - * @member {boolean} - * @default false - */ - this.uploadUvMatrix = false; - - /** - * Uploads vertices buffer every frame, like in PixiJS V3 and V4. - * - * @member {boolean} - * @default true - */ - this.autoUpdate = true; + this.start = 0; + this.size = 0; } /** - * The tint applied to the Rope. This is a hex value. A value of - * 0xFFFFFF will remove any tint effect. + * Renders the object using the WebGL renderer * - * @member {number} - * @memberof PIXI.Sprite# - * @default 0xFFFFFF + * @param {PIXI.Renderer} renderer a reference to the WebGL renderer + * @private */ - get tint() + _render(renderer) { - return this._tint; + renderer.batch.setObjectRenderer(renderer.plugins[this.pluginName]); + renderer.plugins[this.pluginName].render(this); } /** - * Sets the tint of the rope. + * Updates the bounds of the mesh as a rectangle. The bounds calculation takes the worldTransform into account. + * there must be a aVertexPosition attribute present in the geometry for bounds to be calculated correctly. * - * @param {number} value - The value to set to. + * @private */ - set tint(value) + _calculateBounds() { - this._tint = value; - - hex2rgb(this._tint, this._tintRGB); - } - - /** - * The blend mode to be applied to the sprite. Set to `PIXI.BLEND_MODES.NORMAL` to remove any blend mode. - * - * @member {number} - * @default PIXI.BLEND_MODES.NORMAL - * @see PIXI.BLEND_MODES - */ - get blendMode() - { - return this.state.blendMode; - } - - set blendMode(value) // eslint-disable-line require-jsdoc - { - this.state.blendMode = value; - } - - /** - * The texture that the mesh uses. - * - * @member {PIXI.Texture} - */ - get texture() - { - return this._texture; - } - - set texture(value) // eslint-disable-line require-jsdoc - { - if (this._texture === value) + // The position property could be set manually? + if (this.geometry.attributes.aVertexPosition) { - return; + const vertices = this.geometry.getAttribute('aVertexPosition').data; + + // TODO - we can cache local bounds and use them if they are dirty (like graphics) + this._bounds.addVertices(this.transform, vertices, 0, vertices.length); + } + } + + /** + * Tests if a point is inside this mesh. Works only for TRIANGLE_MESH + * + * @param {PIXI.Point} point the point to test + * @return {boolean} the result of the test + */ + containsPoint(point) + { + if (!this.getBounds().contains(point.x, point.y)) + { + return false; } - this._texture = value; - this.uniforms.uSampler = this.texture; + this.worldTransform.applyInverse(point, tempPoint); - if (value) + const vertices = this.geometry.getAttribute('aVertexPosition').data; + + const points = tempPolygon.points; + const indices = this.geometry.getIndex().data; + const len = indices.length; + const step = this.drawMode === 4 ? 3 : 1; + + for (let i = 0; i + 2 < len; i += step) { - // wait for the texture to load - if (value.baseTexture.valid) + const ind0 = indices[i] * 2; + const ind1 = indices[i + 1] * 2; + const ind2 = indices[i + 2] * 2; + + points[0] = vertices[ind0]; + points[1] = vertices[ind0 + 1]; + points[2] = vertices[ind1]; + points[3] = vertices[ind1 + 1]; + points[4] = vertices[ind2]; + points[5] = vertices[ind2 + 1]; + + if (tempPolygon.contains(tempPoint.x, tempPoint.y)) { - this._onTextureUpdate(); + return true; + } + } + + return false; + } + + /** + * Destroys the Mesh object. + * + * @param {object|boolean} [options] - Options parameter. A boolean will act as if all + * options have been set to that value + * @param {boolean} [options.children=false] - if set to true, all the children will have + * their destroy method called as well. 'options' will be passed on to those calls. + * @param {boolean} [options.texture=false] - Only used for child Sprites if options.children is set to true + * Should it destroy the texture of the child sprite + * @param {boolean} [options.baseTexture=false] - Only used for child Sprites if options.children is set to true + * Should it destroy the base texture of the child sprite + */ + destroy(options) + { + // for each webgl data entry, destroy the WebGLGraphicsData + for (const id in this._glDatas) + { + const data = this._glDatas[id]; + + if (data.destroy) + { + data.destroy(); } else { - value.once('update', this._onTextureUpdate, this); + if (data.vertexBuffer) + { + data.vertexBuffer.destroy(); + data.vertexBuffer = null; + } + if (data.indexBuffer) + { + data.indexBuffer.destroy(); + data.indexBuffer = null; + } + if (data.uvBuffer) + { + data.uvBuffer.destroy(); + data.uvBuffer = null; + } + if (data.vao) + { + data.vao.destroy(); + data.vao = null; + } } } - } - _render(renderer) - { - const baseTex = this._texture.baseTexture; + this._glDatas = null; - premultiplyRgba(this._tintRGB, this.worldAlpha, this.uniforms.uColor, baseTex.premultiplyAlpha); - super._render(renderer); - } - /** - * When the texture is updated, this event will fire to update the scale and frame - * - * @private - */ - _onTextureUpdate() - { - // constructor texture update stop - if (!this.uvMatrix) - { - return; - } - this.uvMatrix.texture = this._texture; - this.refresh(); - } + this.geometry = null; + this.shader = null; + this.state = null; - /** - * multiplies uvs only if uploadUvMatrix is false - * call it after you change uvs manually - * make sure that texture is valid - */ - multiplyUvs() - { - if (!this.uploadUvMatrix) - { - this.uvMatrix.multiplyUvs(this.uvs); - } - } - - /** - * Refreshes uvs for generated meshes (rope, plane) - * sometimes refreshes vertices too - * - * @param {boolean} [forceUpdate=false] if true, matrices will be updated any case - */ - refresh(forceUpdate) - { - if (this.uvMatrix.update(forceUpdate)) - { - this._refresh(); - } - } - - /** - * Updates the object transform for rendering - * - * @private - */ - updateTransform() - { - if (this.autoUpdate) - { - this.geometry.buffers[0].update(); - } - this.containerUpdateTransform(); - } - - /** - * re-calculates mesh coords - * @private - */ - _refresh() - { - /* empty */ + super.destroy(options); } } diff --git a/packages/mesh/src/MeshRenderer.js b/packages/mesh/src/MeshRenderer.js index 12b159b..d7baf9b 100644 --- a/packages/mesh/src/MeshRenderer.js +++ b/packages/mesh/src/MeshRenderer.js @@ -36,7 +36,7 @@ /** * renders mesh * @private - * @param {PIXI.RawMesh} mesh mesh instance + * @param {PIXI.Mesh} mesh mesh instance */ render(mesh) { diff --git a/packages/mesh/src/NineSlicePlane.js b/packages/mesh/src/NineSlicePlane.js deleted file mode 100644 index 0bae92c..0000000 --- a/packages/mesh/src/NineSlicePlane.js +++ /dev/null @@ -1,270 +0,0 @@ -import Plane from './Plane'; - -const DEFAULT_BORDER_SIZE = 10; - -/** - * The NineSlicePlane allows you to stretch a texture using 9-slice scaling. The corners will remain unscaled (useful - * for buttons with rounded corners for example) and the other areas will be scaled horizontally and or vertically - * - *```js - * let Plane9 = new PIXI.NineSlicePlane(PIXI.Texture.from('BoxWithRoundedCorners.png'), 15, 15, 15, 15); - * ``` - *
- *      A                          B
- *    +---+----------------------+---+
- *  C | 1 |          2           | 3 |
- *    +---+----------------------+---+
- *    |   |                      |   |
- *    | 4 |          5           | 6 |
- *    |   |                      |   |
- *    +---+----------------------+---+
- *  D | 7 |          8           | 9 |
- *    +---+----------------------+---+
-
- *  When changing this objects width and/or height:
- *     areas 1 3 7 and 9 will remain unscaled.
- *     areas 2 and 8 will be stretched horizontally
- *     areas 4 and 6 will be stretched vertically
- *     area 5 will be stretched both horizontally and vertically
- * 
- * - * @class - * @extends PIXI.Plane - * @memberof PIXI - * - */ -export default class NineSlicePlane extends Plane -{ - /** - * @param {PIXI.Texture} texture - The texture to use on the NineSlicePlane. - * @param {int} [leftWidth=10] size of the left vertical bar (A) - * @param {int} [topHeight=10] size of the top horizontal bar (C) - * @param {int} [rightWidth=10] size of the right vertical bar (B) - * @param {int} [bottomHeight=10] size of the bottom horizontal bar (D) - */ - constructor(texture, leftWidth, topHeight, rightWidth, bottomHeight) - { - super(texture, 4, 4); - - this._origWidth = texture.orig.width; - this._origHeight = texture.orig.height; - - /** - * The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane - * - * @member {number} - * @memberof PIXI.NineSlicePlane# - * @override - */ - this._width = this._origWidth; - - /** - * The height of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane - * - * @member {number} - * @memberof PIXI.NineSlicePlane# - * @override - */ - this._height = this._origHeight; - - /** - * The width of the left column (a) - * - * @member {number} - * @memberof PIXI.NineSlicePlane# - * @override - */ - this._leftWidth = typeof leftWidth !== 'undefined' ? leftWidth : DEFAULT_BORDER_SIZE; - - /** - * The width of the right column (b) - * - * @member {number} - * @memberof PIXI.NineSlicePlane# - * @override - */ - this._rightWidth = typeof rightWidth !== 'undefined' ? rightWidth : DEFAULT_BORDER_SIZE; - - /** - * The height of the top row (c) - * - * @member {number} - * @memberof PIXI.NineSlicePlane# - * @override - */ - this._topHeight = typeof topHeight !== 'undefined' ? topHeight : DEFAULT_BORDER_SIZE; - - /** - * The height of the bottom row (d) - * - * @member {number} - * @memberof PIXI.NineSlicePlane# - * @override - */ - this._bottomHeight = typeof bottomHeight !== 'undefined' ? bottomHeight : DEFAULT_BORDER_SIZE; - - this.refresh(true); - } - - /** - * Updates the horizontal vertices. - * - */ - updateHorizontalVertices() - { - const vertices = this.vertices; - - const h = this._topHeight + this._bottomHeight; - const scale = this._height > h ? 1.0 : this._height / h; - - vertices[9] = vertices[11] = vertices[13] = vertices[15] = this._topHeight * scale; - vertices[17] = vertices[19] = vertices[21] = vertices[23] = this._height - (this._bottomHeight * scale); - vertices[25] = vertices[27] = vertices[29] = vertices[31] = this._height; - } - - /** - * Updates the vertical vertices. - * - */ - updateVerticalVertices() - { - const vertices = this.vertices; - - const w = this._leftWidth + this._rightWidth; - const scale = this._width > w ? 1.0 : this._width / w; - - vertices[2] = vertices[10] = vertices[18] = vertices[26] = this._leftWidth * scale; - vertices[4] = vertices[12] = vertices[20] = vertices[28] = this._width - (this._rightWidth * scale); - vertices[6] = vertices[14] = vertices[22] = vertices[30] = this._width; - } - - /** - * The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane - * - * @member {number} - */ - get width() - { - return this._width; - } - - set width(value) // eslint-disable-line require-jsdoc - { - this._width = value; - this._refresh(); - } - - /** - * The height of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane - * - * @member {number} - */ - get height() - { - return this._height; - } - - set height(value) // eslint-disable-line require-jsdoc - { - this._height = value; - this._refresh(); - } - - /** - * The width of the left column - * - * @member {number} - */ - get leftWidth() - { - return this._leftWidth; - } - - set leftWidth(value) // eslint-disable-line require-jsdoc - { - this._leftWidth = value; - this._refresh(); - } - - /** - * The width of the right column - * - * @member {number} - */ - get rightWidth() - { - return this._rightWidth; - } - - set rightWidth(value) // eslint-disable-line require-jsdoc - { - this._rightWidth = value; - this._refresh(); - } - - /** - * The height of the top row - * - * @member {number} - */ - get topHeight() - { - return this._topHeight; - } - - set topHeight(value) // eslint-disable-line require-jsdoc - { - this._topHeight = value; - this._refresh(); - } - - /** - * The height of the bottom row - * - * @member {number} - */ - get bottomHeight() - { - return this._bottomHeight; - } - - set bottomHeight(value) // eslint-disable-line require-jsdoc - { - this._bottomHeight = value; - this._refresh(); - } - - /** - * Refreshes NineSlicePlane coords. All of them. - */ - _refresh() - { - super._refresh(); - - const uvs = this.uvs; - const texture = this._texture; - - this._origWidth = texture.orig.width; - this._origHeight = texture.orig.height; - - const _uvw = 1.0 / this._origWidth; - const _uvh = 1.0 / this._origHeight; - - uvs[0] = uvs[8] = uvs[16] = uvs[24] = 0; - uvs[1] = uvs[3] = uvs[5] = uvs[7] = 0; - uvs[6] = uvs[14] = uvs[22] = uvs[30] = 1; - uvs[25] = uvs[27] = uvs[29] = uvs[31] = 1; - - uvs[2] = uvs[10] = uvs[18] = uvs[26] = _uvw * this._leftWidth; - uvs[4] = uvs[12] = uvs[20] = uvs[28] = 1 - (_uvw * this._rightWidth); - uvs[9] = uvs[11] = uvs[13] = uvs[15] = _uvh * this._topHeight; - uvs[17] = uvs[19] = uvs[21] = uvs[23] = 1 - (_uvh * this._bottomHeight); - - this.updateHorizontalVertices(); - this.updateVerticalVertices(); - - this.geometry.buffers[1].update(); - - this.multiplyUvs(); - } -} diff --git a/packages/mesh/src/Plane.js b/packages/mesh/src/Plane.js deleted file mode 100644 index c416b4c..0000000 --- a/packages/mesh/src/Plane.js +++ /dev/null @@ -1,100 +0,0 @@ -import Mesh from './Mesh'; - -/** - * The Plane allows you to draw a texture across several points and them manipulate these points - * - *```js - * for (let i = 0; i < 20; i++) { - * points.push(new PIXI.Point(i * 50, 0)); - * }; - * let Plane = new PIXI.Plane(PIXI.Texture.from("snake.png"), points); - * ``` - * - * @class - * @extends PIXI.Mesh - * @memberof PIXI - * - */ -export default class Plane extends Mesh -{ - /** - * @param {PIXI.Texture} texture - The texture to use on the Plane. - * @param {number} verticesX - The number of vertices in the x-axis - * @param {number} verticesY - The number of vertices in the y-axis - * @param {object} [opts] - an options object - add meshWidth and meshHeight, temporary object for PixiJS v5 alpha - */ - constructor(texture, verticesX, verticesY, opts = {}) - { - super(texture, new Float32Array(1), new Float32Array(1), new Uint16Array(1), 4); - - this.verticesX = verticesX || 10; - this.verticesY = verticesY || 10; - - this.meshWidth = opts.meshWidth || 0; - this.meshHeight = opts.meshHeight || 0; - - this.refresh(); - } - - /** - * Refreshes plane coordinates - * @private - */ - _refresh() - { - const texture = this._texture; - const total = this.verticesX * this.verticesY; - const verts = []; - const uvs = []; - const indices = []; - - const segmentsX = this.verticesX - 1; - const segmentsY = this.verticesY - 1; - - const sizeX = (this.meshWidth || texture.width) / segmentsX; - const sizeY = (this.meshHeight || texture.height) / segmentsY; - - for (let i = 0; i < total; i++) - { - const x = (i % this.verticesX); - const y = ((i / this.verticesX) | 0); - - verts.push(x * sizeX, y * sizeY); - - uvs.push(x / segmentsX, y / segmentsY); - } - - // cons - - const totalSub = segmentsX * segmentsY; - - for (let i = 0; i < totalSub; i++) - { - const xpos = i % segmentsX; - const ypos = (i / segmentsX) | 0; - - const value = (ypos * this.verticesX) + xpos; - const value2 = (ypos * this.verticesX) + xpos + 1; - const value3 = ((ypos + 1) * this.verticesX) + xpos; - const value4 = ((ypos + 1) * this.verticesX) + xpos + 1; - - indices.push(value, value2, value3); - indices.push(value2, value4, value3); - } - - this.vertices = new Float32Array(verts); - this.uvs = new Float32Array(uvs); - this.indices = new Uint16Array(indices); - - this.geometry.buffers[0].data = this.vertices; - this.geometry.buffers[1].data = this.uvs; - this.geometry.indexBuffer.data = this.indices; - - // ensure that the changes are uploaded - this.geometry.buffers[0].update(); - this.geometry.buffers[1].update(); - this.geometry.indexBuffer.update(); - - this.multiplyUvs(); - } -} diff --git a/packages/mesh/src/RawMesh.js b/packages/mesh/src/RawMesh.js deleted file mode 100644 index 7297e94..0000000 --- a/packages/mesh/src/RawMesh.js +++ /dev/null @@ -1,220 +0,0 @@ -import { State } from '@pixi/core'; -import { DRAW_MODES } from '@pixi/constants'; -import { Point, Polygon } from '@pixi/math'; -import { Container } from '@pixi/display'; - -const tempPoint = new Point(); -const tempPolygon = new Polygon(); - -/** - * Base mesh class. - * The reason for this class is to empower you to have maximum flexibility to render any kind of webGL you can think of. - * This class assumes a certain level of webGL knowledge. - * If you know a bit this should abstract enough away to make you life easier! - * Pretty much ALL WebGL can be broken down into the following: - * Geometry - The structure and data for the mesh. This can include anything from positions, uvs, normals, colors etc.. - * Shader - This is the shader that pixi will render the geometry with. (attributes in the shader must match the geometry!) - * Uniforms - These are the values passed to the shader when the mesh is rendered. - * As a shader can be reused across multiple objects, it made sense to allow uniforms to exist outside of the shader - * State - This is the state of WebGL required to render the mesh. - * Through a combination of the above elements you can render anything you want, 2D or 3D! - * - * @class - * @extends PIXI.Container - * @memberof PIXI - */ -export default class RawMesh extends Container -{ - /** - * @param {PIXI.Geometry} geometry the geometry the mesh will use - * @param {PIXI.Shader} shader the shader the mesh will use - * @param {PIXI.State} state the state that the webGL context is required to be in to render the mesh - * @param {number} drawMode the drawMode, can be any of the PIXI.DRAW_MODES consts - */ - constructor(geometry, shader, state, drawMode = DRAW_MODES.TRIANGLES) - { - super(); - - /** - * the geometry the mesh will use - * @type {PIXI.Geometry} - */ - this.geometry = geometry; - - /** - * the shader the mesh will use - * @type {PIXI.Shader} - */ - this.shader = shader; - - /** - * the webGL state the mesh requires to render - * @type {PIXI.State} - */ - this.state = state || new State(); - - /** - * The way the Mesh should be drawn, can be any of the {@link PIXI.RawMesh.DRAW_MODES} consts - * - * @member {number} - * @see PIXI.RawMesh.DRAW_MODES - */ - this.drawMode = drawMode; - - /** - * The way uniforms that will be used by the mesh's shader. - * @member {Object} - */ - - /** - * A map of renderer IDs to webgl render data - * - * @private - * @member {object} - */ - this._glDatas = {}; - - /** - * Plugin that is responsible for rendering this element. - * Allows to customize the rendering process without overriding '_render' & '_renderCanvas' methods. - * - * @member {string} - * @default 'mesh' - */ - this.pluginName = 'mesh'; - - this.start = 0; - this.size = 0; - } - - /** - * Renders the object using the WebGL renderer - * - * @param {PIXI.Renderer} renderer a reference to the WebGL renderer - * @private - */ - _render(renderer) - { - renderer.batch.setObjectRenderer(renderer.plugins[this.pluginName]); - renderer.plugins[this.pluginName].render(this); - } - - /** - * Updates the bounds of the mesh as a rectangle. The bounds calculation takes the worldTransform into account. - * there must be a aVertexPosition attribute present in the geometry for bounds to be calculated correctly. - * - * @private - */ - _calculateBounds() - { - // The position property could be set manually? - if (this.geometry.attributes.aVertexPosition) - { - const vertices = this.geometry.getAttribute('aVertexPosition').data; - - // TODO - we can cache local bounds and use them if they are dirty (like graphics) - this._bounds.addVertices(this.transform, vertices, 0, vertices.length); - } - } - - /** - * Tests if a point is inside this mesh. Works only for TRIANGLE_MESH - * - * @param {PIXI.Point} point the point to test - * @return {boolean} the result of the test - */ - containsPoint(point) - { - if (!this.getBounds().contains(point.x, point.y)) - { - return false; - } - - this.worldTransform.applyInverse(point, tempPoint); - - const vertices = this.geometry.getAttribute('aVertexPosition').data; - - const points = tempPolygon.points; - const indices = this.geometry.getIndex().data; - const len = indices.length; - const step = this.drawMode === 4 ? 3 : 1; - - for (let i = 0; i + 2 < len; i += step) - { - const ind0 = indices[i] * 2; - const ind1 = indices[i + 1] * 2; - const ind2 = indices[i + 2] * 2; - - points[0] = vertices[ind0]; - points[1] = vertices[ind0 + 1]; - points[2] = vertices[ind1]; - points[3] = vertices[ind1 + 1]; - points[4] = vertices[ind2]; - points[5] = vertices[ind2 + 1]; - - if (tempPolygon.contains(tempPoint.x, tempPoint.y)) - { - return true; - } - } - - return false; - } - - /** - * Destroys the RawMesh object. - * - * @param {object|boolean} [options] - Options parameter. A boolean will act as if all - * options have been set to that value - * @param {boolean} [options.children=false] - if set to true, all the children will have - * their destroy method called as well. 'options' will be passed on to those calls. - * @param {boolean} [options.texture=false] - Only used for child Sprites if options.children is set to true - * Should it destroy the texture of the child sprite - * @param {boolean} [options.baseTexture=false] - Only used for child Sprites if options.children is set to true - * Should it destroy the base texture of the child sprite - */ - destroy(options) - { - // for each webgl data entry, destroy the WebGLGraphicsData - for (const id in this._glDatas) - { - const data = this._glDatas[id]; - - if (data.destroy) - { - data.destroy(); - } - else - { - if (data.vertexBuffer) - { - data.vertexBuffer.destroy(); - data.vertexBuffer = null; - } - if (data.indexBuffer) - { - data.indexBuffer.destroy(); - data.indexBuffer = null; - } - if (data.uvBuffer) - { - data.uvBuffer.destroy(); - data.uvBuffer = null; - } - if (data.vao) - { - data.vao.destroy(); - data.vao = null; - } - } - } - - this._glDatas = null; - - this.geometry = null; - this.shader = null; - this.state = null; - - super.destroy(options); - } -} diff --git a/packages/mesh/src/Rope.js b/packages/mesh/src/Rope.js deleted file mode 100644 index b4f85d3..0000000 --- a/packages/mesh/src/Rope.js +++ /dev/null @@ -1,182 +0,0 @@ -import Mesh from './Mesh'; - -/** - * The rope allows you to draw a texture across several points and them manipulate these points - * - *```js - * for (let i = 0; i < 20; i++) { - * points.push(new PIXI.Point(i * 50, 0)); - * }; - * let rope = new PIXI.Rope(PIXI.Texture.from("snake.png"), points); - * ``` - * - * @class - * @extends PIXI.Mesh - * @memberof PIXI - * - */ -export default class Rope extends Mesh -{ - /** - * @param {PIXI.Texture} texture - The texture to use on the rope. - * @param {PIXI.Point[]} points - An array of {@link PIXI.Point} objects to construct this rope. - */ - constructor(texture, points) - { - super(texture, new Float32Array(points.length * 4), - new Float32Array(points.length * 4), - new Uint16Array(points.length * 2), - 5); - - /* - * @member {PIXI.Point[]} An array of points that determine the rope - */ - this.points = points; - this.refresh(); - } - /** - * Refreshes Rope indices and uvs - * @private - */ - _refresh() - { - const points = this.points; - - if (!points) return; - - const vertexBuffer = this.geometry.getAttribute('aVertexPosition'); - const uvBuffer = this.geometry.getAttribute('aTextureCoord'); - const indexBuffer = this.geometry.getIndex(); - - // if too little points, or texture hasn't got UVs set yet just move on. - if (points.length < 1 || !this.texture._uvs) - { - return; - } - - // if the number of points has changed we will need to recreate the arraybuffers - if (vertexBuffer.data.length / 4 !== points.length) - { - vertexBuffer.data = new Float32Array(points.length * 4); - uvBuffer.data = new Float32Array(points.length * 4); - indexBuffer.data = new Uint16Array(points.length * 2); - } - - const uvs = uvBuffer.data; - const indices = indexBuffer.data; - - uvs[0] = 0; - uvs[1] = 0; - uvs[2] = 0; - uvs[3] = 1; - - indices[0] = 0; - indices[1] = 1; - - const total = points.length; - - for (let i = 1; i < total; i++) - { - // time to do some smart drawing! - let index = i * 4; - const amount = i / (total - 1); - - uvs[index] = amount; - uvs[index + 1] = 0; - - uvs[index + 2] = amount; - uvs[index + 3] = 1; - - index = i * 2; - indices[index] = index; - indices[index + 1] = index + 1; - } - - // ensure that the changes are uploaded - uvBuffer.update(); - indexBuffer.update(); - - this.multiplyUvs(); - this.refreshVertices(); - } - - /** - * refreshes vertices of Rope mesh - */ - refreshVertices() - { - const points = this.points; - - if (points.length < 1) - { - return; - } - - let lastPoint = points[0]; - let nextPoint; - let perpX = 0; - let perpY = 0; - - // this.count -= 0.2; - - const vertices = this.vertices; - const total = points.length; - - for (let i = 0; i < total; i++) - { - const point = points[i]; - const index = i * 4; - - if (i < points.length - 1) - { - nextPoint = points[i + 1]; - } - else - { - nextPoint = point; - } - - perpY = -(nextPoint.x - lastPoint.x); - perpX = nextPoint.y - lastPoint.y; - - let ratio = (1 - (i / (total - 1))) * 10; - - if (ratio > 1) - { - ratio = 1; - } - - const perpLength = Math.sqrt((perpX * perpX) + (perpY * perpY)); - const num = this._texture.height / 2; // (20 + Math.abs(Math.sin((i + this.count) * 0.3) * 50) )* ratio; - - perpX /= perpLength; - perpY /= perpLength; - - perpX *= num; - perpY *= num; - - vertices[index] = point.x + perpX; - vertices[index + 1] = point.y + perpY; - vertices[index + 2] = point.x - perpX; - vertices[index + 3] = point.y - perpY; - - lastPoint = point; - } - - this.geometry.buffers[0].update(); - } - - /** - * Updates the object transform for rendering - * - * @private - */ - updateTransform() - { - if (this.autoUpdate) - { - this.refreshVertices(); - } - this.containerUpdateTransform(); - } -} diff --git a/packages/mesh/src/index.js b/packages/mesh/src/index.js index a245772..e14ab9f 100644 --- a/packages/mesh/src/index.js +++ b/packages/mesh/src/index.js @@ -1,6 +1,2 @@ export { default as Mesh } from './Mesh'; -export { default as RawMesh } from './RawMesh'; export { default as MeshRenderer } from './MeshRenderer'; -export { default as Plane } from './Plane'; -export { default as NineSlicePlane } from './NineSlicePlane'; -export { default as Rope } from './Rope'; diff --git a/bundles/pixi.js/package.json b/bundles/pixi.js/package.json index 49c7276..177e059 100644 --- a/bundles/pixi.js/package.json +++ b/bundles/pixi.js/package.json @@ -49,6 +49,7 @@ "@pixi/loaders": "^5.0.0-alpha.2", "@pixi/math": "^5.0.0-alpha.2", "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/mesh-extras": "^5.0.0-alpha.2", "@pixi/mixin-cache-as-bitmap": "^5.0.0-alpha.2", "@pixi/mixin-get-child-by-name": "^5.0.0-alpha.2", "@pixi/mixin-get-global-position": "^5.0.0-alpha.2", diff --git a/bundles/pixi.js/src/deprecated.js b/bundles/pixi.js/src/deprecated.js index 147617c..dbebeb0 100644 --- a/bundles/pixi.js/src/deprecated.js +++ b/bundles/pixi.js/src/deprecated.js @@ -263,15 +263,15 @@ Object.defineProperties(PIXI.mesh, { /** * @class PIXI.mesh.Mesh - * @see PIXI.Mesh + * @see PIXI.Mesh2d * @deprecated since 5.0.0 */ Mesh: { get() { - warn('PIXI.mesh.Mesh has moved to PIXI.Mesh'); + warn('PIXI.mesh.Mesh has moved to PIXI.Mesh2d'); - return PIXI.Mesh; + return PIXI.Mesh2d; }, }, /** @@ -315,15 +315,15 @@ }, /** * @class PIXI.mesh.RawMesh - * @see PIXI.RawMesh + * @see PIXI.Mesh * @deprecated since 5.0.0 */ RawMesh: { get() { - warn('PIXI.mesh.RawMesh has moved to PIXI.RawMesh'); + warn('PIXI.mesh.RawMesh has moved to PIXI.Mesh'); - return PIXI.RawMesh; + return PIXI.Mesh; }, }, /** diff --git a/bundles/pixi.js/src/index.js b/bundles/pixi.js/src/index.js index a3a0d1b..6fdabf0 100644 --- a/bundles/pixi.js/src/index.js +++ b/bundles/pixi.js/src/index.js @@ -9,6 +9,7 @@ import * as loaders from '@pixi/loaders'; import * as math from '@pixi/math'; import * as mesh from '@pixi/mesh'; +import * as meshExtras from '@pixi/mesh-extras'; import * as particles from '@pixi/particles'; import * as prepare from '@pixi/prepare'; import * as sprite from '@pixi/sprite'; @@ -128,6 +129,7 @@ loaders, math, mesh, + meshExtras, particles, sprite, spriteAnimated, @@ -152,6 +154,7 @@ export * from '@pixi/loaders'; export * from '@pixi/math'; export * from '@pixi/mesh'; +export * from '@pixi/mesh-extras'; export * from '@pixi/particles'; export * from '@pixi/sprite'; export * from '@pixi/spritesheet'; diff --git a/package-lock.json b/package-lock.json index 7fe6db7..0814729 100644 --- a/package-lock.json +++ b/package-lock.json @@ -209,7 +209,7 @@ "argparse": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", - "integrity": "sha1-vNZ5HqWuCXJeF+WtmIE0zUCz2RE=", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", "dev": true, "requires": { "sprintf-js": "1.0.3" @@ -228,7 +228,7 @@ "arr-flatten": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz", - "integrity": "sha1-NgSLv/TntH4TZkQxbJlmnqWukfE=", + "integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==", "dev": true }, "arr-union": { @@ -297,7 +297,7 @@ "assertion-error": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", - "integrity": "sha1-5gtrDo8wG9l+U3UhW9pAbIURjAs=", + "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", "dev": true }, "async": { @@ -396,7 +396,7 @@ "brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha1-PH/L9SnYcibz0vUrlm/1Jx60Qd0=", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, "requires": { "balanced-match": "1.0.0", @@ -568,7 +568,7 @@ "circular-json": { "version": "0.3.3", "resolved": "https://registry.npmjs.org/circular-json/-/circular-json-0.3.3.tgz", - "integrity": "sha1-gVyZ6oT2gJUp0vRXkb34JxE1LWY=", + "integrity": "sha512-UZK3NBx2Mca+b5LsG7bY183pHWt5Y1xts4P3Pz7ENTwGVnJOUWbRb3ocjvX7hx9tq/yTAdclXm9sZ38gNuem4A==", "dev": true }, "cli-cursor": { @@ -638,7 +638,7 @@ "color-convert": { "version": "1.9.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.1.tgz", - "integrity": "sha1-wSYRB66y8pTr/+ye2eytUppgl+0=", + "integrity": "sha512-mjGanIiwQJskCC18rPR6OmrZ6fm2Lc7PeGFYwCmy5J34wC6F1PzdGL6xeMfmgicfYcNLGuVFA3WzXtIDCQSZxQ==", "dev": true, "requires": { "color-name": "1.1.3" @@ -1427,7 +1427,7 @@ "boom": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/boom/-/boom-5.2.0.tgz", - "integrity": "sha1-XdnabuOl8wIHdDYpDLcX0/SlTgI=", + "integrity": "sha512-Z5BTk6ZRe4tXXQlkqftmsAUANpXmuwlsF5Oov8ThoMbQRzdGTA1ngYRW160GexgOgjsFOKJz0LYhoNi+2AMBUw==", "dev": true, "requires": { "hoek": "4.2.1" @@ -1471,7 +1471,7 @@ "debug": { "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha1-XRKFFd8TT/Mn6QpMk/Tgd6U2NB8=", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", "dev": true, "requires": { "ms": "2.0.0" @@ -1585,7 +1585,7 @@ "doctrine": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", - "integrity": "sha1-XNAfwQFiG0LEzX9dGmYkNxbT850=", + "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", "dev": true, "requires": { "esutils": "2.0.2" @@ -1662,7 +1662,7 @@ "es6-promise": { "version": "4.2.4", "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.4.tgz", - "integrity": "sha1-3EIhwrFlGHYL2MOaUtjzVvwA7Sk=", + "integrity": "sha512-/NdNZVJg+uZgtm9eS3O6lrOLYmQag2DjdEXuPaHlZ6RuVqgqaVZfgYCepEIKsLqwdQArOPtC3XzRLqGGfT8KQQ==", "dev": true }, "escape-string-regexp": { @@ -1788,7 +1788,7 @@ "espree": { "version": "3.5.4", "resolved": "https://registry.npmjs.org/espree/-/espree-3.5.4.tgz", - "integrity": "sha1-sPRHGHyKi+2US4FaZgvd9d610ac=", + "integrity": "sha512-yAcIQxtmMiB/jL32dzEp2enBeidsB7xWPLNiw3IIkpVds1P+h7qF9YwJq1yUNzp2OKXgAprs4F61ih66UsoD1A==", "dev": true, "requires": { "acorn": "5.5.0", @@ -1798,7 +1798,7 @@ "esprima": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.0.tgz", - "integrity": "sha1-RJnt3NERDgshi6zy+n9/WfVcqAQ=", + "integrity": "sha512-oftTcaMu/EGrEIu904mWteKIv8vMuOgGYo7EhVJJN00R/EED9DCua/xxHRdYnKtcECzVg7xOWhflvJMnqcFZjw==", "dev": true }, "esquery": { @@ -1813,7 +1813,7 @@ "esrecurse": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.2.1.tgz", - "integrity": "sha1-AHo7n9vCs7uH5IeeoZyS/b05Qs8=", + "integrity": "sha512-64RBB++fIOAXPw3P9cy89qfMlvZEXZkqqJkjqqXIvzP5ezRZjW+lPWjw35UX/3EhUPFYbg5ER4JYgDw4007/DQ==", "dev": true, "requires": { "estraverse": "4.2.0" @@ -2024,7 +2024,7 @@ "find-root": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/find-root/-/find-root-1.1.0.tgz", - "integrity": "sha1-q8/Iunb3CMQql7PWhbfpRQv7nOQ=", + "integrity": "sha512-NKfW6bec6GfKc0SGx1e07QZY9PE99u0Bft/0rzSD5k3sO/vwkVUpDUKVm5Gpp5Ue3YfShPFTX2070tDs5kB9Ng==", "dev": true }, "find-up": { @@ -2103,7 +2103,7 @@ "supports-color": { "version": "5.3.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.3.0.tgz", - "integrity": "sha1-WySsFduA+pJ89SJ6SjP9PEx2dsA=", + "integrity": "sha512-0aP01LLIskjKs3lq52EC0aGBAJhLq7B2Rd8HC/DR/PtNNpcLilNmHC12O+hu0usQpo7wtHNRqtrhBwtDb0+dNg==", "dev": true, "requires": { "has-flag": "3.0.0" @@ -2567,7 +2567,7 @@ "glob": { "version": "7.1.2", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", - "integrity": "sha1-wZyd+aAocC1nhhI4SmVSQExjbRU=", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", "dev": true, "requires": { "fs.realpath": "1.0.0", @@ -2672,7 +2672,7 @@ "growl": { "version": "1.10.3", "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.3.tgz", - "integrity": "sha1-GSa6kM8+3+KttJJ/WIC8IsZseQ8=", + "integrity": "sha512-hKlsbA5Vu3xsh1Cg3J7jSmX/WaW6A5oBeqzM88oNbCRQFz+zUaXm6yxS4RVytp1scBoJzSYl4YAEOQIt6O8V1Q==", "dev": true }, "handlebars": { @@ -2738,7 +2738,7 @@ "hawk": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/hawk/-/hawk-6.0.2.tgz", - "integrity": "sha1-r02RTrBl+bXOTZ0RwcshJu7MMDg=", + "integrity": "sha512-miowhl2+U7Qle4vdLqDdPt9m09K6yZhkLDTWGoUiUzrQCn+mHHSmfJgAyGaLRZbPmTqfFFjRV1QWCW0VWUJBbQ==", "dev": true, "requires": { "boom": "4.3.1", @@ -2756,7 +2756,7 @@ "hoek": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/hoek/-/hoek-4.2.1.tgz", - "integrity": "sha1-ljRQKqEsRF3Vp8VzS1cruHOKrLs=", + "integrity": "sha512-QLg82fGkfnJ/4iy1xZ81/9SIJiq1NGFUMGs6ParyjBZr6jW2Ufj/snDqTHixNlHdPNwN2RLVD0Pi3igeK9+JfA==", "dev": true }, "home-path": { @@ -2791,7 +2791,7 @@ "ignore": { "version": "3.3.7", "resolved": "https://registry.npmjs.org/ignore/-/ignore-3.3.7.tgz", - "integrity": "sha1-YSKJv7PCIOGGpYEYYY1b6MG6sCE=", + "integrity": "sha512-YGG3ejvBNHRqu0559EOxxNFihD0AjpvHlC/pdGKd3X3ofe+CoJkYazwNJYTNebqpPKN+VVQbh4ZFn1DivMNuHA==", "dev": true }, "imurmurhash": { @@ -2828,7 +2828,7 @@ "ini": { "version": "1.3.5", "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", - "integrity": "sha1-7uJfVtscnsYIXgwid4CD9Zar+Sc=", + "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==", "dev": true }, "inquirer": { @@ -2901,7 +2901,7 @@ "is-buffer": { "version": "1.1.6", "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", - "integrity": "sha1-76ouqdqg16suoTqXsritUf776L4=", + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", "dev": true }, "is-builtin-module": { @@ -3054,7 +3054,7 @@ "is-resolvable": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/is-resolvable/-/is-resolvable-1.1.0.tgz", - "integrity": "sha1-+xj4fOH+uSUWnJpAfBkxijIG7Yg=", + "integrity": "sha512-qgDYXFSR5WvEfuS5dMj6oTMEbrrSaM0CrFk2Yiq/gXnBvD9pMa2jGXxyhGLfvhZpuMZe18CJpFxAt3CRs42NMg==", "dev": true }, "is-retry-allowed": { @@ -3204,7 +3204,7 @@ "js-yaml": { "version": "3.11.0", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.11.0.tgz", - "integrity": "sha1-WXwai9VxUvJtYizkEXhRpR9euu8=", + "integrity": "sha512-saJstZWv7oNeOyBh3+Dx1qWzhW0+e6/8eDzo7p5rDFqxntSztloLtuKu+Ejhtq82jsilwOIZYsCz+lIjthg1Hw==", "dev": true, "requires": { "argparse": "1.0.10", @@ -3324,7 +3324,7 @@ "just-extend": { "version": "1.1.27", "resolved": "https://registry.npmjs.org/just-extend/-/just-extend-1.1.27.tgz", - "integrity": "sha1-7G55QQ/5FORyZSq/oOYDwD1g6QU=", + "integrity": "sha512-mJVp13Ix6gFo3SBAy9U/kL+oeZqzlYYYLQBwXVBlVzIsZwBqGREnOro24oC/8s8aox+rJhtZ2DiQof++IrkA+g==", "dev": true }, "kind-of": { @@ -3703,7 +3703,7 @@ "lodash": { "version": "4.17.5", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.5.tgz", - "integrity": "sha1-maktZcAnLevoyWtgV7yPv6O+1RE=", + "integrity": "sha512-svL3uiZf1RwhH+cWrfZn3A4+U58wbP0tGVTLQPbjplZxZ8ROD9VLuNgsRniTlLe7OlSqR79RUehXgpBW/s0IQw==", "dev": true }, "lodash._reinterpolate": { @@ -3740,7 +3740,7 @@ "lolex": { "version": "2.3.2", "resolved": "https://registry.npmjs.org/lolex/-/lolex-2.3.2.tgz", - "integrity": "sha1-hflFBCUQO/nnpgZo6iXcQydMqAc=", + "integrity": "sha512-A5pN2tkFj7H0dGIAM6MFvHKMJcPnjZsOMvR7ujCjfgW5TbV6H9vb1PgxLtHvjqNZTHsUolz+6/WEO0N1xNx2ng==", "dev": true }, "longest": { @@ -3816,7 +3816,7 @@ "marked": { "version": "0.3.17", "resolved": "https://registry.npmjs.org/marked/-/marked-0.3.17.tgz", - "integrity": "sha1-YH8GZos8axJGso8T2nYRasGqLSs=", + "integrity": "sha512-+AKbNsjZl6jFfLPwHhWmGTqE009wTKn3RTmn9K8oUKHrX/abPJjtcRtXpYB/FFrwPJRUA86LX/de3T0knkPCmQ==", "dev": true }, "mem": { @@ -3896,13 +3896,13 @@ "mime-db": { "version": "1.33.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.33.0.tgz", - "integrity": "sha1-o0kgUKXLm2NFBUHjnZeI0icng9s=", + "integrity": "sha512-BHJ/EKruNIqJf/QahvxwQZXKygOQ256myeN/Ew+THcAa5q+PjyTTMMeNQC4DZw5AwfvelsUrA6B67NKMqXDbzQ==", "dev": true }, "mime-types": { "version": "2.1.18", "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.18.tgz", - "integrity": "sha1-bzI/YKg9ERRvgx/xH9ZuL+VQO7g=", + "integrity": "sha512-lc/aahn+t4/SWV/qcmumYjymLsWfN3ELhpmVuUFjgsORruuZPVSwAQryq+HHGvO/SI2KVX26bx+En+zhM8g8hQ==", "dev": true, "requires": { "mime-db": "1.33.0" @@ -3917,7 +3917,7 @@ "minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha1-UWbihkV/AzBgZL5Ul+jbsMPTIIM=", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "dev": true, "requires": { "brace-expansion": "1.1.11" @@ -4071,7 +4071,7 @@ "normalize-package-data": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.4.0.tgz", - "integrity": "sha1-EvlaMH1YNSB1oEkHuErIvpisAS8=", + "integrity": "sha512-9jjUFbTPfEy3R/ad/2oNbKtW9Hgovl5O1FvFWKkKblNXoN/Oou6+9+KKohPK13Yc3/TyunyWhJp6gvRNR/PPAw==", "dev": true, "requires": { "hosted-git-info": "2.5.0", @@ -4511,7 +4511,7 @@ "process-nextick-args": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", - "integrity": "sha1-o31zL0JxtKsa0HDTVQjoKQeI/6o=", + "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==", "dev": true }, "progress": { @@ -4584,7 +4584,7 @@ "qs": { "version": "6.5.1", "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.1.tgz", - "integrity": "sha1-NJzfbu+J7EXBLX1es/wMhwNDptg=", + "integrity": "sha512-eRzhrN1WSINYCDCbrz796z37LOe3m5tmW7RQf6oBntukAG1nmovJvhnwHHRMAfeoItc1m2Hk02WER2aQ/iqs+A==", "dev": true }, "quick-lru": { @@ -4596,7 +4596,7 @@ "randomatic": { "version": "1.1.7", "resolved": "https://registry.npmjs.org/randomatic/-/randomatic-1.1.7.tgz", - "integrity": "sha1-x6vpzIuHwLqodrGf3oP9RkeX44w=", + "integrity": "sha512-D5JUjPyJbaJDkuAazpVnSfVkLlpeO3wDlPROTMLGKG1zMFNFRgrciKo1ltz/AzNTkqE0HzDx655QOL51N06how==", "dev": true, "requires": { "is-number": "3.0.0", @@ -4701,7 +4701,7 @@ "regex-cache": { "version": "0.4.4", "resolved": "https://registry.npmjs.org/regex-cache/-/regex-cache-0.4.4.tgz", - "integrity": "sha1-db3FiioUls7EihKDW8VMjVYjNt0=", + "integrity": "sha512-nVIZwtCjkC9YgvWkpM55B5rBhBYRZhAaJbgcFYXXsHnbZ9UZI9nnVWYZpBlCqv9ho2eZryPnWrZGsOdPwVWXWQ==", "dev": true, "requires": { "is-equal-shallow": "0.1.3" @@ -4729,7 +4729,7 @@ "remap-istanbul": { "version": "0.10.1", "resolved": "https://registry.npmjs.org/remap-istanbul/-/remap-istanbul-0.10.1.tgz", - "integrity": "sha1-OqWN1QIdSZ8zbTulvzu7kcG4jjc=", + "integrity": "sha512-gsNQXs5kJLhErICSyYhzVZ++C8LBW8dgwr874Y2QvzAUS75zBlD/juZgXs39nbYJ09fZDlX2AVLVJAY2jbFJoQ==", "dev": true, "requires": { "amdefine": "1.0.1", @@ -4769,7 +4769,7 @@ "source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha1-dHIq8y6WFOnCh6jQu95IteLxomM=", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", "dev": true }, "through2": { @@ -4883,7 +4883,7 @@ "resolve": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.5.0.tgz", - "integrity": "sha1-HwmsznlsmnYlefMbLBzEw83fnzY=", + "integrity": "sha512-hgoSGrc3pjzAPHNBg+KnFcK2HwlHTs/YrAGUr6qgTVUZmXv1UEXXl0bZNBKMA9fud6lRYFdPGz0xXxycPzmmiw==", "dev": true, "requires": { "path-parse": "1.0.5" @@ -4924,7 +4924,7 @@ "rimraf": { "version": "2.6.2", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", - "integrity": "sha1-LtgVDSShbqhlHm1u8PR8QVjOejY=", + "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", "dev": true, "requires": { "glob": "7.1.2" @@ -5063,19 +5063,19 @@ "safe-buffer": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", - "integrity": "sha1-iTMSr2myEj3vcfV4iQAWce6yyFM=", + "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", "dev": true }, "samsam": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/samsam/-/samsam-1.3.0.tgz", - "integrity": "sha1-jR2TUOJWItow3j5EumkrUiGrfFA=", + "integrity": "sha512-1HwIYD/8UlOtFS3QO3w7ey+SdSDFE4HRNLZoZRYVQefrOY3l17epswImeB1ijgJFQJodIaHcwkp3r/myBjFVbg==", "dev": true }, "semver": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz", - "integrity": "sha1-3Eu8emyp2Rbe5dQ1FvAJK1j3uKs=", + "integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==", "dev": true }, "set-blocking": { @@ -5117,7 +5117,7 @@ "sinon-chai": { "version": "2.14.0", "resolved": "https://registry.npmjs.org/sinon-chai/-/sinon-chai-2.14.0.tgz", - "integrity": "sha1-2n3UzIPNaiYLZ8yg96n9riahIF0=", + "integrity": "sha512-9stIF1utB0ywNHNT7RgiXbdmen8QDCRsrTjw+G9TgKt1Yexjiv8TOWZ6WHsTPz57Yky3DIswZvEqX8fpuHNDtQ==", "dev": true }, "slash": { @@ -5146,7 +5146,7 @@ "sntp": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/sntp/-/sntp-2.1.0.tgz", - "integrity": "sha1-LGzsFP7cIiJznK+bXD2F0cxaLMg=", + "integrity": "sha512-FL1b58BDrqS3A11lJ0zEdnJ3UOKqVxawAkF3k7F0CVN7VQ34aZrV+G8BZ1WC9ZL7NyrwsW0oviwsWDgRuVYtJg==", "dev": true, "requires": { "hoek": "4.2.1" @@ -5203,7 +5203,7 @@ "spdx-correct": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.0.0.tgz", - "integrity": "sha1-BaW01xU6GVvJLDxCW2nzsqlSTII=", + "integrity": "sha512-N19o9z5cEyc8yQQPukRCZ9EUmb4HUpnrmaL/fxS2pBo2jbfcFRVuFZ/oFC+vZz0MNNk0h80iMn5/S6qGZOL5+g==", "dev": true, "requires": { "spdx-expression-parse": "3.0.0", @@ -5213,13 +5213,13 @@ "spdx-exceptions": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.1.0.tgz", - "integrity": "sha1-LHrmEFbHFKW5ubKyr30xHvXHj+k=", + "integrity": "sha512-4K1NsmrlCU1JJgUrtgEeTVyfx8VaYea9J9LvARxhbHtVtohPs/gFGG5yy49beySjlIMhhXZ4QqujIZEfS4l6Cg==", "dev": true }, "spdx-expression-parse": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.0.tgz", - "integrity": "sha1-meEZt6XaAOBUkcn6M4t5BII7QdA=", + "integrity": "sha512-Yg6D3XpRD4kkOmTpdgbUiEJFKghJH03fiC1OPll5h/0sO6neh2jqRDVHOQ4o/LMea0tgCkbMgea5ip/e+MkWyg==", "dev": true, "requires": { "spdx-exceptions": "2.1.0", @@ -5229,7 +5229,7 @@ "spdx-license-ids": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.0.tgz", - "integrity": "sha1-enzShHDMbToc/m1miG9rxDDTrIc=", + "integrity": "sha512-2+EPwgbnmOIl8HjGBXXMd9NAu02vLjOO1nWw4kmeRDFyHn+M/ETfHxQUK0oXg8ctgVnl9t3rosNVsZ1jG61nDA==", "dev": true }, "speedometer": { @@ -5566,7 +5566,7 @@ "tough-cookie": { "version": "2.3.4", "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.4.tgz", - "integrity": "sha1-7GDO44rGdQY//JelwYlwV47oNlU=", + "integrity": "sha512-TZ6TTfI5NtZnuyy/Kecv+CnoROnyXn2DN97LontgQpCwsX2XyLYCC0ENhYkehSOwAp8rTQKc/NUIF7BkQ5rKLA==", "dev": true, "requires": { "punycode": "1.4.1" @@ -5708,13 +5708,13 @@ "uuid": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.2.1.tgz", - "integrity": "sha1-EsUou51Y0LkmXZovbw/ovhf/HxQ=", + "integrity": "sha512-jZnMwlb9Iku/O3smGWvZhauCf6cvvpKi4BKRiliS3cxnI+Gz9j5MEpTz2UFuXiKPJocb7gnsLHwiS05ige5BEA==", "dev": true }, "validate-npm-package-license": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.3.tgz", - "integrity": "sha1-gWQ7y+8b3+zUYjeT3EZIlIupgzg=", + "integrity": "sha512-63ZOUnL4SIXj4L0NixR3L1lcjO38crAbgrTpl28t8jjrfuiOBL5Iygm+60qPs/KsZGzPNg6Smnc/oY16QTjF0g==", "dev": true, "requires": { "spdx-correct": "3.0.0", @@ -5750,7 +5750,7 @@ "which": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/which/-/which-1.3.0.tgz", - "integrity": "sha1-/wS9/AEO5UfXgL7DjhrBwnd9JTo=", + "integrity": "sha512-xcJpopdamTuY5duC/KnTTNBraPK54YwpenP4lzxU8H91GudWpFv38u0CKjclE1Wi2EH2EDz5LRcHcKbCIzqGyg==", "dev": true, "requires": { "isexe": "2.0.0" diff --git a/packages/canvas/canvas-mesh/package.json b/packages/canvas/canvas-mesh/package.json index 691cd2c..6744a17 100644 --- a/packages/canvas/canvas-mesh/package.json +++ b/packages/canvas/canvas-mesh/package.json @@ -24,6 +24,7 @@ "dependencies": { "@pixi/constants": "^5.0.0-alpha.2", "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/mesh-extras": "^5.0.0-alpha.2", "@pixi/settings": "^5.0.0-alpha.2" }, "devDependencies": { diff --git a/packages/canvas/canvas-mesh/src/Mesh.js b/packages/canvas/canvas-mesh/src/Mesh.js index 900a872..c43a74b 100644 --- a/packages/canvas/canvas-mesh/src/Mesh.js +++ b/packages/canvas/canvas-mesh/src/Mesh.js @@ -1,36 +1,14 @@ import { Mesh } from '@pixi/mesh'; -import { settings } from './settings'; - -// IMPORTANT: Please do NOT use this as a precedent to use `settings` after the object is created -// this was merely created to completely decouple canvas from the base Mesh class and we are -// unable to add `canvasPadding` in the constructor anymore, as the case was for PixiJS v4. /** - * Internal variable for `canvasPadding`. + * Renders the object using the Canvas renderer * * @private - * @memberof PIXI.Mesh - * @member {number} - * @default null - */ -Mesh.prototype._canvasPadding = null; - -/** - * Triangles in canvas mode are automatically antialiased, use this value to force triangles - * to overlap a bit with each other. To set the global default, set {@link PIXI.settings.MESH_CANVAS_PADDING} - * - * @see PIXI.settings.MESH_CANVAS_PADDING - * @member {number} canvasPadding + * @method _renderCanvas * @memberof PIXI.Mesh# - * @default 0 + * @param {PIXI.CanvasRenderer} renderer - The canvas renderer. */ -Object.defineProperty(Mesh.prototype, 'canvasPadding', { - get() - { - return this._canvasPadding !== null ? this._canvasPadding : settings.MESH_CANVAS_PADDING; - }, - set(value) - { - this._canvasPadding = value; - }, -}); +Mesh.prototype._renderCanvas = function _renderCanvas(renderer) +{ + renderer.plugins[this.pluginName].render(this); +}; diff --git a/packages/canvas/canvas-mesh/src/Mesh2d.js b/packages/canvas/canvas-mesh/src/Mesh2d.js new file mode 100644 index 0000000..d0bd80f --- /dev/null +++ b/packages/canvas/canvas-mesh/src/Mesh2d.js @@ -0,0 +1,36 @@ +import { Mesh2d } from '@pixi/mesh-extras'; +import { settings } from './settings'; + +// IMPORTANT: Please do NOT use this as a precedent to use `settings` after the object is created +// this was merely created to completely decouple canvas from the base Mesh class and we are +// unable to add `canvasPadding` in the constructor anymore, as the case was for PixiJS v4. + +/** + * Internal variable for `canvasPadding`. + * + * @private + * @memberof PIXI.Mesh2d + * @member {number} + * @default null + */ +Mesh2d.prototype._canvasPadding = null; + +/** + * Triangles in canvas mode are automatically antialiased, use this value to force triangles + * to overlap a bit with each other. To set the global default, set {@link PIXI.settings.MESH_CANVAS_PADDING} + * + * @see PIXI.settings.MESH_CANVAS_PADDING + * @member {number} canvasPadding + * @memberof PIXI.Mesh2d# + * @default 0 + */ +Object.defineProperty(Mesh2d.prototype, 'canvasPadding', { + get() + { + return this._canvasPadding !== null ? this._canvasPadding : settings.MESH_CANVAS_PADDING; + }, + set(value) + { + this._canvasPadding = value; + }, +}); diff --git a/packages/canvas/canvas-mesh/src/NineSlicePlane.js b/packages/canvas/canvas-mesh/src/NineSlicePlane.js index 09eaf9c..2fd5acc 100644 --- a/packages/canvas/canvas-mesh/src/NineSlicePlane.js +++ b/packages/canvas/canvas-mesh/src/NineSlicePlane.js @@ -1,4 +1,4 @@ -import { NineSlicePlane } from '@pixi/mesh'; +import { NineSlicePlane } from '@pixi/mesh-extras'; /** * Renders the object using the Canvas renderer diff --git a/packages/canvas/canvas-mesh/src/RawMesh.js b/packages/canvas/canvas-mesh/src/RawMesh.js deleted file mode 100644 index bf40184..0000000 --- a/packages/canvas/canvas-mesh/src/RawMesh.js +++ /dev/null @@ -1,14 +0,0 @@ -import { RawMesh } from '@pixi/mesh'; - -/** - * Renders the object using the Canvas renderer - * - * @private - * @method _renderCanvas - * @memberof PIXI.RawMesh# - * @param {PIXI.CanvasRenderer} renderer - The canvas renderer. - */ -RawMesh.prototype._renderCanvas = function _renderCanvas(renderer) -{ - renderer.plugins[this.pluginName].render(this); -}; diff --git a/packages/canvas/canvas-mesh/src/index.js b/packages/canvas/canvas-mesh/src/index.js index 2295016..f4fa31d 100644 --- a/packages/canvas/canvas-mesh/src/index.js +++ b/packages/canvas/canvas-mesh/src/index.js @@ -1,6 +1,6 @@ export { default as CanvasMeshRenderer } from './CanvasMeshRenderer'; import './settings'; -import './Mesh'; +import './Mesh2d'; import './NineSlicePlane'; -import './RawMesh'; +import './Mesh'; diff --git a/packages/canvas/canvas-mesh/src/settings.js b/packages/canvas/canvas-mesh/src/settings.js index 4cefb4c..e81b8e0 100644 --- a/packages/canvas/canvas-mesh/src/settings.js +++ b/packages/canvas/canvas-mesh/src/settings.js @@ -3,7 +3,7 @@ /** * Default `canvasPadding` for canvas-based Mesh rendering. * - * @see PIXI.Mesh#canvasPadding + * @see PIXI.Mesh2d#canvasPadding * @static * @constant * @memberof PIXI.settings diff --git a/packages/mesh-extras/LICENSE b/packages/mesh-extras/LICENSE new file mode 100644 index 0000000..148e3eb --- /dev/null +++ b/packages/mesh-extras/LICENSE @@ -0,0 +1,21 @@ +The MIT License + +Copyright (c) 2013-2018 Mathew Groves, Chad Engler + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/packages/mesh-extras/README.md b/packages/mesh-extras/README.md new file mode 100644 index 0000000..1d9b0e1 --- /dev/null +++ b/packages/mesh-extras/README.md @@ -0,0 +1,19 @@ +# @pixi/mesh-extras + +## Installation + +```bash +npm install @pixi/mesh-extras +``` + +## Usage + +```js +import { MeshRenderer } from '@pixi/mesh'; +import { Renderer } from '@pixi/core'; +import { Rope } from '@pixi/mesh-extras'; + +Renderer.registerPlugin('mesh', MeshRenderer); + +const rope = new Rope(); +``` \ No newline at end of file diff --git a/packages/mesh-extras/package.json b/packages/mesh-extras/package.json new file mode 100644 index 0000000..d134f64 --- /dev/null +++ b/packages/mesh-extras/package.json @@ -0,0 +1,38 @@ +{ + "name": "@pixi/mesh-extras", + "version": "5.0.0-alpha.2", + "main": "lib/mesh-extras.js", + "module": "lib/mesh-extras.es.js", + "description": "Custom Mesh display objects, like Rope and Plane", + "author": "Mat Groves", + "contributors": [ + "Matt Karl " + ], + "homepage": "http://pixijs.com/", + "bugs": "https://github.com/pixijs/pixi.js/issues", + "license": "MIT", + "repository": { + "type": "git", + "url": "https://github.com/pixijs/pixi.js.git" + }, + "publishConfig": { + "access": "public" + }, + "scripts": { + "test": "floss --path test" + }, + "files": [ + "lib" + ], + "dependencies": { + "@pixi/constants": "^5.0.0-alpha.2", + "@pixi/core": "^5.0.0-alpha.2", + "@pixi/math": "^5.0.0-alpha.2", + "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/utils": "^5.0.0-alpha.2" + }, + "devDependencies": { + "@pixi/loaders": "^5.0.0-alpha.2", + "floss": "^2.1.3" + } +} diff --git a/packages/mesh-extras/src/Mesh2d.js b/packages/mesh-extras/src/Mesh2d.js new file mode 100644 index 0000000..d113a5e --- /dev/null +++ b/packages/mesh-extras/src/Mesh2d.js @@ -0,0 +1,263 @@ +import { Mesh } from '@pixi/mesh'; +import { Geometry, Program, Shader, Texture, TextureMatrix } from '@pixi/core'; +import { Matrix } from '@pixi/math'; +import { BLEND_MODES } from '@pixi/constants'; +import { hex2rgb, premultiplyRgba } from '@pixi/utils'; +import vertex from './mesh.vert'; +import fragment from './mesh.frag'; + +let meshProgram; + +/** + * Base mesh class + * @class + * @extends PIXI.Container + * @memberof PIXI + */ +export default class Mesh2d extends Mesh +{ + /** + * @param {PIXI.Texture} [texture=Texture.EMPTY] - The texture to use + * @param {Float32Array} [vertices] - if you want to specify the vertices + * @param {Float32Array} [uvs] - if you want to specify the uvs + * @param {Uint16Array} [indices] - if you want to specify the indices + * @param {number} [drawMode] - the drawMode, can be any of the Mesh.DRAW_MODES consts + */ + constructor(texture = Texture.EMPTY, vertices, uvs, indices, drawMode) + { + const geometry = new Geometry(); + + if (!meshProgram) + { + meshProgram = new Program(vertex, fragment); + } + + geometry.addAttribute('aVertexPosition', vertices) + .addAttribute('aTextureCoord', uvs) + .addIndex(indices); + + geometry.getAttribute('aVertexPosition').static = false; + + const uniforms = { + uSampler: texture, + uTextureMatrix: Matrix.IDENTITY, + alpha: 1, + uColor: new Float32Array([1, 1, 1, 1]), + }; + + super(geometry, new Shader(meshProgram, uniforms), null, drawMode); + + /** + * The Uvs of the Mesh + * + * @member {Float32Array} + */ + this.uvs = geometry.getAttribute('aTextureCoord').data; + + /** + * An array of vertices + * + * @member {Float32Array} + */ + this.vertices = geometry.getAttribute('aVertexPosition').data; + + this.uniforms = uniforms; + + /** + * The texture of the Mesh + * + * @member {PIXI.Texture} + * @default PIXI.Texture.EMPTY + * @private + */ + this.texture = texture; + + /** + * The tint applied to the mesh. This is a [r,g,b] value. A value of [1,1,1] will remove any + * tint effect. + * + * @member {number} + * @private + */ + this._tintRGB = new Float32Array([1, 1, 1]); + + // Set default tint + this.tint = 0xFFFFFF; + + this.blendMode = BLEND_MODES.NORMAL; + + /** + * TextureMatrix instance for this Mesh, used to track Texture changes + * + * @member {PIXI.TextureMatrix} + * @readonly + */ + this.uvMatrix = new TextureMatrix(this._texture); + + /** + * whether or not upload uvMatrix to shader + * if its false, then uvs should be pre-multiplied + * if you change it for generated mesh, please call 'refresh(true)' + * @member {boolean} + * @default false + */ + this.uploadUvMatrix = false; + + /** + * Uploads vertices buffer every frame, like in PixiJS V3 and V4. + * + * @member {boolean} + * @default true + */ + this.autoUpdate = true; + } + + /** + * The tint applied to the Rope. This is a hex value. A value of + * 0xFFFFFF will remove any tint effect. + * + * @member {number} + * @memberof PIXI.Sprite# + * @default 0xFFFFFF + */ + get tint() + { + return this._tint; + } + + /** + * Sets the tint of the rope. + * + * @param {number} value - The value to set to. + */ + set tint(value) + { + this._tint = value; + + hex2rgb(this._tint, this._tintRGB); + } + + /** + * The blend mode to be applied to the sprite. Set to `PIXI.BLEND_MODES.NORMAL` to remove any blend mode. + * + * @member {number} + * @default PIXI.BLEND_MODES.NORMAL + * @see PIXI.BLEND_MODES + */ + get blendMode() + { + return this.state.blendMode; + } + + set blendMode(value) // eslint-disable-line require-jsdoc + { + this.state.blendMode = value; + } + + /** + * The texture that the mesh uses. + * + * @member {PIXI.Texture} + */ + get texture() + { + return this._texture; + } + + set texture(value) // eslint-disable-line require-jsdoc + { + if (this._texture === value) + { + return; + } + + this._texture = value; + this.uniforms.uSampler = this.texture; + + if (value) + { + // wait for the texture to load + if (value.baseTexture.valid) + { + this._onTextureUpdate(); + } + else + { + value.once('update', this._onTextureUpdate, this); + } + } + } + + _render(renderer) + { + const baseTex = this._texture.baseTexture; + + premultiplyRgba(this._tintRGB, this.worldAlpha, this.uniforms.uColor, baseTex.premultiplyAlpha); + super._render(renderer); + } + /** + * When the texture is updated, this event will fire to update the scale and frame + * + * @private + */ + _onTextureUpdate() + { + // constructor texture update stop + if (!this.uvMatrix) + { + return; + } + this.uvMatrix.texture = this._texture; + this.refresh(); + } + + /** + * multiplies uvs only if uploadUvMatrix is false + * call it after you change uvs manually + * make sure that texture is valid + */ + multiplyUvs() + { + if (!this.uploadUvMatrix) + { + this.uvMatrix.multiplyUvs(this.uvs); + } + } + + /** + * Refreshes uvs for generated meshes (rope, plane) + * sometimes refreshes vertices too + * + * @param {boolean} [forceUpdate=false] if true, matrices will be updated any case + */ + refresh(forceUpdate) + { + if (this.uvMatrix.update(forceUpdate)) + { + this._refresh(); + } + } + + /** + * Updates the object transform for rendering + * + * @private + */ + updateTransform() + { + if (this.autoUpdate) + { + this.geometry.buffers[0].update(); + } + this.containerUpdateTransform(); + } + + /** + * re-calculates mesh coords + * @private + */ + _refresh() + { + /* empty */ + } +} diff --git a/packages/mesh-extras/src/NineSlicePlane.js b/packages/mesh-extras/src/NineSlicePlane.js new file mode 100644 index 0000000..0bae92c --- /dev/null +++ b/packages/mesh-extras/src/NineSlicePlane.js @@ -0,0 +1,270 @@ +import Plane from './Plane'; + +const DEFAULT_BORDER_SIZE = 10; + +/** + * The NineSlicePlane allows you to stretch a texture using 9-slice scaling. The corners will remain unscaled (useful + * for buttons with rounded corners for example) and the other areas will be scaled horizontally and or vertically + * + *```js + * let Plane9 = new PIXI.NineSlicePlane(PIXI.Texture.from('BoxWithRoundedCorners.png'), 15, 15, 15, 15); + * ``` + *
+ *      A                          B
+ *    +---+----------------------+---+
+ *  C | 1 |          2           | 3 |
+ *    +---+----------------------+---+
+ *    |   |                      |   |
+ *    | 4 |          5           | 6 |
+ *    |   |                      |   |
+ *    +---+----------------------+---+
+ *  D | 7 |          8           | 9 |
+ *    +---+----------------------+---+
+
+ *  When changing this objects width and/or height:
+ *     areas 1 3 7 and 9 will remain unscaled.
+ *     areas 2 and 8 will be stretched horizontally
+ *     areas 4 and 6 will be stretched vertically
+ *     area 5 will be stretched both horizontally and vertically
+ * 
+ * + * @class + * @extends PIXI.Plane + * @memberof PIXI + * + */ +export default class NineSlicePlane extends Plane +{ + /** + * @param {PIXI.Texture} texture - The texture to use on the NineSlicePlane. + * @param {int} [leftWidth=10] size of the left vertical bar (A) + * @param {int} [topHeight=10] size of the top horizontal bar (C) + * @param {int} [rightWidth=10] size of the right vertical bar (B) + * @param {int} [bottomHeight=10] size of the bottom horizontal bar (D) + */ + constructor(texture, leftWidth, topHeight, rightWidth, bottomHeight) + { + super(texture, 4, 4); + + this._origWidth = texture.orig.width; + this._origHeight = texture.orig.height; + + /** + * The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._width = this._origWidth; + + /** + * The height of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._height = this._origHeight; + + /** + * The width of the left column (a) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._leftWidth = typeof leftWidth !== 'undefined' ? leftWidth : DEFAULT_BORDER_SIZE; + + /** + * The width of the right column (b) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._rightWidth = typeof rightWidth !== 'undefined' ? rightWidth : DEFAULT_BORDER_SIZE; + + /** + * The height of the top row (c) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._topHeight = typeof topHeight !== 'undefined' ? topHeight : DEFAULT_BORDER_SIZE; + + /** + * The height of the bottom row (d) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._bottomHeight = typeof bottomHeight !== 'undefined' ? bottomHeight : DEFAULT_BORDER_SIZE; + + this.refresh(true); + } + + /** + * Updates the horizontal vertices. + * + */ + updateHorizontalVertices() + { + const vertices = this.vertices; + + const h = this._topHeight + this._bottomHeight; + const scale = this._height > h ? 1.0 : this._height / h; + + vertices[9] = vertices[11] = vertices[13] = vertices[15] = this._topHeight * scale; + vertices[17] = vertices[19] = vertices[21] = vertices[23] = this._height - (this._bottomHeight * scale); + vertices[25] = vertices[27] = vertices[29] = vertices[31] = this._height; + } + + /** + * Updates the vertical vertices. + * + */ + updateVerticalVertices() + { + const vertices = this.vertices; + + const w = this._leftWidth + this._rightWidth; + const scale = this._width > w ? 1.0 : this._width / w; + + vertices[2] = vertices[10] = vertices[18] = vertices[26] = this._leftWidth * scale; + vertices[4] = vertices[12] = vertices[20] = vertices[28] = this._width - (this._rightWidth * scale); + vertices[6] = vertices[14] = vertices[22] = vertices[30] = this._width; + } + + /** + * The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + */ + get width() + { + return this._width; + } + + set width(value) // eslint-disable-line require-jsdoc + { + this._width = value; + this._refresh(); + } + + /** + * The height of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + */ + get height() + { + return this._height; + } + + set height(value) // eslint-disable-line require-jsdoc + { + this._height = value; + this._refresh(); + } + + /** + * The width of the left column + * + * @member {number} + */ + get leftWidth() + { + return this._leftWidth; + } + + set leftWidth(value) // eslint-disable-line require-jsdoc + { + this._leftWidth = value; + this._refresh(); + } + + /** + * The width of the right column + * + * @member {number} + */ + get rightWidth() + { + return this._rightWidth; + } + + set rightWidth(value) // eslint-disable-line require-jsdoc + { + this._rightWidth = value; + this._refresh(); + } + + /** + * The height of the top row + * + * @member {number} + */ + get topHeight() + { + return this._topHeight; + } + + set topHeight(value) // eslint-disable-line require-jsdoc + { + this._topHeight = value; + this._refresh(); + } + + /** + * The height of the bottom row + * + * @member {number} + */ + get bottomHeight() + { + return this._bottomHeight; + } + + set bottomHeight(value) // eslint-disable-line require-jsdoc + { + this._bottomHeight = value; + this._refresh(); + } + + /** + * Refreshes NineSlicePlane coords. All of them. + */ + _refresh() + { + super._refresh(); + + const uvs = this.uvs; + const texture = this._texture; + + this._origWidth = texture.orig.width; + this._origHeight = texture.orig.height; + + const _uvw = 1.0 / this._origWidth; + const _uvh = 1.0 / this._origHeight; + + uvs[0] = uvs[8] = uvs[16] = uvs[24] = 0; + uvs[1] = uvs[3] = uvs[5] = uvs[7] = 0; + uvs[6] = uvs[14] = uvs[22] = uvs[30] = 1; + uvs[25] = uvs[27] = uvs[29] = uvs[31] = 1; + + uvs[2] = uvs[10] = uvs[18] = uvs[26] = _uvw * this._leftWidth; + uvs[4] = uvs[12] = uvs[20] = uvs[28] = 1 - (_uvw * this._rightWidth); + uvs[9] = uvs[11] = uvs[13] = uvs[15] = _uvh * this._topHeight; + uvs[17] = uvs[19] = uvs[21] = uvs[23] = 1 - (_uvh * this._bottomHeight); + + this.updateHorizontalVertices(); + this.updateVerticalVertices(); + + this.geometry.buffers[1].update(); + + this.multiplyUvs(); + } +} diff --git a/packages/mesh-extras/src/Plane.js b/packages/mesh-extras/src/Plane.js new file mode 100644 index 0000000..1c240c4 --- /dev/null +++ b/packages/mesh-extras/src/Plane.js @@ -0,0 +1,100 @@ +import Mesh2d from './Mesh2d'; + +/** + * The Plane allows you to draw a texture across several points and them manipulate these points + * + *```js + * for (let i = 0; i < 20; i++) { + * points.push(new PIXI.Point(i * 50, 0)); + * }; + * let Plane = new PIXI.Plane(PIXI.Texture.from("snake.png"), points); + * ``` + * + * @class + * @extends PIXI.Mesh + * @memberof PIXI + * + */ +export default class Plane extends Mesh2d +{ + /** + * @param {PIXI.Texture} texture - The texture to use on the Plane. + * @param {number} verticesX - The number of vertices in the x-axis + * @param {number} verticesY - The number of vertices in the y-axis + * @param {object} [opts] - an options object - add meshWidth and meshHeight, temporary object for PixiJS v5 alpha + */ + constructor(texture, verticesX, verticesY, opts = {}) + { + super(texture, new Float32Array(1), new Float32Array(1), new Uint16Array(1), 4); + + this.verticesX = verticesX || 10; + this.verticesY = verticesY || 10; + + this.meshWidth = opts.meshWidth || 0; + this.meshHeight = opts.meshHeight || 0; + + this.refresh(); + } + + /** + * Refreshes plane coordinates + * @private + */ + _refresh() + { + const texture = this._texture; + const total = this.verticesX * this.verticesY; + const verts = []; + const uvs = []; + const indices = []; + + const segmentsX = this.verticesX - 1; + const segmentsY = this.verticesY - 1; + + const sizeX = (this.meshWidth || texture.width) / segmentsX; + const sizeY = (this.meshHeight || texture.height) / segmentsY; + + for (let i = 0; i < total; i++) + { + const x = (i % this.verticesX); + const y = ((i / this.verticesX) | 0); + + verts.push(x * sizeX, y * sizeY); + + uvs.push(x / segmentsX, y / segmentsY); + } + + // cons + + const totalSub = segmentsX * segmentsY; + + for (let i = 0; i < totalSub; i++) + { + const xpos = i % segmentsX; + const ypos = (i / segmentsX) | 0; + + const value = (ypos * this.verticesX) + xpos; + const value2 = (ypos * this.verticesX) + xpos + 1; + const value3 = ((ypos + 1) * this.verticesX) + xpos; + const value4 = ((ypos + 1) * this.verticesX) + xpos + 1; + + indices.push(value, value2, value3); + indices.push(value2, value4, value3); + } + + this.vertices = new Float32Array(verts); + this.uvs = new Float32Array(uvs); + this.indices = new Uint16Array(indices); + + this.geometry.buffers[0].data = this.vertices; + this.geometry.buffers[1].data = this.uvs; + this.geometry.indexBuffer.data = this.indices; + + // ensure that the changes are uploaded + this.geometry.buffers[0].update(); + this.geometry.buffers[1].update(); + this.geometry.indexBuffer.update(); + + this.multiplyUvs(); + } +} diff --git a/packages/mesh-extras/src/Rope.js b/packages/mesh-extras/src/Rope.js new file mode 100644 index 0000000..9cfde38 --- /dev/null +++ b/packages/mesh-extras/src/Rope.js @@ -0,0 +1,182 @@ +import Mesh2d from './Mesh2d'; + +/** + * The rope allows you to draw a texture across several points and them manipulate these points + * + *```js + * for (let i = 0; i < 20; i++) { + * points.push(new PIXI.Point(i * 50, 0)); + * }; + * let rope = new PIXI.Rope(PIXI.Texture.from("snake.png"), points); + * ``` + * + * @class + * @extends PIXI.Mesh + * @memberof PIXI + * + */ +export default class Rope extends Mesh2d +{ + /** + * @param {PIXI.Texture} texture - The texture to use on the rope. + * @param {PIXI.Point[]} points - An array of {@link PIXI.Point} objects to construct this rope. + */ + constructor(texture, points) + { + super(texture, new Float32Array(points.length * 4), + new Float32Array(points.length * 4), + new Uint16Array(points.length * 2), + 5); + + /* + * @member {PIXI.Point[]} An array of points that determine the rope + */ + this.points = points; + this.refresh(); + } + /** + * Refreshes Rope indices and uvs + * @private + */ + _refresh() + { + const points = this.points; + + if (!points) return; + + const vertexBuffer = this.geometry.getAttribute('aVertexPosition'); + const uvBuffer = this.geometry.getAttribute('aTextureCoord'); + const indexBuffer = this.geometry.getIndex(); + + // if too little points, or texture hasn't got UVs set yet just move on. + if (points.length < 1 || !this.texture._uvs) + { + return; + } + + // if the number of points has changed we will need to recreate the arraybuffers + if (vertexBuffer.data.length / 4 !== points.length) + { + vertexBuffer.data = new Float32Array(points.length * 4); + uvBuffer.data = new Float32Array(points.length * 4); + indexBuffer.data = new Uint16Array(points.length * 2); + } + + const uvs = uvBuffer.data; + const indices = indexBuffer.data; + + uvs[0] = 0; + uvs[1] = 0; + uvs[2] = 0; + uvs[3] = 1; + + indices[0] = 0; + indices[1] = 1; + + const total = points.length; + + for (let i = 1; i < total; i++) + { + // time to do some smart drawing! + let index = i * 4; + const amount = i / (total - 1); + + uvs[index] = amount; + uvs[index + 1] = 0; + + uvs[index + 2] = amount; + uvs[index + 3] = 1; + + index = i * 2; + indices[index] = index; + indices[index + 1] = index + 1; + } + + // ensure that the changes are uploaded + uvBuffer.update(); + indexBuffer.update(); + + this.multiplyUvs(); + this.refreshVertices(); + } + + /** + * refreshes vertices of Rope mesh + */ + refreshVertices() + { + const points = this.points; + + if (points.length < 1) + { + return; + } + + let lastPoint = points[0]; + let nextPoint; + let perpX = 0; + let perpY = 0; + + // this.count -= 0.2; + + const vertices = this.vertices; + const total = points.length; + + for (let i = 0; i < total; i++) + { + const point = points[i]; + const index = i * 4; + + if (i < points.length - 1) + { + nextPoint = points[i + 1]; + } + else + { + nextPoint = point; + } + + perpY = -(nextPoint.x - lastPoint.x); + perpX = nextPoint.y - lastPoint.y; + + let ratio = (1 - (i / (total - 1))) * 10; + + if (ratio > 1) + { + ratio = 1; + } + + const perpLength = Math.sqrt((perpX * perpX) + (perpY * perpY)); + const num = this._texture.height / 2; // (20 + Math.abs(Math.sin((i + this.count) * 0.3) * 50) )* ratio; + + perpX /= perpLength; + perpY /= perpLength; + + perpX *= num; + perpY *= num; + + vertices[index] = point.x + perpX; + vertices[index + 1] = point.y + perpY; + vertices[index + 2] = point.x - perpX; + vertices[index + 3] = point.y - perpY; + + lastPoint = point; + } + + this.geometry.buffers[0].update(); + } + + /** + * Updates the object transform for rendering + * + * @private + */ + updateTransform() + { + if (this.autoUpdate) + { + this.refreshVertices(); + } + this.containerUpdateTransform(); + } +} diff --git a/packages/mesh-extras/src/index.js b/packages/mesh-extras/src/index.js new file mode 100644 index 0000000..decf454 --- /dev/null +++ b/packages/mesh-extras/src/index.js @@ -0,0 +1,4 @@ +export { default as Mesh2d } from './Mesh2d'; +export { default as Plane } from './Plane'; +export { default as NineSlicePlane } from './NineSlicePlane'; +export { default as Rope } from './Rope'; diff --git a/packages/mesh-extras/src/mesh.frag b/packages/mesh-extras/src/mesh.frag new file mode 100644 index 0000000..6096983 --- /dev/null +++ b/packages/mesh-extras/src/mesh.frag @@ -0,0 +1,9 @@ +varying vec2 vTextureCoord; +uniform vec4 uColor; + +uniform sampler2D uSampler; + +void main(void) +{ + gl_FragColor = texture2D(uSampler, vTextureCoord) * uColor; +} diff --git a/packages/mesh-extras/src/mesh.vert b/packages/mesh-extras/src/mesh.vert new file mode 100644 index 0000000..0526df9 --- /dev/null +++ b/packages/mesh-extras/src/mesh.vert @@ -0,0 +1,15 @@ +attribute vec2 aVertexPosition; +attribute vec2 aTextureCoord; + +uniform mat3 projectionMatrix; +uniform mat3 translationMatrix; +uniform mat3 uTextureMatrix; + +varying vec2 vTextureCoord; + +void main(void) +{ + gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); + + vTextureCoord = (uTextureMatrix * vec3(aTextureCoord, 1.0)).xy; +} diff --git a/packages/mesh-extras/test/.eslintrc.json b/packages/mesh-extras/test/.eslintrc.json new file mode 100644 index 0000000..2ad8efb --- /dev/null +++ b/packages/mesh-extras/test/.eslintrc.json @@ -0,0 +1,12 @@ +{ + "globals": { + "expect": false, + "assert": false, + "sinon": false, + "PIXI": false + }, + "rules": { + "func-names": 0, + "no-unused-expressions": 0 + } +} \ No newline at end of file diff --git a/packages/mesh-extras/test/Plane.js b/packages/mesh-extras/test/Plane.js new file mode 100644 index 0000000..f9b1c25 --- /dev/null +++ b/packages/mesh-extras/test/Plane.js @@ -0,0 +1,60 @@ +const { Plane } = require('../'); +const { isWebGLSupported, skipHello } = require('@pixi/utils'); +const { Loader } = require('@pixi/loaders'); +const { Point } = require('@pixi/math'); +const { RenderTexture, Texture } = require('@pixi/core'); + +skipHello(); + +function withGL(fn) +{ + return isWebGLSupported() ? fn : undefined; +} + +// TODO: fix with webglrenderer +describe('PIXI.mesh.Plane', function () +{ + it.skip('should create a plane from an external image', withGL(function (done) + { + const loader = new Loader(); + + loader.add('testBitmap', `file://${__dirname}/resources/bitmap-1.png`) + .load(function (loader, resources) + { + const plane = new Plane(resources.testBitmap.texture, 100, 100); + + expect(plane.verticesX).to.equal(100); + expect(plane.verticesY).to.equal(100); + done(); + }); + })); + + it.skip('should create a new empty textured Plane', withGL(function () + { + const plane = new Plane(Texture.EMPTY, 100, 100); + + expect(plane.verticesX).to.equal(100); + expect(plane.verticesY).to.equal(100); + })); + + describe('containsPoint', function () + { + it.skip('should return true when point inside', withGL(function () + { + const point = new Point(10, 10); + const texture = new RenderTexture.create(20, 30); + const plane = new Plane(texture, 100, 100); + + expect(plane.containsPoint(point)).to.be.true; + })); + + it.skip('should return false when point outside', withGL(function () + { + const point = new Point(100, 100); + const texture = new RenderTexture.create(20, 30); + const plane = new Plane(texture, 100, 100); + + expect(plane.containsPoint(point)).to.be.false; + })); + }); +}); diff --git a/packages/mesh-extras/test/index.js b/packages/mesh-extras/test/index.js new file mode 100644 index 0000000..d767624 --- /dev/null +++ b/packages/mesh-extras/test/index.js @@ -0,0 +1 @@ +require('./Plane'); diff --git a/packages/mesh-extras/test/resources/bitmap-1.png b/packages/mesh-extras/test/resources/bitmap-1.png new file mode 100644 index 0000000..1284fb8 --- /dev/null +++ b/packages/mesh-extras/test/resources/bitmap-1.png Binary files differ diff --git a/packages/mesh/package.json b/packages/mesh/package.json index 8b1f8d9..10bd8e3 100644 --- a/packages/mesh/package.json +++ b/packages/mesh/package.json @@ -18,22 +18,16 @@ "publishConfig": { "access": "public" }, - "scripts": { - "test": "floss --path test" - }, "files": [ "lib" ], "dependencies": { - "@pixi/canvas-renderer": "^5.0.0-alpha.2", "@pixi/constants": "^5.0.0-alpha.2", "@pixi/core": "^5.0.0-alpha.2", "@pixi/display": "^5.0.0-alpha.2", - "@pixi/math": "^5.0.0-alpha.2", - "@pixi/utils": "^5.0.0-alpha.2" + "@pixi/math": "^5.0.0-alpha.2" }, "devDependencies": { - "@pixi/loaders": "^5.0.0-alpha.2", "floss": "^2.1.3" } } diff --git a/packages/mesh/src/Mesh.js b/packages/mesh/src/Mesh.js index e7c8f9e..1f35b7a 100644 --- a/packages/mesh/src/Mesh.js +++ b/packages/mesh/src/Mesh.js @@ -1,263 +1,220 @@ -import RawMesh from './RawMesh'; -import { Geometry, Program, Shader, Texture, TextureMatrix } from '@pixi/core'; -import { Matrix } from '@pixi/math'; -import { BLEND_MODES } from '@pixi/constants'; -import { hex2rgb, premultiplyRgba } from '@pixi/utils'; -import vertex from './mesh.vert'; -import fragment from './mesh.frag'; +import { State } from '@pixi/core'; +import { DRAW_MODES } from '@pixi/constants'; +import { Point, Polygon } from '@pixi/math'; +import { Container } from '@pixi/display'; -let meshProgram; +const tempPoint = new Point(); +const tempPolygon = new Polygon(); /** - * Base mesh class + * Base mesh class. + * The reason for this class is to empower you to have maximum flexibility to render any kind of webGL you can think of. + * This class assumes a certain level of webGL knowledge. + * If you know a bit this should abstract enough away to make you life easier! + * Pretty much ALL WebGL can be broken down into the following: + * Geometry - The structure and data for the mesh. This can include anything from positions, uvs, normals, colors etc.. + * Shader - This is the shader that pixi will render the geometry with. (attributes in the shader must match the geometry!) + * Uniforms - These are the values passed to the shader when the mesh is rendered. + * As a shader can be reused across multiple objects, it made sense to allow uniforms to exist outside of the shader + * State - This is the state of WebGL required to render the mesh. + * Through a combination of the above elements you can render anything you want, 2D or 3D! + * * @class * @extends PIXI.Container * @memberof PIXI */ -export default class Mesh extends RawMesh +export default class Mesh extends Container { /** - * @param {PIXI.Texture} [texture=Texture.EMPTY] - The texture to use - * @param {Float32Array} [vertices] - if you want to specify the vertices - * @param {Float32Array} [uvs] - if you want to specify the uvs - * @param {Uint16Array} [indices] - if you want to specify the indices - * @param {number} [drawMode] - the drawMode, can be any of the Mesh.DRAW_MODES consts + * @param {PIXI.Geometry} geometry the geometry the mesh will use + * @param {PIXI.Shader} shader the shader the mesh will use + * @param {PIXI.State} state the state that the webGL context is required to be in to render the mesh + * @param {number} drawMode the drawMode, can be any of the PIXI.DRAW_MODES consts */ - constructor(texture = Texture.EMPTY, vertices, uvs, indices, drawMode) + constructor(geometry, shader, state, drawMode = DRAW_MODES.TRIANGLES) { - const geometry = new Geometry(); - - if (!meshProgram) - { - meshProgram = new Program(vertex, fragment); - } - - geometry.addAttribute('aVertexPosition', vertices) - .addAttribute('aTextureCoord', uvs) - .addIndex(indices); - - geometry.getAttribute('aVertexPosition').static = false; - - const uniforms = { - uSampler: texture, - uTextureMatrix: Matrix.IDENTITY, - alpha: 1, - uColor: new Float32Array([1, 1, 1, 1]), - }; - - super(geometry, new Shader(meshProgram, uniforms), null, drawMode); + super(); /** - * The Uvs of the Mesh - * - * @member {Float32Array} + * the geometry the mesh will use + * @type {PIXI.Geometry} */ - this.uvs = geometry.getAttribute('aTextureCoord').data; + this.geometry = geometry; /** - * An array of vertices - * - * @member {Float32Array} + * the shader the mesh will use + * @type {PIXI.Shader} */ - this.vertices = geometry.getAttribute('aVertexPosition').data; - - this.uniforms = uniforms; + this.shader = shader; /** - * The texture of the Mesh - * - * @member {PIXI.Texture} - * @default PIXI.Texture.EMPTY - * @private + * the webGL state the mesh requires to render + * @type {PIXI.State} */ - this.texture = texture; + this.state = state || new State(); /** - * The tint applied to the mesh. This is a [r,g,b] value. A value of [1,1,1] will remove any - * tint effect. + * The way the Mesh should be drawn, can be any of the {@link PIXI.Mesh.DRAW_MODES} consts * * @member {number} + * @see PIXI.Mesh.DRAW_MODES + */ + this.drawMode = drawMode; + + /** + * The way uniforms that will be used by the mesh's shader. + * @member {Object} + */ + + /** + * A map of renderer IDs to webgl render data + * * @private + * @member {object} */ - this._tintRGB = new Float32Array([1, 1, 1]); - - // Set default tint - this.tint = 0xFFFFFF; - - this.blendMode = BLEND_MODES.NORMAL; + this._glDatas = {}; /** - * TextureMatrix instance for this Mesh, used to track Texture changes + * Plugin that is responsible for rendering this element. + * Allows to customize the rendering process without overriding '_render' & '_renderCanvas' methods. * - * @member {PIXI.TextureMatrix} - * @readonly + * @member {string} + * @default 'mesh' */ - this.uvMatrix = new TextureMatrix(this._texture); + this.pluginName = 'mesh'; - /** - * whether or not upload uvMatrix to shader - * if its false, then uvs should be pre-multiplied - * if you change it for generated mesh, please call 'refresh(true)' - * @member {boolean} - * @default false - */ - this.uploadUvMatrix = false; - - /** - * Uploads vertices buffer every frame, like in PixiJS V3 and V4. - * - * @member {boolean} - * @default true - */ - this.autoUpdate = true; + this.start = 0; + this.size = 0; } /** - * The tint applied to the Rope. This is a hex value. A value of - * 0xFFFFFF will remove any tint effect. + * Renders the object using the WebGL renderer * - * @member {number} - * @memberof PIXI.Sprite# - * @default 0xFFFFFF + * @param {PIXI.Renderer} renderer a reference to the WebGL renderer + * @private */ - get tint() + _render(renderer) { - return this._tint; + renderer.batch.setObjectRenderer(renderer.plugins[this.pluginName]); + renderer.plugins[this.pluginName].render(this); } /** - * Sets the tint of the rope. + * Updates the bounds of the mesh as a rectangle. The bounds calculation takes the worldTransform into account. + * there must be a aVertexPosition attribute present in the geometry for bounds to be calculated correctly. * - * @param {number} value - The value to set to. + * @private */ - set tint(value) + _calculateBounds() { - this._tint = value; - - hex2rgb(this._tint, this._tintRGB); - } - - /** - * The blend mode to be applied to the sprite. Set to `PIXI.BLEND_MODES.NORMAL` to remove any blend mode. - * - * @member {number} - * @default PIXI.BLEND_MODES.NORMAL - * @see PIXI.BLEND_MODES - */ - get blendMode() - { - return this.state.blendMode; - } - - set blendMode(value) // eslint-disable-line require-jsdoc - { - this.state.blendMode = value; - } - - /** - * The texture that the mesh uses. - * - * @member {PIXI.Texture} - */ - get texture() - { - return this._texture; - } - - set texture(value) // eslint-disable-line require-jsdoc - { - if (this._texture === value) + // The position property could be set manually? + if (this.geometry.attributes.aVertexPosition) { - return; + const vertices = this.geometry.getAttribute('aVertexPosition').data; + + // TODO - we can cache local bounds and use them if they are dirty (like graphics) + this._bounds.addVertices(this.transform, vertices, 0, vertices.length); + } + } + + /** + * Tests if a point is inside this mesh. Works only for TRIANGLE_MESH + * + * @param {PIXI.Point} point the point to test + * @return {boolean} the result of the test + */ + containsPoint(point) + { + if (!this.getBounds().contains(point.x, point.y)) + { + return false; } - this._texture = value; - this.uniforms.uSampler = this.texture; + this.worldTransform.applyInverse(point, tempPoint); - if (value) + const vertices = this.geometry.getAttribute('aVertexPosition').data; + + const points = tempPolygon.points; + const indices = this.geometry.getIndex().data; + const len = indices.length; + const step = this.drawMode === 4 ? 3 : 1; + + for (let i = 0; i + 2 < len; i += step) { - // wait for the texture to load - if (value.baseTexture.valid) + const ind0 = indices[i] * 2; + const ind1 = indices[i + 1] * 2; + const ind2 = indices[i + 2] * 2; + + points[0] = vertices[ind0]; + points[1] = vertices[ind0 + 1]; + points[2] = vertices[ind1]; + points[3] = vertices[ind1 + 1]; + points[4] = vertices[ind2]; + points[5] = vertices[ind2 + 1]; + + if (tempPolygon.contains(tempPoint.x, tempPoint.y)) { - this._onTextureUpdate(); + return true; + } + } + + return false; + } + + /** + * Destroys the Mesh object. + * + * @param {object|boolean} [options] - Options parameter. A boolean will act as if all + * options have been set to that value + * @param {boolean} [options.children=false] - if set to true, all the children will have + * their destroy method called as well. 'options' will be passed on to those calls. + * @param {boolean} [options.texture=false] - Only used for child Sprites if options.children is set to true + * Should it destroy the texture of the child sprite + * @param {boolean} [options.baseTexture=false] - Only used for child Sprites if options.children is set to true + * Should it destroy the base texture of the child sprite + */ + destroy(options) + { + // for each webgl data entry, destroy the WebGLGraphicsData + for (const id in this._glDatas) + { + const data = this._glDatas[id]; + + if (data.destroy) + { + data.destroy(); } else { - value.once('update', this._onTextureUpdate, this); + if (data.vertexBuffer) + { + data.vertexBuffer.destroy(); + data.vertexBuffer = null; + } + if (data.indexBuffer) + { + data.indexBuffer.destroy(); + data.indexBuffer = null; + } + if (data.uvBuffer) + { + data.uvBuffer.destroy(); + data.uvBuffer = null; + } + if (data.vao) + { + data.vao.destroy(); + data.vao = null; + } } } - } - _render(renderer) - { - const baseTex = this._texture.baseTexture; + this._glDatas = null; - premultiplyRgba(this._tintRGB, this.worldAlpha, this.uniforms.uColor, baseTex.premultiplyAlpha); - super._render(renderer); - } - /** - * When the texture is updated, this event will fire to update the scale and frame - * - * @private - */ - _onTextureUpdate() - { - // constructor texture update stop - if (!this.uvMatrix) - { - return; - } - this.uvMatrix.texture = this._texture; - this.refresh(); - } + this.geometry = null; + this.shader = null; + this.state = null; - /** - * multiplies uvs only if uploadUvMatrix is false - * call it after you change uvs manually - * make sure that texture is valid - */ - multiplyUvs() - { - if (!this.uploadUvMatrix) - { - this.uvMatrix.multiplyUvs(this.uvs); - } - } - - /** - * Refreshes uvs for generated meshes (rope, plane) - * sometimes refreshes vertices too - * - * @param {boolean} [forceUpdate=false] if true, matrices will be updated any case - */ - refresh(forceUpdate) - { - if (this.uvMatrix.update(forceUpdate)) - { - this._refresh(); - } - } - - /** - * Updates the object transform for rendering - * - * @private - */ - updateTransform() - { - if (this.autoUpdate) - { - this.geometry.buffers[0].update(); - } - this.containerUpdateTransform(); - } - - /** - * re-calculates mesh coords - * @private - */ - _refresh() - { - /* empty */ + super.destroy(options); } } diff --git a/packages/mesh/src/MeshRenderer.js b/packages/mesh/src/MeshRenderer.js index 12b159b..d7baf9b 100644 --- a/packages/mesh/src/MeshRenderer.js +++ b/packages/mesh/src/MeshRenderer.js @@ -36,7 +36,7 @@ /** * renders mesh * @private - * @param {PIXI.RawMesh} mesh mesh instance + * @param {PIXI.Mesh} mesh mesh instance */ render(mesh) { diff --git a/packages/mesh/src/NineSlicePlane.js b/packages/mesh/src/NineSlicePlane.js deleted file mode 100644 index 0bae92c..0000000 --- a/packages/mesh/src/NineSlicePlane.js +++ /dev/null @@ -1,270 +0,0 @@ -import Plane from './Plane'; - -const DEFAULT_BORDER_SIZE = 10; - -/** - * The NineSlicePlane allows you to stretch a texture using 9-slice scaling. The corners will remain unscaled (useful - * for buttons with rounded corners for example) and the other areas will be scaled horizontally and or vertically - * - *```js - * let Plane9 = new PIXI.NineSlicePlane(PIXI.Texture.from('BoxWithRoundedCorners.png'), 15, 15, 15, 15); - * ``` - *
- *      A                          B
- *    +---+----------------------+---+
- *  C | 1 |          2           | 3 |
- *    +---+----------------------+---+
- *    |   |                      |   |
- *    | 4 |          5           | 6 |
- *    |   |                      |   |
- *    +---+----------------------+---+
- *  D | 7 |          8           | 9 |
- *    +---+----------------------+---+
-
- *  When changing this objects width and/or height:
- *     areas 1 3 7 and 9 will remain unscaled.
- *     areas 2 and 8 will be stretched horizontally
- *     areas 4 and 6 will be stretched vertically
- *     area 5 will be stretched both horizontally and vertically
- * 
- * - * @class - * @extends PIXI.Plane - * @memberof PIXI - * - */ -export default class NineSlicePlane extends Plane -{ - /** - * @param {PIXI.Texture} texture - The texture to use on the NineSlicePlane. - * @param {int} [leftWidth=10] size of the left vertical bar (A) - * @param {int} [topHeight=10] size of the top horizontal bar (C) - * @param {int} [rightWidth=10] size of the right vertical bar (B) - * @param {int} [bottomHeight=10] size of the bottom horizontal bar (D) - */ - constructor(texture, leftWidth, topHeight, rightWidth, bottomHeight) - { - super(texture, 4, 4); - - this._origWidth = texture.orig.width; - this._origHeight = texture.orig.height; - - /** - * The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane - * - * @member {number} - * @memberof PIXI.NineSlicePlane# - * @override - */ - this._width = this._origWidth; - - /** - * The height of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane - * - * @member {number} - * @memberof PIXI.NineSlicePlane# - * @override - */ - this._height = this._origHeight; - - /** - * The width of the left column (a) - * - * @member {number} - * @memberof PIXI.NineSlicePlane# - * @override - */ - this._leftWidth = typeof leftWidth !== 'undefined' ? leftWidth : DEFAULT_BORDER_SIZE; - - /** - * The width of the right column (b) - * - * @member {number} - * @memberof PIXI.NineSlicePlane# - * @override - */ - this._rightWidth = typeof rightWidth !== 'undefined' ? rightWidth : DEFAULT_BORDER_SIZE; - - /** - * The height of the top row (c) - * - * @member {number} - * @memberof PIXI.NineSlicePlane# - * @override - */ - this._topHeight = typeof topHeight !== 'undefined' ? topHeight : DEFAULT_BORDER_SIZE; - - /** - * The height of the bottom row (d) - * - * @member {number} - * @memberof PIXI.NineSlicePlane# - * @override - */ - this._bottomHeight = typeof bottomHeight !== 'undefined' ? bottomHeight : DEFAULT_BORDER_SIZE; - - this.refresh(true); - } - - /** - * Updates the horizontal vertices. - * - */ - updateHorizontalVertices() - { - const vertices = this.vertices; - - const h = this._topHeight + this._bottomHeight; - const scale = this._height > h ? 1.0 : this._height / h; - - vertices[9] = vertices[11] = vertices[13] = vertices[15] = this._topHeight * scale; - vertices[17] = vertices[19] = vertices[21] = vertices[23] = this._height - (this._bottomHeight * scale); - vertices[25] = vertices[27] = vertices[29] = vertices[31] = this._height; - } - - /** - * Updates the vertical vertices. - * - */ - updateVerticalVertices() - { - const vertices = this.vertices; - - const w = this._leftWidth + this._rightWidth; - const scale = this._width > w ? 1.0 : this._width / w; - - vertices[2] = vertices[10] = vertices[18] = vertices[26] = this._leftWidth * scale; - vertices[4] = vertices[12] = vertices[20] = vertices[28] = this._width - (this._rightWidth * scale); - vertices[6] = vertices[14] = vertices[22] = vertices[30] = this._width; - } - - /** - * The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane - * - * @member {number} - */ - get width() - { - return this._width; - } - - set width(value) // eslint-disable-line require-jsdoc - { - this._width = value; - this._refresh(); - } - - /** - * The height of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane - * - * @member {number} - */ - get height() - { - return this._height; - } - - set height(value) // eslint-disable-line require-jsdoc - { - this._height = value; - this._refresh(); - } - - /** - * The width of the left column - * - * @member {number} - */ - get leftWidth() - { - return this._leftWidth; - } - - set leftWidth(value) // eslint-disable-line require-jsdoc - { - this._leftWidth = value; - this._refresh(); - } - - /** - * The width of the right column - * - * @member {number} - */ - get rightWidth() - { - return this._rightWidth; - } - - set rightWidth(value) // eslint-disable-line require-jsdoc - { - this._rightWidth = value; - this._refresh(); - } - - /** - * The height of the top row - * - * @member {number} - */ - get topHeight() - { - return this._topHeight; - } - - set topHeight(value) // eslint-disable-line require-jsdoc - { - this._topHeight = value; - this._refresh(); - } - - /** - * The height of the bottom row - * - * @member {number} - */ - get bottomHeight() - { - return this._bottomHeight; - } - - set bottomHeight(value) // eslint-disable-line require-jsdoc - { - this._bottomHeight = value; - this._refresh(); - } - - /** - * Refreshes NineSlicePlane coords. All of them. - */ - _refresh() - { - super._refresh(); - - const uvs = this.uvs; - const texture = this._texture; - - this._origWidth = texture.orig.width; - this._origHeight = texture.orig.height; - - const _uvw = 1.0 / this._origWidth; - const _uvh = 1.0 / this._origHeight; - - uvs[0] = uvs[8] = uvs[16] = uvs[24] = 0; - uvs[1] = uvs[3] = uvs[5] = uvs[7] = 0; - uvs[6] = uvs[14] = uvs[22] = uvs[30] = 1; - uvs[25] = uvs[27] = uvs[29] = uvs[31] = 1; - - uvs[2] = uvs[10] = uvs[18] = uvs[26] = _uvw * this._leftWidth; - uvs[4] = uvs[12] = uvs[20] = uvs[28] = 1 - (_uvw * this._rightWidth); - uvs[9] = uvs[11] = uvs[13] = uvs[15] = _uvh * this._topHeight; - uvs[17] = uvs[19] = uvs[21] = uvs[23] = 1 - (_uvh * this._bottomHeight); - - this.updateHorizontalVertices(); - this.updateVerticalVertices(); - - this.geometry.buffers[1].update(); - - this.multiplyUvs(); - } -} diff --git a/packages/mesh/src/Plane.js b/packages/mesh/src/Plane.js deleted file mode 100644 index c416b4c..0000000 --- a/packages/mesh/src/Plane.js +++ /dev/null @@ -1,100 +0,0 @@ -import Mesh from './Mesh'; - -/** - * The Plane allows you to draw a texture across several points and them manipulate these points - * - *```js - * for (let i = 0; i < 20; i++) { - * points.push(new PIXI.Point(i * 50, 0)); - * }; - * let Plane = new PIXI.Plane(PIXI.Texture.from("snake.png"), points); - * ``` - * - * @class - * @extends PIXI.Mesh - * @memberof PIXI - * - */ -export default class Plane extends Mesh -{ - /** - * @param {PIXI.Texture} texture - The texture to use on the Plane. - * @param {number} verticesX - The number of vertices in the x-axis - * @param {number} verticesY - The number of vertices in the y-axis - * @param {object} [opts] - an options object - add meshWidth and meshHeight, temporary object for PixiJS v5 alpha - */ - constructor(texture, verticesX, verticesY, opts = {}) - { - super(texture, new Float32Array(1), new Float32Array(1), new Uint16Array(1), 4); - - this.verticesX = verticesX || 10; - this.verticesY = verticesY || 10; - - this.meshWidth = opts.meshWidth || 0; - this.meshHeight = opts.meshHeight || 0; - - this.refresh(); - } - - /** - * Refreshes plane coordinates - * @private - */ - _refresh() - { - const texture = this._texture; - const total = this.verticesX * this.verticesY; - const verts = []; - const uvs = []; - const indices = []; - - const segmentsX = this.verticesX - 1; - const segmentsY = this.verticesY - 1; - - const sizeX = (this.meshWidth || texture.width) / segmentsX; - const sizeY = (this.meshHeight || texture.height) / segmentsY; - - for (let i = 0; i < total; i++) - { - const x = (i % this.verticesX); - const y = ((i / this.verticesX) | 0); - - verts.push(x * sizeX, y * sizeY); - - uvs.push(x / segmentsX, y / segmentsY); - } - - // cons - - const totalSub = segmentsX * segmentsY; - - for (let i = 0; i < totalSub; i++) - { - const xpos = i % segmentsX; - const ypos = (i / segmentsX) | 0; - - const value = (ypos * this.verticesX) + xpos; - const value2 = (ypos * this.verticesX) + xpos + 1; - const value3 = ((ypos + 1) * this.verticesX) + xpos; - const value4 = ((ypos + 1) * this.verticesX) + xpos + 1; - - indices.push(value, value2, value3); - indices.push(value2, value4, value3); - } - - this.vertices = new Float32Array(verts); - this.uvs = new Float32Array(uvs); - this.indices = new Uint16Array(indices); - - this.geometry.buffers[0].data = this.vertices; - this.geometry.buffers[1].data = this.uvs; - this.geometry.indexBuffer.data = this.indices; - - // ensure that the changes are uploaded - this.geometry.buffers[0].update(); - this.geometry.buffers[1].update(); - this.geometry.indexBuffer.update(); - - this.multiplyUvs(); - } -} diff --git a/packages/mesh/src/RawMesh.js b/packages/mesh/src/RawMesh.js deleted file mode 100644 index 7297e94..0000000 --- a/packages/mesh/src/RawMesh.js +++ /dev/null @@ -1,220 +0,0 @@ -import { State } from '@pixi/core'; -import { DRAW_MODES } from '@pixi/constants'; -import { Point, Polygon } from '@pixi/math'; -import { Container } from '@pixi/display'; - -const tempPoint = new Point(); -const tempPolygon = new Polygon(); - -/** - * Base mesh class. - * The reason for this class is to empower you to have maximum flexibility to render any kind of webGL you can think of. - * This class assumes a certain level of webGL knowledge. - * If you know a bit this should abstract enough away to make you life easier! - * Pretty much ALL WebGL can be broken down into the following: - * Geometry - The structure and data for the mesh. This can include anything from positions, uvs, normals, colors etc.. - * Shader - This is the shader that pixi will render the geometry with. (attributes in the shader must match the geometry!) - * Uniforms - These are the values passed to the shader when the mesh is rendered. - * As a shader can be reused across multiple objects, it made sense to allow uniforms to exist outside of the shader - * State - This is the state of WebGL required to render the mesh. - * Through a combination of the above elements you can render anything you want, 2D or 3D! - * - * @class - * @extends PIXI.Container - * @memberof PIXI - */ -export default class RawMesh extends Container -{ - /** - * @param {PIXI.Geometry} geometry the geometry the mesh will use - * @param {PIXI.Shader} shader the shader the mesh will use - * @param {PIXI.State} state the state that the webGL context is required to be in to render the mesh - * @param {number} drawMode the drawMode, can be any of the PIXI.DRAW_MODES consts - */ - constructor(geometry, shader, state, drawMode = DRAW_MODES.TRIANGLES) - { - super(); - - /** - * the geometry the mesh will use - * @type {PIXI.Geometry} - */ - this.geometry = geometry; - - /** - * the shader the mesh will use - * @type {PIXI.Shader} - */ - this.shader = shader; - - /** - * the webGL state the mesh requires to render - * @type {PIXI.State} - */ - this.state = state || new State(); - - /** - * The way the Mesh should be drawn, can be any of the {@link PIXI.RawMesh.DRAW_MODES} consts - * - * @member {number} - * @see PIXI.RawMesh.DRAW_MODES - */ - this.drawMode = drawMode; - - /** - * The way uniforms that will be used by the mesh's shader. - * @member {Object} - */ - - /** - * A map of renderer IDs to webgl render data - * - * @private - * @member {object} - */ - this._glDatas = {}; - - /** - * Plugin that is responsible for rendering this element. - * Allows to customize the rendering process without overriding '_render' & '_renderCanvas' methods. - * - * @member {string} - * @default 'mesh' - */ - this.pluginName = 'mesh'; - - this.start = 0; - this.size = 0; - } - - /** - * Renders the object using the WebGL renderer - * - * @param {PIXI.Renderer} renderer a reference to the WebGL renderer - * @private - */ - _render(renderer) - { - renderer.batch.setObjectRenderer(renderer.plugins[this.pluginName]); - renderer.plugins[this.pluginName].render(this); - } - - /** - * Updates the bounds of the mesh as a rectangle. The bounds calculation takes the worldTransform into account. - * there must be a aVertexPosition attribute present in the geometry for bounds to be calculated correctly. - * - * @private - */ - _calculateBounds() - { - // The position property could be set manually? - if (this.geometry.attributes.aVertexPosition) - { - const vertices = this.geometry.getAttribute('aVertexPosition').data; - - // TODO - we can cache local bounds and use them if they are dirty (like graphics) - this._bounds.addVertices(this.transform, vertices, 0, vertices.length); - } - } - - /** - * Tests if a point is inside this mesh. Works only for TRIANGLE_MESH - * - * @param {PIXI.Point} point the point to test - * @return {boolean} the result of the test - */ - containsPoint(point) - { - if (!this.getBounds().contains(point.x, point.y)) - { - return false; - } - - this.worldTransform.applyInverse(point, tempPoint); - - const vertices = this.geometry.getAttribute('aVertexPosition').data; - - const points = tempPolygon.points; - const indices = this.geometry.getIndex().data; - const len = indices.length; - const step = this.drawMode === 4 ? 3 : 1; - - for (let i = 0; i + 2 < len; i += step) - { - const ind0 = indices[i] * 2; - const ind1 = indices[i + 1] * 2; - const ind2 = indices[i + 2] * 2; - - points[0] = vertices[ind0]; - points[1] = vertices[ind0 + 1]; - points[2] = vertices[ind1]; - points[3] = vertices[ind1 + 1]; - points[4] = vertices[ind2]; - points[5] = vertices[ind2 + 1]; - - if (tempPolygon.contains(tempPoint.x, tempPoint.y)) - { - return true; - } - } - - return false; - } - - /** - * Destroys the RawMesh object. - * - * @param {object|boolean} [options] - Options parameter. A boolean will act as if all - * options have been set to that value - * @param {boolean} [options.children=false] - if set to true, all the children will have - * their destroy method called as well. 'options' will be passed on to those calls. - * @param {boolean} [options.texture=false] - Only used for child Sprites if options.children is set to true - * Should it destroy the texture of the child sprite - * @param {boolean} [options.baseTexture=false] - Only used for child Sprites if options.children is set to true - * Should it destroy the base texture of the child sprite - */ - destroy(options) - { - // for each webgl data entry, destroy the WebGLGraphicsData - for (const id in this._glDatas) - { - const data = this._glDatas[id]; - - if (data.destroy) - { - data.destroy(); - } - else - { - if (data.vertexBuffer) - { - data.vertexBuffer.destroy(); - data.vertexBuffer = null; - } - if (data.indexBuffer) - { - data.indexBuffer.destroy(); - data.indexBuffer = null; - } - if (data.uvBuffer) - { - data.uvBuffer.destroy(); - data.uvBuffer = null; - } - if (data.vao) - { - data.vao.destroy(); - data.vao = null; - } - } - } - - this._glDatas = null; - - this.geometry = null; - this.shader = null; - this.state = null; - - super.destroy(options); - } -} diff --git a/packages/mesh/src/Rope.js b/packages/mesh/src/Rope.js deleted file mode 100644 index b4f85d3..0000000 --- a/packages/mesh/src/Rope.js +++ /dev/null @@ -1,182 +0,0 @@ -import Mesh from './Mesh'; - -/** - * The rope allows you to draw a texture across several points and them manipulate these points - * - *```js - * for (let i = 0; i < 20; i++) { - * points.push(new PIXI.Point(i * 50, 0)); - * }; - * let rope = new PIXI.Rope(PIXI.Texture.from("snake.png"), points); - * ``` - * - * @class - * @extends PIXI.Mesh - * @memberof PIXI - * - */ -export default class Rope extends Mesh -{ - /** - * @param {PIXI.Texture} texture - The texture to use on the rope. - * @param {PIXI.Point[]} points - An array of {@link PIXI.Point} objects to construct this rope. - */ - constructor(texture, points) - { - super(texture, new Float32Array(points.length * 4), - new Float32Array(points.length * 4), - new Uint16Array(points.length * 2), - 5); - - /* - * @member {PIXI.Point[]} An array of points that determine the rope - */ - this.points = points; - this.refresh(); - } - /** - * Refreshes Rope indices and uvs - * @private - */ - _refresh() - { - const points = this.points; - - if (!points) return; - - const vertexBuffer = this.geometry.getAttribute('aVertexPosition'); - const uvBuffer = this.geometry.getAttribute('aTextureCoord'); - const indexBuffer = this.geometry.getIndex(); - - // if too little points, or texture hasn't got UVs set yet just move on. - if (points.length < 1 || !this.texture._uvs) - { - return; - } - - // if the number of points has changed we will need to recreate the arraybuffers - if (vertexBuffer.data.length / 4 !== points.length) - { - vertexBuffer.data = new Float32Array(points.length * 4); - uvBuffer.data = new Float32Array(points.length * 4); - indexBuffer.data = new Uint16Array(points.length * 2); - } - - const uvs = uvBuffer.data; - const indices = indexBuffer.data; - - uvs[0] = 0; - uvs[1] = 0; - uvs[2] = 0; - uvs[3] = 1; - - indices[0] = 0; - indices[1] = 1; - - const total = points.length; - - for (let i = 1; i < total; i++) - { - // time to do some smart drawing! - let index = i * 4; - const amount = i / (total - 1); - - uvs[index] = amount; - uvs[index + 1] = 0; - - uvs[index + 2] = amount; - uvs[index + 3] = 1; - - index = i * 2; - indices[index] = index; - indices[index + 1] = index + 1; - } - - // ensure that the changes are uploaded - uvBuffer.update(); - indexBuffer.update(); - - this.multiplyUvs(); - this.refreshVertices(); - } - - /** - * refreshes vertices of Rope mesh - */ - refreshVertices() - { - const points = this.points; - - if (points.length < 1) - { - return; - } - - let lastPoint = points[0]; - let nextPoint; - let perpX = 0; - let perpY = 0; - - // this.count -= 0.2; - - const vertices = this.vertices; - const total = points.length; - - for (let i = 0; i < total; i++) - { - const point = points[i]; - const index = i * 4; - - if (i < points.length - 1) - { - nextPoint = points[i + 1]; - } - else - { - nextPoint = point; - } - - perpY = -(nextPoint.x - lastPoint.x); - perpX = nextPoint.y - lastPoint.y; - - let ratio = (1 - (i / (total - 1))) * 10; - - if (ratio > 1) - { - ratio = 1; - } - - const perpLength = Math.sqrt((perpX * perpX) + (perpY * perpY)); - const num = this._texture.height / 2; // (20 + Math.abs(Math.sin((i + this.count) * 0.3) * 50) )* ratio; - - perpX /= perpLength; - perpY /= perpLength; - - perpX *= num; - perpY *= num; - - vertices[index] = point.x + perpX; - vertices[index + 1] = point.y + perpY; - vertices[index + 2] = point.x - perpX; - vertices[index + 3] = point.y - perpY; - - lastPoint = point; - } - - this.geometry.buffers[0].update(); - } - - /** - * Updates the object transform for rendering - * - * @private - */ - updateTransform() - { - if (this.autoUpdate) - { - this.refreshVertices(); - } - this.containerUpdateTransform(); - } -} diff --git a/packages/mesh/src/index.js b/packages/mesh/src/index.js index a245772..e14ab9f 100644 --- a/packages/mesh/src/index.js +++ b/packages/mesh/src/index.js @@ -1,6 +1,2 @@ export { default as Mesh } from './Mesh'; -export { default as RawMesh } from './RawMesh'; export { default as MeshRenderer } from './MeshRenderer'; -export { default as Plane } from './Plane'; -export { default as NineSlicePlane } from './NineSlicePlane'; -export { default as Rope } from './Rope'; diff --git a/packages/mesh/src/mesh.frag b/packages/mesh/src/mesh.frag deleted file mode 100644 index 6096983..0000000 --- a/packages/mesh/src/mesh.frag +++ /dev/null @@ -1,9 +0,0 @@ -varying vec2 vTextureCoord; -uniform vec4 uColor; - -uniform sampler2D uSampler; - -void main(void) -{ - gl_FragColor = texture2D(uSampler, vTextureCoord) * uColor; -} diff --git a/bundles/pixi.js/package.json b/bundles/pixi.js/package.json index 49c7276..177e059 100644 --- a/bundles/pixi.js/package.json +++ b/bundles/pixi.js/package.json @@ -49,6 +49,7 @@ "@pixi/loaders": "^5.0.0-alpha.2", "@pixi/math": "^5.0.0-alpha.2", "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/mesh-extras": "^5.0.0-alpha.2", "@pixi/mixin-cache-as-bitmap": "^5.0.0-alpha.2", "@pixi/mixin-get-child-by-name": "^5.0.0-alpha.2", "@pixi/mixin-get-global-position": "^5.0.0-alpha.2", diff --git a/bundles/pixi.js/src/deprecated.js b/bundles/pixi.js/src/deprecated.js index 147617c..dbebeb0 100644 --- a/bundles/pixi.js/src/deprecated.js +++ b/bundles/pixi.js/src/deprecated.js @@ -263,15 +263,15 @@ Object.defineProperties(PIXI.mesh, { /** * @class PIXI.mesh.Mesh - * @see PIXI.Mesh + * @see PIXI.Mesh2d * @deprecated since 5.0.0 */ Mesh: { get() { - warn('PIXI.mesh.Mesh has moved to PIXI.Mesh'); + warn('PIXI.mesh.Mesh has moved to PIXI.Mesh2d'); - return PIXI.Mesh; + return PIXI.Mesh2d; }, }, /** @@ -315,15 +315,15 @@ }, /** * @class PIXI.mesh.RawMesh - * @see PIXI.RawMesh + * @see PIXI.Mesh * @deprecated since 5.0.0 */ RawMesh: { get() { - warn('PIXI.mesh.RawMesh has moved to PIXI.RawMesh'); + warn('PIXI.mesh.RawMesh has moved to PIXI.Mesh'); - return PIXI.RawMesh; + return PIXI.Mesh; }, }, /** diff --git a/bundles/pixi.js/src/index.js b/bundles/pixi.js/src/index.js index a3a0d1b..6fdabf0 100644 --- a/bundles/pixi.js/src/index.js +++ b/bundles/pixi.js/src/index.js @@ -9,6 +9,7 @@ import * as loaders from '@pixi/loaders'; import * as math from '@pixi/math'; import * as mesh from '@pixi/mesh'; +import * as meshExtras from '@pixi/mesh-extras'; import * as particles from '@pixi/particles'; import * as prepare from '@pixi/prepare'; import * as sprite from '@pixi/sprite'; @@ -128,6 +129,7 @@ loaders, math, mesh, + meshExtras, particles, sprite, spriteAnimated, @@ -152,6 +154,7 @@ export * from '@pixi/loaders'; export * from '@pixi/math'; export * from '@pixi/mesh'; +export * from '@pixi/mesh-extras'; export * from '@pixi/particles'; export * from '@pixi/sprite'; export * from '@pixi/spritesheet'; diff --git a/package-lock.json b/package-lock.json index 7fe6db7..0814729 100644 --- a/package-lock.json +++ b/package-lock.json @@ -209,7 +209,7 @@ "argparse": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", - "integrity": "sha1-vNZ5HqWuCXJeF+WtmIE0zUCz2RE=", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", "dev": true, "requires": { "sprintf-js": "1.0.3" @@ -228,7 +228,7 @@ "arr-flatten": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz", - "integrity": "sha1-NgSLv/TntH4TZkQxbJlmnqWukfE=", + "integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==", "dev": true }, "arr-union": { @@ -297,7 +297,7 @@ "assertion-error": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", - "integrity": "sha1-5gtrDo8wG9l+U3UhW9pAbIURjAs=", + "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", "dev": true }, "async": { @@ -396,7 +396,7 @@ "brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha1-PH/L9SnYcibz0vUrlm/1Jx60Qd0=", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, "requires": { "balanced-match": "1.0.0", @@ -568,7 +568,7 @@ "circular-json": { "version": "0.3.3", "resolved": "https://registry.npmjs.org/circular-json/-/circular-json-0.3.3.tgz", - "integrity": "sha1-gVyZ6oT2gJUp0vRXkb34JxE1LWY=", + "integrity": "sha512-UZK3NBx2Mca+b5LsG7bY183pHWt5Y1xts4P3Pz7ENTwGVnJOUWbRb3ocjvX7hx9tq/yTAdclXm9sZ38gNuem4A==", "dev": true }, "cli-cursor": { @@ -638,7 +638,7 @@ "color-convert": { "version": "1.9.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.1.tgz", - "integrity": "sha1-wSYRB66y8pTr/+ye2eytUppgl+0=", + "integrity": "sha512-mjGanIiwQJskCC18rPR6OmrZ6fm2Lc7PeGFYwCmy5J34wC6F1PzdGL6xeMfmgicfYcNLGuVFA3WzXtIDCQSZxQ==", "dev": true, "requires": { "color-name": "1.1.3" @@ -1427,7 +1427,7 @@ "boom": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/boom/-/boom-5.2.0.tgz", - "integrity": "sha1-XdnabuOl8wIHdDYpDLcX0/SlTgI=", + "integrity": "sha512-Z5BTk6ZRe4tXXQlkqftmsAUANpXmuwlsF5Oov8ThoMbQRzdGTA1ngYRW160GexgOgjsFOKJz0LYhoNi+2AMBUw==", "dev": true, "requires": { "hoek": "4.2.1" @@ -1471,7 +1471,7 @@ "debug": { "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha1-XRKFFd8TT/Mn6QpMk/Tgd6U2NB8=", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", "dev": true, "requires": { "ms": "2.0.0" @@ -1585,7 +1585,7 @@ "doctrine": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", - "integrity": "sha1-XNAfwQFiG0LEzX9dGmYkNxbT850=", + "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", "dev": true, "requires": { "esutils": "2.0.2" @@ -1662,7 +1662,7 @@ "es6-promise": { "version": "4.2.4", "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.4.tgz", - "integrity": "sha1-3EIhwrFlGHYL2MOaUtjzVvwA7Sk=", + "integrity": "sha512-/NdNZVJg+uZgtm9eS3O6lrOLYmQag2DjdEXuPaHlZ6RuVqgqaVZfgYCepEIKsLqwdQArOPtC3XzRLqGGfT8KQQ==", "dev": true }, "escape-string-regexp": { @@ -1788,7 +1788,7 @@ "espree": { "version": "3.5.4", "resolved": "https://registry.npmjs.org/espree/-/espree-3.5.4.tgz", - "integrity": "sha1-sPRHGHyKi+2US4FaZgvd9d610ac=", + "integrity": "sha512-yAcIQxtmMiB/jL32dzEp2enBeidsB7xWPLNiw3IIkpVds1P+h7qF9YwJq1yUNzp2OKXgAprs4F61ih66UsoD1A==", "dev": true, "requires": { "acorn": "5.5.0", @@ -1798,7 +1798,7 @@ "esprima": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.0.tgz", - "integrity": "sha1-RJnt3NERDgshi6zy+n9/WfVcqAQ=", + "integrity": "sha512-oftTcaMu/EGrEIu904mWteKIv8vMuOgGYo7EhVJJN00R/EED9DCua/xxHRdYnKtcECzVg7xOWhflvJMnqcFZjw==", "dev": true }, "esquery": { @@ -1813,7 +1813,7 @@ "esrecurse": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.2.1.tgz", - "integrity": "sha1-AHo7n9vCs7uH5IeeoZyS/b05Qs8=", + "integrity": "sha512-64RBB++fIOAXPw3P9cy89qfMlvZEXZkqqJkjqqXIvzP5ezRZjW+lPWjw35UX/3EhUPFYbg5ER4JYgDw4007/DQ==", "dev": true, "requires": { "estraverse": "4.2.0" @@ -2024,7 +2024,7 @@ "find-root": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/find-root/-/find-root-1.1.0.tgz", - "integrity": "sha1-q8/Iunb3CMQql7PWhbfpRQv7nOQ=", + "integrity": "sha512-NKfW6bec6GfKc0SGx1e07QZY9PE99u0Bft/0rzSD5k3sO/vwkVUpDUKVm5Gpp5Ue3YfShPFTX2070tDs5kB9Ng==", "dev": true }, "find-up": { @@ -2103,7 +2103,7 @@ "supports-color": { "version": "5.3.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.3.0.tgz", - "integrity": "sha1-WySsFduA+pJ89SJ6SjP9PEx2dsA=", + "integrity": "sha512-0aP01LLIskjKs3lq52EC0aGBAJhLq7B2Rd8HC/DR/PtNNpcLilNmHC12O+hu0usQpo7wtHNRqtrhBwtDb0+dNg==", "dev": true, "requires": { "has-flag": "3.0.0" @@ -2567,7 +2567,7 @@ "glob": { "version": "7.1.2", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", - "integrity": "sha1-wZyd+aAocC1nhhI4SmVSQExjbRU=", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", "dev": true, "requires": { "fs.realpath": "1.0.0", @@ -2672,7 +2672,7 @@ "growl": { "version": "1.10.3", "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.3.tgz", - "integrity": "sha1-GSa6kM8+3+KttJJ/WIC8IsZseQ8=", + "integrity": "sha512-hKlsbA5Vu3xsh1Cg3J7jSmX/WaW6A5oBeqzM88oNbCRQFz+zUaXm6yxS4RVytp1scBoJzSYl4YAEOQIt6O8V1Q==", "dev": true }, "handlebars": { @@ -2738,7 +2738,7 @@ "hawk": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/hawk/-/hawk-6.0.2.tgz", - "integrity": "sha1-r02RTrBl+bXOTZ0RwcshJu7MMDg=", + "integrity": "sha512-miowhl2+U7Qle4vdLqDdPt9m09K6yZhkLDTWGoUiUzrQCn+mHHSmfJgAyGaLRZbPmTqfFFjRV1QWCW0VWUJBbQ==", "dev": true, "requires": { "boom": "4.3.1", @@ -2756,7 +2756,7 @@ "hoek": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/hoek/-/hoek-4.2.1.tgz", - "integrity": "sha1-ljRQKqEsRF3Vp8VzS1cruHOKrLs=", + "integrity": "sha512-QLg82fGkfnJ/4iy1xZ81/9SIJiq1NGFUMGs6ParyjBZr6jW2Ufj/snDqTHixNlHdPNwN2RLVD0Pi3igeK9+JfA==", "dev": true }, "home-path": { @@ -2791,7 +2791,7 @@ "ignore": { "version": "3.3.7", "resolved": "https://registry.npmjs.org/ignore/-/ignore-3.3.7.tgz", - "integrity": "sha1-YSKJv7PCIOGGpYEYYY1b6MG6sCE=", + "integrity": "sha512-YGG3ejvBNHRqu0559EOxxNFihD0AjpvHlC/pdGKd3X3ofe+CoJkYazwNJYTNebqpPKN+VVQbh4ZFn1DivMNuHA==", "dev": true }, "imurmurhash": { @@ -2828,7 +2828,7 @@ "ini": { "version": "1.3.5", "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", - "integrity": "sha1-7uJfVtscnsYIXgwid4CD9Zar+Sc=", + "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==", "dev": true }, "inquirer": { @@ -2901,7 +2901,7 @@ "is-buffer": { "version": "1.1.6", "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", - "integrity": "sha1-76ouqdqg16suoTqXsritUf776L4=", + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", "dev": true }, "is-builtin-module": { @@ -3054,7 +3054,7 @@ "is-resolvable": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/is-resolvable/-/is-resolvable-1.1.0.tgz", - "integrity": "sha1-+xj4fOH+uSUWnJpAfBkxijIG7Yg=", + "integrity": "sha512-qgDYXFSR5WvEfuS5dMj6oTMEbrrSaM0CrFk2Yiq/gXnBvD9pMa2jGXxyhGLfvhZpuMZe18CJpFxAt3CRs42NMg==", "dev": true }, "is-retry-allowed": { @@ -3204,7 +3204,7 @@ "js-yaml": { "version": "3.11.0", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.11.0.tgz", - "integrity": "sha1-WXwai9VxUvJtYizkEXhRpR9euu8=", + "integrity": "sha512-saJstZWv7oNeOyBh3+Dx1qWzhW0+e6/8eDzo7p5rDFqxntSztloLtuKu+Ejhtq82jsilwOIZYsCz+lIjthg1Hw==", "dev": true, "requires": { "argparse": "1.0.10", @@ -3324,7 +3324,7 @@ "just-extend": { "version": "1.1.27", "resolved": "https://registry.npmjs.org/just-extend/-/just-extend-1.1.27.tgz", - "integrity": "sha1-7G55QQ/5FORyZSq/oOYDwD1g6QU=", + "integrity": "sha512-mJVp13Ix6gFo3SBAy9U/kL+oeZqzlYYYLQBwXVBlVzIsZwBqGREnOro24oC/8s8aox+rJhtZ2DiQof++IrkA+g==", "dev": true }, "kind-of": { @@ -3703,7 +3703,7 @@ "lodash": { "version": "4.17.5", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.5.tgz", - "integrity": "sha1-maktZcAnLevoyWtgV7yPv6O+1RE=", + "integrity": "sha512-svL3uiZf1RwhH+cWrfZn3A4+U58wbP0tGVTLQPbjplZxZ8ROD9VLuNgsRniTlLe7OlSqR79RUehXgpBW/s0IQw==", "dev": true }, "lodash._reinterpolate": { @@ -3740,7 +3740,7 @@ "lolex": { "version": "2.3.2", "resolved": "https://registry.npmjs.org/lolex/-/lolex-2.3.2.tgz", - "integrity": "sha1-hflFBCUQO/nnpgZo6iXcQydMqAc=", + "integrity": "sha512-A5pN2tkFj7H0dGIAM6MFvHKMJcPnjZsOMvR7ujCjfgW5TbV6H9vb1PgxLtHvjqNZTHsUolz+6/WEO0N1xNx2ng==", "dev": true }, "longest": { @@ -3816,7 +3816,7 @@ "marked": { "version": "0.3.17", "resolved": "https://registry.npmjs.org/marked/-/marked-0.3.17.tgz", - "integrity": "sha1-YH8GZos8axJGso8T2nYRasGqLSs=", + "integrity": "sha512-+AKbNsjZl6jFfLPwHhWmGTqE009wTKn3RTmn9K8oUKHrX/abPJjtcRtXpYB/FFrwPJRUA86LX/de3T0knkPCmQ==", "dev": true }, "mem": { @@ -3896,13 +3896,13 @@ "mime-db": { "version": "1.33.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.33.0.tgz", - "integrity": "sha1-o0kgUKXLm2NFBUHjnZeI0icng9s=", + "integrity": "sha512-BHJ/EKruNIqJf/QahvxwQZXKygOQ256myeN/Ew+THcAa5q+PjyTTMMeNQC4DZw5AwfvelsUrA6B67NKMqXDbzQ==", "dev": true }, "mime-types": { "version": "2.1.18", "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.18.tgz", - "integrity": "sha1-bzI/YKg9ERRvgx/xH9ZuL+VQO7g=", + "integrity": "sha512-lc/aahn+t4/SWV/qcmumYjymLsWfN3ELhpmVuUFjgsORruuZPVSwAQryq+HHGvO/SI2KVX26bx+En+zhM8g8hQ==", "dev": true, "requires": { "mime-db": "1.33.0" @@ -3917,7 +3917,7 @@ "minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha1-UWbihkV/AzBgZL5Ul+jbsMPTIIM=", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "dev": true, "requires": { "brace-expansion": "1.1.11" @@ -4071,7 +4071,7 @@ "normalize-package-data": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.4.0.tgz", - "integrity": "sha1-EvlaMH1YNSB1oEkHuErIvpisAS8=", + "integrity": "sha512-9jjUFbTPfEy3R/ad/2oNbKtW9Hgovl5O1FvFWKkKblNXoN/Oou6+9+KKohPK13Yc3/TyunyWhJp6gvRNR/PPAw==", "dev": true, "requires": { "hosted-git-info": "2.5.0", @@ -4511,7 +4511,7 @@ "process-nextick-args": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", - "integrity": "sha1-o31zL0JxtKsa0HDTVQjoKQeI/6o=", + "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==", "dev": true }, "progress": { @@ -4584,7 +4584,7 @@ "qs": { "version": "6.5.1", "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.1.tgz", - "integrity": "sha1-NJzfbu+J7EXBLX1es/wMhwNDptg=", + "integrity": "sha512-eRzhrN1WSINYCDCbrz796z37LOe3m5tmW7RQf6oBntukAG1nmovJvhnwHHRMAfeoItc1m2Hk02WER2aQ/iqs+A==", "dev": true }, "quick-lru": { @@ -4596,7 +4596,7 @@ "randomatic": { "version": "1.1.7", "resolved": "https://registry.npmjs.org/randomatic/-/randomatic-1.1.7.tgz", - "integrity": "sha1-x6vpzIuHwLqodrGf3oP9RkeX44w=", + "integrity": "sha512-D5JUjPyJbaJDkuAazpVnSfVkLlpeO3wDlPROTMLGKG1zMFNFRgrciKo1ltz/AzNTkqE0HzDx655QOL51N06how==", "dev": true, "requires": { "is-number": "3.0.0", @@ -4701,7 +4701,7 @@ "regex-cache": { "version": "0.4.4", "resolved": "https://registry.npmjs.org/regex-cache/-/regex-cache-0.4.4.tgz", - "integrity": "sha1-db3FiioUls7EihKDW8VMjVYjNt0=", + "integrity": "sha512-nVIZwtCjkC9YgvWkpM55B5rBhBYRZhAaJbgcFYXXsHnbZ9UZI9nnVWYZpBlCqv9ho2eZryPnWrZGsOdPwVWXWQ==", "dev": true, "requires": { "is-equal-shallow": "0.1.3" @@ -4729,7 +4729,7 @@ "remap-istanbul": { "version": "0.10.1", "resolved": "https://registry.npmjs.org/remap-istanbul/-/remap-istanbul-0.10.1.tgz", - "integrity": "sha1-OqWN1QIdSZ8zbTulvzu7kcG4jjc=", + "integrity": "sha512-gsNQXs5kJLhErICSyYhzVZ++C8LBW8dgwr874Y2QvzAUS75zBlD/juZgXs39nbYJ09fZDlX2AVLVJAY2jbFJoQ==", "dev": true, "requires": { "amdefine": "1.0.1", @@ -4769,7 +4769,7 @@ "source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha1-dHIq8y6WFOnCh6jQu95IteLxomM=", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", "dev": true }, "through2": { @@ -4883,7 +4883,7 @@ "resolve": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.5.0.tgz", - "integrity": "sha1-HwmsznlsmnYlefMbLBzEw83fnzY=", + "integrity": "sha512-hgoSGrc3pjzAPHNBg+KnFcK2HwlHTs/YrAGUr6qgTVUZmXv1UEXXl0bZNBKMA9fud6lRYFdPGz0xXxycPzmmiw==", "dev": true, "requires": { "path-parse": "1.0.5" @@ -4924,7 +4924,7 @@ "rimraf": { "version": "2.6.2", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", - "integrity": "sha1-LtgVDSShbqhlHm1u8PR8QVjOejY=", + "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", "dev": true, "requires": { "glob": "7.1.2" @@ -5063,19 +5063,19 @@ "safe-buffer": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", - "integrity": "sha1-iTMSr2myEj3vcfV4iQAWce6yyFM=", + "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", "dev": true }, "samsam": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/samsam/-/samsam-1.3.0.tgz", - "integrity": "sha1-jR2TUOJWItow3j5EumkrUiGrfFA=", + "integrity": "sha512-1HwIYD/8UlOtFS3QO3w7ey+SdSDFE4HRNLZoZRYVQefrOY3l17epswImeB1ijgJFQJodIaHcwkp3r/myBjFVbg==", "dev": true }, "semver": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz", - "integrity": "sha1-3Eu8emyp2Rbe5dQ1FvAJK1j3uKs=", + "integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==", "dev": true }, "set-blocking": { @@ -5117,7 +5117,7 @@ "sinon-chai": { "version": "2.14.0", "resolved": "https://registry.npmjs.org/sinon-chai/-/sinon-chai-2.14.0.tgz", - "integrity": "sha1-2n3UzIPNaiYLZ8yg96n9riahIF0=", + "integrity": "sha512-9stIF1utB0ywNHNT7RgiXbdmen8QDCRsrTjw+G9TgKt1Yexjiv8TOWZ6WHsTPz57Yky3DIswZvEqX8fpuHNDtQ==", "dev": true }, "slash": { @@ -5146,7 +5146,7 @@ "sntp": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/sntp/-/sntp-2.1.0.tgz", - "integrity": "sha1-LGzsFP7cIiJznK+bXD2F0cxaLMg=", + "integrity": "sha512-FL1b58BDrqS3A11lJ0zEdnJ3UOKqVxawAkF3k7F0CVN7VQ34aZrV+G8BZ1WC9ZL7NyrwsW0oviwsWDgRuVYtJg==", "dev": true, "requires": { "hoek": "4.2.1" @@ -5203,7 +5203,7 @@ "spdx-correct": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.0.0.tgz", - "integrity": "sha1-BaW01xU6GVvJLDxCW2nzsqlSTII=", + "integrity": "sha512-N19o9z5cEyc8yQQPukRCZ9EUmb4HUpnrmaL/fxS2pBo2jbfcFRVuFZ/oFC+vZz0MNNk0h80iMn5/S6qGZOL5+g==", "dev": true, "requires": { "spdx-expression-parse": "3.0.0", @@ -5213,13 +5213,13 @@ "spdx-exceptions": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.1.0.tgz", - "integrity": "sha1-LHrmEFbHFKW5ubKyr30xHvXHj+k=", + "integrity": "sha512-4K1NsmrlCU1JJgUrtgEeTVyfx8VaYea9J9LvARxhbHtVtohPs/gFGG5yy49beySjlIMhhXZ4QqujIZEfS4l6Cg==", "dev": true }, "spdx-expression-parse": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.0.tgz", - "integrity": "sha1-meEZt6XaAOBUkcn6M4t5BII7QdA=", + "integrity": "sha512-Yg6D3XpRD4kkOmTpdgbUiEJFKghJH03fiC1OPll5h/0sO6neh2jqRDVHOQ4o/LMea0tgCkbMgea5ip/e+MkWyg==", "dev": true, "requires": { "spdx-exceptions": "2.1.0", @@ -5229,7 +5229,7 @@ "spdx-license-ids": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.0.tgz", - "integrity": "sha1-enzShHDMbToc/m1miG9rxDDTrIc=", + "integrity": "sha512-2+EPwgbnmOIl8HjGBXXMd9NAu02vLjOO1nWw4kmeRDFyHn+M/ETfHxQUK0oXg8ctgVnl9t3rosNVsZ1jG61nDA==", "dev": true }, "speedometer": { @@ -5566,7 +5566,7 @@ "tough-cookie": { "version": "2.3.4", "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.4.tgz", - "integrity": "sha1-7GDO44rGdQY//JelwYlwV47oNlU=", + "integrity": "sha512-TZ6TTfI5NtZnuyy/Kecv+CnoROnyXn2DN97LontgQpCwsX2XyLYCC0ENhYkehSOwAp8rTQKc/NUIF7BkQ5rKLA==", "dev": true, "requires": { "punycode": "1.4.1" @@ -5708,13 +5708,13 @@ "uuid": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.2.1.tgz", - "integrity": "sha1-EsUou51Y0LkmXZovbw/ovhf/HxQ=", + "integrity": "sha512-jZnMwlb9Iku/O3smGWvZhauCf6cvvpKi4BKRiliS3cxnI+Gz9j5MEpTz2UFuXiKPJocb7gnsLHwiS05ige5BEA==", "dev": true }, "validate-npm-package-license": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.3.tgz", - "integrity": "sha1-gWQ7y+8b3+zUYjeT3EZIlIupgzg=", + "integrity": "sha512-63ZOUnL4SIXj4L0NixR3L1lcjO38crAbgrTpl28t8jjrfuiOBL5Iygm+60qPs/KsZGzPNg6Smnc/oY16QTjF0g==", "dev": true, "requires": { "spdx-correct": "3.0.0", @@ -5750,7 +5750,7 @@ "which": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/which/-/which-1.3.0.tgz", - "integrity": "sha1-/wS9/AEO5UfXgL7DjhrBwnd9JTo=", + "integrity": "sha512-xcJpopdamTuY5duC/KnTTNBraPK54YwpenP4lzxU8H91GudWpFv38u0CKjclE1Wi2EH2EDz5LRcHcKbCIzqGyg==", "dev": true, "requires": { "isexe": "2.0.0" diff --git a/packages/canvas/canvas-mesh/package.json b/packages/canvas/canvas-mesh/package.json index 691cd2c..6744a17 100644 --- a/packages/canvas/canvas-mesh/package.json +++ b/packages/canvas/canvas-mesh/package.json @@ -24,6 +24,7 @@ "dependencies": { "@pixi/constants": "^5.0.0-alpha.2", "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/mesh-extras": "^5.0.0-alpha.2", "@pixi/settings": "^5.0.0-alpha.2" }, "devDependencies": { diff --git a/packages/canvas/canvas-mesh/src/Mesh.js b/packages/canvas/canvas-mesh/src/Mesh.js index 900a872..c43a74b 100644 --- a/packages/canvas/canvas-mesh/src/Mesh.js +++ b/packages/canvas/canvas-mesh/src/Mesh.js @@ -1,36 +1,14 @@ import { Mesh } from '@pixi/mesh'; -import { settings } from './settings'; - -// IMPORTANT: Please do NOT use this as a precedent to use `settings` after the object is created -// this was merely created to completely decouple canvas from the base Mesh class and we are -// unable to add `canvasPadding` in the constructor anymore, as the case was for PixiJS v4. /** - * Internal variable for `canvasPadding`. + * Renders the object using the Canvas renderer * * @private - * @memberof PIXI.Mesh - * @member {number} - * @default null - */ -Mesh.prototype._canvasPadding = null; - -/** - * Triangles in canvas mode are automatically antialiased, use this value to force triangles - * to overlap a bit with each other. To set the global default, set {@link PIXI.settings.MESH_CANVAS_PADDING} - * - * @see PIXI.settings.MESH_CANVAS_PADDING - * @member {number} canvasPadding + * @method _renderCanvas * @memberof PIXI.Mesh# - * @default 0 + * @param {PIXI.CanvasRenderer} renderer - The canvas renderer. */ -Object.defineProperty(Mesh.prototype, 'canvasPadding', { - get() - { - return this._canvasPadding !== null ? this._canvasPadding : settings.MESH_CANVAS_PADDING; - }, - set(value) - { - this._canvasPadding = value; - }, -}); +Mesh.prototype._renderCanvas = function _renderCanvas(renderer) +{ + renderer.plugins[this.pluginName].render(this); +}; diff --git a/packages/canvas/canvas-mesh/src/Mesh2d.js b/packages/canvas/canvas-mesh/src/Mesh2d.js new file mode 100644 index 0000000..d0bd80f --- /dev/null +++ b/packages/canvas/canvas-mesh/src/Mesh2d.js @@ -0,0 +1,36 @@ +import { Mesh2d } from '@pixi/mesh-extras'; +import { settings } from './settings'; + +// IMPORTANT: Please do NOT use this as a precedent to use `settings` after the object is created +// this was merely created to completely decouple canvas from the base Mesh class and we are +// unable to add `canvasPadding` in the constructor anymore, as the case was for PixiJS v4. + +/** + * Internal variable for `canvasPadding`. + * + * @private + * @memberof PIXI.Mesh2d + * @member {number} + * @default null + */ +Mesh2d.prototype._canvasPadding = null; + +/** + * Triangles in canvas mode are automatically antialiased, use this value to force triangles + * to overlap a bit with each other. To set the global default, set {@link PIXI.settings.MESH_CANVAS_PADDING} + * + * @see PIXI.settings.MESH_CANVAS_PADDING + * @member {number} canvasPadding + * @memberof PIXI.Mesh2d# + * @default 0 + */ +Object.defineProperty(Mesh2d.prototype, 'canvasPadding', { + get() + { + return this._canvasPadding !== null ? this._canvasPadding : settings.MESH_CANVAS_PADDING; + }, + set(value) + { + this._canvasPadding = value; + }, +}); diff --git a/packages/canvas/canvas-mesh/src/NineSlicePlane.js b/packages/canvas/canvas-mesh/src/NineSlicePlane.js index 09eaf9c..2fd5acc 100644 --- a/packages/canvas/canvas-mesh/src/NineSlicePlane.js +++ b/packages/canvas/canvas-mesh/src/NineSlicePlane.js @@ -1,4 +1,4 @@ -import { NineSlicePlane } from '@pixi/mesh'; +import { NineSlicePlane } from '@pixi/mesh-extras'; /** * Renders the object using the Canvas renderer diff --git a/packages/canvas/canvas-mesh/src/RawMesh.js b/packages/canvas/canvas-mesh/src/RawMesh.js deleted file mode 100644 index bf40184..0000000 --- a/packages/canvas/canvas-mesh/src/RawMesh.js +++ /dev/null @@ -1,14 +0,0 @@ -import { RawMesh } from '@pixi/mesh'; - -/** - * Renders the object using the Canvas renderer - * - * @private - * @method _renderCanvas - * @memberof PIXI.RawMesh# - * @param {PIXI.CanvasRenderer} renderer - The canvas renderer. - */ -RawMesh.prototype._renderCanvas = function _renderCanvas(renderer) -{ - renderer.plugins[this.pluginName].render(this); -}; diff --git a/packages/canvas/canvas-mesh/src/index.js b/packages/canvas/canvas-mesh/src/index.js index 2295016..f4fa31d 100644 --- a/packages/canvas/canvas-mesh/src/index.js +++ b/packages/canvas/canvas-mesh/src/index.js @@ -1,6 +1,6 @@ export { default as CanvasMeshRenderer } from './CanvasMeshRenderer'; import './settings'; -import './Mesh'; +import './Mesh2d'; import './NineSlicePlane'; -import './RawMesh'; +import './Mesh'; diff --git a/packages/canvas/canvas-mesh/src/settings.js b/packages/canvas/canvas-mesh/src/settings.js index 4cefb4c..e81b8e0 100644 --- a/packages/canvas/canvas-mesh/src/settings.js +++ b/packages/canvas/canvas-mesh/src/settings.js @@ -3,7 +3,7 @@ /** * Default `canvasPadding` for canvas-based Mesh rendering. * - * @see PIXI.Mesh#canvasPadding + * @see PIXI.Mesh2d#canvasPadding * @static * @constant * @memberof PIXI.settings diff --git a/packages/mesh-extras/LICENSE b/packages/mesh-extras/LICENSE new file mode 100644 index 0000000..148e3eb --- /dev/null +++ b/packages/mesh-extras/LICENSE @@ -0,0 +1,21 @@ +The MIT License + +Copyright (c) 2013-2018 Mathew Groves, Chad Engler + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/packages/mesh-extras/README.md b/packages/mesh-extras/README.md new file mode 100644 index 0000000..1d9b0e1 --- /dev/null +++ b/packages/mesh-extras/README.md @@ -0,0 +1,19 @@ +# @pixi/mesh-extras + +## Installation + +```bash +npm install @pixi/mesh-extras +``` + +## Usage + +```js +import { MeshRenderer } from '@pixi/mesh'; +import { Renderer } from '@pixi/core'; +import { Rope } from '@pixi/mesh-extras'; + +Renderer.registerPlugin('mesh', MeshRenderer); + +const rope = new Rope(); +``` \ No newline at end of file diff --git a/packages/mesh-extras/package.json b/packages/mesh-extras/package.json new file mode 100644 index 0000000..d134f64 --- /dev/null +++ b/packages/mesh-extras/package.json @@ -0,0 +1,38 @@ +{ + "name": "@pixi/mesh-extras", + "version": "5.0.0-alpha.2", + "main": "lib/mesh-extras.js", + "module": "lib/mesh-extras.es.js", + "description": "Custom Mesh display objects, like Rope and Plane", + "author": "Mat Groves", + "contributors": [ + "Matt Karl " + ], + "homepage": "http://pixijs.com/", + "bugs": "https://github.com/pixijs/pixi.js/issues", + "license": "MIT", + "repository": { + "type": "git", + "url": "https://github.com/pixijs/pixi.js.git" + }, + "publishConfig": { + "access": "public" + }, + "scripts": { + "test": "floss --path test" + }, + "files": [ + "lib" + ], + "dependencies": { + "@pixi/constants": "^5.0.0-alpha.2", + "@pixi/core": "^5.0.0-alpha.2", + "@pixi/math": "^5.0.0-alpha.2", + "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/utils": "^5.0.0-alpha.2" + }, + "devDependencies": { + "@pixi/loaders": "^5.0.0-alpha.2", + "floss": "^2.1.3" + } +} diff --git a/packages/mesh-extras/src/Mesh2d.js b/packages/mesh-extras/src/Mesh2d.js new file mode 100644 index 0000000..d113a5e --- /dev/null +++ b/packages/mesh-extras/src/Mesh2d.js @@ -0,0 +1,263 @@ +import { Mesh } from '@pixi/mesh'; +import { Geometry, Program, Shader, Texture, TextureMatrix } from '@pixi/core'; +import { Matrix } from '@pixi/math'; +import { BLEND_MODES } from '@pixi/constants'; +import { hex2rgb, premultiplyRgba } from '@pixi/utils'; +import vertex from './mesh.vert'; +import fragment from './mesh.frag'; + +let meshProgram; + +/** + * Base mesh class + * @class + * @extends PIXI.Container + * @memberof PIXI + */ +export default class Mesh2d extends Mesh +{ + /** + * @param {PIXI.Texture} [texture=Texture.EMPTY] - The texture to use + * @param {Float32Array} [vertices] - if you want to specify the vertices + * @param {Float32Array} [uvs] - if you want to specify the uvs + * @param {Uint16Array} [indices] - if you want to specify the indices + * @param {number} [drawMode] - the drawMode, can be any of the Mesh.DRAW_MODES consts + */ + constructor(texture = Texture.EMPTY, vertices, uvs, indices, drawMode) + { + const geometry = new Geometry(); + + if (!meshProgram) + { + meshProgram = new Program(vertex, fragment); + } + + geometry.addAttribute('aVertexPosition', vertices) + .addAttribute('aTextureCoord', uvs) + .addIndex(indices); + + geometry.getAttribute('aVertexPosition').static = false; + + const uniforms = { + uSampler: texture, + uTextureMatrix: Matrix.IDENTITY, + alpha: 1, + uColor: new Float32Array([1, 1, 1, 1]), + }; + + super(geometry, new Shader(meshProgram, uniforms), null, drawMode); + + /** + * The Uvs of the Mesh + * + * @member {Float32Array} + */ + this.uvs = geometry.getAttribute('aTextureCoord').data; + + /** + * An array of vertices + * + * @member {Float32Array} + */ + this.vertices = geometry.getAttribute('aVertexPosition').data; + + this.uniforms = uniforms; + + /** + * The texture of the Mesh + * + * @member {PIXI.Texture} + * @default PIXI.Texture.EMPTY + * @private + */ + this.texture = texture; + + /** + * The tint applied to the mesh. This is a [r,g,b] value. A value of [1,1,1] will remove any + * tint effect. + * + * @member {number} + * @private + */ + this._tintRGB = new Float32Array([1, 1, 1]); + + // Set default tint + this.tint = 0xFFFFFF; + + this.blendMode = BLEND_MODES.NORMAL; + + /** + * TextureMatrix instance for this Mesh, used to track Texture changes + * + * @member {PIXI.TextureMatrix} + * @readonly + */ + this.uvMatrix = new TextureMatrix(this._texture); + + /** + * whether or not upload uvMatrix to shader + * if its false, then uvs should be pre-multiplied + * if you change it for generated mesh, please call 'refresh(true)' + * @member {boolean} + * @default false + */ + this.uploadUvMatrix = false; + + /** + * Uploads vertices buffer every frame, like in PixiJS V3 and V4. + * + * @member {boolean} + * @default true + */ + this.autoUpdate = true; + } + + /** + * The tint applied to the Rope. This is a hex value. A value of + * 0xFFFFFF will remove any tint effect. + * + * @member {number} + * @memberof PIXI.Sprite# + * @default 0xFFFFFF + */ + get tint() + { + return this._tint; + } + + /** + * Sets the tint of the rope. + * + * @param {number} value - The value to set to. + */ + set tint(value) + { + this._tint = value; + + hex2rgb(this._tint, this._tintRGB); + } + + /** + * The blend mode to be applied to the sprite. Set to `PIXI.BLEND_MODES.NORMAL` to remove any blend mode. + * + * @member {number} + * @default PIXI.BLEND_MODES.NORMAL + * @see PIXI.BLEND_MODES + */ + get blendMode() + { + return this.state.blendMode; + } + + set blendMode(value) // eslint-disable-line require-jsdoc + { + this.state.blendMode = value; + } + + /** + * The texture that the mesh uses. + * + * @member {PIXI.Texture} + */ + get texture() + { + return this._texture; + } + + set texture(value) // eslint-disable-line require-jsdoc + { + if (this._texture === value) + { + return; + } + + this._texture = value; + this.uniforms.uSampler = this.texture; + + if (value) + { + // wait for the texture to load + if (value.baseTexture.valid) + { + this._onTextureUpdate(); + } + else + { + value.once('update', this._onTextureUpdate, this); + } + } + } + + _render(renderer) + { + const baseTex = this._texture.baseTexture; + + premultiplyRgba(this._tintRGB, this.worldAlpha, this.uniforms.uColor, baseTex.premultiplyAlpha); + super._render(renderer); + } + /** + * When the texture is updated, this event will fire to update the scale and frame + * + * @private + */ + _onTextureUpdate() + { + // constructor texture update stop + if (!this.uvMatrix) + { + return; + } + this.uvMatrix.texture = this._texture; + this.refresh(); + } + + /** + * multiplies uvs only if uploadUvMatrix is false + * call it after you change uvs manually + * make sure that texture is valid + */ + multiplyUvs() + { + if (!this.uploadUvMatrix) + { + this.uvMatrix.multiplyUvs(this.uvs); + } + } + + /** + * Refreshes uvs for generated meshes (rope, plane) + * sometimes refreshes vertices too + * + * @param {boolean} [forceUpdate=false] if true, matrices will be updated any case + */ + refresh(forceUpdate) + { + if (this.uvMatrix.update(forceUpdate)) + { + this._refresh(); + } + } + + /** + * Updates the object transform for rendering + * + * @private + */ + updateTransform() + { + if (this.autoUpdate) + { + this.geometry.buffers[0].update(); + } + this.containerUpdateTransform(); + } + + /** + * re-calculates mesh coords + * @private + */ + _refresh() + { + /* empty */ + } +} diff --git a/packages/mesh-extras/src/NineSlicePlane.js b/packages/mesh-extras/src/NineSlicePlane.js new file mode 100644 index 0000000..0bae92c --- /dev/null +++ b/packages/mesh-extras/src/NineSlicePlane.js @@ -0,0 +1,270 @@ +import Plane from './Plane'; + +const DEFAULT_BORDER_SIZE = 10; + +/** + * The NineSlicePlane allows you to stretch a texture using 9-slice scaling. The corners will remain unscaled (useful + * for buttons with rounded corners for example) and the other areas will be scaled horizontally and or vertically + * + *```js + * let Plane9 = new PIXI.NineSlicePlane(PIXI.Texture.from('BoxWithRoundedCorners.png'), 15, 15, 15, 15); + * ``` + *
+ *      A                          B
+ *    +---+----------------------+---+
+ *  C | 1 |          2           | 3 |
+ *    +---+----------------------+---+
+ *    |   |                      |   |
+ *    | 4 |          5           | 6 |
+ *    |   |                      |   |
+ *    +---+----------------------+---+
+ *  D | 7 |          8           | 9 |
+ *    +---+----------------------+---+
+
+ *  When changing this objects width and/or height:
+ *     areas 1 3 7 and 9 will remain unscaled.
+ *     areas 2 and 8 will be stretched horizontally
+ *     areas 4 and 6 will be stretched vertically
+ *     area 5 will be stretched both horizontally and vertically
+ * 
+ * + * @class + * @extends PIXI.Plane + * @memberof PIXI + * + */ +export default class NineSlicePlane extends Plane +{ + /** + * @param {PIXI.Texture} texture - The texture to use on the NineSlicePlane. + * @param {int} [leftWidth=10] size of the left vertical bar (A) + * @param {int} [topHeight=10] size of the top horizontal bar (C) + * @param {int} [rightWidth=10] size of the right vertical bar (B) + * @param {int} [bottomHeight=10] size of the bottom horizontal bar (D) + */ + constructor(texture, leftWidth, topHeight, rightWidth, bottomHeight) + { + super(texture, 4, 4); + + this._origWidth = texture.orig.width; + this._origHeight = texture.orig.height; + + /** + * The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._width = this._origWidth; + + /** + * The height of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._height = this._origHeight; + + /** + * The width of the left column (a) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._leftWidth = typeof leftWidth !== 'undefined' ? leftWidth : DEFAULT_BORDER_SIZE; + + /** + * The width of the right column (b) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._rightWidth = typeof rightWidth !== 'undefined' ? rightWidth : DEFAULT_BORDER_SIZE; + + /** + * The height of the top row (c) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._topHeight = typeof topHeight !== 'undefined' ? topHeight : DEFAULT_BORDER_SIZE; + + /** + * The height of the bottom row (d) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._bottomHeight = typeof bottomHeight !== 'undefined' ? bottomHeight : DEFAULT_BORDER_SIZE; + + this.refresh(true); + } + + /** + * Updates the horizontal vertices. + * + */ + updateHorizontalVertices() + { + const vertices = this.vertices; + + const h = this._topHeight + this._bottomHeight; + const scale = this._height > h ? 1.0 : this._height / h; + + vertices[9] = vertices[11] = vertices[13] = vertices[15] = this._topHeight * scale; + vertices[17] = vertices[19] = vertices[21] = vertices[23] = this._height - (this._bottomHeight * scale); + vertices[25] = vertices[27] = vertices[29] = vertices[31] = this._height; + } + + /** + * Updates the vertical vertices. + * + */ + updateVerticalVertices() + { + const vertices = this.vertices; + + const w = this._leftWidth + this._rightWidth; + const scale = this._width > w ? 1.0 : this._width / w; + + vertices[2] = vertices[10] = vertices[18] = vertices[26] = this._leftWidth * scale; + vertices[4] = vertices[12] = vertices[20] = vertices[28] = this._width - (this._rightWidth * scale); + vertices[6] = vertices[14] = vertices[22] = vertices[30] = this._width; + } + + /** + * The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + */ + get width() + { + return this._width; + } + + set width(value) // eslint-disable-line require-jsdoc + { + this._width = value; + this._refresh(); + } + + /** + * The height of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + */ + get height() + { + return this._height; + } + + set height(value) // eslint-disable-line require-jsdoc + { + this._height = value; + this._refresh(); + } + + /** + * The width of the left column + * + * @member {number} + */ + get leftWidth() + { + return this._leftWidth; + } + + set leftWidth(value) // eslint-disable-line require-jsdoc + { + this._leftWidth = value; + this._refresh(); + } + + /** + * The width of the right column + * + * @member {number} + */ + get rightWidth() + { + return this._rightWidth; + } + + set rightWidth(value) // eslint-disable-line require-jsdoc + { + this._rightWidth = value; + this._refresh(); + } + + /** + * The height of the top row + * + * @member {number} + */ + get topHeight() + { + return this._topHeight; + } + + set topHeight(value) // eslint-disable-line require-jsdoc + { + this._topHeight = value; + this._refresh(); + } + + /** + * The height of the bottom row + * + * @member {number} + */ + get bottomHeight() + { + return this._bottomHeight; + } + + set bottomHeight(value) // eslint-disable-line require-jsdoc + { + this._bottomHeight = value; + this._refresh(); + } + + /** + * Refreshes NineSlicePlane coords. All of them. + */ + _refresh() + { + super._refresh(); + + const uvs = this.uvs; + const texture = this._texture; + + this._origWidth = texture.orig.width; + this._origHeight = texture.orig.height; + + const _uvw = 1.0 / this._origWidth; + const _uvh = 1.0 / this._origHeight; + + uvs[0] = uvs[8] = uvs[16] = uvs[24] = 0; + uvs[1] = uvs[3] = uvs[5] = uvs[7] = 0; + uvs[6] = uvs[14] = uvs[22] = uvs[30] = 1; + uvs[25] = uvs[27] = uvs[29] = uvs[31] = 1; + + uvs[2] = uvs[10] = uvs[18] = uvs[26] = _uvw * this._leftWidth; + uvs[4] = uvs[12] = uvs[20] = uvs[28] = 1 - (_uvw * this._rightWidth); + uvs[9] = uvs[11] = uvs[13] = uvs[15] = _uvh * this._topHeight; + uvs[17] = uvs[19] = uvs[21] = uvs[23] = 1 - (_uvh * this._bottomHeight); + + this.updateHorizontalVertices(); + this.updateVerticalVertices(); + + this.geometry.buffers[1].update(); + + this.multiplyUvs(); + } +} diff --git a/packages/mesh-extras/src/Plane.js b/packages/mesh-extras/src/Plane.js new file mode 100644 index 0000000..1c240c4 --- /dev/null +++ b/packages/mesh-extras/src/Plane.js @@ -0,0 +1,100 @@ +import Mesh2d from './Mesh2d'; + +/** + * The Plane allows you to draw a texture across several points and them manipulate these points + * + *```js + * for (let i = 0; i < 20; i++) { + * points.push(new PIXI.Point(i * 50, 0)); + * }; + * let Plane = new PIXI.Plane(PIXI.Texture.from("snake.png"), points); + * ``` + * + * @class + * @extends PIXI.Mesh + * @memberof PIXI + * + */ +export default class Plane extends Mesh2d +{ + /** + * @param {PIXI.Texture} texture - The texture to use on the Plane. + * @param {number} verticesX - The number of vertices in the x-axis + * @param {number} verticesY - The number of vertices in the y-axis + * @param {object} [opts] - an options object - add meshWidth and meshHeight, temporary object for PixiJS v5 alpha + */ + constructor(texture, verticesX, verticesY, opts = {}) + { + super(texture, new Float32Array(1), new Float32Array(1), new Uint16Array(1), 4); + + this.verticesX = verticesX || 10; + this.verticesY = verticesY || 10; + + this.meshWidth = opts.meshWidth || 0; + this.meshHeight = opts.meshHeight || 0; + + this.refresh(); + } + + /** + * Refreshes plane coordinates + * @private + */ + _refresh() + { + const texture = this._texture; + const total = this.verticesX * this.verticesY; + const verts = []; + const uvs = []; + const indices = []; + + const segmentsX = this.verticesX - 1; + const segmentsY = this.verticesY - 1; + + const sizeX = (this.meshWidth || texture.width) / segmentsX; + const sizeY = (this.meshHeight || texture.height) / segmentsY; + + for (let i = 0; i < total; i++) + { + const x = (i % this.verticesX); + const y = ((i / this.verticesX) | 0); + + verts.push(x * sizeX, y * sizeY); + + uvs.push(x / segmentsX, y / segmentsY); + } + + // cons + + const totalSub = segmentsX * segmentsY; + + for (let i = 0; i < totalSub; i++) + { + const xpos = i % segmentsX; + const ypos = (i / segmentsX) | 0; + + const value = (ypos * this.verticesX) + xpos; + const value2 = (ypos * this.verticesX) + xpos + 1; + const value3 = ((ypos + 1) * this.verticesX) + xpos; + const value4 = ((ypos + 1) * this.verticesX) + xpos + 1; + + indices.push(value, value2, value3); + indices.push(value2, value4, value3); + } + + this.vertices = new Float32Array(verts); + this.uvs = new Float32Array(uvs); + this.indices = new Uint16Array(indices); + + this.geometry.buffers[0].data = this.vertices; + this.geometry.buffers[1].data = this.uvs; + this.geometry.indexBuffer.data = this.indices; + + // ensure that the changes are uploaded + this.geometry.buffers[0].update(); + this.geometry.buffers[1].update(); + this.geometry.indexBuffer.update(); + + this.multiplyUvs(); + } +} diff --git a/packages/mesh-extras/src/Rope.js b/packages/mesh-extras/src/Rope.js new file mode 100644 index 0000000..9cfde38 --- /dev/null +++ b/packages/mesh-extras/src/Rope.js @@ -0,0 +1,182 @@ +import Mesh2d from './Mesh2d'; + +/** + * The rope allows you to draw a texture across several points and them manipulate these points + * + *```js + * for (let i = 0; i < 20; i++) { + * points.push(new PIXI.Point(i * 50, 0)); + * }; + * let rope = new PIXI.Rope(PIXI.Texture.from("snake.png"), points); + * ``` + * + * @class + * @extends PIXI.Mesh + * @memberof PIXI + * + */ +export default class Rope extends Mesh2d +{ + /** + * @param {PIXI.Texture} texture - The texture to use on the rope. + * @param {PIXI.Point[]} points - An array of {@link PIXI.Point} objects to construct this rope. + */ + constructor(texture, points) + { + super(texture, new Float32Array(points.length * 4), + new Float32Array(points.length * 4), + new Uint16Array(points.length * 2), + 5); + + /* + * @member {PIXI.Point[]} An array of points that determine the rope + */ + this.points = points; + this.refresh(); + } + /** + * Refreshes Rope indices and uvs + * @private + */ + _refresh() + { + const points = this.points; + + if (!points) return; + + const vertexBuffer = this.geometry.getAttribute('aVertexPosition'); + const uvBuffer = this.geometry.getAttribute('aTextureCoord'); + const indexBuffer = this.geometry.getIndex(); + + // if too little points, or texture hasn't got UVs set yet just move on. + if (points.length < 1 || !this.texture._uvs) + { + return; + } + + // if the number of points has changed we will need to recreate the arraybuffers + if (vertexBuffer.data.length / 4 !== points.length) + { + vertexBuffer.data = new Float32Array(points.length * 4); + uvBuffer.data = new Float32Array(points.length * 4); + indexBuffer.data = new Uint16Array(points.length * 2); + } + + const uvs = uvBuffer.data; + const indices = indexBuffer.data; + + uvs[0] = 0; + uvs[1] = 0; + uvs[2] = 0; + uvs[3] = 1; + + indices[0] = 0; + indices[1] = 1; + + const total = points.length; + + for (let i = 1; i < total; i++) + { + // time to do some smart drawing! + let index = i * 4; + const amount = i / (total - 1); + + uvs[index] = amount; + uvs[index + 1] = 0; + + uvs[index + 2] = amount; + uvs[index + 3] = 1; + + index = i * 2; + indices[index] = index; + indices[index + 1] = index + 1; + } + + // ensure that the changes are uploaded + uvBuffer.update(); + indexBuffer.update(); + + this.multiplyUvs(); + this.refreshVertices(); + } + + /** + * refreshes vertices of Rope mesh + */ + refreshVertices() + { + const points = this.points; + + if (points.length < 1) + { + return; + } + + let lastPoint = points[0]; + let nextPoint; + let perpX = 0; + let perpY = 0; + + // this.count -= 0.2; + + const vertices = this.vertices; + const total = points.length; + + for (let i = 0; i < total; i++) + { + const point = points[i]; + const index = i * 4; + + if (i < points.length - 1) + { + nextPoint = points[i + 1]; + } + else + { + nextPoint = point; + } + + perpY = -(nextPoint.x - lastPoint.x); + perpX = nextPoint.y - lastPoint.y; + + let ratio = (1 - (i / (total - 1))) * 10; + + if (ratio > 1) + { + ratio = 1; + } + + const perpLength = Math.sqrt((perpX * perpX) + (perpY * perpY)); + const num = this._texture.height / 2; // (20 + Math.abs(Math.sin((i + this.count) * 0.3) * 50) )* ratio; + + perpX /= perpLength; + perpY /= perpLength; + + perpX *= num; + perpY *= num; + + vertices[index] = point.x + perpX; + vertices[index + 1] = point.y + perpY; + vertices[index + 2] = point.x - perpX; + vertices[index + 3] = point.y - perpY; + + lastPoint = point; + } + + this.geometry.buffers[0].update(); + } + + /** + * Updates the object transform for rendering + * + * @private + */ + updateTransform() + { + if (this.autoUpdate) + { + this.refreshVertices(); + } + this.containerUpdateTransform(); + } +} diff --git a/packages/mesh-extras/src/index.js b/packages/mesh-extras/src/index.js new file mode 100644 index 0000000..decf454 --- /dev/null +++ b/packages/mesh-extras/src/index.js @@ -0,0 +1,4 @@ +export { default as Mesh2d } from './Mesh2d'; +export { default as Plane } from './Plane'; +export { default as NineSlicePlane } from './NineSlicePlane'; +export { default as Rope } from './Rope'; diff --git a/packages/mesh-extras/src/mesh.frag b/packages/mesh-extras/src/mesh.frag new file mode 100644 index 0000000..6096983 --- /dev/null +++ b/packages/mesh-extras/src/mesh.frag @@ -0,0 +1,9 @@ +varying vec2 vTextureCoord; +uniform vec4 uColor; + +uniform sampler2D uSampler; + +void main(void) +{ + gl_FragColor = texture2D(uSampler, vTextureCoord) * uColor; +} diff --git a/packages/mesh-extras/src/mesh.vert b/packages/mesh-extras/src/mesh.vert new file mode 100644 index 0000000..0526df9 --- /dev/null +++ b/packages/mesh-extras/src/mesh.vert @@ -0,0 +1,15 @@ +attribute vec2 aVertexPosition; +attribute vec2 aTextureCoord; + +uniform mat3 projectionMatrix; +uniform mat3 translationMatrix; +uniform mat3 uTextureMatrix; + +varying vec2 vTextureCoord; + +void main(void) +{ + gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); + + vTextureCoord = (uTextureMatrix * vec3(aTextureCoord, 1.0)).xy; +} diff --git a/packages/mesh-extras/test/.eslintrc.json b/packages/mesh-extras/test/.eslintrc.json new file mode 100644 index 0000000..2ad8efb --- /dev/null +++ b/packages/mesh-extras/test/.eslintrc.json @@ -0,0 +1,12 @@ +{ + "globals": { + "expect": false, + "assert": false, + "sinon": false, + "PIXI": false + }, + "rules": { + "func-names": 0, + "no-unused-expressions": 0 + } +} \ No newline at end of file diff --git a/packages/mesh-extras/test/Plane.js b/packages/mesh-extras/test/Plane.js new file mode 100644 index 0000000..f9b1c25 --- /dev/null +++ b/packages/mesh-extras/test/Plane.js @@ -0,0 +1,60 @@ +const { Plane } = require('../'); +const { isWebGLSupported, skipHello } = require('@pixi/utils'); +const { Loader } = require('@pixi/loaders'); +const { Point } = require('@pixi/math'); +const { RenderTexture, Texture } = require('@pixi/core'); + +skipHello(); + +function withGL(fn) +{ + return isWebGLSupported() ? fn : undefined; +} + +// TODO: fix with webglrenderer +describe('PIXI.mesh.Plane', function () +{ + it.skip('should create a plane from an external image', withGL(function (done) + { + const loader = new Loader(); + + loader.add('testBitmap', `file://${__dirname}/resources/bitmap-1.png`) + .load(function (loader, resources) + { + const plane = new Plane(resources.testBitmap.texture, 100, 100); + + expect(plane.verticesX).to.equal(100); + expect(plane.verticesY).to.equal(100); + done(); + }); + })); + + it.skip('should create a new empty textured Plane', withGL(function () + { + const plane = new Plane(Texture.EMPTY, 100, 100); + + expect(plane.verticesX).to.equal(100); + expect(plane.verticesY).to.equal(100); + })); + + describe('containsPoint', function () + { + it.skip('should return true when point inside', withGL(function () + { + const point = new Point(10, 10); + const texture = new RenderTexture.create(20, 30); + const plane = new Plane(texture, 100, 100); + + expect(plane.containsPoint(point)).to.be.true; + })); + + it.skip('should return false when point outside', withGL(function () + { + const point = new Point(100, 100); + const texture = new RenderTexture.create(20, 30); + const plane = new Plane(texture, 100, 100); + + expect(plane.containsPoint(point)).to.be.false; + })); + }); +}); diff --git a/packages/mesh-extras/test/index.js b/packages/mesh-extras/test/index.js new file mode 100644 index 0000000..d767624 --- /dev/null +++ b/packages/mesh-extras/test/index.js @@ -0,0 +1 @@ +require('./Plane'); diff --git a/packages/mesh-extras/test/resources/bitmap-1.png b/packages/mesh-extras/test/resources/bitmap-1.png new file mode 100644 index 0000000..1284fb8 --- /dev/null +++ b/packages/mesh-extras/test/resources/bitmap-1.png Binary files differ diff --git a/packages/mesh/package.json b/packages/mesh/package.json index 8b1f8d9..10bd8e3 100644 --- a/packages/mesh/package.json +++ b/packages/mesh/package.json @@ -18,22 +18,16 @@ "publishConfig": { "access": "public" }, - "scripts": { - "test": "floss --path test" - }, "files": [ "lib" ], "dependencies": { - "@pixi/canvas-renderer": "^5.0.0-alpha.2", "@pixi/constants": "^5.0.0-alpha.2", "@pixi/core": "^5.0.0-alpha.2", "@pixi/display": "^5.0.0-alpha.2", - "@pixi/math": "^5.0.0-alpha.2", - "@pixi/utils": "^5.0.0-alpha.2" + "@pixi/math": "^5.0.0-alpha.2" }, "devDependencies": { - "@pixi/loaders": "^5.0.0-alpha.2", "floss": "^2.1.3" } } diff --git a/packages/mesh/src/Mesh.js b/packages/mesh/src/Mesh.js index e7c8f9e..1f35b7a 100644 --- a/packages/mesh/src/Mesh.js +++ b/packages/mesh/src/Mesh.js @@ -1,263 +1,220 @@ -import RawMesh from './RawMesh'; -import { Geometry, Program, Shader, Texture, TextureMatrix } from '@pixi/core'; -import { Matrix } from '@pixi/math'; -import { BLEND_MODES } from '@pixi/constants'; -import { hex2rgb, premultiplyRgba } from '@pixi/utils'; -import vertex from './mesh.vert'; -import fragment from './mesh.frag'; +import { State } from '@pixi/core'; +import { DRAW_MODES } from '@pixi/constants'; +import { Point, Polygon } from '@pixi/math'; +import { Container } from '@pixi/display'; -let meshProgram; +const tempPoint = new Point(); +const tempPolygon = new Polygon(); /** - * Base mesh class + * Base mesh class. + * The reason for this class is to empower you to have maximum flexibility to render any kind of webGL you can think of. + * This class assumes a certain level of webGL knowledge. + * If you know a bit this should abstract enough away to make you life easier! + * Pretty much ALL WebGL can be broken down into the following: + * Geometry - The structure and data for the mesh. This can include anything from positions, uvs, normals, colors etc.. + * Shader - This is the shader that pixi will render the geometry with. (attributes in the shader must match the geometry!) + * Uniforms - These are the values passed to the shader when the mesh is rendered. + * As a shader can be reused across multiple objects, it made sense to allow uniforms to exist outside of the shader + * State - This is the state of WebGL required to render the mesh. + * Through a combination of the above elements you can render anything you want, 2D or 3D! + * * @class * @extends PIXI.Container * @memberof PIXI */ -export default class Mesh extends RawMesh +export default class Mesh extends Container { /** - * @param {PIXI.Texture} [texture=Texture.EMPTY] - The texture to use - * @param {Float32Array} [vertices] - if you want to specify the vertices - * @param {Float32Array} [uvs] - if you want to specify the uvs - * @param {Uint16Array} [indices] - if you want to specify the indices - * @param {number} [drawMode] - the drawMode, can be any of the Mesh.DRAW_MODES consts + * @param {PIXI.Geometry} geometry the geometry the mesh will use + * @param {PIXI.Shader} shader the shader the mesh will use + * @param {PIXI.State} state the state that the webGL context is required to be in to render the mesh + * @param {number} drawMode the drawMode, can be any of the PIXI.DRAW_MODES consts */ - constructor(texture = Texture.EMPTY, vertices, uvs, indices, drawMode) + constructor(geometry, shader, state, drawMode = DRAW_MODES.TRIANGLES) { - const geometry = new Geometry(); - - if (!meshProgram) - { - meshProgram = new Program(vertex, fragment); - } - - geometry.addAttribute('aVertexPosition', vertices) - .addAttribute('aTextureCoord', uvs) - .addIndex(indices); - - geometry.getAttribute('aVertexPosition').static = false; - - const uniforms = { - uSampler: texture, - uTextureMatrix: Matrix.IDENTITY, - alpha: 1, - uColor: new Float32Array([1, 1, 1, 1]), - }; - - super(geometry, new Shader(meshProgram, uniforms), null, drawMode); + super(); /** - * The Uvs of the Mesh - * - * @member {Float32Array} + * the geometry the mesh will use + * @type {PIXI.Geometry} */ - this.uvs = geometry.getAttribute('aTextureCoord').data; + this.geometry = geometry; /** - * An array of vertices - * - * @member {Float32Array} + * the shader the mesh will use + * @type {PIXI.Shader} */ - this.vertices = geometry.getAttribute('aVertexPosition').data; - - this.uniforms = uniforms; + this.shader = shader; /** - * The texture of the Mesh - * - * @member {PIXI.Texture} - * @default PIXI.Texture.EMPTY - * @private + * the webGL state the mesh requires to render + * @type {PIXI.State} */ - this.texture = texture; + this.state = state || new State(); /** - * The tint applied to the mesh. This is a [r,g,b] value. A value of [1,1,1] will remove any - * tint effect. + * The way the Mesh should be drawn, can be any of the {@link PIXI.Mesh.DRAW_MODES} consts * * @member {number} + * @see PIXI.Mesh.DRAW_MODES + */ + this.drawMode = drawMode; + + /** + * The way uniforms that will be used by the mesh's shader. + * @member {Object} + */ + + /** + * A map of renderer IDs to webgl render data + * * @private + * @member {object} */ - this._tintRGB = new Float32Array([1, 1, 1]); - - // Set default tint - this.tint = 0xFFFFFF; - - this.blendMode = BLEND_MODES.NORMAL; + this._glDatas = {}; /** - * TextureMatrix instance for this Mesh, used to track Texture changes + * Plugin that is responsible for rendering this element. + * Allows to customize the rendering process without overriding '_render' & '_renderCanvas' methods. * - * @member {PIXI.TextureMatrix} - * @readonly + * @member {string} + * @default 'mesh' */ - this.uvMatrix = new TextureMatrix(this._texture); + this.pluginName = 'mesh'; - /** - * whether or not upload uvMatrix to shader - * if its false, then uvs should be pre-multiplied - * if you change it for generated mesh, please call 'refresh(true)' - * @member {boolean} - * @default false - */ - this.uploadUvMatrix = false; - - /** - * Uploads vertices buffer every frame, like in PixiJS V3 and V4. - * - * @member {boolean} - * @default true - */ - this.autoUpdate = true; + this.start = 0; + this.size = 0; } /** - * The tint applied to the Rope. This is a hex value. A value of - * 0xFFFFFF will remove any tint effect. + * Renders the object using the WebGL renderer * - * @member {number} - * @memberof PIXI.Sprite# - * @default 0xFFFFFF + * @param {PIXI.Renderer} renderer a reference to the WebGL renderer + * @private */ - get tint() + _render(renderer) { - return this._tint; + renderer.batch.setObjectRenderer(renderer.plugins[this.pluginName]); + renderer.plugins[this.pluginName].render(this); } /** - * Sets the tint of the rope. + * Updates the bounds of the mesh as a rectangle. The bounds calculation takes the worldTransform into account. + * there must be a aVertexPosition attribute present in the geometry for bounds to be calculated correctly. * - * @param {number} value - The value to set to. + * @private */ - set tint(value) + _calculateBounds() { - this._tint = value; - - hex2rgb(this._tint, this._tintRGB); - } - - /** - * The blend mode to be applied to the sprite. Set to `PIXI.BLEND_MODES.NORMAL` to remove any blend mode. - * - * @member {number} - * @default PIXI.BLEND_MODES.NORMAL - * @see PIXI.BLEND_MODES - */ - get blendMode() - { - return this.state.blendMode; - } - - set blendMode(value) // eslint-disable-line require-jsdoc - { - this.state.blendMode = value; - } - - /** - * The texture that the mesh uses. - * - * @member {PIXI.Texture} - */ - get texture() - { - return this._texture; - } - - set texture(value) // eslint-disable-line require-jsdoc - { - if (this._texture === value) + // The position property could be set manually? + if (this.geometry.attributes.aVertexPosition) { - return; + const vertices = this.geometry.getAttribute('aVertexPosition').data; + + // TODO - we can cache local bounds and use them if they are dirty (like graphics) + this._bounds.addVertices(this.transform, vertices, 0, vertices.length); + } + } + + /** + * Tests if a point is inside this mesh. Works only for TRIANGLE_MESH + * + * @param {PIXI.Point} point the point to test + * @return {boolean} the result of the test + */ + containsPoint(point) + { + if (!this.getBounds().contains(point.x, point.y)) + { + return false; } - this._texture = value; - this.uniforms.uSampler = this.texture; + this.worldTransform.applyInverse(point, tempPoint); - if (value) + const vertices = this.geometry.getAttribute('aVertexPosition').data; + + const points = tempPolygon.points; + const indices = this.geometry.getIndex().data; + const len = indices.length; + const step = this.drawMode === 4 ? 3 : 1; + + for (let i = 0; i + 2 < len; i += step) { - // wait for the texture to load - if (value.baseTexture.valid) + const ind0 = indices[i] * 2; + const ind1 = indices[i + 1] * 2; + const ind2 = indices[i + 2] * 2; + + points[0] = vertices[ind0]; + points[1] = vertices[ind0 + 1]; + points[2] = vertices[ind1]; + points[3] = vertices[ind1 + 1]; + points[4] = vertices[ind2]; + points[5] = vertices[ind2 + 1]; + + if (tempPolygon.contains(tempPoint.x, tempPoint.y)) { - this._onTextureUpdate(); + return true; + } + } + + return false; + } + + /** + * Destroys the Mesh object. + * + * @param {object|boolean} [options] - Options parameter. A boolean will act as if all + * options have been set to that value + * @param {boolean} [options.children=false] - if set to true, all the children will have + * their destroy method called as well. 'options' will be passed on to those calls. + * @param {boolean} [options.texture=false] - Only used for child Sprites if options.children is set to true + * Should it destroy the texture of the child sprite + * @param {boolean} [options.baseTexture=false] - Only used for child Sprites if options.children is set to true + * Should it destroy the base texture of the child sprite + */ + destroy(options) + { + // for each webgl data entry, destroy the WebGLGraphicsData + for (const id in this._glDatas) + { + const data = this._glDatas[id]; + + if (data.destroy) + { + data.destroy(); } else { - value.once('update', this._onTextureUpdate, this); + if (data.vertexBuffer) + { + data.vertexBuffer.destroy(); + data.vertexBuffer = null; + } + if (data.indexBuffer) + { + data.indexBuffer.destroy(); + data.indexBuffer = null; + } + if (data.uvBuffer) + { + data.uvBuffer.destroy(); + data.uvBuffer = null; + } + if (data.vao) + { + data.vao.destroy(); + data.vao = null; + } } } - } - _render(renderer) - { - const baseTex = this._texture.baseTexture; + this._glDatas = null; - premultiplyRgba(this._tintRGB, this.worldAlpha, this.uniforms.uColor, baseTex.premultiplyAlpha); - super._render(renderer); - } - /** - * When the texture is updated, this event will fire to update the scale and frame - * - * @private - */ - _onTextureUpdate() - { - // constructor texture update stop - if (!this.uvMatrix) - { - return; - } - this.uvMatrix.texture = this._texture; - this.refresh(); - } + this.geometry = null; + this.shader = null; + this.state = null; - /** - * multiplies uvs only if uploadUvMatrix is false - * call it after you change uvs manually - * make sure that texture is valid - */ - multiplyUvs() - { - if (!this.uploadUvMatrix) - { - this.uvMatrix.multiplyUvs(this.uvs); - } - } - - /** - * Refreshes uvs for generated meshes (rope, plane) - * sometimes refreshes vertices too - * - * @param {boolean} [forceUpdate=false] if true, matrices will be updated any case - */ - refresh(forceUpdate) - { - if (this.uvMatrix.update(forceUpdate)) - { - this._refresh(); - } - } - - /** - * Updates the object transform for rendering - * - * @private - */ - updateTransform() - { - if (this.autoUpdate) - { - this.geometry.buffers[0].update(); - } - this.containerUpdateTransform(); - } - - /** - * re-calculates mesh coords - * @private - */ - _refresh() - { - /* empty */ + super.destroy(options); } } diff --git a/packages/mesh/src/MeshRenderer.js b/packages/mesh/src/MeshRenderer.js index 12b159b..d7baf9b 100644 --- a/packages/mesh/src/MeshRenderer.js +++ b/packages/mesh/src/MeshRenderer.js @@ -36,7 +36,7 @@ /** * renders mesh * @private - * @param {PIXI.RawMesh} mesh mesh instance + * @param {PIXI.Mesh} mesh mesh instance */ render(mesh) { diff --git a/packages/mesh/src/NineSlicePlane.js b/packages/mesh/src/NineSlicePlane.js deleted file mode 100644 index 0bae92c..0000000 --- a/packages/mesh/src/NineSlicePlane.js +++ /dev/null @@ -1,270 +0,0 @@ -import Plane from './Plane'; - -const DEFAULT_BORDER_SIZE = 10; - -/** - * The NineSlicePlane allows you to stretch a texture using 9-slice scaling. The corners will remain unscaled (useful - * for buttons with rounded corners for example) and the other areas will be scaled horizontally and or vertically - * - *```js - * let Plane9 = new PIXI.NineSlicePlane(PIXI.Texture.from('BoxWithRoundedCorners.png'), 15, 15, 15, 15); - * ``` - *
- *      A                          B
- *    +---+----------------------+---+
- *  C | 1 |          2           | 3 |
- *    +---+----------------------+---+
- *    |   |                      |   |
- *    | 4 |          5           | 6 |
- *    |   |                      |   |
- *    +---+----------------------+---+
- *  D | 7 |          8           | 9 |
- *    +---+----------------------+---+
-
- *  When changing this objects width and/or height:
- *     areas 1 3 7 and 9 will remain unscaled.
- *     areas 2 and 8 will be stretched horizontally
- *     areas 4 and 6 will be stretched vertically
- *     area 5 will be stretched both horizontally and vertically
- * 
- * - * @class - * @extends PIXI.Plane - * @memberof PIXI - * - */ -export default class NineSlicePlane extends Plane -{ - /** - * @param {PIXI.Texture} texture - The texture to use on the NineSlicePlane. - * @param {int} [leftWidth=10] size of the left vertical bar (A) - * @param {int} [topHeight=10] size of the top horizontal bar (C) - * @param {int} [rightWidth=10] size of the right vertical bar (B) - * @param {int} [bottomHeight=10] size of the bottom horizontal bar (D) - */ - constructor(texture, leftWidth, topHeight, rightWidth, bottomHeight) - { - super(texture, 4, 4); - - this._origWidth = texture.orig.width; - this._origHeight = texture.orig.height; - - /** - * The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane - * - * @member {number} - * @memberof PIXI.NineSlicePlane# - * @override - */ - this._width = this._origWidth; - - /** - * The height of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane - * - * @member {number} - * @memberof PIXI.NineSlicePlane# - * @override - */ - this._height = this._origHeight; - - /** - * The width of the left column (a) - * - * @member {number} - * @memberof PIXI.NineSlicePlane# - * @override - */ - this._leftWidth = typeof leftWidth !== 'undefined' ? leftWidth : DEFAULT_BORDER_SIZE; - - /** - * The width of the right column (b) - * - * @member {number} - * @memberof PIXI.NineSlicePlane# - * @override - */ - this._rightWidth = typeof rightWidth !== 'undefined' ? rightWidth : DEFAULT_BORDER_SIZE; - - /** - * The height of the top row (c) - * - * @member {number} - * @memberof PIXI.NineSlicePlane# - * @override - */ - this._topHeight = typeof topHeight !== 'undefined' ? topHeight : DEFAULT_BORDER_SIZE; - - /** - * The height of the bottom row (d) - * - * @member {number} - * @memberof PIXI.NineSlicePlane# - * @override - */ - this._bottomHeight = typeof bottomHeight !== 'undefined' ? bottomHeight : DEFAULT_BORDER_SIZE; - - this.refresh(true); - } - - /** - * Updates the horizontal vertices. - * - */ - updateHorizontalVertices() - { - const vertices = this.vertices; - - const h = this._topHeight + this._bottomHeight; - const scale = this._height > h ? 1.0 : this._height / h; - - vertices[9] = vertices[11] = vertices[13] = vertices[15] = this._topHeight * scale; - vertices[17] = vertices[19] = vertices[21] = vertices[23] = this._height - (this._bottomHeight * scale); - vertices[25] = vertices[27] = vertices[29] = vertices[31] = this._height; - } - - /** - * Updates the vertical vertices. - * - */ - updateVerticalVertices() - { - const vertices = this.vertices; - - const w = this._leftWidth + this._rightWidth; - const scale = this._width > w ? 1.0 : this._width / w; - - vertices[2] = vertices[10] = vertices[18] = vertices[26] = this._leftWidth * scale; - vertices[4] = vertices[12] = vertices[20] = vertices[28] = this._width - (this._rightWidth * scale); - vertices[6] = vertices[14] = vertices[22] = vertices[30] = this._width; - } - - /** - * The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane - * - * @member {number} - */ - get width() - { - return this._width; - } - - set width(value) // eslint-disable-line require-jsdoc - { - this._width = value; - this._refresh(); - } - - /** - * The height of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane - * - * @member {number} - */ - get height() - { - return this._height; - } - - set height(value) // eslint-disable-line require-jsdoc - { - this._height = value; - this._refresh(); - } - - /** - * The width of the left column - * - * @member {number} - */ - get leftWidth() - { - return this._leftWidth; - } - - set leftWidth(value) // eslint-disable-line require-jsdoc - { - this._leftWidth = value; - this._refresh(); - } - - /** - * The width of the right column - * - * @member {number} - */ - get rightWidth() - { - return this._rightWidth; - } - - set rightWidth(value) // eslint-disable-line require-jsdoc - { - this._rightWidth = value; - this._refresh(); - } - - /** - * The height of the top row - * - * @member {number} - */ - get topHeight() - { - return this._topHeight; - } - - set topHeight(value) // eslint-disable-line require-jsdoc - { - this._topHeight = value; - this._refresh(); - } - - /** - * The height of the bottom row - * - * @member {number} - */ - get bottomHeight() - { - return this._bottomHeight; - } - - set bottomHeight(value) // eslint-disable-line require-jsdoc - { - this._bottomHeight = value; - this._refresh(); - } - - /** - * Refreshes NineSlicePlane coords. All of them. - */ - _refresh() - { - super._refresh(); - - const uvs = this.uvs; - const texture = this._texture; - - this._origWidth = texture.orig.width; - this._origHeight = texture.orig.height; - - const _uvw = 1.0 / this._origWidth; - const _uvh = 1.0 / this._origHeight; - - uvs[0] = uvs[8] = uvs[16] = uvs[24] = 0; - uvs[1] = uvs[3] = uvs[5] = uvs[7] = 0; - uvs[6] = uvs[14] = uvs[22] = uvs[30] = 1; - uvs[25] = uvs[27] = uvs[29] = uvs[31] = 1; - - uvs[2] = uvs[10] = uvs[18] = uvs[26] = _uvw * this._leftWidth; - uvs[4] = uvs[12] = uvs[20] = uvs[28] = 1 - (_uvw * this._rightWidth); - uvs[9] = uvs[11] = uvs[13] = uvs[15] = _uvh * this._topHeight; - uvs[17] = uvs[19] = uvs[21] = uvs[23] = 1 - (_uvh * this._bottomHeight); - - this.updateHorizontalVertices(); - this.updateVerticalVertices(); - - this.geometry.buffers[1].update(); - - this.multiplyUvs(); - } -} diff --git a/packages/mesh/src/Plane.js b/packages/mesh/src/Plane.js deleted file mode 100644 index c416b4c..0000000 --- a/packages/mesh/src/Plane.js +++ /dev/null @@ -1,100 +0,0 @@ -import Mesh from './Mesh'; - -/** - * The Plane allows you to draw a texture across several points and them manipulate these points - * - *```js - * for (let i = 0; i < 20; i++) { - * points.push(new PIXI.Point(i * 50, 0)); - * }; - * let Plane = new PIXI.Plane(PIXI.Texture.from("snake.png"), points); - * ``` - * - * @class - * @extends PIXI.Mesh - * @memberof PIXI - * - */ -export default class Plane extends Mesh -{ - /** - * @param {PIXI.Texture} texture - The texture to use on the Plane. - * @param {number} verticesX - The number of vertices in the x-axis - * @param {number} verticesY - The number of vertices in the y-axis - * @param {object} [opts] - an options object - add meshWidth and meshHeight, temporary object for PixiJS v5 alpha - */ - constructor(texture, verticesX, verticesY, opts = {}) - { - super(texture, new Float32Array(1), new Float32Array(1), new Uint16Array(1), 4); - - this.verticesX = verticesX || 10; - this.verticesY = verticesY || 10; - - this.meshWidth = opts.meshWidth || 0; - this.meshHeight = opts.meshHeight || 0; - - this.refresh(); - } - - /** - * Refreshes plane coordinates - * @private - */ - _refresh() - { - const texture = this._texture; - const total = this.verticesX * this.verticesY; - const verts = []; - const uvs = []; - const indices = []; - - const segmentsX = this.verticesX - 1; - const segmentsY = this.verticesY - 1; - - const sizeX = (this.meshWidth || texture.width) / segmentsX; - const sizeY = (this.meshHeight || texture.height) / segmentsY; - - for (let i = 0; i < total; i++) - { - const x = (i % this.verticesX); - const y = ((i / this.verticesX) | 0); - - verts.push(x * sizeX, y * sizeY); - - uvs.push(x / segmentsX, y / segmentsY); - } - - // cons - - const totalSub = segmentsX * segmentsY; - - for (let i = 0; i < totalSub; i++) - { - const xpos = i % segmentsX; - const ypos = (i / segmentsX) | 0; - - const value = (ypos * this.verticesX) + xpos; - const value2 = (ypos * this.verticesX) + xpos + 1; - const value3 = ((ypos + 1) * this.verticesX) + xpos; - const value4 = ((ypos + 1) * this.verticesX) + xpos + 1; - - indices.push(value, value2, value3); - indices.push(value2, value4, value3); - } - - this.vertices = new Float32Array(verts); - this.uvs = new Float32Array(uvs); - this.indices = new Uint16Array(indices); - - this.geometry.buffers[0].data = this.vertices; - this.geometry.buffers[1].data = this.uvs; - this.geometry.indexBuffer.data = this.indices; - - // ensure that the changes are uploaded - this.geometry.buffers[0].update(); - this.geometry.buffers[1].update(); - this.geometry.indexBuffer.update(); - - this.multiplyUvs(); - } -} diff --git a/packages/mesh/src/RawMesh.js b/packages/mesh/src/RawMesh.js deleted file mode 100644 index 7297e94..0000000 --- a/packages/mesh/src/RawMesh.js +++ /dev/null @@ -1,220 +0,0 @@ -import { State } from '@pixi/core'; -import { DRAW_MODES } from '@pixi/constants'; -import { Point, Polygon } from '@pixi/math'; -import { Container } from '@pixi/display'; - -const tempPoint = new Point(); -const tempPolygon = new Polygon(); - -/** - * Base mesh class. - * The reason for this class is to empower you to have maximum flexibility to render any kind of webGL you can think of. - * This class assumes a certain level of webGL knowledge. - * If you know a bit this should abstract enough away to make you life easier! - * Pretty much ALL WebGL can be broken down into the following: - * Geometry - The structure and data for the mesh. This can include anything from positions, uvs, normals, colors etc.. - * Shader - This is the shader that pixi will render the geometry with. (attributes in the shader must match the geometry!) - * Uniforms - These are the values passed to the shader when the mesh is rendered. - * As a shader can be reused across multiple objects, it made sense to allow uniforms to exist outside of the shader - * State - This is the state of WebGL required to render the mesh. - * Through a combination of the above elements you can render anything you want, 2D or 3D! - * - * @class - * @extends PIXI.Container - * @memberof PIXI - */ -export default class RawMesh extends Container -{ - /** - * @param {PIXI.Geometry} geometry the geometry the mesh will use - * @param {PIXI.Shader} shader the shader the mesh will use - * @param {PIXI.State} state the state that the webGL context is required to be in to render the mesh - * @param {number} drawMode the drawMode, can be any of the PIXI.DRAW_MODES consts - */ - constructor(geometry, shader, state, drawMode = DRAW_MODES.TRIANGLES) - { - super(); - - /** - * the geometry the mesh will use - * @type {PIXI.Geometry} - */ - this.geometry = geometry; - - /** - * the shader the mesh will use - * @type {PIXI.Shader} - */ - this.shader = shader; - - /** - * the webGL state the mesh requires to render - * @type {PIXI.State} - */ - this.state = state || new State(); - - /** - * The way the Mesh should be drawn, can be any of the {@link PIXI.RawMesh.DRAW_MODES} consts - * - * @member {number} - * @see PIXI.RawMesh.DRAW_MODES - */ - this.drawMode = drawMode; - - /** - * The way uniforms that will be used by the mesh's shader. - * @member {Object} - */ - - /** - * A map of renderer IDs to webgl render data - * - * @private - * @member {object} - */ - this._glDatas = {}; - - /** - * Plugin that is responsible for rendering this element. - * Allows to customize the rendering process without overriding '_render' & '_renderCanvas' methods. - * - * @member {string} - * @default 'mesh' - */ - this.pluginName = 'mesh'; - - this.start = 0; - this.size = 0; - } - - /** - * Renders the object using the WebGL renderer - * - * @param {PIXI.Renderer} renderer a reference to the WebGL renderer - * @private - */ - _render(renderer) - { - renderer.batch.setObjectRenderer(renderer.plugins[this.pluginName]); - renderer.plugins[this.pluginName].render(this); - } - - /** - * Updates the bounds of the mesh as a rectangle. The bounds calculation takes the worldTransform into account. - * there must be a aVertexPosition attribute present in the geometry for bounds to be calculated correctly. - * - * @private - */ - _calculateBounds() - { - // The position property could be set manually? - if (this.geometry.attributes.aVertexPosition) - { - const vertices = this.geometry.getAttribute('aVertexPosition').data; - - // TODO - we can cache local bounds and use them if they are dirty (like graphics) - this._bounds.addVertices(this.transform, vertices, 0, vertices.length); - } - } - - /** - * Tests if a point is inside this mesh. Works only for TRIANGLE_MESH - * - * @param {PIXI.Point} point the point to test - * @return {boolean} the result of the test - */ - containsPoint(point) - { - if (!this.getBounds().contains(point.x, point.y)) - { - return false; - } - - this.worldTransform.applyInverse(point, tempPoint); - - const vertices = this.geometry.getAttribute('aVertexPosition').data; - - const points = tempPolygon.points; - const indices = this.geometry.getIndex().data; - const len = indices.length; - const step = this.drawMode === 4 ? 3 : 1; - - for (let i = 0; i + 2 < len; i += step) - { - const ind0 = indices[i] * 2; - const ind1 = indices[i + 1] * 2; - const ind2 = indices[i + 2] * 2; - - points[0] = vertices[ind0]; - points[1] = vertices[ind0 + 1]; - points[2] = vertices[ind1]; - points[3] = vertices[ind1 + 1]; - points[4] = vertices[ind2]; - points[5] = vertices[ind2 + 1]; - - if (tempPolygon.contains(tempPoint.x, tempPoint.y)) - { - return true; - } - } - - return false; - } - - /** - * Destroys the RawMesh object. - * - * @param {object|boolean} [options] - Options parameter. A boolean will act as if all - * options have been set to that value - * @param {boolean} [options.children=false] - if set to true, all the children will have - * their destroy method called as well. 'options' will be passed on to those calls. - * @param {boolean} [options.texture=false] - Only used for child Sprites if options.children is set to true - * Should it destroy the texture of the child sprite - * @param {boolean} [options.baseTexture=false] - Only used for child Sprites if options.children is set to true - * Should it destroy the base texture of the child sprite - */ - destroy(options) - { - // for each webgl data entry, destroy the WebGLGraphicsData - for (const id in this._glDatas) - { - const data = this._glDatas[id]; - - if (data.destroy) - { - data.destroy(); - } - else - { - if (data.vertexBuffer) - { - data.vertexBuffer.destroy(); - data.vertexBuffer = null; - } - if (data.indexBuffer) - { - data.indexBuffer.destroy(); - data.indexBuffer = null; - } - if (data.uvBuffer) - { - data.uvBuffer.destroy(); - data.uvBuffer = null; - } - if (data.vao) - { - data.vao.destroy(); - data.vao = null; - } - } - } - - this._glDatas = null; - - this.geometry = null; - this.shader = null; - this.state = null; - - super.destroy(options); - } -} diff --git a/packages/mesh/src/Rope.js b/packages/mesh/src/Rope.js deleted file mode 100644 index b4f85d3..0000000 --- a/packages/mesh/src/Rope.js +++ /dev/null @@ -1,182 +0,0 @@ -import Mesh from './Mesh'; - -/** - * The rope allows you to draw a texture across several points and them manipulate these points - * - *```js - * for (let i = 0; i < 20; i++) { - * points.push(new PIXI.Point(i * 50, 0)); - * }; - * let rope = new PIXI.Rope(PIXI.Texture.from("snake.png"), points); - * ``` - * - * @class - * @extends PIXI.Mesh - * @memberof PIXI - * - */ -export default class Rope extends Mesh -{ - /** - * @param {PIXI.Texture} texture - The texture to use on the rope. - * @param {PIXI.Point[]} points - An array of {@link PIXI.Point} objects to construct this rope. - */ - constructor(texture, points) - { - super(texture, new Float32Array(points.length * 4), - new Float32Array(points.length * 4), - new Uint16Array(points.length * 2), - 5); - - /* - * @member {PIXI.Point[]} An array of points that determine the rope - */ - this.points = points; - this.refresh(); - } - /** - * Refreshes Rope indices and uvs - * @private - */ - _refresh() - { - const points = this.points; - - if (!points) return; - - const vertexBuffer = this.geometry.getAttribute('aVertexPosition'); - const uvBuffer = this.geometry.getAttribute('aTextureCoord'); - const indexBuffer = this.geometry.getIndex(); - - // if too little points, or texture hasn't got UVs set yet just move on. - if (points.length < 1 || !this.texture._uvs) - { - return; - } - - // if the number of points has changed we will need to recreate the arraybuffers - if (vertexBuffer.data.length / 4 !== points.length) - { - vertexBuffer.data = new Float32Array(points.length * 4); - uvBuffer.data = new Float32Array(points.length * 4); - indexBuffer.data = new Uint16Array(points.length * 2); - } - - const uvs = uvBuffer.data; - const indices = indexBuffer.data; - - uvs[0] = 0; - uvs[1] = 0; - uvs[2] = 0; - uvs[3] = 1; - - indices[0] = 0; - indices[1] = 1; - - const total = points.length; - - for (let i = 1; i < total; i++) - { - // time to do some smart drawing! - let index = i * 4; - const amount = i / (total - 1); - - uvs[index] = amount; - uvs[index + 1] = 0; - - uvs[index + 2] = amount; - uvs[index + 3] = 1; - - index = i * 2; - indices[index] = index; - indices[index + 1] = index + 1; - } - - // ensure that the changes are uploaded - uvBuffer.update(); - indexBuffer.update(); - - this.multiplyUvs(); - this.refreshVertices(); - } - - /** - * refreshes vertices of Rope mesh - */ - refreshVertices() - { - const points = this.points; - - if (points.length < 1) - { - return; - } - - let lastPoint = points[0]; - let nextPoint; - let perpX = 0; - let perpY = 0; - - // this.count -= 0.2; - - const vertices = this.vertices; - const total = points.length; - - for (let i = 0; i < total; i++) - { - const point = points[i]; - const index = i * 4; - - if (i < points.length - 1) - { - nextPoint = points[i + 1]; - } - else - { - nextPoint = point; - } - - perpY = -(nextPoint.x - lastPoint.x); - perpX = nextPoint.y - lastPoint.y; - - let ratio = (1 - (i / (total - 1))) * 10; - - if (ratio > 1) - { - ratio = 1; - } - - const perpLength = Math.sqrt((perpX * perpX) + (perpY * perpY)); - const num = this._texture.height / 2; // (20 + Math.abs(Math.sin((i + this.count) * 0.3) * 50) )* ratio; - - perpX /= perpLength; - perpY /= perpLength; - - perpX *= num; - perpY *= num; - - vertices[index] = point.x + perpX; - vertices[index + 1] = point.y + perpY; - vertices[index + 2] = point.x - perpX; - vertices[index + 3] = point.y - perpY; - - lastPoint = point; - } - - this.geometry.buffers[0].update(); - } - - /** - * Updates the object transform for rendering - * - * @private - */ - updateTransform() - { - if (this.autoUpdate) - { - this.refreshVertices(); - } - this.containerUpdateTransform(); - } -} diff --git a/packages/mesh/src/index.js b/packages/mesh/src/index.js index a245772..e14ab9f 100644 --- a/packages/mesh/src/index.js +++ b/packages/mesh/src/index.js @@ -1,6 +1,2 @@ export { default as Mesh } from './Mesh'; -export { default as RawMesh } from './RawMesh'; export { default as MeshRenderer } from './MeshRenderer'; -export { default as Plane } from './Plane'; -export { default as NineSlicePlane } from './NineSlicePlane'; -export { default as Rope } from './Rope'; diff --git a/packages/mesh/src/mesh.frag b/packages/mesh/src/mesh.frag deleted file mode 100644 index 6096983..0000000 --- a/packages/mesh/src/mesh.frag +++ /dev/null @@ -1,9 +0,0 @@ -varying vec2 vTextureCoord; -uniform vec4 uColor; - -uniform sampler2D uSampler; - -void main(void) -{ - gl_FragColor = texture2D(uSampler, vTextureCoord) * uColor; -} diff --git a/packages/mesh/src/mesh.vert b/packages/mesh/src/mesh.vert deleted file mode 100644 index 0526df9..0000000 --- a/packages/mesh/src/mesh.vert +++ /dev/null @@ -1,15 +0,0 @@ -attribute vec2 aVertexPosition; -attribute vec2 aTextureCoord; - -uniform mat3 projectionMatrix; -uniform mat3 translationMatrix; -uniform mat3 uTextureMatrix; - -varying vec2 vTextureCoord; - -void main(void) -{ - gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); - - vTextureCoord = (uTextureMatrix * vec3(aTextureCoord, 1.0)).xy; -} diff --git a/bundles/pixi.js/package.json b/bundles/pixi.js/package.json index 49c7276..177e059 100644 --- a/bundles/pixi.js/package.json +++ b/bundles/pixi.js/package.json @@ -49,6 +49,7 @@ "@pixi/loaders": "^5.0.0-alpha.2", "@pixi/math": "^5.0.0-alpha.2", "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/mesh-extras": "^5.0.0-alpha.2", "@pixi/mixin-cache-as-bitmap": "^5.0.0-alpha.2", "@pixi/mixin-get-child-by-name": "^5.0.0-alpha.2", "@pixi/mixin-get-global-position": "^5.0.0-alpha.2", diff --git a/bundles/pixi.js/src/deprecated.js b/bundles/pixi.js/src/deprecated.js index 147617c..dbebeb0 100644 --- a/bundles/pixi.js/src/deprecated.js +++ b/bundles/pixi.js/src/deprecated.js @@ -263,15 +263,15 @@ Object.defineProperties(PIXI.mesh, { /** * @class PIXI.mesh.Mesh - * @see PIXI.Mesh + * @see PIXI.Mesh2d * @deprecated since 5.0.0 */ Mesh: { get() { - warn('PIXI.mesh.Mesh has moved to PIXI.Mesh'); + warn('PIXI.mesh.Mesh has moved to PIXI.Mesh2d'); - return PIXI.Mesh; + return PIXI.Mesh2d; }, }, /** @@ -315,15 +315,15 @@ }, /** * @class PIXI.mesh.RawMesh - * @see PIXI.RawMesh + * @see PIXI.Mesh * @deprecated since 5.0.0 */ RawMesh: { get() { - warn('PIXI.mesh.RawMesh has moved to PIXI.RawMesh'); + warn('PIXI.mesh.RawMesh has moved to PIXI.Mesh'); - return PIXI.RawMesh; + return PIXI.Mesh; }, }, /** diff --git a/bundles/pixi.js/src/index.js b/bundles/pixi.js/src/index.js index a3a0d1b..6fdabf0 100644 --- a/bundles/pixi.js/src/index.js +++ b/bundles/pixi.js/src/index.js @@ -9,6 +9,7 @@ import * as loaders from '@pixi/loaders'; import * as math from '@pixi/math'; import * as mesh from '@pixi/mesh'; +import * as meshExtras from '@pixi/mesh-extras'; import * as particles from '@pixi/particles'; import * as prepare from '@pixi/prepare'; import * as sprite from '@pixi/sprite'; @@ -128,6 +129,7 @@ loaders, math, mesh, + meshExtras, particles, sprite, spriteAnimated, @@ -152,6 +154,7 @@ export * from '@pixi/loaders'; export * from '@pixi/math'; export * from '@pixi/mesh'; +export * from '@pixi/mesh-extras'; export * from '@pixi/particles'; export * from '@pixi/sprite'; export * from '@pixi/spritesheet'; diff --git a/package-lock.json b/package-lock.json index 7fe6db7..0814729 100644 --- a/package-lock.json +++ b/package-lock.json @@ -209,7 +209,7 @@ "argparse": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", - "integrity": "sha1-vNZ5HqWuCXJeF+WtmIE0zUCz2RE=", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", "dev": true, "requires": { "sprintf-js": "1.0.3" @@ -228,7 +228,7 @@ "arr-flatten": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz", - "integrity": "sha1-NgSLv/TntH4TZkQxbJlmnqWukfE=", + "integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==", "dev": true }, "arr-union": { @@ -297,7 +297,7 @@ "assertion-error": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", - "integrity": "sha1-5gtrDo8wG9l+U3UhW9pAbIURjAs=", + "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", "dev": true }, "async": { @@ -396,7 +396,7 @@ "brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha1-PH/L9SnYcibz0vUrlm/1Jx60Qd0=", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, "requires": { "balanced-match": "1.0.0", @@ -568,7 +568,7 @@ "circular-json": { "version": "0.3.3", "resolved": "https://registry.npmjs.org/circular-json/-/circular-json-0.3.3.tgz", - "integrity": "sha1-gVyZ6oT2gJUp0vRXkb34JxE1LWY=", + "integrity": "sha512-UZK3NBx2Mca+b5LsG7bY183pHWt5Y1xts4P3Pz7ENTwGVnJOUWbRb3ocjvX7hx9tq/yTAdclXm9sZ38gNuem4A==", "dev": true }, "cli-cursor": { @@ -638,7 +638,7 @@ "color-convert": { "version": "1.9.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.1.tgz", - "integrity": "sha1-wSYRB66y8pTr/+ye2eytUppgl+0=", + "integrity": "sha512-mjGanIiwQJskCC18rPR6OmrZ6fm2Lc7PeGFYwCmy5J34wC6F1PzdGL6xeMfmgicfYcNLGuVFA3WzXtIDCQSZxQ==", "dev": true, "requires": { "color-name": "1.1.3" @@ -1427,7 +1427,7 @@ "boom": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/boom/-/boom-5.2.0.tgz", - "integrity": "sha1-XdnabuOl8wIHdDYpDLcX0/SlTgI=", + "integrity": "sha512-Z5BTk6ZRe4tXXQlkqftmsAUANpXmuwlsF5Oov8ThoMbQRzdGTA1ngYRW160GexgOgjsFOKJz0LYhoNi+2AMBUw==", "dev": true, "requires": { "hoek": "4.2.1" @@ -1471,7 +1471,7 @@ "debug": { "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha1-XRKFFd8TT/Mn6QpMk/Tgd6U2NB8=", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", "dev": true, "requires": { "ms": "2.0.0" @@ -1585,7 +1585,7 @@ "doctrine": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", - "integrity": "sha1-XNAfwQFiG0LEzX9dGmYkNxbT850=", + "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", "dev": true, "requires": { "esutils": "2.0.2" @@ -1662,7 +1662,7 @@ "es6-promise": { "version": "4.2.4", "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.4.tgz", - "integrity": "sha1-3EIhwrFlGHYL2MOaUtjzVvwA7Sk=", + "integrity": "sha512-/NdNZVJg+uZgtm9eS3O6lrOLYmQag2DjdEXuPaHlZ6RuVqgqaVZfgYCepEIKsLqwdQArOPtC3XzRLqGGfT8KQQ==", "dev": true }, "escape-string-regexp": { @@ -1788,7 +1788,7 @@ "espree": { "version": "3.5.4", "resolved": "https://registry.npmjs.org/espree/-/espree-3.5.4.tgz", - "integrity": "sha1-sPRHGHyKi+2US4FaZgvd9d610ac=", + "integrity": "sha512-yAcIQxtmMiB/jL32dzEp2enBeidsB7xWPLNiw3IIkpVds1P+h7qF9YwJq1yUNzp2OKXgAprs4F61ih66UsoD1A==", "dev": true, "requires": { "acorn": "5.5.0", @@ -1798,7 +1798,7 @@ "esprima": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.0.tgz", - "integrity": "sha1-RJnt3NERDgshi6zy+n9/WfVcqAQ=", + "integrity": "sha512-oftTcaMu/EGrEIu904mWteKIv8vMuOgGYo7EhVJJN00R/EED9DCua/xxHRdYnKtcECzVg7xOWhflvJMnqcFZjw==", "dev": true }, "esquery": { @@ -1813,7 +1813,7 @@ "esrecurse": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.2.1.tgz", - "integrity": "sha1-AHo7n9vCs7uH5IeeoZyS/b05Qs8=", + "integrity": "sha512-64RBB++fIOAXPw3P9cy89qfMlvZEXZkqqJkjqqXIvzP5ezRZjW+lPWjw35UX/3EhUPFYbg5ER4JYgDw4007/DQ==", "dev": true, "requires": { "estraverse": "4.2.0" @@ -2024,7 +2024,7 @@ "find-root": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/find-root/-/find-root-1.1.0.tgz", - "integrity": "sha1-q8/Iunb3CMQql7PWhbfpRQv7nOQ=", + "integrity": "sha512-NKfW6bec6GfKc0SGx1e07QZY9PE99u0Bft/0rzSD5k3sO/vwkVUpDUKVm5Gpp5Ue3YfShPFTX2070tDs5kB9Ng==", "dev": true }, "find-up": { @@ -2103,7 +2103,7 @@ "supports-color": { "version": "5.3.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.3.0.tgz", - "integrity": "sha1-WySsFduA+pJ89SJ6SjP9PEx2dsA=", + "integrity": "sha512-0aP01LLIskjKs3lq52EC0aGBAJhLq7B2Rd8HC/DR/PtNNpcLilNmHC12O+hu0usQpo7wtHNRqtrhBwtDb0+dNg==", "dev": true, "requires": { "has-flag": "3.0.0" @@ -2567,7 +2567,7 @@ "glob": { "version": "7.1.2", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", - "integrity": "sha1-wZyd+aAocC1nhhI4SmVSQExjbRU=", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", "dev": true, "requires": { "fs.realpath": "1.0.0", @@ -2672,7 +2672,7 @@ "growl": { "version": "1.10.3", "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.3.tgz", - "integrity": "sha1-GSa6kM8+3+KttJJ/WIC8IsZseQ8=", + "integrity": "sha512-hKlsbA5Vu3xsh1Cg3J7jSmX/WaW6A5oBeqzM88oNbCRQFz+zUaXm6yxS4RVytp1scBoJzSYl4YAEOQIt6O8V1Q==", "dev": true }, "handlebars": { @@ -2738,7 +2738,7 @@ "hawk": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/hawk/-/hawk-6.0.2.tgz", - "integrity": "sha1-r02RTrBl+bXOTZ0RwcshJu7MMDg=", + "integrity": "sha512-miowhl2+U7Qle4vdLqDdPt9m09K6yZhkLDTWGoUiUzrQCn+mHHSmfJgAyGaLRZbPmTqfFFjRV1QWCW0VWUJBbQ==", "dev": true, "requires": { "boom": "4.3.1", @@ -2756,7 +2756,7 @@ "hoek": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/hoek/-/hoek-4.2.1.tgz", - "integrity": "sha1-ljRQKqEsRF3Vp8VzS1cruHOKrLs=", + "integrity": "sha512-QLg82fGkfnJ/4iy1xZ81/9SIJiq1NGFUMGs6ParyjBZr6jW2Ufj/snDqTHixNlHdPNwN2RLVD0Pi3igeK9+JfA==", "dev": true }, "home-path": { @@ -2791,7 +2791,7 @@ "ignore": { "version": "3.3.7", "resolved": "https://registry.npmjs.org/ignore/-/ignore-3.3.7.tgz", - "integrity": "sha1-YSKJv7PCIOGGpYEYYY1b6MG6sCE=", + "integrity": "sha512-YGG3ejvBNHRqu0559EOxxNFihD0AjpvHlC/pdGKd3X3ofe+CoJkYazwNJYTNebqpPKN+VVQbh4ZFn1DivMNuHA==", "dev": true }, "imurmurhash": { @@ -2828,7 +2828,7 @@ "ini": { "version": "1.3.5", "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", - "integrity": "sha1-7uJfVtscnsYIXgwid4CD9Zar+Sc=", + "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==", "dev": true }, "inquirer": { @@ -2901,7 +2901,7 @@ "is-buffer": { "version": "1.1.6", "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", - "integrity": "sha1-76ouqdqg16suoTqXsritUf776L4=", + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", "dev": true }, "is-builtin-module": { @@ -3054,7 +3054,7 @@ "is-resolvable": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/is-resolvable/-/is-resolvable-1.1.0.tgz", - "integrity": "sha1-+xj4fOH+uSUWnJpAfBkxijIG7Yg=", + "integrity": "sha512-qgDYXFSR5WvEfuS5dMj6oTMEbrrSaM0CrFk2Yiq/gXnBvD9pMa2jGXxyhGLfvhZpuMZe18CJpFxAt3CRs42NMg==", "dev": true }, "is-retry-allowed": { @@ -3204,7 +3204,7 @@ "js-yaml": { "version": "3.11.0", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.11.0.tgz", - "integrity": "sha1-WXwai9VxUvJtYizkEXhRpR9euu8=", + "integrity": "sha512-saJstZWv7oNeOyBh3+Dx1qWzhW0+e6/8eDzo7p5rDFqxntSztloLtuKu+Ejhtq82jsilwOIZYsCz+lIjthg1Hw==", "dev": true, "requires": { "argparse": "1.0.10", @@ -3324,7 +3324,7 @@ "just-extend": { "version": "1.1.27", "resolved": "https://registry.npmjs.org/just-extend/-/just-extend-1.1.27.tgz", - "integrity": "sha1-7G55QQ/5FORyZSq/oOYDwD1g6QU=", + "integrity": "sha512-mJVp13Ix6gFo3SBAy9U/kL+oeZqzlYYYLQBwXVBlVzIsZwBqGREnOro24oC/8s8aox+rJhtZ2DiQof++IrkA+g==", "dev": true }, "kind-of": { @@ -3703,7 +3703,7 @@ "lodash": { "version": "4.17.5", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.5.tgz", - "integrity": "sha1-maktZcAnLevoyWtgV7yPv6O+1RE=", + "integrity": "sha512-svL3uiZf1RwhH+cWrfZn3A4+U58wbP0tGVTLQPbjplZxZ8ROD9VLuNgsRniTlLe7OlSqR79RUehXgpBW/s0IQw==", "dev": true }, "lodash._reinterpolate": { @@ -3740,7 +3740,7 @@ "lolex": { "version": "2.3.2", "resolved": "https://registry.npmjs.org/lolex/-/lolex-2.3.2.tgz", - "integrity": "sha1-hflFBCUQO/nnpgZo6iXcQydMqAc=", + "integrity": "sha512-A5pN2tkFj7H0dGIAM6MFvHKMJcPnjZsOMvR7ujCjfgW5TbV6H9vb1PgxLtHvjqNZTHsUolz+6/WEO0N1xNx2ng==", "dev": true }, "longest": { @@ -3816,7 +3816,7 @@ "marked": { "version": "0.3.17", "resolved": "https://registry.npmjs.org/marked/-/marked-0.3.17.tgz", - "integrity": "sha1-YH8GZos8axJGso8T2nYRasGqLSs=", + "integrity": "sha512-+AKbNsjZl6jFfLPwHhWmGTqE009wTKn3RTmn9K8oUKHrX/abPJjtcRtXpYB/FFrwPJRUA86LX/de3T0knkPCmQ==", "dev": true }, "mem": { @@ -3896,13 +3896,13 @@ "mime-db": { "version": "1.33.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.33.0.tgz", - "integrity": "sha1-o0kgUKXLm2NFBUHjnZeI0icng9s=", + "integrity": "sha512-BHJ/EKruNIqJf/QahvxwQZXKygOQ256myeN/Ew+THcAa5q+PjyTTMMeNQC4DZw5AwfvelsUrA6B67NKMqXDbzQ==", "dev": true }, "mime-types": { "version": "2.1.18", "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.18.tgz", - "integrity": "sha1-bzI/YKg9ERRvgx/xH9ZuL+VQO7g=", + "integrity": "sha512-lc/aahn+t4/SWV/qcmumYjymLsWfN3ELhpmVuUFjgsORruuZPVSwAQryq+HHGvO/SI2KVX26bx+En+zhM8g8hQ==", "dev": true, "requires": { "mime-db": "1.33.0" @@ -3917,7 +3917,7 @@ "minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha1-UWbihkV/AzBgZL5Ul+jbsMPTIIM=", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "dev": true, "requires": { "brace-expansion": "1.1.11" @@ -4071,7 +4071,7 @@ "normalize-package-data": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.4.0.tgz", - "integrity": "sha1-EvlaMH1YNSB1oEkHuErIvpisAS8=", + "integrity": "sha512-9jjUFbTPfEy3R/ad/2oNbKtW9Hgovl5O1FvFWKkKblNXoN/Oou6+9+KKohPK13Yc3/TyunyWhJp6gvRNR/PPAw==", "dev": true, "requires": { "hosted-git-info": "2.5.0", @@ -4511,7 +4511,7 @@ "process-nextick-args": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", - "integrity": "sha1-o31zL0JxtKsa0HDTVQjoKQeI/6o=", + "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==", "dev": true }, "progress": { @@ -4584,7 +4584,7 @@ "qs": { "version": "6.5.1", "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.1.tgz", - "integrity": "sha1-NJzfbu+J7EXBLX1es/wMhwNDptg=", + "integrity": "sha512-eRzhrN1WSINYCDCbrz796z37LOe3m5tmW7RQf6oBntukAG1nmovJvhnwHHRMAfeoItc1m2Hk02WER2aQ/iqs+A==", "dev": true }, "quick-lru": { @@ -4596,7 +4596,7 @@ "randomatic": { "version": "1.1.7", "resolved": "https://registry.npmjs.org/randomatic/-/randomatic-1.1.7.tgz", - "integrity": "sha1-x6vpzIuHwLqodrGf3oP9RkeX44w=", + "integrity": "sha512-D5JUjPyJbaJDkuAazpVnSfVkLlpeO3wDlPROTMLGKG1zMFNFRgrciKo1ltz/AzNTkqE0HzDx655QOL51N06how==", "dev": true, "requires": { "is-number": "3.0.0", @@ -4701,7 +4701,7 @@ "regex-cache": { "version": "0.4.4", "resolved": "https://registry.npmjs.org/regex-cache/-/regex-cache-0.4.4.tgz", - "integrity": "sha1-db3FiioUls7EihKDW8VMjVYjNt0=", + "integrity": "sha512-nVIZwtCjkC9YgvWkpM55B5rBhBYRZhAaJbgcFYXXsHnbZ9UZI9nnVWYZpBlCqv9ho2eZryPnWrZGsOdPwVWXWQ==", "dev": true, "requires": { "is-equal-shallow": "0.1.3" @@ -4729,7 +4729,7 @@ "remap-istanbul": { "version": "0.10.1", "resolved": "https://registry.npmjs.org/remap-istanbul/-/remap-istanbul-0.10.1.tgz", - "integrity": "sha1-OqWN1QIdSZ8zbTulvzu7kcG4jjc=", + "integrity": "sha512-gsNQXs5kJLhErICSyYhzVZ++C8LBW8dgwr874Y2QvzAUS75zBlD/juZgXs39nbYJ09fZDlX2AVLVJAY2jbFJoQ==", "dev": true, "requires": { "amdefine": "1.0.1", @@ -4769,7 +4769,7 @@ "source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha1-dHIq8y6WFOnCh6jQu95IteLxomM=", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", "dev": true }, "through2": { @@ -4883,7 +4883,7 @@ "resolve": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.5.0.tgz", - "integrity": "sha1-HwmsznlsmnYlefMbLBzEw83fnzY=", + "integrity": "sha512-hgoSGrc3pjzAPHNBg+KnFcK2HwlHTs/YrAGUr6qgTVUZmXv1UEXXl0bZNBKMA9fud6lRYFdPGz0xXxycPzmmiw==", "dev": true, "requires": { "path-parse": "1.0.5" @@ -4924,7 +4924,7 @@ "rimraf": { "version": "2.6.2", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", - "integrity": "sha1-LtgVDSShbqhlHm1u8PR8QVjOejY=", + "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", "dev": true, "requires": { "glob": "7.1.2" @@ -5063,19 +5063,19 @@ "safe-buffer": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", - "integrity": "sha1-iTMSr2myEj3vcfV4iQAWce6yyFM=", + "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", "dev": true }, "samsam": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/samsam/-/samsam-1.3.0.tgz", - "integrity": "sha1-jR2TUOJWItow3j5EumkrUiGrfFA=", + "integrity": "sha512-1HwIYD/8UlOtFS3QO3w7ey+SdSDFE4HRNLZoZRYVQefrOY3l17epswImeB1ijgJFQJodIaHcwkp3r/myBjFVbg==", "dev": true }, "semver": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz", - "integrity": "sha1-3Eu8emyp2Rbe5dQ1FvAJK1j3uKs=", + "integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==", "dev": true }, "set-blocking": { @@ -5117,7 +5117,7 @@ "sinon-chai": { "version": "2.14.0", "resolved": "https://registry.npmjs.org/sinon-chai/-/sinon-chai-2.14.0.tgz", - "integrity": "sha1-2n3UzIPNaiYLZ8yg96n9riahIF0=", + "integrity": "sha512-9stIF1utB0ywNHNT7RgiXbdmen8QDCRsrTjw+G9TgKt1Yexjiv8TOWZ6WHsTPz57Yky3DIswZvEqX8fpuHNDtQ==", "dev": true }, "slash": { @@ -5146,7 +5146,7 @@ "sntp": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/sntp/-/sntp-2.1.0.tgz", - "integrity": "sha1-LGzsFP7cIiJznK+bXD2F0cxaLMg=", + "integrity": "sha512-FL1b58BDrqS3A11lJ0zEdnJ3UOKqVxawAkF3k7F0CVN7VQ34aZrV+G8BZ1WC9ZL7NyrwsW0oviwsWDgRuVYtJg==", "dev": true, "requires": { "hoek": "4.2.1" @@ -5203,7 +5203,7 @@ "spdx-correct": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.0.0.tgz", - "integrity": "sha1-BaW01xU6GVvJLDxCW2nzsqlSTII=", + "integrity": "sha512-N19o9z5cEyc8yQQPukRCZ9EUmb4HUpnrmaL/fxS2pBo2jbfcFRVuFZ/oFC+vZz0MNNk0h80iMn5/S6qGZOL5+g==", "dev": true, "requires": { "spdx-expression-parse": "3.0.0", @@ -5213,13 +5213,13 @@ "spdx-exceptions": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.1.0.tgz", - "integrity": "sha1-LHrmEFbHFKW5ubKyr30xHvXHj+k=", + "integrity": "sha512-4K1NsmrlCU1JJgUrtgEeTVyfx8VaYea9J9LvARxhbHtVtohPs/gFGG5yy49beySjlIMhhXZ4QqujIZEfS4l6Cg==", "dev": true }, "spdx-expression-parse": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.0.tgz", - "integrity": "sha1-meEZt6XaAOBUkcn6M4t5BII7QdA=", + "integrity": "sha512-Yg6D3XpRD4kkOmTpdgbUiEJFKghJH03fiC1OPll5h/0sO6neh2jqRDVHOQ4o/LMea0tgCkbMgea5ip/e+MkWyg==", "dev": true, "requires": { "spdx-exceptions": "2.1.0", @@ -5229,7 +5229,7 @@ "spdx-license-ids": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.0.tgz", - "integrity": "sha1-enzShHDMbToc/m1miG9rxDDTrIc=", + "integrity": "sha512-2+EPwgbnmOIl8HjGBXXMd9NAu02vLjOO1nWw4kmeRDFyHn+M/ETfHxQUK0oXg8ctgVnl9t3rosNVsZ1jG61nDA==", "dev": true }, "speedometer": { @@ -5566,7 +5566,7 @@ "tough-cookie": { "version": "2.3.4", "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.4.tgz", - "integrity": "sha1-7GDO44rGdQY//JelwYlwV47oNlU=", + "integrity": "sha512-TZ6TTfI5NtZnuyy/Kecv+CnoROnyXn2DN97LontgQpCwsX2XyLYCC0ENhYkehSOwAp8rTQKc/NUIF7BkQ5rKLA==", "dev": true, "requires": { "punycode": "1.4.1" @@ -5708,13 +5708,13 @@ "uuid": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.2.1.tgz", - "integrity": "sha1-EsUou51Y0LkmXZovbw/ovhf/HxQ=", + "integrity": "sha512-jZnMwlb9Iku/O3smGWvZhauCf6cvvpKi4BKRiliS3cxnI+Gz9j5MEpTz2UFuXiKPJocb7gnsLHwiS05ige5BEA==", "dev": true }, "validate-npm-package-license": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.3.tgz", - "integrity": "sha1-gWQ7y+8b3+zUYjeT3EZIlIupgzg=", + "integrity": "sha512-63ZOUnL4SIXj4L0NixR3L1lcjO38crAbgrTpl28t8jjrfuiOBL5Iygm+60qPs/KsZGzPNg6Smnc/oY16QTjF0g==", "dev": true, "requires": { "spdx-correct": "3.0.0", @@ -5750,7 +5750,7 @@ "which": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/which/-/which-1.3.0.tgz", - "integrity": "sha1-/wS9/AEO5UfXgL7DjhrBwnd9JTo=", + "integrity": "sha512-xcJpopdamTuY5duC/KnTTNBraPK54YwpenP4lzxU8H91GudWpFv38u0CKjclE1Wi2EH2EDz5LRcHcKbCIzqGyg==", "dev": true, "requires": { "isexe": "2.0.0" diff --git a/packages/canvas/canvas-mesh/package.json b/packages/canvas/canvas-mesh/package.json index 691cd2c..6744a17 100644 --- a/packages/canvas/canvas-mesh/package.json +++ b/packages/canvas/canvas-mesh/package.json @@ -24,6 +24,7 @@ "dependencies": { "@pixi/constants": "^5.0.0-alpha.2", "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/mesh-extras": "^5.0.0-alpha.2", "@pixi/settings": "^5.0.0-alpha.2" }, "devDependencies": { diff --git a/packages/canvas/canvas-mesh/src/Mesh.js b/packages/canvas/canvas-mesh/src/Mesh.js index 900a872..c43a74b 100644 --- a/packages/canvas/canvas-mesh/src/Mesh.js +++ b/packages/canvas/canvas-mesh/src/Mesh.js @@ -1,36 +1,14 @@ import { Mesh } from '@pixi/mesh'; -import { settings } from './settings'; - -// IMPORTANT: Please do NOT use this as a precedent to use `settings` after the object is created -// this was merely created to completely decouple canvas from the base Mesh class and we are -// unable to add `canvasPadding` in the constructor anymore, as the case was for PixiJS v4. /** - * Internal variable for `canvasPadding`. + * Renders the object using the Canvas renderer * * @private - * @memberof PIXI.Mesh - * @member {number} - * @default null - */ -Mesh.prototype._canvasPadding = null; - -/** - * Triangles in canvas mode are automatically antialiased, use this value to force triangles - * to overlap a bit with each other. To set the global default, set {@link PIXI.settings.MESH_CANVAS_PADDING} - * - * @see PIXI.settings.MESH_CANVAS_PADDING - * @member {number} canvasPadding + * @method _renderCanvas * @memberof PIXI.Mesh# - * @default 0 + * @param {PIXI.CanvasRenderer} renderer - The canvas renderer. */ -Object.defineProperty(Mesh.prototype, 'canvasPadding', { - get() - { - return this._canvasPadding !== null ? this._canvasPadding : settings.MESH_CANVAS_PADDING; - }, - set(value) - { - this._canvasPadding = value; - }, -}); +Mesh.prototype._renderCanvas = function _renderCanvas(renderer) +{ + renderer.plugins[this.pluginName].render(this); +}; diff --git a/packages/canvas/canvas-mesh/src/Mesh2d.js b/packages/canvas/canvas-mesh/src/Mesh2d.js new file mode 100644 index 0000000..d0bd80f --- /dev/null +++ b/packages/canvas/canvas-mesh/src/Mesh2d.js @@ -0,0 +1,36 @@ +import { Mesh2d } from '@pixi/mesh-extras'; +import { settings } from './settings'; + +// IMPORTANT: Please do NOT use this as a precedent to use `settings` after the object is created +// this was merely created to completely decouple canvas from the base Mesh class and we are +// unable to add `canvasPadding` in the constructor anymore, as the case was for PixiJS v4. + +/** + * Internal variable for `canvasPadding`. + * + * @private + * @memberof PIXI.Mesh2d + * @member {number} + * @default null + */ +Mesh2d.prototype._canvasPadding = null; + +/** + * Triangles in canvas mode are automatically antialiased, use this value to force triangles + * to overlap a bit with each other. To set the global default, set {@link PIXI.settings.MESH_CANVAS_PADDING} + * + * @see PIXI.settings.MESH_CANVAS_PADDING + * @member {number} canvasPadding + * @memberof PIXI.Mesh2d# + * @default 0 + */ +Object.defineProperty(Mesh2d.prototype, 'canvasPadding', { + get() + { + return this._canvasPadding !== null ? this._canvasPadding : settings.MESH_CANVAS_PADDING; + }, + set(value) + { + this._canvasPadding = value; + }, +}); diff --git a/packages/canvas/canvas-mesh/src/NineSlicePlane.js b/packages/canvas/canvas-mesh/src/NineSlicePlane.js index 09eaf9c..2fd5acc 100644 --- a/packages/canvas/canvas-mesh/src/NineSlicePlane.js +++ b/packages/canvas/canvas-mesh/src/NineSlicePlane.js @@ -1,4 +1,4 @@ -import { NineSlicePlane } from '@pixi/mesh'; +import { NineSlicePlane } from '@pixi/mesh-extras'; /** * Renders the object using the Canvas renderer diff --git a/packages/canvas/canvas-mesh/src/RawMesh.js b/packages/canvas/canvas-mesh/src/RawMesh.js deleted file mode 100644 index bf40184..0000000 --- a/packages/canvas/canvas-mesh/src/RawMesh.js +++ /dev/null @@ -1,14 +0,0 @@ -import { RawMesh } from '@pixi/mesh'; - -/** - * Renders the object using the Canvas renderer - * - * @private - * @method _renderCanvas - * @memberof PIXI.RawMesh# - * @param {PIXI.CanvasRenderer} renderer - The canvas renderer. - */ -RawMesh.prototype._renderCanvas = function _renderCanvas(renderer) -{ - renderer.plugins[this.pluginName].render(this); -}; diff --git a/packages/canvas/canvas-mesh/src/index.js b/packages/canvas/canvas-mesh/src/index.js index 2295016..f4fa31d 100644 --- a/packages/canvas/canvas-mesh/src/index.js +++ b/packages/canvas/canvas-mesh/src/index.js @@ -1,6 +1,6 @@ export { default as CanvasMeshRenderer } from './CanvasMeshRenderer'; import './settings'; -import './Mesh'; +import './Mesh2d'; import './NineSlicePlane'; -import './RawMesh'; +import './Mesh'; diff --git a/packages/canvas/canvas-mesh/src/settings.js b/packages/canvas/canvas-mesh/src/settings.js index 4cefb4c..e81b8e0 100644 --- a/packages/canvas/canvas-mesh/src/settings.js +++ b/packages/canvas/canvas-mesh/src/settings.js @@ -3,7 +3,7 @@ /** * Default `canvasPadding` for canvas-based Mesh rendering. * - * @see PIXI.Mesh#canvasPadding + * @see PIXI.Mesh2d#canvasPadding * @static * @constant * @memberof PIXI.settings diff --git a/packages/mesh-extras/LICENSE b/packages/mesh-extras/LICENSE new file mode 100644 index 0000000..148e3eb --- /dev/null +++ b/packages/mesh-extras/LICENSE @@ -0,0 +1,21 @@ +The MIT License + +Copyright (c) 2013-2018 Mathew Groves, Chad Engler + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/packages/mesh-extras/README.md b/packages/mesh-extras/README.md new file mode 100644 index 0000000..1d9b0e1 --- /dev/null +++ b/packages/mesh-extras/README.md @@ -0,0 +1,19 @@ +# @pixi/mesh-extras + +## Installation + +```bash +npm install @pixi/mesh-extras +``` + +## Usage + +```js +import { MeshRenderer } from '@pixi/mesh'; +import { Renderer } from '@pixi/core'; +import { Rope } from '@pixi/mesh-extras'; + +Renderer.registerPlugin('mesh', MeshRenderer); + +const rope = new Rope(); +``` \ No newline at end of file diff --git a/packages/mesh-extras/package.json b/packages/mesh-extras/package.json new file mode 100644 index 0000000..d134f64 --- /dev/null +++ b/packages/mesh-extras/package.json @@ -0,0 +1,38 @@ +{ + "name": "@pixi/mesh-extras", + "version": "5.0.0-alpha.2", + "main": "lib/mesh-extras.js", + "module": "lib/mesh-extras.es.js", + "description": "Custom Mesh display objects, like Rope and Plane", + "author": "Mat Groves", + "contributors": [ + "Matt Karl " + ], + "homepage": "http://pixijs.com/", + "bugs": "https://github.com/pixijs/pixi.js/issues", + "license": "MIT", + "repository": { + "type": "git", + "url": "https://github.com/pixijs/pixi.js.git" + }, + "publishConfig": { + "access": "public" + }, + "scripts": { + "test": "floss --path test" + }, + "files": [ + "lib" + ], + "dependencies": { + "@pixi/constants": "^5.0.0-alpha.2", + "@pixi/core": "^5.0.0-alpha.2", + "@pixi/math": "^5.0.0-alpha.2", + "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/utils": "^5.0.0-alpha.2" + }, + "devDependencies": { + "@pixi/loaders": "^5.0.0-alpha.2", + "floss": "^2.1.3" + } +} diff --git a/packages/mesh-extras/src/Mesh2d.js b/packages/mesh-extras/src/Mesh2d.js new file mode 100644 index 0000000..d113a5e --- /dev/null +++ b/packages/mesh-extras/src/Mesh2d.js @@ -0,0 +1,263 @@ +import { Mesh } from '@pixi/mesh'; +import { Geometry, Program, Shader, Texture, TextureMatrix } from '@pixi/core'; +import { Matrix } from '@pixi/math'; +import { BLEND_MODES } from '@pixi/constants'; +import { hex2rgb, premultiplyRgba } from '@pixi/utils'; +import vertex from './mesh.vert'; +import fragment from './mesh.frag'; + +let meshProgram; + +/** + * Base mesh class + * @class + * @extends PIXI.Container + * @memberof PIXI + */ +export default class Mesh2d extends Mesh +{ + /** + * @param {PIXI.Texture} [texture=Texture.EMPTY] - The texture to use + * @param {Float32Array} [vertices] - if you want to specify the vertices + * @param {Float32Array} [uvs] - if you want to specify the uvs + * @param {Uint16Array} [indices] - if you want to specify the indices + * @param {number} [drawMode] - the drawMode, can be any of the Mesh.DRAW_MODES consts + */ + constructor(texture = Texture.EMPTY, vertices, uvs, indices, drawMode) + { + const geometry = new Geometry(); + + if (!meshProgram) + { + meshProgram = new Program(vertex, fragment); + } + + geometry.addAttribute('aVertexPosition', vertices) + .addAttribute('aTextureCoord', uvs) + .addIndex(indices); + + geometry.getAttribute('aVertexPosition').static = false; + + const uniforms = { + uSampler: texture, + uTextureMatrix: Matrix.IDENTITY, + alpha: 1, + uColor: new Float32Array([1, 1, 1, 1]), + }; + + super(geometry, new Shader(meshProgram, uniforms), null, drawMode); + + /** + * The Uvs of the Mesh + * + * @member {Float32Array} + */ + this.uvs = geometry.getAttribute('aTextureCoord').data; + + /** + * An array of vertices + * + * @member {Float32Array} + */ + this.vertices = geometry.getAttribute('aVertexPosition').data; + + this.uniforms = uniforms; + + /** + * The texture of the Mesh + * + * @member {PIXI.Texture} + * @default PIXI.Texture.EMPTY + * @private + */ + this.texture = texture; + + /** + * The tint applied to the mesh. This is a [r,g,b] value. A value of [1,1,1] will remove any + * tint effect. + * + * @member {number} + * @private + */ + this._tintRGB = new Float32Array([1, 1, 1]); + + // Set default tint + this.tint = 0xFFFFFF; + + this.blendMode = BLEND_MODES.NORMAL; + + /** + * TextureMatrix instance for this Mesh, used to track Texture changes + * + * @member {PIXI.TextureMatrix} + * @readonly + */ + this.uvMatrix = new TextureMatrix(this._texture); + + /** + * whether or not upload uvMatrix to shader + * if its false, then uvs should be pre-multiplied + * if you change it for generated mesh, please call 'refresh(true)' + * @member {boolean} + * @default false + */ + this.uploadUvMatrix = false; + + /** + * Uploads vertices buffer every frame, like in PixiJS V3 and V4. + * + * @member {boolean} + * @default true + */ + this.autoUpdate = true; + } + + /** + * The tint applied to the Rope. This is a hex value. A value of + * 0xFFFFFF will remove any tint effect. + * + * @member {number} + * @memberof PIXI.Sprite# + * @default 0xFFFFFF + */ + get tint() + { + return this._tint; + } + + /** + * Sets the tint of the rope. + * + * @param {number} value - The value to set to. + */ + set tint(value) + { + this._tint = value; + + hex2rgb(this._tint, this._tintRGB); + } + + /** + * The blend mode to be applied to the sprite. Set to `PIXI.BLEND_MODES.NORMAL` to remove any blend mode. + * + * @member {number} + * @default PIXI.BLEND_MODES.NORMAL + * @see PIXI.BLEND_MODES + */ + get blendMode() + { + return this.state.blendMode; + } + + set blendMode(value) // eslint-disable-line require-jsdoc + { + this.state.blendMode = value; + } + + /** + * The texture that the mesh uses. + * + * @member {PIXI.Texture} + */ + get texture() + { + return this._texture; + } + + set texture(value) // eslint-disable-line require-jsdoc + { + if (this._texture === value) + { + return; + } + + this._texture = value; + this.uniforms.uSampler = this.texture; + + if (value) + { + // wait for the texture to load + if (value.baseTexture.valid) + { + this._onTextureUpdate(); + } + else + { + value.once('update', this._onTextureUpdate, this); + } + } + } + + _render(renderer) + { + const baseTex = this._texture.baseTexture; + + premultiplyRgba(this._tintRGB, this.worldAlpha, this.uniforms.uColor, baseTex.premultiplyAlpha); + super._render(renderer); + } + /** + * When the texture is updated, this event will fire to update the scale and frame + * + * @private + */ + _onTextureUpdate() + { + // constructor texture update stop + if (!this.uvMatrix) + { + return; + } + this.uvMatrix.texture = this._texture; + this.refresh(); + } + + /** + * multiplies uvs only if uploadUvMatrix is false + * call it after you change uvs manually + * make sure that texture is valid + */ + multiplyUvs() + { + if (!this.uploadUvMatrix) + { + this.uvMatrix.multiplyUvs(this.uvs); + } + } + + /** + * Refreshes uvs for generated meshes (rope, plane) + * sometimes refreshes vertices too + * + * @param {boolean} [forceUpdate=false] if true, matrices will be updated any case + */ + refresh(forceUpdate) + { + if (this.uvMatrix.update(forceUpdate)) + { + this._refresh(); + } + } + + /** + * Updates the object transform for rendering + * + * @private + */ + updateTransform() + { + if (this.autoUpdate) + { + this.geometry.buffers[0].update(); + } + this.containerUpdateTransform(); + } + + /** + * re-calculates mesh coords + * @private + */ + _refresh() + { + /* empty */ + } +} diff --git a/packages/mesh-extras/src/NineSlicePlane.js b/packages/mesh-extras/src/NineSlicePlane.js new file mode 100644 index 0000000..0bae92c --- /dev/null +++ b/packages/mesh-extras/src/NineSlicePlane.js @@ -0,0 +1,270 @@ +import Plane from './Plane'; + +const DEFAULT_BORDER_SIZE = 10; + +/** + * The NineSlicePlane allows you to stretch a texture using 9-slice scaling. The corners will remain unscaled (useful + * for buttons with rounded corners for example) and the other areas will be scaled horizontally and or vertically + * + *```js + * let Plane9 = new PIXI.NineSlicePlane(PIXI.Texture.from('BoxWithRoundedCorners.png'), 15, 15, 15, 15); + * ``` + *
+ *      A                          B
+ *    +---+----------------------+---+
+ *  C | 1 |          2           | 3 |
+ *    +---+----------------------+---+
+ *    |   |                      |   |
+ *    | 4 |          5           | 6 |
+ *    |   |                      |   |
+ *    +---+----------------------+---+
+ *  D | 7 |          8           | 9 |
+ *    +---+----------------------+---+
+
+ *  When changing this objects width and/or height:
+ *     areas 1 3 7 and 9 will remain unscaled.
+ *     areas 2 and 8 will be stretched horizontally
+ *     areas 4 and 6 will be stretched vertically
+ *     area 5 will be stretched both horizontally and vertically
+ * 
+ * + * @class + * @extends PIXI.Plane + * @memberof PIXI + * + */ +export default class NineSlicePlane extends Plane +{ + /** + * @param {PIXI.Texture} texture - The texture to use on the NineSlicePlane. + * @param {int} [leftWidth=10] size of the left vertical bar (A) + * @param {int} [topHeight=10] size of the top horizontal bar (C) + * @param {int} [rightWidth=10] size of the right vertical bar (B) + * @param {int} [bottomHeight=10] size of the bottom horizontal bar (D) + */ + constructor(texture, leftWidth, topHeight, rightWidth, bottomHeight) + { + super(texture, 4, 4); + + this._origWidth = texture.orig.width; + this._origHeight = texture.orig.height; + + /** + * The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._width = this._origWidth; + + /** + * The height of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._height = this._origHeight; + + /** + * The width of the left column (a) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._leftWidth = typeof leftWidth !== 'undefined' ? leftWidth : DEFAULT_BORDER_SIZE; + + /** + * The width of the right column (b) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._rightWidth = typeof rightWidth !== 'undefined' ? rightWidth : DEFAULT_BORDER_SIZE; + + /** + * The height of the top row (c) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._topHeight = typeof topHeight !== 'undefined' ? topHeight : DEFAULT_BORDER_SIZE; + + /** + * The height of the bottom row (d) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._bottomHeight = typeof bottomHeight !== 'undefined' ? bottomHeight : DEFAULT_BORDER_SIZE; + + this.refresh(true); + } + + /** + * Updates the horizontal vertices. + * + */ + updateHorizontalVertices() + { + const vertices = this.vertices; + + const h = this._topHeight + this._bottomHeight; + const scale = this._height > h ? 1.0 : this._height / h; + + vertices[9] = vertices[11] = vertices[13] = vertices[15] = this._topHeight * scale; + vertices[17] = vertices[19] = vertices[21] = vertices[23] = this._height - (this._bottomHeight * scale); + vertices[25] = vertices[27] = vertices[29] = vertices[31] = this._height; + } + + /** + * Updates the vertical vertices. + * + */ + updateVerticalVertices() + { + const vertices = this.vertices; + + const w = this._leftWidth + this._rightWidth; + const scale = this._width > w ? 1.0 : this._width / w; + + vertices[2] = vertices[10] = vertices[18] = vertices[26] = this._leftWidth * scale; + vertices[4] = vertices[12] = vertices[20] = vertices[28] = this._width - (this._rightWidth * scale); + vertices[6] = vertices[14] = vertices[22] = vertices[30] = this._width; + } + + /** + * The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + */ + get width() + { + return this._width; + } + + set width(value) // eslint-disable-line require-jsdoc + { + this._width = value; + this._refresh(); + } + + /** + * The height of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + */ + get height() + { + return this._height; + } + + set height(value) // eslint-disable-line require-jsdoc + { + this._height = value; + this._refresh(); + } + + /** + * The width of the left column + * + * @member {number} + */ + get leftWidth() + { + return this._leftWidth; + } + + set leftWidth(value) // eslint-disable-line require-jsdoc + { + this._leftWidth = value; + this._refresh(); + } + + /** + * The width of the right column + * + * @member {number} + */ + get rightWidth() + { + return this._rightWidth; + } + + set rightWidth(value) // eslint-disable-line require-jsdoc + { + this._rightWidth = value; + this._refresh(); + } + + /** + * The height of the top row + * + * @member {number} + */ + get topHeight() + { + return this._topHeight; + } + + set topHeight(value) // eslint-disable-line require-jsdoc + { + this._topHeight = value; + this._refresh(); + } + + /** + * The height of the bottom row + * + * @member {number} + */ + get bottomHeight() + { + return this._bottomHeight; + } + + set bottomHeight(value) // eslint-disable-line require-jsdoc + { + this._bottomHeight = value; + this._refresh(); + } + + /** + * Refreshes NineSlicePlane coords. All of them. + */ + _refresh() + { + super._refresh(); + + const uvs = this.uvs; + const texture = this._texture; + + this._origWidth = texture.orig.width; + this._origHeight = texture.orig.height; + + const _uvw = 1.0 / this._origWidth; + const _uvh = 1.0 / this._origHeight; + + uvs[0] = uvs[8] = uvs[16] = uvs[24] = 0; + uvs[1] = uvs[3] = uvs[5] = uvs[7] = 0; + uvs[6] = uvs[14] = uvs[22] = uvs[30] = 1; + uvs[25] = uvs[27] = uvs[29] = uvs[31] = 1; + + uvs[2] = uvs[10] = uvs[18] = uvs[26] = _uvw * this._leftWidth; + uvs[4] = uvs[12] = uvs[20] = uvs[28] = 1 - (_uvw * this._rightWidth); + uvs[9] = uvs[11] = uvs[13] = uvs[15] = _uvh * this._topHeight; + uvs[17] = uvs[19] = uvs[21] = uvs[23] = 1 - (_uvh * this._bottomHeight); + + this.updateHorizontalVertices(); + this.updateVerticalVertices(); + + this.geometry.buffers[1].update(); + + this.multiplyUvs(); + } +} diff --git a/packages/mesh-extras/src/Plane.js b/packages/mesh-extras/src/Plane.js new file mode 100644 index 0000000..1c240c4 --- /dev/null +++ b/packages/mesh-extras/src/Plane.js @@ -0,0 +1,100 @@ +import Mesh2d from './Mesh2d'; + +/** + * The Plane allows you to draw a texture across several points and them manipulate these points + * + *```js + * for (let i = 0; i < 20; i++) { + * points.push(new PIXI.Point(i * 50, 0)); + * }; + * let Plane = new PIXI.Plane(PIXI.Texture.from("snake.png"), points); + * ``` + * + * @class + * @extends PIXI.Mesh + * @memberof PIXI + * + */ +export default class Plane extends Mesh2d +{ + /** + * @param {PIXI.Texture} texture - The texture to use on the Plane. + * @param {number} verticesX - The number of vertices in the x-axis + * @param {number} verticesY - The number of vertices in the y-axis + * @param {object} [opts] - an options object - add meshWidth and meshHeight, temporary object for PixiJS v5 alpha + */ + constructor(texture, verticesX, verticesY, opts = {}) + { + super(texture, new Float32Array(1), new Float32Array(1), new Uint16Array(1), 4); + + this.verticesX = verticesX || 10; + this.verticesY = verticesY || 10; + + this.meshWidth = opts.meshWidth || 0; + this.meshHeight = opts.meshHeight || 0; + + this.refresh(); + } + + /** + * Refreshes plane coordinates + * @private + */ + _refresh() + { + const texture = this._texture; + const total = this.verticesX * this.verticesY; + const verts = []; + const uvs = []; + const indices = []; + + const segmentsX = this.verticesX - 1; + const segmentsY = this.verticesY - 1; + + const sizeX = (this.meshWidth || texture.width) / segmentsX; + const sizeY = (this.meshHeight || texture.height) / segmentsY; + + for (let i = 0; i < total; i++) + { + const x = (i % this.verticesX); + const y = ((i / this.verticesX) | 0); + + verts.push(x * sizeX, y * sizeY); + + uvs.push(x / segmentsX, y / segmentsY); + } + + // cons + + const totalSub = segmentsX * segmentsY; + + for (let i = 0; i < totalSub; i++) + { + const xpos = i % segmentsX; + const ypos = (i / segmentsX) | 0; + + const value = (ypos * this.verticesX) + xpos; + const value2 = (ypos * this.verticesX) + xpos + 1; + const value3 = ((ypos + 1) * this.verticesX) + xpos; + const value4 = ((ypos + 1) * this.verticesX) + xpos + 1; + + indices.push(value, value2, value3); + indices.push(value2, value4, value3); + } + + this.vertices = new Float32Array(verts); + this.uvs = new Float32Array(uvs); + this.indices = new Uint16Array(indices); + + this.geometry.buffers[0].data = this.vertices; + this.geometry.buffers[1].data = this.uvs; + this.geometry.indexBuffer.data = this.indices; + + // ensure that the changes are uploaded + this.geometry.buffers[0].update(); + this.geometry.buffers[1].update(); + this.geometry.indexBuffer.update(); + + this.multiplyUvs(); + } +} diff --git a/packages/mesh-extras/src/Rope.js b/packages/mesh-extras/src/Rope.js new file mode 100644 index 0000000..9cfde38 --- /dev/null +++ b/packages/mesh-extras/src/Rope.js @@ -0,0 +1,182 @@ +import Mesh2d from './Mesh2d'; + +/** + * The rope allows you to draw a texture across several points and them manipulate these points + * + *```js + * for (let i = 0; i < 20; i++) { + * points.push(new PIXI.Point(i * 50, 0)); + * }; + * let rope = new PIXI.Rope(PIXI.Texture.from("snake.png"), points); + * ``` + * + * @class + * @extends PIXI.Mesh + * @memberof PIXI + * + */ +export default class Rope extends Mesh2d +{ + /** + * @param {PIXI.Texture} texture - The texture to use on the rope. + * @param {PIXI.Point[]} points - An array of {@link PIXI.Point} objects to construct this rope. + */ + constructor(texture, points) + { + super(texture, new Float32Array(points.length * 4), + new Float32Array(points.length * 4), + new Uint16Array(points.length * 2), + 5); + + /* + * @member {PIXI.Point[]} An array of points that determine the rope + */ + this.points = points; + this.refresh(); + } + /** + * Refreshes Rope indices and uvs + * @private + */ + _refresh() + { + const points = this.points; + + if (!points) return; + + const vertexBuffer = this.geometry.getAttribute('aVertexPosition'); + const uvBuffer = this.geometry.getAttribute('aTextureCoord'); + const indexBuffer = this.geometry.getIndex(); + + // if too little points, or texture hasn't got UVs set yet just move on. + if (points.length < 1 || !this.texture._uvs) + { + return; + } + + // if the number of points has changed we will need to recreate the arraybuffers + if (vertexBuffer.data.length / 4 !== points.length) + { + vertexBuffer.data = new Float32Array(points.length * 4); + uvBuffer.data = new Float32Array(points.length * 4); + indexBuffer.data = new Uint16Array(points.length * 2); + } + + const uvs = uvBuffer.data; + const indices = indexBuffer.data; + + uvs[0] = 0; + uvs[1] = 0; + uvs[2] = 0; + uvs[3] = 1; + + indices[0] = 0; + indices[1] = 1; + + const total = points.length; + + for (let i = 1; i < total; i++) + { + // time to do some smart drawing! + let index = i * 4; + const amount = i / (total - 1); + + uvs[index] = amount; + uvs[index + 1] = 0; + + uvs[index + 2] = amount; + uvs[index + 3] = 1; + + index = i * 2; + indices[index] = index; + indices[index + 1] = index + 1; + } + + // ensure that the changes are uploaded + uvBuffer.update(); + indexBuffer.update(); + + this.multiplyUvs(); + this.refreshVertices(); + } + + /** + * refreshes vertices of Rope mesh + */ + refreshVertices() + { + const points = this.points; + + if (points.length < 1) + { + return; + } + + let lastPoint = points[0]; + let nextPoint; + let perpX = 0; + let perpY = 0; + + // this.count -= 0.2; + + const vertices = this.vertices; + const total = points.length; + + for (let i = 0; i < total; i++) + { + const point = points[i]; + const index = i * 4; + + if (i < points.length - 1) + { + nextPoint = points[i + 1]; + } + else + { + nextPoint = point; + } + + perpY = -(nextPoint.x - lastPoint.x); + perpX = nextPoint.y - lastPoint.y; + + let ratio = (1 - (i / (total - 1))) * 10; + + if (ratio > 1) + { + ratio = 1; + } + + const perpLength = Math.sqrt((perpX * perpX) + (perpY * perpY)); + const num = this._texture.height / 2; // (20 + Math.abs(Math.sin((i + this.count) * 0.3) * 50) )* ratio; + + perpX /= perpLength; + perpY /= perpLength; + + perpX *= num; + perpY *= num; + + vertices[index] = point.x + perpX; + vertices[index + 1] = point.y + perpY; + vertices[index + 2] = point.x - perpX; + vertices[index + 3] = point.y - perpY; + + lastPoint = point; + } + + this.geometry.buffers[0].update(); + } + + /** + * Updates the object transform for rendering + * + * @private + */ + updateTransform() + { + if (this.autoUpdate) + { + this.refreshVertices(); + } + this.containerUpdateTransform(); + } +} diff --git a/packages/mesh-extras/src/index.js b/packages/mesh-extras/src/index.js new file mode 100644 index 0000000..decf454 --- /dev/null +++ b/packages/mesh-extras/src/index.js @@ -0,0 +1,4 @@ +export { default as Mesh2d } from './Mesh2d'; +export { default as Plane } from './Plane'; +export { default as NineSlicePlane } from './NineSlicePlane'; +export { default as Rope } from './Rope'; diff --git a/packages/mesh-extras/src/mesh.frag b/packages/mesh-extras/src/mesh.frag new file mode 100644 index 0000000..6096983 --- /dev/null +++ b/packages/mesh-extras/src/mesh.frag @@ -0,0 +1,9 @@ +varying vec2 vTextureCoord; +uniform vec4 uColor; + +uniform sampler2D uSampler; + +void main(void) +{ + gl_FragColor = texture2D(uSampler, vTextureCoord) * uColor; +} diff --git a/packages/mesh-extras/src/mesh.vert b/packages/mesh-extras/src/mesh.vert new file mode 100644 index 0000000..0526df9 --- /dev/null +++ b/packages/mesh-extras/src/mesh.vert @@ -0,0 +1,15 @@ +attribute vec2 aVertexPosition; +attribute vec2 aTextureCoord; + +uniform mat3 projectionMatrix; +uniform mat3 translationMatrix; +uniform mat3 uTextureMatrix; + +varying vec2 vTextureCoord; + +void main(void) +{ + gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); + + vTextureCoord = (uTextureMatrix * vec3(aTextureCoord, 1.0)).xy; +} diff --git a/packages/mesh-extras/test/.eslintrc.json b/packages/mesh-extras/test/.eslintrc.json new file mode 100644 index 0000000..2ad8efb --- /dev/null +++ b/packages/mesh-extras/test/.eslintrc.json @@ -0,0 +1,12 @@ +{ + "globals": { + "expect": false, + "assert": false, + "sinon": false, + "PIXI": false + }, + "rules": { + "func-names": 0, + "no-unused-expressions": 0 + } +} \ No newline at end of file diff --git a/packages/mesh-extras/test/Plane.js b/packages/mesh-extras/test/Plane.js new file mode 100644 index 0000000..f9b1c25 --- /dev/null +++ b/packages/mesh-extras/test/Plane.js @@ -0,0 +1,60 @@ +const { Plane } = require('../'); +const { isWebGLSupported, skipHello } = require('@pixi/utils'); +const { Loader } = require('@pixi/loaders'); +const { Point } = require('@pixi/math'); +const { RenderTexture, Texture } = require('@pixi/core'); + +skipHello(); + +function withGL(fn) +{ + return isWebGLSupported() ? fn : undefined; +} + +// TODO: fix with webglrenderer +describe('PIXI.mesh.Plane', function () +{ + it.skip('should create a plane from an external image', withGL(function (done) + { + const loader = new Loader(); + + loader.add('testBitmap', `file://${__dirname}/resources/bitmap-1.png`) + .load(function (loader, resources) + { + const plane = new Plane(resources.testBitmap.texture, 100, 100); + + expect(plane.verticesX).to.equal(100); + expect(plane.verticesY).to.equal(100); + done(); + }); + })); + + it.skip('should create a new empty textured Plane', withGL(function () + { + const plane = new Plane(Texture.EMPTY, 100, 100); + + expect(plane.verticesX).to.equal(100); + expect(plane.verticesY).to.equal(100); + })); + + describe('containsPoint', function () + { + it.skip('should return true when point inside', withGL(function () + { + const point = new Point(10, 10); + const texture = new RenderTexture.create(20, 30); + const plane = new Plane(texture, 100, 100); + + expect(plane.containsPoint(point)).to.be.true; + })); + + it.skip('should return false when point outside', withGL(function () + { + const point = new Point(100, 100); + const texture = new RenderTexture.create(20, 30); + const plane = new Plane(texture, 100, 100); + + expect(plane.containsPoint(point)).to.be.false; + })); + }); +}); diff --git a/packages/mesh-extras/test/index.js b/packages/mesh-extras/test/index.js new file mode 100644 index 0000000..d767624 --- /dev/null +++ b/packages/mesh-extras/test/index.js @@ -0,0 +1 @@ +require('./Plane'); diff --git a/packages/mesh-extras/test/resources/bitmap-1.png b/packages/mesh-extras/test/resources/bitmap-1.png new file mode 100644 index 0000000..1284fb8 --- /dev/null +++ b/packages/mesh-extras/test/resources/bitmap-1.png Binary files differ diff --git a/packages/mesh/package.json b/packages/mesh/package.json index 8b1f8d9..10bd8e3 100644 --- a/packages/mesh/package.json +++ b/packages/mesh/package.json @@ -18,22 +18,16 @@ "publishConfig": { "access": "public" }, - "scripts": { - "test": "floss --path test" - }, "files": [ "lib" ], "dependencies": { - "@pixi/canvas-renderer": "^5.0.0-alpha.2", "@pixi/constants": "^5.0.0-alpha.2", "@pixi/core": "^5.0.0-alpha.2", "@pixi/display": "^5.0.0-alpha.2", - "@pixi/math": "^5.0.0-alpha.2", - "@pixi/utils": "^5.0.0-alpha.2" + "@pixi/math": "^5.0.0-alpha.2" }, "devDependencies": { - "@pixi/loaders": "^5.0.0-alpha.2", "floss": "^2.1.3" } } diff --git a/packages/mesh/src/Mesh.js b/packages/mesh/src/Mesh.js index e7c8f9e..1f35b7a 100644 --- a/packages/mesh/src/Mesh.js +++ b/packages/mesh/src/Mesh.js @@ -1,263 +1,220 @@ -import RawMesh from './RawMesh'; -import { Geometry, Program, Shader, Texture, TextureMatrix } from '@pixi/core'; -import { Matrix } from '@pixi/math'; -import { BLEND_MODES } from '@pixi/constants'; -import { hex2rgb, premultiplyRgba } from '@pixi/utils'; -import vertex from './mesh.vert'; -import fragment from './mesh.frag'; +import { State } from '@pixi/core'; +import { DRAW_MODES } from '@pixi/constants'; +import { Point, Polygon } from '@pixi/math'; +import { Container } from '@pixi/display'; -let meshProgram; +const tempPoint = new Point(); +const tempPolygon = new Polygon(); /** - * Base mesh class + * Base mesh class. + * The reason for this class is to empower you to have maximum flexibility to render any kind of webGL you can think of. + * This class assumes a certain level of webGL knowledge. + * If you know a bit this should abstract enough away to make you life easier! + * Pretty much ALL WebGL can be broken down into the following: + * Geometry - The structure and data for the mesh. This can include anything from positions, uvs, normals, colors etc.. + * Shader - This is the shader that pixi will render the geometry with. (attributes in the shader must match the geometry!) + * Uniforms - These are the values passed to the shader when the mesh is rendered. + * As a shader can be reused across multiple objects, it made sense to allow uniforms to exist outside of the shader + * State - This is the state of WebGL required to render the mesh. + * Through a combination of the above elements you can render anything you want, 2D or 3D! + * * @class * @extends PIXI.Container * @memberof PIXI */ -export default class Mesh extends RawMesh +export default class Mesh extends Container { /** - * @param {PIXI.Texture} [texture=Texture.EMPTY] - The texture to use - * @param {Float32Array} [vertices] - if you want to specify the vertices - * @param {Float32Array} [uvs] - if you want to specify the uvs - * @param {Uint16Array} [indices] - if you want to specify the indices - * @param {number} [drawMode] - the drawMode, can be any of the Mesh.DRAW_MODES consts + * @param {PIXI.Geometry} geometry the geometry the mesh will use + * @param {PIXI.Shader} shader the shader the mesh will use + * @param {PIXI.State} state the state that the webGL context is required to be in to render the mesh + * @param {number} drawMode the drawMode, can be any of the PIXI.DRAW_MODES consts */ - constructor(texture = Texture.EMPTY, vertices, uvs, indices, drawMode) + constructor(geometry, shader, state, drawMode = DRAW_MODES.TRIANGLES) { - const geometry = new Geometry(); - - if (!meshProgram) - { - meshProgram = new Program(vertex, fragment); - } - - geometry.addAttribute('aVertexPosition', vertices) - .addAttribute('aTextureCoord', uvs) - .addIndex(indices); - - geometry.getAttribute('aVertexPosition').static = false; - - const uniforms = { - uSampler: texture, - uTextureMatrix: Matrix.IDENTITY, - alpha: 1, - uColor: new Float32Array([1, 1, 1, 1]), - }; - - super(geometry, new Shader(meshProgram, uniforms), null, drawMode); + super(); /** - * The Uvs of the Mesh - * - * @member {Float32Array} + * the geometry the mesh will use + * @type {PIXI.Geometry} */ - this.uvs = geometry.getAttribute('aTextureCoord').data; + this.geometry = geometry; /** - * An array of vertices - * - * @member {Float32Array} + * the shader the mesh will use + * @type {PIXI.Shader} */ - this.vertices = geometry.getAttribute('aVertexPosition').data; - - this.uniforms = uniforms; + this.shader = shader; /** - * The texture of the Mesh - * - * @member {PIXI.Texture} - * @default PIXI.Texture.EMPTY - * @private + * the webGL state the mesh requires to render + * @type {PIXI.State} */ - this.texture = texture; + this.state = state || new State(); /** - * The tint applied to the mesh. This is a [r,g,b] value. A value of [1,1,1] will remove any - * tint effect. + * The way the Mesh should be drawn, can be any of the {@link PIXI.Mesh.DRAW_MODES} consts * * @member {number} + * @see PIXI.Mesh.DRAW_MODES + */ + this.drawMode = drawMode; + + /** + * The way uniforms that will be used by the mesh's shader. + * @member {Object} + */ + + /** + * A map of renderer IDs to webgl render data + * * @private + * @member {object} */ - this._tintRGB = new Float32Array([1, 1, 1]); - - // Set default tint - this.tint = 0xFFFFFF; - - this.blendMode = BLEND_MODES.NORMAL; + this._glDatas = {}; /** - * TextureMatrix instance for this Mesh, used to track Texture changes + * Plugin that is responsible for rendering this element. + * Allows to customize the rendering process without overriding '_render' & '_renderCanvas' methods. * - * @member {PIXI.TextureMatrix} - * @readonly + * @member {string} + * @default 'mesh' */ - this.uvMatrix = new TextureMatrix(this._texture); + this.pluginName = 'mesh'; - /** - * whether or not upload uvMatrix to shader - * if its false, then uvs should be pre-multiplied - * if you change it for generated mesh, please call 'refresh(true)' - * @member {boolean} - * @default false - */ - this.uploadUvMatrix = false; - - /** - * Uploads vertices buffer every frame, like in PixiJS V3 and V4. - * - * @member {boolean} - * @default true - */ - this.autoUpdate = true; + this.start = 0; + this.size = 0; } /** - * The tint applied to the Rope. This is a hex value. A value of - * 0xFFFFFF will remove any tint effect. + * Renders the object using the WebGL renderer * - * @member {number} - * @memberof PIXI.Sprite# - * @default 0xFFFFFF + * @param {PIXI.Renderer} renderer a reference to the WebGL renderer + * @private */ - get tint() + _render(renderer) { - return this._tint; + renderer.batch.setObjectRenderer(renderer.plugins[this.pluginName]); + renderer.plugins[this.pluginName].render(this); } /** - * Sets the tint of the rope. + * Updates the bounds of the mesh as a rectangle. The bounds calculation takes the worldTransform into account. + * there must be a aVertexPosition attribute present in the geometry for bounds to be calculated correctly. * - * @param {number} value - The value to set to. + * @private */ - set tint(value) + _calculateBounds() { - this._tint = value; - - hex2rgb(this._tint, this._tintRGB); - } - - /** - * The blend mode to be applied to the sprite. Set to `PIXI.BLEND_MODES.NORMAL` to remove any blend mode. - * - * @member {number} - * @default PIXI.BLEND_MODES.NORMAL - * @see PIXI.BLEND_MODES - */ - get blendMode() - { - return this.state.blendMode; - } - - set blendMode(value) // eslint-disable-line require-jsdoc - { - this.state.blendMode = value; - } - - /** - * The texture that the mesh uses. - * - * @member {PIXI.Texture} - */ - get texture() - { - return this._texture; - } - - set texture(value) // eslint-disable-line require-jsdoc - { - if (this._texture === value) + // The position property could be set manually? + if (this.geometry.attributes.aVertexPosition) { - return; + const vertices = this.geometry.getAttribute('aVertexPosition').data; + + // TODO - we can cache local bounds and use them if they are dirty (like graphics) + this._bounds.addVertices(this.transform, vertices, 0, vertices.length); + } + } + + /** + * Tests if a point is inside this mesh. Works only for TRIANGLE_MESH + * + * @param {PIXI.Point} point the point to test + * @return {boolean} the result of the test + */ + containsPoint(point) + { + if (!this.getBounds().contains(point.x, point.y)) + { + return false; } - this._texture = value; - this.uniforms.uSampler = this.texture; + this.worldTransform.applyInverse(point, tempPoint); - if (value) + const vertices = this.geometry.getAttribute('aVertexPosition').data; + + const points = tempPolygon.points; + const indices = this.geometry.getIndex().data; + const len = indices.length; + const step = this.drawMode === 4 ? 3 : 1; + + for (let i = 0; i + 2 < len; i += step) { - // wait for the texture to load - if (value.baseTexture.valid) + const ind0 = indices[i] * 2; + const ind1 = indices[i + 1] * 2; + const ind2 = indices[i + 2] * 2; + + points[0] = vertices[ind0]; + points[1] = vertices[ind0 + 1]; + points[2] = vertices[ind1]; + points[3] = vertices[ind1 + 1]; + points[4] = vertices[ind2]; + points[5] = vertices[ind2 + 1]; + + if (tempPolygon.contains(tempPoint.x, tempPoint.y)) { - this._onTextureUpdate(); + return true; + } + } + + return false; + } + + /** + * Destroys the Mesh object. + * + * @param {object|boolean} [options] - Options parameter. A boolean will act as if all + * options have been set to that value + * @param {boolean} [options.children=false] - if set to true, all the children will have + * their destroy method called as well. 'options' will be passed on to those calls. + * @param {boolean} [options.texture=false] - Only used for child Sprites if options.children is set to true + * Should it destroy the texture of the child sprite + * @param {boolean} [options.baseTexture=false] - Only used for child Sprites if options.children is set to true + * Should it destroy the base texture of the child sprite + */ + destroy(options) + { + // for each webgl data entry, destroy the WebGLGraphicsData + for (const id in this._glDatas) + { + const data = this._glDatas[id]; + + if (data.destroy) + { + data.destroy(); } else { - value.once('update', this._onTextureUpdate, this); + if (data.vertexBuffer) + { + data.vertexBuffer.destroy(); + data.vertexBuffer = null; + } + if (data.indexBuffer) + { + data.indexBuffer.destroy(); + data.indexBuffer = null; + } + if (data.uvBuffer) + { + data.uvBuffer.destroy(); + data.uvBuffer = null; + } + if (data.vao) + { + data.vao.destroy(); + data.vao = null; + } } } - } - _render(renderer) - { - const baseTex = this._texture.baseTexture; + this._glDatas = null; - premultiplyRgba(this._tintRGB, this.worldAlpha, this.uniforms.uColor, baseTex.premultiplyAlpha); - super._render(renderer); - } - /** - * When the texture is updated, this event will fire to update the scale and frame - * - * @private - */ - _onTextureUpdate() - { - // constructor texture update stop - if (!this.uvMatrix) - { - return; - } - this.uvMatrix.texture = this._texture; - this.refresh(); - } + this.geometry = null; + this.shader = null; + this.state = null; - /** - * multiplies uvs only if uploadUvMatrix is false - * call it after you change uvs manually - * make sure that texture is valid - */ - multiplyUvs() - { - if (!this.uploadUvMatrix) - { - this.uvMatrix.multiplyUvs(this.uvs); - } - } - - /** - * Refreshes uvs for generated meshes (rope, plane) - * sometimes refreshes vertices too - * - * @param {boolean} [forceUpdate=false] if true, matrices will be updated any case - */ - refresh(forceUpdate) - { - if (this.uvMatrix.update(forceUpdate)) - { - this._refresh(); - } - } - - /** - * Updates the object transform for rendering - * - * @private - */ - updateTransform() - { - if (this.autoUpdate) - { - this.geometry.buffers[0].update(); - } - this.containerUpdateTransform(); - } - - /** - * re-calculates mesh coords - * @private - */ - _refresh() - { - /* empty */ + super.destroy(options); } } diff --git a/packages/mesh/src/MeshRenderer.js b/packages/mesh/src/MeshRenderer.js index 12b159b..d7baf9b 100644 --- a/packages/mesh/src/MeshRenderer.js +++ b/packages/mesh/src/MeshRenderer.js @@ -36,7 +36,7 @@ /** * renders mesh * @private - * @param {PIXI.RawMesh} mesh mesh instance + * @param {PIXI.Mesh} mesh mesh instance */ render(mesh) { diff --git a/packages/mesh/src/NineSlicePlane.js b/packages/mesh/src/NineSlicePlane.js deleted file mode 100644 index 0bae92c..0000000 --- a/packages/mesh/src/NineSlicePlane.js +++ /dev/null @@ -1,270 +0,0 @@ -import Plane from './Plane'; - -const DEFAULT_BORDER_SIZE = 10; - -/** - * The NineSlicePlane allows you to stretch a texture using 9-slice scaling. The corners will remain unscaled (useful - * for buttons with rounded corners for example) and the other areas will be scaled horizontally and or vertically - * - *```js - * let Plane9 = new PIXI.NineSlicePlane(PIXI.Texture.from('BoxWithRoundedCorners.png'), 15, 15, 15, 15); - * ``` - *
- *      A                          B
- *    +---+----------------------+---+
- *  C | 1 |          2           | 3 |
- *    +---+----------------------+---+
- *    |   |                      |   |
- *    | 4 |          5           | 6 |
- *    |   |                      |   |
- *    +---+----------------------+---+
- *  D | 7 |          8           | 9 |
- *    +---+----------------------+---+
-
- *  When changing this objects width and/or height:
- *     areas 1 3 7 and 9 will remain unscaled.
- *     areas 2 and 8 will be stretched horizontally
- *     areas 4 and 6 will be stretched vertically
- *     area 5 will be stretched both horizontally and vertically
- * 
- * - * @class - * @extends PIXI.Plane - * @memberof PIXI - * - */ -export default class NineSlicePlane extends Plane -{ - /** - * @param {PIXI.Texture} texture - The texture to use on the NineSlicePlane. - * @param {int} [leftWidth=10] size of the left vertical bar (A) - * @param {int} [topHeight=10] size of the top horizontal bar (C) - * @param {int} [rightWidth=10] size of the right vertical bar (B) - * @param {int} [bottomHeight=10] size of the bottom horizontal bar (D) - */ - constructor(texture, leftWidth, topHeight, rightWidth, bottomHeight) - { - super(texture, 4, 4); - - this._origWidth = texture.orig.width; - this._origHeight = texture.orig.height; - - /** - * The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane - * - * @member {number} - * @memberof PIXI.NineSlicePlane# - * @override - */ - this._width = this._origWidth; - - /** - * The height of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane - * - * @member {number} - * @memberof PIXI.NineSlicePlane# - * @override - */ - this._height = this._origHeight; - - /** - * The width of the left column (a) - * - * @member {number} - * @memberof PIXI.NineSlicePlane# - * @override - */ - this._leftWidth = typeof leftWidth !== 'undefined' ? leftWidth : DEFAULT_BORDER_SIZE; - - /** - * The width of the right column (b) - * - * @member {number} - * @memberof PIXI.NineSlicePlane# - * @override - */ - this._rightWidth = typeof rightWidth !== 'undefined' ? rightWidth : DEFAULT_BORDER_SIZE; - - /** - * The height of the top row (c) - * - * @member {number} - * @memberof PIXI.NineSlicePlane# - * @override - */ - this._topHeight = typeof topHeight !== 'undefined' ? topHeight : DEFAULT_BORDER_SIZE; - - /** - * The height of the bottom row (d) - * - * @member {number} - * @memberof PIXI.NineSlicePlane# - * @override - */ - this._bottomHeight = typeof bottomHeight !== 'undefined' ? bottomHeight : DEFAULT_BORDER_SIZE; - - this.refresh(true); - } - - /** - * Updates the horizontal vertices. - * - */ - updateHorizontalVertices() - { - const vertices = this.vertices; - - const h = this._topHeight + this._bottomHeight; - const scale = this._height > h ? 1.0 : this._height / h; - - vertices[9] = vertices[11] = vertices[13] = vertices[15] = this._topHeight * scale; - vertices[17] = vertices[19] = vertices[21] = vertices[23] = this._height - (this._bottomHeight * scale); - vertices[25] = vertices[27] = vertices[29] = vertices[31] = this._height; - } - - /** - * Updates the vertical vertices. - * - */ - updateVerticalVertices() - { - const vertices = this.vertices; - - const w = this._leftWidth + this._rightWidth; - const scale = this._width > w ? 1.0 : this._width / w; - - vertices[2] = vertices[10] = vertices[18] = vertices[26] = this._leftWidth * scale; - vertices[4] = vertices[12] = vertices[20] = vertices[28] = this._width - (this._rightWidth * scale); - vertices[6] = vertices[14] = vertices[22] = vertices[30] = this._width; - } - - /** - * The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane - * - * @member {number} - */ - get width() - { - return this._width; - } - - set width(value) // eslint-disable-line require-jsdoc - { - this._width = value; - this._refresh(); - } - - /** - * The height of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane - * - * @member {number} - */ - get height() - { - return this._height; - } - - set height(value) // eslint-disable-line require-jsdoc - { - this._height = value; - this._refresh(); - } - - /** - * The width of the left column - * - * @member {number} - */ - get leftWidth() - { - return this._leftWidth; - } - - set leftWidth(value) // eslint-disable-line require-jsdoc - { - this._leftWidth = value; - this._refresh(); - } - - /** - * The width of the right column - * - * @member {number} - */ - get rightWidth() - { - return this._rightWidth; - } - - set rightWidth(value) // eslint-disable-line require-jsdoc - { - this._rightWidth = value; - this._refresh(); - } - - /** - * The height of the top row - * - * @member {number} - */ - get topHeight() - { - return this._topHeight; - } - - set topHeight(value) // eslint-disable-line require-jsdoc - { - this._topHeight = value; - this._refresh(); - } - - /** - * The height of the bottom row - * - * @member {number} - */ - get bottomHeight() - { - return this._bottomHeight; - } - - set bottomHeight(value) // eslint-disable-line require-jsdoc - { - this._bottomHeight = value; - this._refresh(); - } - - /** - * Refreshes NineSlicePlane coords. All of them. - */ - _refresh() - { - super._refresh(); - - const uvs = this.uvs; - const texture = this._texture; - - this._origWidth = texture.orig.width; - this._origHeight = texture.orig.height; - - const _uvw = 1.0 / this._origWidth; - const _uvh = 1.0 / this._origHeight; - - uvs[0] = uvs[8] = uvs[16] = uvs[24] = 0; - uvs[1] = uvs[3] = uvs[5] = uvs[7] = 0; - uvs[6] = uvs[14] = uvs[22] = uvs[30] = 1; - uvs[25] = uvs[27] = uvs[29] = uvs[31] = 1; - - uvs[2] = uvs[10] = uvs[18] = uvs[26] = _uvw * this._leftWidth; - uvs[4] = uvs[12] = uvs[20] = uvs[28] = 1 - (_uvw * this._rightWidth); - uvs[9] = uvs[11] = uvs[13] = uvs[15] = _uvh * this._topHeight; - uvs[17] = uvs[19] = uvs[21] = uvs[23] = 1 - (_uvh * this._bottomHeight); - - this.updateHorizontalVertices(); - this.updateVerticalVertices(); - - this.geometry.buffers[1].update(); - - this.multiplyUvs(); - } -} diff --git a/packages/mesh/src/Plane.js b/packages/mesh/src/Plane.js deleted file mode 100644 index c416b4c..0000000 --- a/packages/mesh/src/Plane.js +++ /dev/null @@ -1,100 +0,0 @@ -import Mesh from './Mesh'; - -/** - * The Plane allows you to draw a texture across several points and them manipulate these points - * - *```js - * for (let i = 0; i < 20; i++) { - * points.push(new PIXI.Point(i * 50, 0)); - * }; - * let Plane = new PIXI.Plane(PIXI.Texture.from("snake.png"), points); - * ``` - * - * @class - * @extends PIXI.Mesh - * @memberof PIXI - * - */ -export default class Plane extends Mesh -{ - /** - * @param {PIXI.Texture} texture - The texture to use on the Plane. - * @param {number} verticesX - The number of vertices in the x-axis - * @param {number} verticesY - The number of vertices in the y-axis - * @param {object} [opts] - an options object - add meshWidth and meshHeight, temporary object for PixiJS v5 alpha - */ - constructor(texture, verticesX, verticesY, opts = {}) - { - super(texture, new Float32Array(1), new Float32Array(1), new Uint16Array(1), 4); - - this.verticesX = verticesX || 10; - this.verticesY = verticesY || 10; - - this.meshWidth = opts.meshWidth || 0; - this.meshHeight = opts.meshHeight || 0; - - this.refresh(); - } - - /** - * Refreshes plane coordinates - * @private - */ - _refresh() - { - const texture = this._texture; - const total = this.verticesX * this.verticesY; - const verts = []; - const uvs = []; - const indices = []; - - const segmentsX = this.verticesX - 1; - const segmentsY = this.verticesY - 1; - - const sizeX = (this.meshWidth || texture.width) / segmentsX; - const sizeY = (this.meshHeight || texture.height) / segmentsY; - - for (let i = 0; i < total; i++) - { - const x = (i % this.verticesX); - const y = ((i / this.verticesX) | 0); - - verts.push(x * sizeX, y * sizeY); - - uvs.push(x / segmentsX, y / segmentsY); - } - - // cons - - const totalSub = segmentsX * segmentsY; - - for (let i = 0; i < totalSub; i++) - { - const xpos = i % segmentsX; - const ypos = (i / segmentsX) | 0; - - const value = (ypos * this.verticesX) + xpos; - const value2 = (ypos * this.verticesX) + xpos + 1; - const value3 = ((ypos + 1) * this.verticesX) + xpos; - const value4 = ((ypos + 1) * this.verticesX) + xpos + 1; - - indices.push(value, value2, value3); - indices.push(value2, value4, value3); - } - - this.vertices = new Float32Array(verts); - this.uvs = new Float32Array(uvs); - this.indices = new Uint16Array(indices); - - this.geometry.buffers[0].data = this.vertices; - this.geometry.buffers[1].data = this.uvs; - this.geometry.indexBuffer.data = this.indices; - - // ensure that the changes are uploaded - this.geometry.buffers[0].update(); - this.geometry.buffers[1].update(); - this.geometry.indexBuffer.update(); - - this.multiplyUvs(); - } -} diff --git a/packages/mesh/src/RawMesh.js b/packages/mesh/src/RawMesh.js deleted file mode 100644 index 7297e94..0000000 --- a/packages/mesh/src/RawMesh.js +++ /dev/null @@ -1,220 +0,0 @@ -import { State } from '@pixi/core'; -import { DRAW_MODES } from '@pixi/constants'; -import { Point, Polygon } from '@pixi/math'; -import { Container } from '@pixi/display'; - -const tempPoint = new Point(); -const tempPolygon = new Polygon(); - -/** - * Base mesh class. - * The reason for this class is to empower you to have maximum flexibility to render any kind of webGL you can think of. - * This class assumes a certain level of webGL knowledge. - * If you know a bit this should abstract enough away to make you life easier! - * Pretty much ALL WebGL can be broken down into the following: - * Geometry - The structure and data for the mesh. This can include anything from positions, uvs, normals, colors etc.. - * Shader - This is the shader that pixi will render the geometry with. (attributes in the shader must match the geometry!) - * Uniforms - These are the values passed to the shader when the mesh is rendered. - * As a shader can be reused across multiple objects, it made sense to allow uniforms to exist outside of the shader - * State - This is the state of WebGL required to render the mesh. - * Through a combination of the above elements you can render anything you want, 2D or 3D! - * - * @class - * @extends PIXI.Container - * @memberof PIXI - */ -export default class RawMesh extends Container -{ - /** - * @param {PIXI.Geometry} geometry the geometry the mesh will use - * @param {PIXI.Shader} shader the shader the mesh will use - * @param {PIXI.State} state the state that the webGL context is required to be in to render the mesh - * @param {number} drawMode the drawMode, can be any of the PIXI.DRAW_MODES consts - */ - constructor(geometry, shader, state, drawMode = DRAW_MODES.TRIANGLES) - { - super(); - - /** - * the geometry the mesh will use - * @type {PIXI.Geometry} - */ - this.geometry = geometry; - - /** - * the shader the mesh will use - * @type {PIXI.Shader} - */ - this.shader = shader; - - /** - * the webGL state the mesh requires to render - * @type {PIXI.State} - */ - this.state = state || new State(); - - /** - * The way the Mesh should be drawn, can be any of the {@link PIXI.RawMesh.DRAW_MODES} consts - * - * @member {number} - * @see PIXI.RawMesh.DRAW_MODES - */ - this.drawMode = drawMode; - - /** - * The way uniforms that will be used by the mesh's shader. - * @member {Object} - */ - - /** - * A map of renderer IDs to webgl render data - * - * @private - * @member {object} - */ - this._glDatas = {}; - - /** - * Plugin that is responsible for rendering this element. - * Allows to customize the rendering process without overriding '_render' & '_renderCanvas' methods. - * - * @member {string} - * @default 'mesh' - */ - this.pluginName = 'mesh'; - - this.start = 0; - this.size = 0; - } - - /** - * Renders the object using the WebGL renderer - * - * @param {PIXI.Renderer} renderer a reference to the WebGL renderer - * @private - */ - _render(renderer) - { - renderer.batch.setObjectRenderer(renderer.plugins[this.pluginName]); - renderer.plugins[this.pluginName].render(this); - } - - /** - * Updates the bounds of the mesh as a rectangle. The bounds calculation takes the worldTransform into account. - * there must be a aVertexPosition attribute present in the geometry for bounds to be calculated correctly. - * - * @private - */ - _calculateBounds() - { - // The position property could be set manually? - if (this.geometry.attributes.aVertexPosition) - { - const vertices = this.geometry.getAttribute('aVertexPosition').data; - - // TODO - we can cache local bounds and use them if they are dirty (like graphics) - this._bounds.addVertices(this.transform, vertices, 0, vertices.length); - } - } - - /** - * Tests if a point is inside this mesh. Works only for TRIANGLE_MESH - * - * @param {PIXI.Point} point the point to test - * @return {boolean} the result of the test - */ - containsPoint(point) - { - if (!this.getBounds().contains(point.x, point.y)) - { - return false; - } - - this.worldTransform.applyInverse(point, tempPoint); - - const vertices = this.geometry.getAttribute('aVertexPosition').data; - - const points = tempPolygon.points; - const indices = this.geometry.getIndex().data; - const len = indices.length; - const step = this.drawMode === 4 ? 3 : 1; - - for (let i = 0; i + 2 < len; i += step) - { - const ind0 = indices[i] * 2; - const ind1 = indices[i + 1] * 2; - const ind2 = indices[i + 2] * 2; - - points[0] = vertices[ind0]; - points[1] = vertices[ind0 + 1]; - points[2] = vertices[ind1]; - points[3] = vertices[ind1 + 1]; - points[4] = vertices[ind2]; - points[5] = vertices[ind2 + 1]; - - if (tempPolygon.contains(tempPoint.x, tempPoint.y)) - { - return true; - } - } - - return false; - } - - /** - * Destroys the RawMesh object. - * - * @param {object|boolean} [options] - Options parameter. A boolean will act as if all - * options have been set to that value - * @param {boolean} [options.children=false] - if set to true, all the children will have - * their destroy method called as well. 'options' will be passed on to those calls. - * @param {boolean} [options.texture=false] - Only used for child Sprites if options.children is set to true - * Should it destroy the texture of the child sprite - * @param {boolean} [options.baseTexture=false] - Only used for child Sprites if options.children is set to true - * Should it destroy the base texture of the child sprite - */ - destroy(options) - { - // for each webgl data entry, destroy the WebGLGraphicsData - for (const id in this._glDatas) - { - const data = this._glDatas[id]; - - if (data.destroy) - { - data.destroy(); - } - else - { - if (data.vertexBuffer) - { - data.vertexBuffer.destroy(); - data.vertexBuffer = null; - } - if (data.indexBuffer) - { - data.indexBuffer.destroy(); - data.indexBuffer = null; - } - if (data.uvBuffer) - { - data.uvBuffer.destroy(); - data.uvBuffer = null; - } - if (data.vao) - { - data.vao.destroy(); - data.vao = null; - } - } - } - - this._glDatas = null; - - this.geometry = null; - this.shader = null; - this.state = null; - - super.destroy(options); - } -} diff --git a/packages/mesh/src/Rope.js b/packages/mesh/src/Rope.js deleted file mode 100644 index b4f85d3..0000000 --- a/packages/mesh/src/Rope.js +++ /dev/null @@ -1,182 +0,0 @@ -import Mesh from './Mesh'; - -/** - * The rope allows you to draw a texture across several points and them manipulate these points - * - *```js - * for (let i = 0; i < 20; i++) { - * points.push(new PIXI.Point(i * 50, 0)); - * }; - * let rope = new PIXI.Rope(PIXI.Texture.from("snake.png"), points); - * ``` - * - * @class - * @extends PIXI.Mesh - * @memberof PIXI - * - */ -export default class Rope extends Mesh -{ - /** - * @param {PIXI.Texture} texture - The texture to use on the rope. - * @param {PIXI.Point[]} points - An array of {@link PIXI.Point} objects to construct this rope. - */ - constructor(texture, points) - { - super(texture, new Float32Array(points.length * 4), - new Float32Array(points.length * 4), - new Uint16Array(points.length * 2), - 5); - - /* - * @member {PIXI.Point[]} An array of points that determine the rope - */ - this.points = points; - this.refresh(); - } - /** - * Refreshes Rope indices and uvs - * @private - */ - _refresh() - { - const points = this.points; - - if (!points) return; - - const vertexBuffer = this.geometry.getAttribute('aVertexPosition'); - const uvBuffer = this.geometry.getAttribute('aTextureCoord'); - const indexBuffer = this.geometry.getIndex(); - - // if too little points, or texture hasn't got UVs set yet just move on. - if (points.length < 1 || !this.texture._uvs) - { - return; - } - - // if the number of points has changed we will need to recreate the arraybuffers - if (vertexBuffer.data.length / 4 !== points.length) - { - vertexBuffer.data = new Float32Array(points.length * 4); - uvBuffer.data = new Float32Array(points.length * 4); - indexBuffer.data = new Uint16Array(points.length * 2); - } - - const uvs = uvBuffer.data; - const indices = indexBuffer.data; - - uvs[0] = 0; - uvs[1] = 0; - uvs[2] = 0; - uvs[3] = 1; - - indices[0] = 0; - indices[1] = 1; - - const total = points.length; - - for (let i = 1; i < total; i++) - { - // time to do some smart drawing! - let index = i * 4; - const amount = i / (total - 1); - - uvs[index] = amount; - uvs[index + 1] = 0; - - uvs[index + 2] = amount; - uvs[index + 3] = 1; - - index = i * 2; - indices[index] = index; - indices[index + 1] = index + 1; - } - - // ensure that the changes are uploaded - uvBuffer.update(); - indexBuffer.update(); - - this.multiplyUvs(); - this.refreshVertices(); - } - - /** - * refreshes vertices of Rope mesh - */ - refreshVertices() - { - const points = this.points; - - if (points.length < 1) - { - return; - } - - let lastPoint = points[0]; - let nextPoint; - let perpX = 0; - let perpY = 0; - - // this.count -= 0.2; - - const vertices = this.vertices; - const total = points.length; - - for (let i = 0; i < total; i++) - { - const point = points[i]; - const index = i * 4; - - if (i < points.length - 1) - { - nextPoint = points[i + 1]; - } - else - { - nextPoint = point; - } - - perpY = -(nextPoint.x - lastPoint.x); - perpX = nextPoint.y - lastPoint.y; - - let ratio = (1 - (i / (total - 1))) * 10; - - if (ratio > 1) - { - ratio = 1; - } - - const perpLength = Math.sqrt((perpX * perpX) + (perpY * perpY)); - const num = this._texture.height / 2; // (20 + Math.abs(Math.sin((i + this.count) * 0.3) * 50) )* ratio; - - perpX /= perpLength; - perpY /= perpLength; - - perpX *= num; - perpY *= num; - - vertices[index] = point.x + perpX; - vertices[index + 1] = point.y + perpY; - vertices[index + 2] = point.x - perpX; - vertices[index + 3] = point.y - perpY; - - lastPoint = point; - } - - this.geometry.buffers[0].update(); - } - - /** - * Updates the object transform for rendering - * - * @private - */ - updateTransform() - { - if (this.autoUpdate) - { - this.refreshVertices(); - } - this.containerUpdateTransform(); - } -} diff --git a/packages/mesh/src/index.js b/packages/mesh/src/index.js index a245772..e14ab9f 100644 --- a/packages/mesh/src/index.js +++ b/packages/mesh/src/index.js @@ -1,6 +1,2 @@ export { default as Mesh } from './Mesh'; -export { default as RawMesh } from './RawMesh'; export { default as MeshRenderer } from './MeshRenderer'; -export { default as Plane } from './Plane'; -export { default as NineSlicePlane } from './NineSlicePlane'; -export { default as Rope } from './Rope'; diff --git a/packages/mesh/src/mesh.frag b/packages/mesh/src/mesh.frag deleted file mode 100644 index 6096983..0000000 --- a/packages/mesh/src/mesh.frag +++ /dev/null @@ -1,9 +0,0 @@ -varying vec2 vTextureCoord; -uniform vec4 uColor; - -uniform sampler2D uSampler; - -void main(void) -{ - gl_FragColor = texture2D(uSampler, vTextureCoord) * uColor; -} diff --git a/packages/mesh/src/mesh.vert b/packages/mesh/src/mesh.vert deleted file mode 100644 index 0526df9..0000000 --- a/packages/mesh/src/mesh.vert +++ /dev/null @@ -1,15 +0,0 @@ -attribute vec2 aVertexPosition; -attribute vec2 aTextureCoord; - -uniform mat3 projectionMatrix; -uniform mat3 translationMatrix; -uniform mat3 uTextureMatrix; - -varying vec2 vTextureCoord; - -void main(void) -{ - gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); - - vTextureCoord = (uTextureMatrix * vec3(aTextureCoord, 1.0)).xy; -} diff --git a/packages/mesh/test/.eslintrc.json b/packages/mesh/test/.eslintrc.json deleted file mode 100644 index 2ad8efb..0000000 --- a/packages/mesh/test/.eslintrc.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "globals": { - "expect": false, - "assert": false, - "sinon": false, - "PIXI": false - }, - "rules": { - "func-names": 0, - "no-unused-expressions": 0 - } -} \ No newline at end of file diff --git a/bundles/pixi.js/package.json b/bundles/pixi.js/package.json index 49c7276..177e059 100644 --- a/bundles/pixi.js/package.json +++ b/bundles/pixi.js/package.json @@ -49,6 +49,7 @@ "@pixi/loaders": "^5.0.0-alpha.2", "@pixi/math": "^5.0.0-alpha.2", "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/mesh-extras": "^5.0.0-alpha.2", "@pixi/mixin-cache-as-bitmap": "^5.0.0-alpha.2", "@pixi/mixin-get-child-by-name": "^5.0.0-alpha.2", "@pixi/mixin-get-global-position": "^5.0.0-alpha.2", diff --git a/bundles/pixi.js/src/deprecated.js b/bundles/pixi.js/src/deprecated.js index 147617c..dbebeb0 100644 --- a/bundles/pixi.js/src/deprecated.js +++ b/bundles/pixi.js/src/deprecated.js @@ -263,15 +263,15 @@ Object.defineProperties(PIXI.mesh, { /** * @class PIXI.mesh.Mesh - * @see PIXI.Mesh + * @see PIXI.Mesh2d * @deprecated since 5.0.0 */ Mesh: { get() { - warn('PIXI.mesh.Mesh has moved to PIXI.Mesh'); + warn('PIXI.mesh.Mesh has moved to PIXI.Mesh2d'); - return PIXI.Mesh; + return PIXI.Mesh2d; }, }, /** @@ -315,15 +315,15 @@ }, /** * @class PIXI.mesh.RawMesh - * @see PIXI.RawMesh + * @see PIXI.Mesh * @deprecated since 5.0.0 */ RawMesh: { get() { - warn('PIXI.mesh.RawMesh has moved to PIXI.RawMesh'); + warn('PIXI.mesh.RawMesh has moved to PIXI.Mesh'); - return PIXI.RawMesh; + return PIXI.Mesh; }, }, /** diff --git a/bundles/pixi.js/src/index.js b/bundles/pixi.js/src/index.js index a3a0d1b..6fdabf0 100644 --- a/bundles/pixi.js/src/index.js +++ b/bundles/pixi.js/src/index.js @@ -9,6 +9,7 @@ import * as loaders from '@pixi/loaders'; import * as math from '@pixi/math'; import * as mesh from '@pixi/mesh'; +import * as meshExtras from '@pixi/mesh-extras'; import * as particles from '@pixi/particles'; import * as prepare from '@pixi/prepare'; import * as sprite from '@pixi/sprite'; @@ -128,6 +129,7 @@ loaders, math, mesh, + meshExtras, particles, sprite, spriteAnimated, @@ -152,6 +154,7 @@ export * from '@pixi/loaders'; export * from '@pixi/math'; export * from '@pixi/mesh'; +export * from '@pixi/mesh-extras'; export * from '@pixi/particles'; export * from '@pixi/sprite'; export * from '@pixi/spritesheet'; diff --git a/package-lock.json b/package-lock.json index 7fe6db7..0814729 100644 --- a/package-lock.json +++ b/package-lock.json @@ -209,7 +209,7 @@ "argparse": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", - "integrity": "sha1-vNZ5HqWuCXJeF+WtmIE0zUCz2RE=", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", "dev": true, "requires": { "sprintf-js": "1.0.3" @@ -228,7 +228,7 @@ "arr-flatten": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz", - "integrity": "sha1-NgSLv/TntH4TZkQxbJlmnqWukfE=", + "integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==", "dev": true }, "arr-union": { @@ -297,7 +297,7 @@ "assertion-error": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", - "integrity": "sha1-5gtrDo8wG9l+U3UhW9pAbIURjAs=", + "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", "dev": true }, "async": { @@ -396,7 +396,7 @@ "brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha1-PH/L9SnYcibz0vUrlm/1Jx60Qd0=", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, "requires": { "balanced-match": "1.0.0", @@ -568,7 +568,7 @@ "circular-json": { "version": "0.3.3", "resolved": "https://registry.npmjs.org/circular-json/-/circular-json-0.3.3.tgz", - "integrity": "sha1-gVyZ6oT2gJUp0vRXkb34JxE1LWY=", + "integrity": "sha512-UZK3NBx2Mca+b5LsG7bY183pHWt5Y1xts4P3Pz7ENTwGVnJOUWbRb3ocjvX7hx9tq/yTAdclXm9sZ38gNuem4A==", "dev": true }, "cli-cursor": { @@ -638,7 +638,7 @@ "color-convert": { "version": "1.9.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.1.tgz", - "integrity": "sha1-wSYRB66y8pTr/+ye2eytUppgl+0=", + "integrity": "sha512-mjGanIiwQJskCC18rPR6OmrZ6fm2Lc7PeGFYwCmy5J34wC6F1PzdGL6xeMfmgicfYcNLGuVFA3WzXtIDCQSZxQ==", "dev": true, "requires": { "color-name": "1.1.3" @@ -1427,7 +1427,7 @@ "boom": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/boom/-/boom-5.2.0.tgz", - "integrity": "sha1-XdnabuOl8wIHdDYpDLcX0/SlTgI=", + "integrity": "sha512-Z5BTk6ZRe4tXXQlkqftmsAUANpXmuwlsF5Oov8ThoMbQRzdGTA1ngYRW160GexgOgjsFOKJz0LYhoNi+2AMBUw==", "dev": true, "requires": { "hoek": "4.2.1" @@ -1471,7 +1471,7 @@ "debug": { "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha1-XRKFFd8TT/Mn6QpMk/Tgd6U2NB8=", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", "dev": true, "requires": { "ms": "2.0.0" @@ -1585,7 +1585,7 @@ "doctrine": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", - "integrity": "sha1-XNAfwQFiG0LEzX9dGmYkNxbT850=", + "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", "dev": true, "requires": { "esutils": "2.0.2" @@ -1662,7 +1662,7 @@ "es6-promise": { "version": "4.2.4", "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.4.tgz", - "integrity": "sha1-3EIhwrFlGHYL2MOaUtjzVvwA7Sk=", + "integrity": "sha512-/NdNZVJg+uZgtm9eS3O6lrOLYmQag2DjdEXuPaHlZ6RuVqgqaVZfgYCepEIKsLqwdQArOPtC3XzRLqGGfT8KQQ==", "dev": true }, "escape-string-regexp": { @@ -1788,7 +1788,7 @@ "espree": { "version": "3.5.4", "resolved": "https://registry.npmjs.org/espree/-/espree-3.5.4.tgz", - "integrity": "sha1-sPRHGHyKi+2US4FaZgvd9d610ac=", + "integrity": "sha512-yAcIQxtmMiB/jL32dzEp2enBeidsB7xWPLNiw3IIkpVds1P+h7qF9YwJq1yUNzp2OKXgAprs4F61ih66UsoD1A==", "dev": true, "requires": { "acorn": "5.5.0", @@ -1798,7 +1798,7 @@ "esprima": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.0.tgz", - "integrity": "sha1-RJnt3NERDgshi6zy+n9/WfVcqAQ=", + "integrity": "sha512-oftTcaMu/EGrEIu904mWteKIv8vMuOgGYo7EhVJJN00R/EED9DCua/xxHRdYnKtcECzVg7xOWhflvJMnqcFZjw==", "dev": true }, "esquery": { @@ -1813,7 +1813,7 @@ "esrecurse": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.2.1.tgz", - "integrity": "sha1-AHo7n9vCs7uH5IeeoZyS/b05Qs8=", + "integrity": "sha512-64RBB++fIOAXPw3P9cy89qfMlvZEXZkqqJkjqqXIvzP5ezRZjW+lPWjw35UX/3EhUPFYbg5ER4JYgDw4007/DQ==", "dev": true, "requires": { "estraverse": "4.2.0" @@ -2024,7 +2024,7 @@ "find-root": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/find-root/-/find-root-1.1.0.tgz", - "integrity": "sha1-q8/Iunb3CMQql7PWhbfpRQv7nOQ=", + "integrity": "sha512-NKfW6bec6GfKc0SGx1e07QZY9PE99u0Bft/0rzSD5k3sO/vwkVUpDUKVm5Gpp5Ue3YfShPFTX2070tDs5kB9Ng==", "dev": true }, "find-up": { @@ -2103,7 +2103,7 @@ "supports-color": { "version": "5.3.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.3.0.tgz", - "integrity": "sha1-WySsFduA+pJ89SJ6SjP9PEx2dsA=", + "integrity": "sha512-0aP01LLIskjKs3lq52EC0aGBAJhLq7B2Rd8HC/DR/PtNNpcLilNmHC12O+hu0usQpo7wtHNRqtrhBwtDb0+dNg==", "dev": true, "requires": { "has-flag": "3.0.0" @@ -2567,7 +2567,7 @@ "glob": { "version": "7.1.2", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", - "integrity": "sha1-wZyd+aAocC1nhhI4SmVSQExjbRU=", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", "dev": true, "requires": { "fs.realpath": "1.0.0", @@ -2672,7 +2672,7 @@ "growl": { "version": "1.10.3", "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.3.tgz", - "integrity": "sha1-GSa6kM8+3+KttJJ/WIC8IsZseQ8=", + "integrity": "sha512-hKlsbA5Vu3xsh1Cg3J7jSmX/WaW6A5oBeqzM88oNbCRQFz+zUaXm6yxS4RVytp1scBoJzSYl4YAEOQIt6O8V1Q==", "dev": true }, "handlebars": { @@ -2738,7 +2738,7 @@ "hawk": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/hawk/-/hawk-6.0.2.tgz", - "integrity": "sha1-r02RTrBl+bXOTZ0RwcshJu7MMDg=", + "integrity": "sha512-miowhl2+U7Qle4vdLqDdPt9m09K6yZhkLDTWGoUiUzrQCn+mHHSmfJgAyGaLRZbPmTqfFFjRV1QWCW0VWUJBbQ==", "dev": true, "requires": { "boom": "4.3.1", @@ -2756,7 +2756,7 @@ "hoek": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/hoek/-/hoek-4.2.1.tgz", - "integrity": "sha1-ljRQKqEsRF3Vp8VzS1cruHOKrLs=", + "integrity": "sha512-QLg82fGkfnJ/4iy1xZ81/9SIJiq1NGFUMGs6ParyjBZr6jW2Ufj/snDqTHixNlHdPNwN2RLVD0Pi3igeK9+JfA==", "dev": true }, "home-path": { @@ -2791,7 +2791,7 @@ "ignore": { "version": "3.3.7", "resolved": "https://registry.npmjs.org/ignore/-/ignore-3.3.7.tgz", - "integrity": "sha1-YSKJv7PCIOGGpYEYYY1b6MG6sCE=", + "integrity": "sha512-YGG3ejvBNHRqu0559EOxxNFihD0AjpvHlC/pdGKd3X3ofe+CoJkYazwNJYTNebqpPKN+VVQbh4ZFn1DivMNuHA==", "dev": true }, "imurmurhash": { @@ -2828,7 +2828,7 @@ "ini": { "version": "1.3.5", "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", - "integrity": "sha1-7uJfVtscnsYIXgwid4CD9Zar+Sc=", + "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==", "dev": true }, "inquirer": { @@ -2901,7 +2901,7 @@ "is-buffer": { "version": "1.1.6", "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", - "integrity": "sha1-76ouqdqg16suoTqXsritUf776L4=", + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", "dev": true }, "is-builtin-module": { @@ -3054,7 +3054,7 @@ "is-resolvable": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/is-resolvable/-/is-resolvable-1.1.0.tgz", - "integrity": "sha1-+xj4fOH+uSUWnJpAfBkxijIG7Yg=", + "integrity": "sha512-qgDYXFSR5WvEfuS5dMj6oTMEbrrSaM0CrFk2Yiq/gXnBvD9pMa2jGXxyhGLfvhZpuMZe18CJpFxAt3CRs42NMg==", "dev": true }, "is-retry-allowed": { @@ -3204,7 +3204,7 @@ "js-yaml": { "version": "3.11.0", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.11.0.tgz", - "integrity": "sha1-WXwai9VxUvJtYizkEXhRpR9euu8=", + "integrity": "sha512-saJstZWv7oNeOyBh3+Dx1qWzhW0+e6/8eDzo7p5rDFqxntSztloLtuKu+Ejhtq82jsilwOIZYsCz+lIjthg1Hw==", "dev": true, "requires": { "argparse": "1.0.10", @@ -3324,7 +3324,7 @@ "just-extend": { "version": "1.1.27", "resolved": "https://registry.npmjs.org/just-extend/-/just-extend-1.1.27.tgz", - "integrity": "sha1-7G55QQ/5FORyZSq/oOYDwD1g6QU=", + "integrity": "sha512-mJVp13Ix6gFo3SBAy9U/kL+oeZqzlYYYLQBwXVBlVzIsZwBqGREnOro24oC/8s8aox+rJhtZ2DiQof++IrkA+g==", "dev": true }, "kind-of": { @@ -3703,7 +3703,7 @@ "lodash": { "version": "4.17.5", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.5.tgz", - "integrity": "sha1-maktZcAnLevoyWtgV7yPv6O+1RE=", + "integrity": "sha512-svL3uiZf1RwhH+cWrfZn3A4+U58wbP0tGVTLQPbjplZxZ8ROD9VLuNgsRniTlLe7OlSqR79RUehXgpBW/s0IQw==", "dev": true }, "lodash._reinterpolate": { @@ -3740,7 +3740,7 @@ "lolex": { "version": "2.3.2", "resolved": "https://registry.npmjs.org/lolex/-/lolex-2.3.2.tgz", - "integrity": "sha1-hflFBCUQO/nnpgZo6iXcQydMqAc=", + "integrity": "sha512-A5pN2tkFj7H0dGIAM6MFvHKMJcPnjZsOMvR7ujCjfgW5TbV6H9vb1PgxLtHvjqNZTHsUolz+6/WEO0N1xNx2ng==", "dev": true }, "longest": { @@ -3816,7 +3816,7 @@ "marked": { "version": "0.3.17", "resolved": "https://registry.npmjs.org/marked/-/marked-0.3.17.tgz", - "integrity": "sha1-YH8GZos8axJGso8T2nYRasGqLSs=", + "integrity": "sha512-+AKbNsjZl6jFfLPwHhWmGTqE009wTKn3RTmn9K8oUKHrX/abPJjtcRtXpYB/FFrwPJRUA86LX/de3T0knkPCmQ==", "dev": true }, "mem": { @@ -3896,13 +3896,13 @@ "mime-db": { "version": "1.33.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.33.0.tgz", - "integrity": "sha1-o0kgUKXLm2NFBUHjnZeI0icng9s=", + "integrity": "sha512-BHJ/EKruNIqJf/QahvxwQZXKygOQ256myeN/Ew+THcAa5q+PjyTTMMeNQC4DZw5AwfvelsUrA6B67NKMqXDbzQ==", "dev": true }, "mime-types": { "version": "2.1.18", "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.18.tgz", - "integrity": "sha1-bzI/YKg9ERRvgx/xH9ZuL+VQO7g=", + "integrity": "sha512-lc/aahn+t4/SWV/qcmumYjymLsWfN3ELhpmVuUFjgsORruuZPVSwAQryq+HHGvO/SI2KVX26bx+En+zhM8g8hQ==", "dev": true, "requires": { "mime-db": "1.33.0" @@ -3917,7 +3917,7 @@ "minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha1-UWbihkV/AzBgZL5Ul+jbsMPTIIM=", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "dev": true, "requires": { "brace-expansion": "1.1.11" @@ -4071,7 +4071,7 @@ "normalize-package-data": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.4.0.tgz", - "integrity": "sha1-EvlaMH1YNSB1oEkHuErIvpisAS8=", + "integrity": "sha512-9jjUFbTPfEy3R/ad/2oNbKtW9Hgovl5O1FvFWKkKblNXoN/Oou6+9+KKohPK13Yc3/TyunyWhJp6gvRNR/PPAw==", "dev": true, "requires": { "hosted-git-info": "2.5.0", @@ -4511,7 +4511,7 @@ "process-nextick-args": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", - "integrity": "sha1-o31zL0JxtKsa0HDTVQjoKQeI/6o=", + "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==", "dev": true }, "progress": { @@ -4584,7 +4584,7 @@ "qs": { "version": "6.5.1", "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.1.tgz", - "integrity": "sha1-NJzfbu+J7EXBLX1es/wMhwNDptg=", + "integrity": "sha512-eRzhrN1WSINYCDCbrz796z37LOe3m5tmW7RQf6oBntukAG1nmovJvhnwHHRMAfeoItc1m2Hk02WER2aQ/iqs+A==", "dev": true }, "quick-lru": { @@ -4596,7 +4596,7 @@ "randomatic": { "version": "1.1.7", "resolved": "https://registry.npmjs.org/randomatic/-/randomatic-1.1.7.tgz", - "integrity": "sha1-x6vpzIuHwLqodrGf3oP9RkeX44w=", + "integrity": "sha512-D5JUjPyJbaJDkuAazpVnSfVkLlpeO3wDlPROTMLGKG1zMFNFRgrciKo1ltz/AzNTkqE0HzDx655QOL51N06how==", "dev": true, "requires": { "is-number": "3.0.0", @@ -4701,7 +4701,7 @@ "regex-cache": { "version": "0.4.4", "resolved": "https://registry.npmjs.org/regex-cache/-/regex-cache-0.4.4.tgz", - "integrity": "sha1-db3FiioUls7EihKDW8VMjVYjNt0=", + "integrity": "sha512-nVIZwtCjkC9YgvWkpM55B5rBhBYRZhAaJbgcFYXXsHnbZ9UZI9nnVWYZpBlCqv9ho2eZryPnWrZGsOdPwVWXWQ==", "dev": true, "requires": { "is-equal-shallow": "0.1.3" @@ -4729,7 +4729,7 @@ "remap-istanbul": { "version": "0.10.1", "resolved": "https://registry.npmjs.org/remap-istanbul/-/remap-istanbul-0.10.1.tgz", - "integrity": "sha1-OqWN1QIdSZ8zbTulvzu7kcG4jjc=", + "integrity": "sha512-gsNQXs5kJLhErICSyYhzVZ++C8LBW8dgwr874Y2QvzAUS75zBlD/juZgXs39nbYJ09fZDlX2AVLVJAY2jbFJoQ==", "dev": true, "requires": { "amdefine": "1.0.1", @@ -4769,7 +4769,7 @@ "source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha1-dHIq8y6WFOnCh6jQu95IteLxomM=", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", "dev": true }, "through2": { @@ -4883,7 +4883,7 @@ "resolve": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.5.0.tgz", - "integrity": "sha1-HwmsznlsmnYlefMbLBzEw83fnzY=", + "integrity": "sha512-hgoSGrc3pjzAPHNBg+KnFcK2HwlHTs/YrAGUr6qgTVUZmXv1UEXXl0bZNBKMA9fud6lRYFdPGz0xXxycPzmmiw==", "dev": true, "requires": { "path-parse": "1.0.5" @@ -4924,7 +4924,7 @@ "rimraf": { "version": "2.6.2", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", - "integrity": "sha1-LtgVDSShbqhlHm1u8PR8QVjOejY=", + "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", "dev": true, "requires": { "glob": "7.1.2" @@ -5063,19 +5063,19 @@ "safe-buffer": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", - "integrity": "sha1-iTMSr2myEj3vcfV4iQAWce6yyFM=", + "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", "dev": true }, "samsam": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/samsam/-/samsam-1.3.0.tgz", - "integrity": "sha1-jR2TUOJWItow3j5EumkrUiGrfFA=", + "integrity": "sha512-1HwIYD/8UlOtFS3QO3w7ey+SdSDFE4HRNLZoZRYVQefrOY3l17epswImeB1ijgJFQJodIaHcwkp3r/myBjFVbg==", "dev": true }, "semver": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz", - "integrity": "sha1-3Eu8emyp2Rbe5dQ1FvAJK1j3uKs=", + "integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==", "dev": true }, "set-blocking": { @@ -5117,7 +5117,7 @@ "sinon-chai": { "version": "2.14.0", "resolved": "https://registry.npmjs.org/sinon-chai/-/sinon-chai-2.14.0.tgz", - "integrity": "sha1-2n3UzIPNaiYLZ8yg96n9riahIF0=", + "integrity": "sha512-9stIF1utB0ywNHNT7RgiXbdmen8QDCRsrTjw+G9TgKt1Yexjiv8TOWZ6WHsTPz57Yky3DIswZvEqX8fpuHNDtQ==", "dev": true }, "slash": { @@ -5146,7 +5146,7 @@ "sntp": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/sntp/-/sntp-2.1.0.tgz", - "integrity": "sha1-LGzsFP7cIiJznK+bXD2F0cxaLMg=", + "integrity": "sha512-FL1b58BDrqS3A11lJ0zEdnJ3UOKqVxawAkF3k7F0CVN7VQ34aZrV+G8BZ1WC9ZL7NyrwsW0oviwsWDgRuVYtJg==", "dev": true, "requires": { "hoek": "4.2.1" @@ -5203,7 +5203,7 @@ "spdx-correct": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.0.0.tgz", - "integrity": "sha1-BaW01xU6GVvJLDxCW2nzsqlSTII=", + "integrity": "sha512-N19o9z5cEyc8yQQPukRCZ9EUmb4HUpnrmaL/fxS2pBo2jbfcFRVuFZ/oFC+vZz0MNNk0h80iMn5/S6qGZOL5+g==", "dev": true, "requires": { "spdx-expression-parse": "3.0.0", @@ -5213,13 +5213,13 @@ "spdx-exceptions": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.1.0.tgz", - "integrity": "sha1-LHrmEFbHFKW5ubKyr30xHvXHj+k=", + "integrity": "sha512-4K1NsmrlCU1JJgUrtgEeTVyfx8VaYea9J9LvARxhbHtVtohPs/gFGG5yy49beySjlIMhhXZ4QqujIZEfS4l6Cg==", "dev": true }, "spdx-expression-parse": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.0.tgz", - "integrity": "sha1-meEZt6XaAOBUkcn6M4t5BII7QdA=", + "integrity": "sha512-Yg6D3XpRD4kkOmTpdgbUiEJFKghJH03fiC1OPll5h/0sO6neh2jqRDVHOQ4o/LMea0tgCkbMgea5ip/e+MkWyg==", "dev": true, "requires": { "spdx-exceptions": "2.1.0", @@ -5229,7 +5229,7 @@ "spdx-license-ids": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.0.tgz", - "integrity": "sha1-enzShHDMbToc/m1miG9rxDDTrIc=", + "integrity": "sha512-2+EPwgbnmOIl8HjGBXXMd9NAu02vLjOO1nWw4kmeRDFyHn+M/ETfHxQUK0oXg8ctgVnl9t3rosNVsZ1jG61nDA==", "dev": true }, "speedometer": { @@ -5566,7 +5566,7 @@ "tough-cookie": { "version": "2.3.4", "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.4.tgz", - "integrity": "sha1-7GDO44rGdQY//JelwYlwV47oNlU=", + "integrity": "sha512-TZ6TTfI5NtZnuyy/Kecv+CnoROnyXn2DN97LontgQpCwsX2XyLYCC0ENhYkehSOwAp8rTQKc/NUIF7BkQ5rKLA==", "dev": true, "requires": { "punycode": "1.4.1" @@ -5708,13 +5708,13 @@ "uuid": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.2.1.tgz", - "integrity": "sha1-EsUou51Y0LkmXZovbw/ovhf/HxQ=", + "integrity": "sha512-jZnMwlb9Iku/O3smGWvZhauCf6cvvpKi4BKRiliS3cxnI+Gz9j5MEpTz2UFuXiKPJocb7gnsLHwiS05ige5BEA==", "dev": true }, "validate-npm-package-license": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.3.tgz", - "integrity": "sha1-gWQ7y+8b3+zUYjeT3EZIlIupgzg=", + "integrity": "sha512-63ZOUnL4SIXj4L0NixR3L1lcjO38crAbgrTpl28t8jjrfuiOBL5Iygm+60qPs/KsZGzPNg6Smnc/oY16QTjF0g==", "dev": true, "requires": { "spdx-correct": "3.0.0", @@ -5750,7 +5750,7 @@ "which": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/which/-/which-1.3.0.tgz", - "integrity": "sha1-/wS9/AEO5UfXgL7DjhrBwnd9JTo=", + "integrity": "sha512-xcJpopdamTuY5duC/KnTTNBraPK54YwpenP4lzxU8H91GudWpFv38u0CKjclE1Wi2EH2EDz5LRcHcKbCIzqGyg==", "dev": true, "requires": { "isexe": "2.0.0" diff --git a/packages/canvas/canvas-mesh/package.json b/packages/canvas/canvas-mesh/package.json index 691cd2c..6744a17 100644 --- a/packages/canvas/canvas-mesh/package.json +++ b/packages/canvas/canvas-mesh/package.json @@ -24,6 +24,7 @@ "dependencies": { "@pixi/constants": "^5.0.0-alpha.2", "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/mesh-extras": "^5.0.0-alpha.2", "@pixi/settings": "^5.0.0-alpha.2" }, "devDependencies": { diff --git a/packages/canvas/canvas-mesh/src/Mesh.js b/packages/canvas/canvas-mesh/src/Mesh.js index 900a872..c43a74b 100644 --- a/packages/canvas/canvas-mesh/src/Mesh.js +++ b/packages/canvas/canvas-mesh/src/Mesh.js @@ -1,36 +1,14 @@ import { Mesh } from '@pixi/mesh'; -import { settings } from './settings'; - -// IMPORTANT: Please do NOT use this as a precedent to use `settings` after the object is created -// this was merely created to completely decouple canvas from the base Mesh class and we are -// unable to add `canvasPadding` in the constructor anymore, as the case was for PixiJS v4. /** - * Internal variable for `canvasPadding`. + * Renders the object using the Canvas renderer * * @private - * @memberof PIXI.Mesh - * @member {number} - * @default null - */ -Mesh.prototype._canvasPadding = null; - -/** - * Triangles in canvas mode are automatically antialiased, use this value to force triangles - * to overlap a bit with each other. To set the global default, set {@link PIXI.settings.MESH_CANVAS_PADDING} - * - * @see PIXI.settings.MESH_CANVAS_PADDING - * @member {number} canvasPadding + * @method _renderCanvas * @memberof PIXI.Mesh# - * @default 0 + * @param {PIXI.CanvasRenderer} renderer - The canvas renderer. */ -Object.defineProperty(Mesh.prototype, 'canvasPadding', { - get() - { - return this._canvasPadding !== null ? this._canvasPadding : settings.MESH_CANVAS_PADDING; - }, - set(value) - { - this._canvasPadding = value; - }, -}); +Mesh.prototype._renderCanvas = function _renderCanvas(renderer) +{ + renderer.plugins[this.pluginName].render(this); +}; diff --git a/packages/canvas/canvas-mesh/src/Mesh2d.js b/packages/canvas/canvas-mesh/src/Mesh2d.js new file mode 100644 index 0000000..d0bd80f --- /dev/null +++ b/packages/canvas/canvas-mesh/src/Mesh2d.js @@ -0,0 +1,36 @@ +import { Mesh2d } from '@pixi/mesh-extras'; +import { settings } from './settings'; + +// IMPORTANT: Please do NOT use this as a precedent to use `settings` after the object is created +// this was merely created to completely decouple canvas from the base Mesh class and we are +// unable to add `canvasPadding` in the constructor anymore, as the case was for PixiJS v4. + +/** + * Internal variable for `canvasPadding`. + * + * @private + * @memberof PIXI.Mesh2d + * @member {number} + * @default null + */ +Mesh2d.prototype._canvasPadding = null; + +/** + * Triangles in canvas mode are automatically antialiased, use this value to force triangles + * to overlap a bit with each other. To set the global default, set {@link PIXI.settings.MESH_CANVAS_PADDING} + * + * @see PIXI.settings.MESH_CANVAS_PADDING + * @member {number} canvasPadding + * @memberof PIXI.Mesh2d# + * @default 0 + */ +Object.defineProperty(Mesh2d.prototype, 'canvasPadding', { + get() + { + return this._canvasPadding !== null ? this._canvasPadding : settings.MESH_CANVAS_PADDING; + }, + set(value) + { + this._canvasPadding = value; + }, +}); diff --git a/packages/canvas/canvas-mesh/src/NineSlicePlane.js b/packages/canvas/canvas-mesh/src/NineSlicePlane.js index 09eaf9c..2fd5acc 100644 --- a/packages/canvas/canvas-mesh/src/NineSlicePlane.js +++ b/packages/canvas/canvas-mesh/src/NineSlicePlane.js @@ -1,4 +1,4 @@ -import { NineSlicePlane } from '@pixi/mesh'; +import { NineSlicePlane } from '@pixi/mesh-extras'; /** * Renders the object using the Canvas renderer diff --git a/packages/canvas/canvas-mesh/src/RawMesh.js b/packages/canvas/canvas-mesh/src/RawMesh.js deleted file mode 100644 index bf40184..0000000 --- a/packages/canvas/canvas-mesh/src/RawMesh.js +++ /dev/null @@ -1,14 +0,0 @@ -import { RawMesh } from '@pixi/mesh'; - -/** - * Renders the object using the Canvas renderer - * - * @private - * @method _renderCanvas - * @memberof PIXI.RawMesh# - * @param {PIXI.CanvasRenderer} renderer - The canvas renderer. - */ -RawMesh.prototype._renderCanvas = function _renderCanvas(renderer) -{ - renderer.plugins[this.pluginName].render(this); -}; diff --git a/packages/canvas/canvas-mesh/src/index.js b/packages/canvas/canvas-mesh/src/index.js index 2295016..f4fa31d 100644 --- a/packages/canvas/canvas-mesh/src/index.js +++ b/packages/canvas/canvas-mesh/src/index.js @@ -1,6 +1,6 @@ export { default as CanvasMeshRenderer } from './CanvasMeshRenderer'; import './settings'; -import './Mesh'; +import './Mesh2d'; import './NineSlicePlane'; -import './RawMesh'; +import './Mesh'; diff --git a/packages/canvas/canvas-mesh/src/settings.js b/packages/canvas/canvas-mesh/src/settings.js index 4cefb4c..e81b8e0 100644 --- a/packages/canvas/canvas-mesh/src/settings.js +++ b/packages/canvas/canvas-mesh/src/settings.js @@ -3,7 +3,7 @@ /** * Default `canvasPadding` for canvas-based Mesh rendering. * - * @see PIXI.Mesh#canvasPadding + * @see PIXI.Mesh2d#canvasPadding * @static * @constant * @memberof PIXI.settings diff --git a/packages/mesh-extras/LICENSE b/packages/mesh-extras/LICENSE new file mode 100644 index 0000000..148e3eb --- /dev/null +++ b/packages/mesh-extras/LICENSE @@ -0,0 +1,21 @@ +The MIT License + +Copyright (c) 2013-2018 Mathew Groves, Chad Engler + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/packages/mesh-extras/README.md b/packages/mesh-extras/README.md new file mode 100644 index 0000000..1d9b0e1 --- /dev/null +++ b/packages/mesh-extras/README.md @@ -0,0 +1,19 @@ +# @pixi/mesh-extras + +## Installation + +```bash +npm install @pixi/mesh-extras +``` + +## Usage + +```js +import { MeshRenderer } from '@pixi/mesh'; +import { Renderer } from '@pixi/core'; +import { Rope } from '@pixi/mesh-extras'; + +Renderer.registerPlugin('mesh', MeshRenderer); + +const rope = new Rope(); +``` \ No newline at end of file diff --git a/packages/mesh-extras/package.json b/packages/mesh-extras/package.json new file mode 100644 index 0000000..d134f64 --- /dev/null +++ b/packages/mesh-extras/package.json @@ -0,0 +1,38 @@ +{ + "name": "@pixi/mesh-extras", + "version": "5.0.0-alpha.2", + "main": "lib/mesh-extras.js", + "module": "lib/mesh-extras.es.js", + "description": "Custom Mesh display objects, like Rope and Plane", + "author": "Mat Groves", + "contributors": [ + "Matt Karl " + ], + "homepage": "http://pixijs.com/", + "bugs": "https://github.com/pixijs/pixi.js/issues", + "license": "MIT", + "repository": { + "type": "git", + "url": "https://github.com/pixijs/pixi.js.git" + }, + "publishConfig": { + "access": "public" + }, + "scripts": { + "test": "floss --path test" + }, + "files": [ + "lib" + ], + "dependencies": { + "@pixi/constants": "^5.0.0-alpha.2", + "@pixi/core": "^5.0.0-alpha.2", + "@pixi/math": "^5.0.0-alpha.2", + "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/utils": "^5.0.0-alpha.2" + }, + "devDependencies": { + "@pixi/loaders": "^5.0.0-alpha.2", + "floss": "^2.1.3" + } +} diff --git a/packages/mesh-extras/src/Mesh2d.js b/packages/mesh-extras/src/Mesh2d.js new file mode 100644 index 0000000..d113a5e --- /dev/null +++ b/packages/mesh-extras/src/Mesh2d.js @@ -0,0 +1,263 @@ +import { Mesh } from '@pixi/mesh'; +import { Geometry, Program, Shader, Texture, TextureMatrix } from '@pixi/core'; +import { Matrix } from '@pixi/math'; +import { BLEND_MODES } from '@pixi/constants'; +import { hex2rgb, premultiplyRgba } from '@pixi/utils'; +import vertex from './mesh.vert'; +import fragment from './mesh.frag'; + +let meshProgram; + +/** + * Base mesh class + * @class + * @extends PIXI.Container + * @memberof PIXI + */ +export default class Mesh2d extends Mesh +{ + /** + * @param {PIXI.Texture} [texture=Texture.EMPTY] - The texture to use + * @param {Float32Array} [vertices] - if you want to specify the vertices + * @param {Float32Array} [uvs] - if you want to specify the uvs + * @param {Uint16Array} [indices] - if you want to specify the indices + * @param {number} [drawMode] - the drawMode, can be any of the Mesh.DRAW_MODES consts + */ + constructor(texture = Texture.EMPTY, vertices, uvs, indices, drawMode) + { + const geometry = new Geometry(); + + if (!meshProgram) + { + meshProgram = new Program(vertex, fragment); + } + + geometry.addAttribute('aVertexPosition', vertices) + .addAttribute('aTextureCoord', uvs) + .addIndex(indices); + + geometry.getAttribute('aVertexPosition').static = false; + + const uniforms = { + uSampler: texture, + uTextureMatrix: Matrix.IDENTITY, + alpha: 1, + uColor: new Float32Array([1, 1, 1, 1]), + }; + + super(geometry, new Shader(meshProgram, uniforms), null, drawMode); + + /** + * The Uvs of the Mesh + * + * @member {Float32Array} + */ + this.uvs = geometry.getAttribute('aTextureCoord').data; + + /** + * An array of vertices + * + * @member {Float32Array} + */ + this.vertices = geometry.getAttribute('aVertexPosition').data; + + this.uniforms = uniforms; + + /** + * The texture of the Mesh + * + * @member {PIXI.Texture} + * @default PIXI.Texture.EMPTY + * @private + */ + this.texture = texture; + + /** + * The tint applied to the mesh. This is a [r,g,b] value. A value of [1,1,1] will remove any + * tint effect. + * + * @member {number} + * @private + */ + this._tintRGB = new Float32Array([1, 1, 1]); + + // Set default tint + this.tint = 0xFFFFFF; + + this.blendMode = BLEND_MODES.NORMAL; + + /** + * TextureMatrix instance for this Mesh, used to track Texture changes + * + * @member {PIXI.TextureMatrix} + * @readonly + */ + this.uvMatrix = new TextureMatrix(this._texture); + + /** + * whether or not upload uvMatrix to shader + * if its false, then uvs should be pre-multiplied + * if you change it for generated mesh, please call 'refresh(true)' + * @member {boolean} + * @default false + */ + this.uploadUvMatrix = false; + + /** + * Uploads vertices buffer every frame, like in PixiJS V3 and V4. + * + * @member {boolean} + * @default true + */ + this.autoUpdate = true; + } + + /** + * The tint applied to the Rope. This is a hex value. A value of + * 0xFFFFFF will remove any tint effect. + * + * @member {number} + * @memberof PIXI.Sprite# + * @default 0xFFFFFF + */ + get tint() + { + return this._tint; + } + + /** + * Sets the tint of the rope. + * + * @param {number} value - The value to set to. + */ + set tint(value) + { + this._tint = value; + + hex2rgb(this._tint, this._tintRGB); + } + + /** + * The blend mode to be applied to the sprite. Set to `PIXI.BLEND_MODES.NORMAL` to remove any blend mode. + * + * @member {number} + * @default PIXI.BLEND_MODES.NORMAL + * @see PIXI.BLEND_MODES + */ + get blendMode() + { + return this.state.blendMode; + } + + set blendMode(value) // eslint-disable-line require-jsdoc + { + this.state.blendMode = value; + } + + /** + * The texture that the mesh uses. + * + * @member {PIXI.Texture} + */ + get texture() + { + return this._texture; + } + + set texture(value) // eslint-disable-line require-jsdoc + { + if (this._texture === value) + { + return; + } + + this._texture = value; + this.uniforms.uSampler = this.texture; + + if (value) + { + // wait for the texture to load + if (value.baseTexture.valid) + { + this._onTextureUpdate(); + } + else + { + value.once('update', this._onTextureUpdate, this); + } + } + } + + _render(renderer) + { + const baseTex = this._texture.baseTexture; + + premultiplyRgba(this._tintRGB, this.worldAlpha, this.uniforms.uColor, baseTex.premultiplyAlpha); + super._render(renderer); + } + /** + * When the texture is updated, this event will fire to update the scale and frame + * + * @private + */ + _onTextureUpdate() + { + // constructor texture update stop + if (!this.uvMatrix) + { + return; + } + this.uvMatrix.texture = this._texture; + this.refresh(); + } + + /** + * multiplies uvs only if uploadUvMatrix is false + * call it after you change uvs manually + * make sure that texture is valid + */ + multiplyUvs() + { + if (!this.uploadUvMatrix) + { + this.uvMatrix.multiplyUvs(this.uvs); + } + } + + /** + * Refreshes uvs for generated meshes (rope, plane) + * sometimes refreshes vertices too + * + * @param {boolean} [forceUpdate=false] if true, matrices will be updated any case + */ + refresh(forceUpdate) + { + if (this.uvMatrix.update(forceUpdate)) + { + this._refresh(); + } + } + + /** + * Updates the object transform for rendering + * + * @private + */ + updateTransform() + { + if (this.autoUpdate) + { + this.geometry.buffers[0].update(); + } + this.containerUpdateTransform(); + } + + /** + * re-calculates mesh coords + * @private + */ + _refresh() + { + /* empty */ + } +} diff --git a/packages/mesh-extras/src/NineSlicePlane.js b/packages/mesh-extras/src/NineSlicePlane.js new file mode 100644 index 0000000..0bae92c --- /dev/null +++ b/packages/mesh-extras/src/NineSlicePlane.js @@ -0,0 +1,270 @@ +import Plane from './Plane'; + +const DEFAULT_BORDER_SIZE = 10; + +/** + * The NineSlicePlane allows you to stretch a texture using 9-slice scaling. The corners will remain unscaled (useful + * for buttons with rounded corners for example) and the other areas will be scaled horizontally and or vertically + * + *```js + * let Plane9 = new PIXI.NineSlicePlane(PIXI.Texture.from('BoxWithRoundedCorners.png'), 15, 15, 15, 15); + * ``` + *
+ *      A                          B
+ *    +---+----------------------+---+
+ *  C | 1 |          2           | 3 |
+ *    +---+----------------------+---+
+ *    |   |                      |   |
+ *    | 4 |          5           | 6 |
+ *    |   |                      |   |
+ *    +---+----------------------+---+
+ *  D | 7 |          8           | 9 |
+ *    +---+----------------------+---+
+
+ *  When changing this objects width and/or height:
+ *     areas 1 3 7 and 9 will remain unscaled.
+ *     areas 2 and 8 will be stretched horizontally
+ *     areas 4 and 6 will be stretched vertically
+ *     area 5 will be stretched both horizontally and vertically
+ * 
+ * + * @class + * @extends PIXI.Plane + * @memberof PIXI + * + */ +export default class NineSlicePlane extends Plane +{ + /** + * @param {PIXI.Texture} texture - The texture to use on the NineSlicePlane. + * @param {int} [leftWidth=10] size of the left vertical bar (A) + * @param {int} [topHeight=10] size of the top horizontal bar (C) + * @param {int} [rightWidth=10] size of the right vertical bar (B) + * @param {int} [bottomHeight=10] size of the bottom horizontal bar (D) + */ + constructor(texture, leftWidth, topHeight, rightWidth, bottomHeight) + { + super(texture, 4, 4); + + this._origWidth = texture.orig.width; + this._origHeight = texture.orig.height; + + /** + * The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._width = this._origWidth; + + /** + * The height of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._height = this._origHeight; + + /** + * The width of the left column (a) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._leftWidth = typeof leftWidth !== 'undefined' ? leftWidth : DEFAULT_BORDER_SIZE; + + /** + * The width of the right column (b) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._rightWidth = typeof rightWidth !== 'undefined' ? rightWidth : DEFAULT_BORDER_SIZE; + + /** + * The height of the top row (c) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._topHeight = typeof topHeight !== 'undefined' ? topHeight : DEFAULT_BORDER_SIZE; + + /** + * The height of the bottom row (d) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._bottomHeight = typeof bottomHeight !== 'undefined' ? bottomHeight : DEFAULT_BORDER_SIZE; + + this.refresh(true); + } + + /** + * Updates the horizontal vertices. + * + */ + updateHorizontalVertices() + { + const vertices = this.vertices; + + const h = this._topHeight + this._bottomHeight; + const scale = this._height > h ? 1.0 : this._height / h; + + vertices[9] = vertices[11] = vertices[13] = vertices[15] = this._topHeight * scale; + vertices[17] = vertices[19] = vertices[21] = vertices[23] = this._height - (this._bottomHeight * scale); + vertices[25] = vertices[27] = vertices[29] = vertices[31] = this._height; + } + + /** + * Updates the vertical vertices. + * + */ + updateVerticalVertices() + { + const vertices = this.vertices; + + const w = this._leftWidth + this._rightWidth; + const scale = this._width > w ? 1.0 : this._width / w; + + vertices[2] = vertices[10] = vertices[18] = vertices[26] = this._leftWidth * scale; + vertices[4] = vertices[12] = vertices[20] = vertices[28] = this._width - (this._rightWidth * scale); + vertices[6] = vertices[14] = vertices[22] = vertices[30] = this._width; + } + + /** + * The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + */ + get width() + { + return this._width; + } + + set width(value) // eslint-disable-line require-jsdoc + { + this._width = value; + this._refresh(); + } + + /** + * The height of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + */ + get height() + { + return this._height; + } + + set height(value) // eslint-disable-line require-jsdoc + { + this._height = value; + this._refresh(); + } + + /** + * The width of the left column + * + * @member {number} + */ + get leftWidth() + { + return this._leftWidth; + } + + set leftWidth(value) // eslint-disable-line require-jsdoc + { + this._leftWidth = value; + this._refresh(); + } + + /** + * The width of the right column + * + * @member {number} + */ + get rightWidth() + { + return this._rightWidth; + } + + set rightWidth(value) // eslint-disable-line require-jsdoc + { + this._rightWidth = value; + this._refresh(); + } + + /** + * The height of the top row + * + * @member {number} + */ + get topHeight() + { + return this._topHeight; + } + + set topHeight(value) // eslint-disable-line require-jsdoc + { + this._topHeight = value; + this._refresh(); + } + + /** + * The height of the bottom row + * + * @member {number} + */ + get bottomHeight() + { + return this._bottomHeight; + } + + set bottomHeight(value) // eslint-disable-line require-jsdoc + { + this._bottomHeight = value; + this._refresh(); + } + + /** + * Refreshes NineSlicePlane coords. All of them. + */ + _refresh() + { + super._refresh(); + + const uvs = this.uvs; + const texture = this._texture; + + this._origWidth = texture.orig.width; + this._origHeight = texture.orig.height; + + const _uvw = 1.0 / this._origWidth; + const _uvh = 1.0 / this._origHeight; + + uvs[0] = uvs[8] = uvs[16] = uvs[24] = 0; + uvs[1] = uvs[3] = uvs[5] = uvs[7] = 0; + uvs[6] = uvs[14] = uvs[22] = uvs[30] = 1; + uvs[25] = uvs[27] = uvs[29] = uvs[31] = 1; + + uvs[2] = uvs[10] = uvs[18] = uvs[26] = _uvw * this._leftWidth; + uvs[4] = uvs[12] = uvs[20] = uvs[28] = 1 - (_uvw * this._rightWidth); + uvs[9] = uvs[11] = uvs[13] = uvs[15] = _uvh * this._topHeight; + uvs[17] = uvs[19] = uvs[21] = uvs[23] = 1 - (_uvh * this._bottomHeight); + + this.updateHorizontalVertices(); + this.updateVerticalVertices(); + + this.geometry.buffers[1].update(); + + this.multiplyUvs(); + } +} diff --git a/packages/mesh-extras/src/Plane.js b/packages/mesh-extras/src/Plane.js new file mode 100644 index 0000000..1c240c4 --- /dev/null +++ b/packages/mesh-extras/src/Plane.js @@ -0,0 +1,100 @@ +import Mesh2d from './Mesh2d'; + +/** + * The Plane allows you to draw a texture across several points and them manipulate these points + * + *```js + * for (let i = 0; i < 20; i++) { + * points.push(new PIXI.Point(i * 50, 0)); + * }; + * let Plane = new PIXI.Plane(PIXI.Texture.from("snake.png"), points); + * ``` + * + * @class + * @extends PIXI.Mesh + * @memberof PIXI + * + */ +export default class Plane extends Mesh2d +{ + /** + * @param {PIXI.Texture} texture - The texture to use on the Plane. + * @param {number} verticesX - The number of vertices in the x-axis + * @param {number} verticesY - The number of vertices in the y-axis + * @param {object} [opts] - an options object - add meshWidth and meshHeight, temporary object for PixiJS v5 alpha + */ + constructor(texture, verticesX, verticesY, opts = {}) + { + super(texture, new Float32Array(1), new Float32Array(1), new Uint16Array(1), 4); + + this.verticesX = verticesX || 10; + this.verticesY = verticesY || 10; + + this.meshWidth = opts.meshWidth || 0; + this.meshHeight = opts.meshHeight || 0; + + this.refresh(); + } + + /** + * Refreshes plane coordinates + * @private + */ + _refresh() + { + const texture = this._texture; + const total = this.verticesX * this.verticesY; + const verts = []; + const uvs = []; + const indices = []; + + const segmentsX = this.verticesX - 1; + const segmentsY = this.verticesY - 1; + + const sizeX = (this.meshWidth || texture.width) / segmentsX; + const sizeY = (this.meshHeight || texture.height) / segmentsY; + + for (let i = 0; i < total; i++) + { + const x = (i % this.verticesX); + const y = ((i / this.verticesX) | 0); + + verts.push(x * sizeX, y * sizeY); + + uvs.push(x / segmentsX, y / segmentsY); + } + + // cons + + const totalSub = segmentsX * segmentsY; + + for (let i = 0; i < totalSub; i++) + { + const xpos = i % segmentsX; + const ypos = (i / segmentsX) | 0; + + const value = (ypos * this.verticesX) + xpos; + const value2 = (ypos * this.verticesX) + xpos + 1; + const value3 = ((ypos + 1) * this.verticesX) + xpos; + const value4 = ((ypos + 1) * this.verticesX) + xpos + 1; + + indices.push(value, value2, value3); + indices.push(value2, value4, value3); + } + + this.vertices = new Float32Array(verts); + this.uvs = new Float32Array(uvs); + this.indices = new Uint16Array(indices); + + this.geometry.buffers[0].data = this.vertices; + this.geometry.buffers[1].data = this.uvs; + this.geometry.indexBuffer.data = this.indices; + + // ensure that the changes are uploaded + this.geometry.buffers[0].update(); + this.geometry.buffers[1].update(); + this.geometry.indexBuffer.update(); + + this.multiplyUvs(); + } +} diff --git a/packages/mesh-extras/src/Rope.js b/packages/mesh-extras/src/Rope.js new file mode 100644 index 0000000..9cfde38 --- /dev/null +++ b/packages/mesh-extras/src/Rope.js @@ -0,0 +1,182 @@ +import Mesh2d from './Mesh2d'; + +/** + * The rope allows you to draw a texture across several points and them manipulate these points + * + *```js + * for (let i = 0; i < 20; i++) { + * points.push(new PIXI.Point(i * 50, 0)); + * }; + * let rope = new PIXI.Rope(PIXI.Texture.from("snake.png"), points); + * ``` + * + * @class + * @extends PIXI.Mesh + * @memberof PIXI + * + */ +export default class Rope extends Mesh2d +{ + /** + * @param {PIXI.Texture} texture - The texture to use on the rope. + * @param {PIXI.Point[]} points - An array of {@link PIXI.Point} objects to construct this rope. + */ + constructor(texture, points) + { + super(texture, new Float32Array(points.length * 4), + new Float32Array(points.length * 4), + new Uint16Array(points.length * 2), + 5); + + /* + * @member {PIXI.Point[]} An array of points that determine the rope + */ + this.points = points; + this.refresh(); + } + /** + * Refreshes Rope indices and uvs + * @private + */ + _refresh() + { + const points = this.points; + + if (!points) return; + + const vertexBuffer = this.geometry.getAttribute('aVertexPosition'); + const uvBuffer = this.geometry.getAttribute('aTextureCoord'); + const indexBuffer = this.geometry.getIndex(); + + // if too little points, or texture hasn't got UVs set yet just move on. + if (points.length < 1 || !this.texture._uvs) + { + return; + } + + // if the number of points has changed we will need to recreate the arraybuffers + if (vertexBuffer.data.length / 4 !== points.length) + { + vertexBuffer.data = new Float32Array(points.length * 4); + uvBuffer.data = new Float32Array(points.length * 4); + indexBuffer.data = new Uint16Array(points.length * 2); + } + + const uvs = uvBuffer.data; + const indices = indexBuffer.data; + + uvs[0] = 0; + uvs[1] = 0; + uvs[2] = 0; + uvs[3] = 1; + + indices[0] = 0; + indices[1] = 1; + + const total = points.length; + + for (let i = 1; i < total; i++) + { + // time to do some smart drawing! + let index = i * 4; + const amount = i / (total - 1); + + uvs[index] = amount; + uvs[index + 1] = 0; + + uvs[index + 2] = amount; + uvs[index + 3] = 1; + + index = i * 2; + indices[index] = index; + indices[index + 1] = index + 1; + } + + // ensure that the changes are uploaded + uvBuffer.update(); + indexBuffer.update(); + + this.multiplyUvs(); + this.refreshVertices(); + } + + /** + * refreshes vertices of Rope mesh + */ + refreshVertices() + { + const points = this.points; + + if (points.length < 1) + { + return; + } + + let lastPoint = points[0]; + let nextPoint; + let perpX = 0; + let perpY = 0; + + // this.count -= 0.2; + + const vertices = this.vertices; + const total = points.length; + + for (let i = 0; i < total; i++) + { + const point = points[i]; + const index = i * 4; + + if (i < points.length - 1) + { + nextPoint = points[i + 1]; + } + else + { + nextPoint = point; + } + + perpY = -(nextPoint.x - lastPoint.x); + perpX = nextPoint.y - lastPoint.y; + + let ratio = (1 - (i / (total - 1))) * 10; + + if (ratio > 1) + { + ratio = 1; + } + + const perpLength = Math.sqrt((perpX * perpX) + (perpY * perpY)); + const num = this._texture.height / 2; // (20 + Math.abs(Math.sin((i + this.count) * 0.3) * 50) )* ratio; + + perpX /= perpLength; + perpY /= perpLength; + + perpX *= num; + perpY *= num; + + vertices[index] = point.x + perpX; + vertices[index + 1] = point.y + perpY; + vertices[index + 2] = point.x - perpX; + vertices[index + 3] = point.y - perpY; + + lastPoint = point; + } + + this.geometry.buffers[0].update(); + } + + /** + * Updates the object transform for rendering + * + * @private + */ + updateTransform() + { + if (this.autoUpdate) + { + this.refreshVertices(); + } + this.containerUpdateTransform(); + } +} diff --git a/packages/mesh-extras/src/index.js b/packages/mesh-extras/src/index.js new file mode 100644 index 0000000..decf454 --- /dev/null +++ b/packages/mesh-extras/src/index.js @@ -0,0 +1,4 @@ +export { default as Mesh2d } from './Mesh2d'; +export { default as Plane } from './Plane'; +export { default as NineSlicePlane } from './NineSlicePlane'; +export { default as Rope } from './Rope'; diff --git a/packages/mesh-extras/src/mesh.frag b/packages/mesh-extras/src/mesh.frag new file mode 100644 index 0000000..6096983 --- /dev/null +++ b/packages/mesh-extras/src/mesh.frag @@ -0,0 +1,9 @@ +varying vec2 vTextureCoord; +uniform vec4 uColor; + +uniform sampler2D uSampler; + +void main(void) +{ + gl_FragColor = texture2D(uSampler, vTextureCoord) * uColor; +} diff --git a/packages/mesh-extras/src/mesh.vert b/packages/mesh-extras/src/mesh.vert new file mode 100644 index 0000000..0526df9 --- /dev/null +++ b/packages/mesh-extras/src/mesh.vert @@ -0,0 +1,15 @@ +attribute vec2 aVertexPosition; +attribute vec2 aTextureCoord; + +uniform mat3 projectionMatrix; +uniform mat3 translationMatrix; +uniform mat3 uTextureMatrix; + +varying vec2 vTextureCoord; + +void main(void) +{ + gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); + + vTextureCoord = (uTextureMatrix * vec3(aTextureCoord, 1.0)).xy; +} diff --git a/packages/mesh-extras/test/.eslintrc.json b/packages/mesh-extras/test/.eslintrc.json new file mode 100644 index 0000000..2ad8efb --- /dev/null +++ b/packages/mesh-extras/test/.eslintrc.json @@ -0,0 +1,12 @@ +{ + "globals": { + "expect": false, + "assert": false, + "sinon": false, + "PIXI": false + }, + "rules": { + "func-names": 0, + "no-unused-expressions": 0 + } +} \ No newline at end of file diff --git a/packages/mesh-extras/test/Plane.js b/packages/mesh-extras/test/Plane.js new file mode 100644 index 0000000..f9b1c25 --- /dev/null +++ b/packages/mesh-extras/test/Plane.js @@ -0,0 +1,60 @@ +const { Plane } = require('../'); +const { isWebGLSupported, skipHello } = require('@pixi/utils'); +const { Loader } = require('@pixi/loaders'); +const { Point } = require('@pixi/math'); +const { RenderTexture, Texture } = require('@pixi/core'); + +skipHello(); + +function withGL(fn) +{ + return isWebGLSupported() ? fn : undefined; +} + +// TODO: fix with webglrenderer +describe('PIXI.mesh.Plane', function () +{ + it.skip('should create a plane from an external image', withGL(function (done) + { + const loader = new Loader(); + + loader.add('testBitmap', `file://${__dirname}/resources/bitmap-1.png`) + .load(function (loader, resources) + { + const plane = new Plane(resources.testBitmap.texture, 100, 100); + + expect(plane.verticesX).to.equal(100); + expect(plane.verticesY).to.equal(100); + done(); + }); + })); + + it.skip('should create a new empty textured Plane', withGL(function () + { + const plane = new Plane(Texture.EMPTY, 100, 100); + + expect(plane.verticesX).to.equal(100); + expect(plane.verticesY).to.equal(100); + })); + + describe('containsPoint', function () + { + it.skip('should return true when point inside', withGL(function () + { + const point = new Point(10, 10); + const texture = new RenderTexture.create(20, 30); + const plane = new Plane(texture, 100, 100); + + expect(plane.containsPoint(point)).to.be.true; + })); + + it.skip('should return false when point outside', withGL(function () + { + const point = new Point(100, 100); + const texture = new RenderTexture.create(20, 30); + const plane = new Plane(texture, 100, 100); + + expect(plane.containsPoint(point)).to.be.false; + })); + }); +}); diff --git a/packages/mesh-extras/test/index.js b/packages/mesh-extras/test/index.js new file mode 100644 index 0000000..d767624 --- /dev/null +++ b/packages/mesh-extras/test/index.js @@ -0,0 +1 @@ +require('./Plane'); diff --git a/packages/mesh-extras/test/resources/bitmap-1.png b/packages/mesh-extras/test/resources/bitmap-1.png new file mode 100644 index 0000000..1284fb8 --- /dev/null +++ b/packages/mesh-extras/test/resources/bitmap-1.png Binary files differ diff --git a/packages/mesh/package.json b/packages/mesh/package.json index 8b1f8d9..10bd8e3 100644 --- a/packages/mesh/package.json +++ b/packages/mesh/package.json @@ -18,22 +18,16 @@ "publishConfig": { "access": "public" }, - "scripts": { - "test": "floss --path test" - }, "files": [ "lib" ], "dependencies": { - "@pixi/canvas-renderer": "^5.0.0-alpha.2", "@pixi/constants": "^5.0.0-alpha.2", "@pixi/core": "^5.0.0-alpha.2", "@pixi/display": "^5.0.0-alpha.2", - "@pixi/math": "^5.0.0-alpha.2", - "@pixi/utils": "^5.0.0-alpha.2" + "@pixi/math": "^5.0.0-alpha.2" }, "devDependencies": { - "@pixi/loaders": "^5.0.0-alpha.2", "floss": "^2.1.3" } } diff --git a/packages/mesh/src/Mesh.js b/packages/mesh/src/Mesh.js index e7c8f9e..1f35b7a 100644 --- a/packages/mesh/src/Mesh.js +++ b/packages/mesh/src/Mesh.js @@ -1,263 +1,220 @@ -import RawMesh from './RawMesh'; -import { Geometry, Program, Shader, Texture, TextureMatrix } from '@pixi/core'; -import { Matrix } from '@pixi/math'; -import { BLEND_MODES } from '@pixi/constants'; -import { hex2rgb, premultiplyRgba } from '@pixi/utils'; -import vertex from './mesh.vert'; -import fragment from './mesh.frag'; +import { State } from '@pixi/core'; +import { DRAW_MODES } from '@pixi/constants'; +import { Point, Polygon } from '@pixi/math'; +import { Container } from '@pixi/display'; -let meshProgram; +const tempPoint = new Point(); +const tempPolygon = new Polygon(); /** - * Base mesh class + * Base mesh class. + * The reason for this class is to empower you to have maximum flexibility to render any kind of webGL you can think of. + * This class assumes a certain level of webGL knowledge. + * If you know a bit this should abstract enough away to make you life easier! + * Pretty much ALL WebGL can be broken down into the following: + * Geometry - The structure and data for the mesh. This can include anything from positions, uvs, normals, colors etc.. + * Shader - This is the shader that pixi will render the geometry with. (attributes in the shader must match the geometry!) + * Uniforms - These are the values passed to the shader when the mesh is rendered. + * As a shader can be reused across multiple objects, it made sense to allow uniforms to exist outside of the shader + * State - This is the state of WebGL required to render the mesh. + * Through a combination of the above elements you can render anything you want, 2D or 3D! + * * @class * @extends PIXI.Container * @memberof PIXI */ -export default class Mesh extends RawMesh +export default class Mesh extends Container { /** - * @param {PIXI.Texture} [texture=Texture.EMPTY] - The texture to use - * @param {Float32Array} [vertices] - if you want to specify the vertices - * @param {Float32Array} [uvs] - if you want to specify the uvs - * @param {Uint16Array} [indices] - if you want to specify the indices - * @param {number} [drawMode] - the drawMode, can be any of the Mesh.DRAW_MODES consts + * @param {PIXI.Geometry} geometry the geometry the mesh will use + * @param {PIXI.Shader} shader the shader the mesh will use + * @param {PIXI.State} state the state that the webGL context is required to be in to render the mesh + * @param {number} drawMode the drawMode, can be any of the PIXI.DRAW_MODES consts */ - constructor(texture = Texture.EMPTY, vertices, uvs, indices, drawMode) + constructor(geometry, shader, state, drawMode = DRAW_MODES.TRIANGLES) { - const geometry = new Geometry(); - - if (!meshProgram) - { - meshProgram = new Program(vertex, fragment); - } - - geometry.addAttribute('aVertexPosition', vertices) - .addAttribute('aTextureCoord', uvs) - .addIndex(indices); - - geometry.getAttribute('aVertexPosition').static = false; - - const uniforms = { - uSampler: texture, - uTextureMatrix: Matrix.IDENTITY, - alpha: 1, - uColor: new Float32Array([1, 1, 1, 1]), - }; - - super(geometry, new Shader(meshProgram, uniforms), null, drawMode); + super(); /** - * The Uvs of the Mesh - * - * @member {Float32Array} + * the geometry the mesh will use + * @type {PIXI.Geometry} */ - this.uvs = geometry.getAttribute('aTextureCoord').data; + this.geometry = geometry; /** - * An array of vertices - * - * @member {Float32Array} + * the shader the mesh will use + * @type {PIXI.Shader} */ - this.vertices = geometry.getAttribute('aVertexPosition').data; - - this.uniforms = uniforms; + this.shader = shader; /** - * The texture of the Mesh - * - * @member {PIXI.Texture} - * @default PIXI.Texture.EMPTY - * @private + * the webGL state the mesh requires to render + * @type {PIXI.State} */ - this.texture = texture; + this.state = state || new State(); /** - * The tint applied to the mesh. This is a [r,g,b] value. A value of [1,1,1] will remove any - * tint effect. + * The way the Mesh should be drawn, can be any of the {@link PIXI.Mesh.DRAW_MODES} consts * * @member {number} + * @see PIXI.Mesh.DRAW_MODES + */ + this.drawMode = drawMode; + + /** + * The way uniforms that will be used by the mesh's shader. + * @member {Object} + */ + + /** + * A map of renderer IDs to webgl render data + * * @private + * @member {object} */ - this._tintRGB = new Float32Array([1, 1, 1]); - - // Set default tint - this.tint = 0xFFFFFF; - - this.blendMode = BLEND_MODES.NORMAL; + this._glDatas = {}; /** - * TextureMatrix instance for this Mesh, used to track Texture changes + * Plugin that is responsible for rendering this element. + * Allows to customize the rendering process without overriding '_render' & '_renderCanvas' methods. * - * @member {PIXI.TextureMatrix} - * @readonly + * @member {string} + * @default 'mesh' */ - this.uvMatrix = new TextureMatrix(this._texture); + this.pluginName = 'mesh'; - /** - * whether or not upload uvMatrix to shader - * if its false, then uvs should be pre-multiplied - * if you change it for generated mesh, please call 'refresh(true)' - * @member {boolean} - * @default false - */ - this.uploadUvMatrix = false; - - /** - * Uploads vertices buffer every frame, like in PixiJS V3 and V4. - * - * @member {boolean} - * @default true - */ - this.autoUpdate = true; + this.start = 0; + this.size = 0; } /** - * The tint applied to the Rope. This is a hex value. A value of - * 0xFFFFFF will remove any tint effect. + * Renders the object using the WebGL renderer * - * @member {number} - * @memberof PIXI.Sprite# - * @default 0xFFFFFF + * @param {PIXI.Renderer} renderer a reference to the WebGL renderer + * @private */ - get tint() + _render(renderer) { - return this._tint; + renderer.batch.setObjectRenderer(renderer.plugins[this.pluginName]); + renderer.plugins[this.pluginName].render(this); } /** - * Sets the tint of the rope. + * Updates the bounds of the mesh as a rectangle. The bounds calculation takes the worldTransform into account. + * there must be a aVertexPosition attribute present in the geometry for bounds to be calculated correctly. * - * @param {number} value - The value to set to. + * @private */ - set tint(value) + _calculateBounds() { - this._tint = value; - - hex2rgb(this._tint, this._tintRGB); - } - - /** - * The blend mode to be applied to the sprite. Set to `PIXI.BLEND_MODES.NORMAL` to remove any blend mode. - * - * @member {number} - * @default PIXI.BLEND_MODES.NORMAL - * @see PIXI.BLEND_MODES - */ - get blendMode() - { - return this.state.blendMode; - } - - set blendMode(value) // eslint-disable-line require-jsdoc - { - this.state.blendMode = value; - } - - /** - * The texture that the mesh uses. - * - * @member {PIXI.Texture} - */ - get texture() - { - return this._texture; - } - - set texture(value) // eslint-disable-line require-jsdoc - { - if (this._texture === value) + // The position property could be set manually? + if (this.geometry.attributes.aVertexPosition) { - return; + const vertices = this.geometry.getAttribute('aVertexPosition').data; + + // TODO - we can cache local bounds and use them if they are dirty (like graphics) + this._bounds.addVertices(this.transform, vertices, 0, vertices.length); + } + } + + /** + * Tests if a point is inside this mesh. Works only for TRIANGLE_MESH + * + * @param {PIXI.Point} point the point to test + * @return {boolean} the result of the test + */ + containsPoint(point) + { + if (!this.getBounds().contains(point.x, point.y)) + { + return false; } - this._texture = value; - this.uniforms.uSampler = this.texture; + this.worldTransform.applyInverse(point, tempPoint); - if (value) + const vertices = this.geometry.getAttribute('aVertexPosition').data; + + const points = tempPolygon.points; + const indices = this.geometry.getIndex().data; + const len = indices.length; + const step = this.drawMode === 4 ? 3 : 1; + + for (let i = 0; i + 2 < len; i += step) { - // wait for the texture to load - if (value.baseTexture.valid) + const ind0 = indices[i] * 2; + const ind1 = indices[i + 1] * 2; + const ind2 = indices[i + 2] * 2; + + points[0] = vertices[ind0]; + points[1] = vertices[ind0 + 1]; + points[2] = vertices[ind1]; + points[3] = vertices[ind1 + 1]; + points[4] = vertices[ind2]; + points[5] = vertices[ind2 + 1]; + + if (tempPolygon.contains(tempPoint.x, tempPoint.y)) { - this._onTextureUpdate(); + return true; + } + } + + return false; + } + + /** + * Destroys the Mesh object. + * + * @param {object|boolean} [options] - Options parameter. A boolean will act as if all + * options have been set to that value + * @param {boolean} [options.children=false] - if set to true, all the children will have + * their destroy method called as well. 'options' will be passed on to those calls. + * @param {boolean} [options.texture=false] - Only used for child Sprites if options.children is set to true + * Should it destroy the texture of the child sprite + * @param {boolean} [options.baseTexture=false] - Only used for child Sprites if options.children is set to true + * Should it destroy the base texture of the child sprite + */ + destroy(options) + { + // for each webgl data entry, destroy the WebGLGraphicsData + for (const id in this._glDatas) + { + const data = this._glDatas[id]; + + if (data.destroy) + { + data.destroy(); } else { - value.once('update', this._onTextureUpdate, this); + if (data.vertexBuffer) + { + data.vertexBuffer.destroy(); + data.vertexBuffer = null; + } + if (data.indexBuffer) + { + data.indexBuffer.destroy(); + data.indexBuffer = null; + } + if (data.uvBuffer) + { + data.uvBuffer.destroy(); + data.uvBuffer = null; + } + if (data.vao) + { + data.vao.destroy(); + data.vao = null; + } } } - } - _render(renderer) - { - const baseTex = this._texture.baseTexture; + this._glDatas = null; - premultiplyRgba(this._tintRGB, this.worldAlpha, this.uniforms.uColor, baseTex.premultiplyAlpha); - super._render(renderer); - } - /** - * When the texture is updated, this event will fire to update the scale and frame - * - * @private - */ - _onTextureUpdate() - { - // constructor texture update stop - if (!this.uvMatrix) - { - return; - } - this.uvMatrix.texture = this._texture; - this.refresh(); - } + this.geometry = null; + this.shader = null; + this.state = null; - /** - * multiplies uvs only if uploadUvMatrix is false - * call it after you change uvs manually - * make sure that texture is valid - */ - multiplyUvs() - { - if (!this.uploadUvMatrix) - { - this.uvMatrix.multiplyUvs(this.uvs); - } - } - - /** - * Refreshes uvs for generated meshes (rope, plane) - * sometimes refreshes vertices too - * - * @param {boolean} [forceUpdate=false] if true, matrices will be updated any case - */ - refresh(forceUpdate) - { - if (this.uvMatrix.update(forceUpdate)) - { - this._refresh(); - } - } - - /** - * Updates the object transform for rendering - * - * @private - */ - updateTransform() - { - if (this.autoUpdate) - { - this.geometry.buffers[0].update(); - } - this.containerUpdateTransform(); - } - - /** - * re-calculates mesh coords - * @private - */ - _refresh() - { - /* empty */ + super.destroy(options); } } diff --git a/packages/mesh/src/MeshRenderer.js b/packages/mesh/src/MeshRenderer.js index 12b159b..d7baf9b 100644 --- a/packages/mesh/src/MeshRenderer.js +++ b/packages/mesh/src/MeshRenderer.js @@ -36,7 +36,7 @@ /** * renders mesh * @private - * @param {PIXI.RawMesh} mesh mesh instance + * @param {PIXI.Mesh} mesh mesh instance */ render(mesh) { diff --git a/packages/mesh/src/NineSlicePlane.js b/packages/mesh/src/NineSlicePlane.js deleted file mode 100644 index 0bae92c..0000000 --- a/packages/mesh/src/NineSlicePlane.js +++ /dev/null @@ -1,270 +0,0 @@ -import Plane from './Plane'; - -const DEFAULT_BORDER_SIZE = 10; - -/** - * The NineSlicePlane allows you to stretch a texture using 9-slice scaling. The corners will remain unscaled (useful - * for buttons with rounded corners for example) and the other areas will be scaled horizontally and or vertically - * - *```js - * let Plane9 = new PIXI.NineSlicePlane(PIXI.Texture.from('BoxWithRoundedCorners.png'), 15, 15, 15, 15); - * ``` - *
- *      A                          B
- *    +---+----------------------+---+
- *  C | 1 |          2           | 3 |
- *    +---+----------------------+---+
- *    |   |                      |   |
- *    | 4 |          5           | 6 |
- *    |   |                      |   |
- *    +---+----------------------+---+
- *  D | 7 |          8           | 9 |
- *    +---+----------------------+---+
-
- *  When changing this objects width and/or height:
- *     areas 1 3 7 and 9 will remain unscaled.
- *     areas 2 and 8 will be stretched horizontally
- *     areas 4 and 6 will be stretched vertically
- *     area 5 will be stretched both horizontally and vertically
- * 
- * - * @class - * @extends PIXI.Plane - * @memberof PIXI - * - */ -export default class NineSlicePlane extends Plane -{ - /** - * @param {PIXI.Texture} texture - The texture to use on the NineSlicePlane. - * @param {int} [leftWidth=10] size of the left vertical bar (A) - * @param {int} [topHeight=10] size of the top horizontal bar (C) - * @param {int} [rightWidth=10] size of the right vertical bar (B) - * @param {int} [bottomHeight=10] size of the bottom horizontal bar (D) - */ - constructor(texture, leftWidth, topHeight, rightWidth, bottomHeight) - { - super(texture, 4, 4); - - this._origWidth = texture.orig.width; - this._origHeight = texture.orig.height; - - /** - * The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane - * - * @member {number} - * @memberof PIXI.NineSlicePlane# - * @override - */ - this._width = this._origWidth; - - /** - * The height of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane - * - * @member {number} - * @memberof PIXI.NineSlicePlane# - * @override - */ - this._height = this._origHeight; - - /** - * The width of the left column (a) - * - * @member {number} - * @memberof PIXI.NineSlicePlane# - * @override - */ - this._leftWidth = typeof leftWidth !== 'undefined' ? leftWidth : DEFAULT_BORDER_SIZE; - - /** - * The width of the right column (b) - * - * @member {number} - * @memberof PIXI.NineSlicePlane# - * @override - */ - this._rightWidth = typeof rightWidth !== 'undefined' ? rightWidth : DEFAULT_BORDER_SIZE; - - /** - * The height of the top row (c) - * - * @member {number} - * @memberof PIXI.NineSlicePlane# - * @override - */ - this._topHeight = typeof topHeight !== 'undefined' ? topHeight : DEFAULT_BORDER_SIZE; - - /** - * The height of the bottom row (d) - * - * @member {number} - * @memberof PIXI.NineSlicePlane# - * @override - */ - this._bottomHeight = typeof bottomHeight !== 'undefined' ? bottomHeight : DEFAULT_BORDER_SIZE; - - this.refresh(true); - } - - /** - * Updates the horizontal vertices. - * - */ - updateHorizontalVertices() - { - const vertices = this.vertices; - - const h = this._topHeight + this._bottomHeight; - const scale = this._height > h ? 1.0 : this._height / h; - - vertices[9] = vertices[11] = vertices[13] = vertices[15] = this._topHeight * scale; - vertices[17] = vertices[19] = vertices[21] = vertices[23] = this._height - (this._bottomHeight * scale); - vertices[25] = vertices[27] = vertices[29] = vertices[31] = this._height; - } - - /** - * Updates the vertical vertices. - * - */ - updateVerticalVertices() - { - const vertices = this.vertices; - - const w = this._leftWidth + this._rightWidth; - const scale = this._width > w ? 1.0 : this._width / w; - - vertices[2] = vertices[10] = vertices[18] = vertices[26] = this._leftWidth * scale; - vertices[4] = vertices[12] = vertices[20] = vertices[28] = this._width - (this._rightWidth * scale); - vertices[6] = vertices[14] = vertices[22] = vertices[30] = this._width; - } - - /** - * The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane - * - * @member {number} - */ - get width() - { - return this._width; - } - - set width(value) // eslint-disable-line require-jsdoc - { - this._width = value; - this._refresh(); - } - - /** - * The height of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane - * - * @member {number} - */ - get height() - { - return this._height; - } - - set height(value) // eslint-disable-line require-jsdoc - { - this._height = value; - this._refresh(); - } - - /** - * The width of the left column - * - * @member {number} - */ - get leftWidth() - { - return this._leftWidth; - } - - set leftWidth(value) // eslint-disable-line require-jsdoc - { - this._leftWidth = value; - this._refresh(); - } - - /** - * The width of the right column - * - * @member {number} - */ - get rightWidth() - { - return this._rightWidth; - } - - set rightWidth(value) // eslint-disable-line require-jsdoc - { - this._rightWidth = value; - this._refresh(); - } - - /** - * The height of the top row - * - * @member {number} - */ - get topHeight() - { - return this._topHeight; - } - - set topHeight(value) // eslint-disable-line require-jsdoc - { - this._topHeight = value; - this._refresh(); - } - - /** - * The height of the bottom row - * - * @member {number} - */ - get bottomHeight() - { - return this._bottomHeight; - } - - set bottomHeight(value) // eslint-disable-line require-jsdoc - { - this._bottomHeight = value; - this._refresh(); - } - - /** - * Refreshes NineSlicePlane coords. All of them. - */ - _refresh() - { - super._refresh(); - - const uvs = this.uvs; - const texture = this._texture; - - this._origWidth = texture.orig.width; - this._origHeight = texture.orig.height; - - const _uvw = 1.0 / this._origWidth; - const _uvh = 1.0 / this._origHeight; - - uvs[0] = uvs[8] = uvs[16] = uvs[24] = 0; - uvs[1] = uvs[3] = uvs[5] = uvs[7] = 0; - uvs[6] = uvs[14] = uvs[22] = uvs[30] = 1; - uvs[25] = uvs[27] = uvs[29] = uvs[31] = 1; - - uvs[2] = uvs[10] = uvs[18] = uvs[26] = _uvw * this._leftWidth; - uvs[4] = uvs[12] = uvs[20] = uvs[28] = 1 - (_uvw * this._rightWidth); - uvs[9] = uvs[11] = uvs[13] = uvs[15] = _uvh * this._topHeight; - uvs[17] = uvs[19] = uvs[21] = uvs[23] = 1 - (_uvh * this._bottomHeight); - - this.updateHorizontalVertices(); - this.updateVerticalVertices(); - - this.geometry.buffers[1].update(); - - this.multiplyUvs(); - } -} diff --git a/packages/mesh/src/Plane.js b/packages/mesh/src/Plane.js deleted file mode 100644 index c416b4c..0000000 --- a/packages/mesh/src/Plane.js +++ /dev/null @@ -1,100 +0,0 @@ -import Mesh from './Mesh'; - -/** - * The Plane allows you to draw a texture across several points and them manipulate these points - * - *```js - * for (let i = 0; i < 20; i++) { - * points.push(new PIXI.Point(i * 50, 0)); - * }; - * let Plane = new PIXI.Plane(PIXI.Texture.from("snake.png"), points); - * ``` - * - * @class - * @extends PIXI.Mesh - * @memberof PIXI - * - */ -export default class Plane extends Mesh -{ - /** - * @param {PIXI.Texture} texture - The texture to use on the Plane. - * @param {number} verticesX - The number of vertices in the x-axis - * @param {number} verticesY - The number of vertices in the y-axis - * @param {object} [opts] - an options object - add meshWidth and meshHeight, temporary object for PixiJS v5 alpha - */ - constructor(texture, verticesX, verticesY, opts = {}) - { - super(texture, new Float32Array(1), new Float32Array(1), new Uint16Array(1), 4); - - this.verticesX = verticesX || 10; - this.verticesY = verticesY || 10; - - this.meshWidth = opts.meshWidth || 0; - this.meshHeight = opts.meshHeight || 0; - - this.refresh(); - } - - /** - * Refreshes plane coordinates - * @private - */ - _refresh() - { - const texture = this._texture; - const total = this.verticesX * this.verticesY; - const verts = []; - const uvs = []; - const indices = []; - - const segmentsX = this.verticesX - 1; - const segmentsY = this.verticesY - 1; - - const sizeX = (this.meshWidth || texture.width) / segmentsX; - const sizeY = (this.meshHeight || texture.height) / segmentsY; - - for (let i = 0; i < total; i++) - { - const x = (i % this.verticesX); - const y = ((i / this.verticesX) | 0); - - verts.push(x * sizeX, y * sizeY); - - uvs.push(x / segmentsX, y / segmentsY); - } - - // cons - - const totalSub = segmentsX * segmentsY; - - for (let i = 0; i < totalSub; i++) - { - const xpos = i % segmentsX; - const ypos = (i / segmentsX) | 0; - - const value = (ypos * this.verticesX) + xpos; - const value2 = (ypos * this.verticesX) + xpos + 1; - const value3 = ((ypos + 1) * this.verticesX) + xpos; - const value4 = ((ypos + 1) * this.verticesX) + xpos + 1; - - indices.push(value, value2, value3); - indices.push(value2, value4, value3); - } - - this.vertices = new Float32Array(verts); - this.uvs = new Float32Array(uvs); - this.indices = new Uint16Array(indices); - - this.geometry.buffers[0].data = this.vertices; - this.geometry.buffers[1].data = this.uvs; - this.geometry.indexBuffer.data = this.indices; - - // ensure that the changes are uploaded - this.geometry.buffers[0].update(); - this.geometry.buffers[1].update(); - this.geometry.indexBuffer.update(); - - this.multiplyUvs(); - } -} diff --git a/packages/mesh/src/RawMesh.js b/packages/mesh/src/RawMesh.js deleted file mode 100644 index 7297e94..0000000 --- a/packages/mesh/src/RawMesh.js +++ /dev/null @@ -1,220 +0,0 @@ -import { State } from '@pixi/core'; -import { DRAW_MODES } from '@pixi/constants'; -import { Point, Polygon } from '@pixi/math'; -import { Container } from '@pixi/display'; - -const tempPoint = new Point(); -const tempPolygon = new Polygon(); - -/** - * Base mesh class. - * The reason for this class is to empower you to have maximum flexibility to render any kind of webGL you can think of. - * This class assumes a certain level of webGL knowledge. - * If you know a bit this should abstract enough away to make you life easier! - * Pretty much ALL WebGL can be broken down into the following: - * Geometry - The structure and data for the mesh. This can include anything from positions, uvs, normals, colors etc.. - * Shader - This is the shader that pixi will render the geometry with. (attributes in the shader must match the geometry!) - * Uniforms - These are the values passed to the shader when the mesh is rendered. - * As a shader can be reused across multiple objects, it made sense to allow uniforms to exist outside of the shader - * State - This is the state of WebGL required to render the mesh. - * Through a combination of the above elements you can render anything you want, 2D or 3D! - * - * @class - * @extends PIXI.Container - * @memberof PIXI - */ -export default class RawMesh extends Container -{ - /** - * @param {PIXI.Geometry} geometry the geometry the mesh will use - * @param {PIXI.Shader} shader the shader the mesh will use - * @param {PIXI.State} state the state that the webGL context is required to be in to render the mesh - * @param {number} drawMode the drawMode, can be any of the PIXI.DRAW_MODES consts - */ - constructor(geometry, shader, state, drawMode = DRAW_MODES.TRIANGLES) - { - super(); - - /** - * the geometry the mesh will use - * @type {PIXI.Geometry} - */ - this.geometry = geometry; - - /** - * the shader the mesh will use - * @type {PIXI.Shader} - */ - this.shader = shader; - - /** - * the webGL state the mesh requires to render - * @type {PIXI.State} - */ - this.state = state || new State(); - - /** - * The way the Mesh should be drawn, can be any of the {@link PIXI.RawMesh.DRAW_MODES} consts - * - * @member {number} - * @see PIXI.RawMesh.DRAW_MODES - */ - this.drawMode = drawMode; - - /** - * The way uniforms that will be used by the mesh's shader. - * @member {Object} - */ - - /** - * A map of renderer IDs to webgl render data - * - * @private - * @member {object} - */ - this._glDatas = {}; - - /** - * Plugin that is responsible for rendering this element. - * Allows to customize the rendering process without overriding '_render' & '_renderCanvas' methods. - * - * @member {string} - * @default 'mesh' - */ - this.pluginName = 'mesh'; - - this.start = 0; - this.size = 0; - } - - /** - * Renders the object using the WebGL renderer - * - * @param {PIXI.Renderer} renderer a reference to the WebGL renderer - * @private - */ - _render(renderer) - { - renderer.batch.setObjectRenderer(renderer.plugins[this.pluginName]); - renderer.plugins[this.pluginName].render(this); - } - - /** - * Updates the bounds of the mesh as a rectangle. The bounds calculation takes the worldTransform into account. - * there must be a aVertexPosition attribute present in the geometry for bounds to be calculated correctly. - * - * @private - */ - _calculateBounds() - { - // The position property could be set manually? - if (this.geometry.attributes.aVertexPosition) - { - const vertices = this.geometry.getAttribute('aVertexPosition').data; - - // TODO - we can cache local bounds and use them if they are dirty (like graphics) - this._bounds.addVertices(this.transform, vertices, 0, vertices.length); - } - } - - /** - * Tests if a point is inside this mesh. Works only for TRIANGLE_MESH - * - * @param {PIXI.Point} point the point to test - * @return {boolean} the result of the test - */ - containsPoint(point) - { - if (!this.getBounds().contains(point.x, point.y)) - { - return false; - } - - this.worldTransform.applyInverse(point, tempPoint); - - const vertices = this.geometry.getAttribute('aVertexPosition').data; - - const points = tempPolygon.points; - const indices = this.geometry.getIndex().data; - const len = indices.length; - const step = this.drawMode === 4 ? 3 : 1; - - for (let i = 0; i + 2 < len; i += step) - { - const ind0 = indices[i] * 2; - const ind1 = indices[i + 1] * 2; - const ind2 = indices[i + 2] * 2; - - points[0] = vertices[ind0]; - points[1] = vertices[ind0 + 1]; - points[2] = vertices[ind1]; - points[3] = vertices[ind1 + 1]; - points[4] = vertices[ind2]; - points[5] = vertices[ind2 + 1]; - - if (tempPolygon.contains(tempPoint.x, tempPoint.y)) - { - return true; - } - } - - return false; - } - - /** - * Destroys the RawMesh object. - * - * @param {object|boolean} [options] - Options parameter. A boolean will act as if all - * options have been set to that value - * @param {boolean} [options.children=false] - if set to true, all the children will have - * their destroy method called as well. 'options' will be passed on to those calls. - * @param {boolean} [options.texture=false] - Only used for child Sprites if options.children is set to true - * Should it destroy the texture of the child sprite - * @param {boolean} [options.baseTexture=false] - Only used for child Sprites if options.children is set to true - * Should it destroy the base texture of the child sprite - */ - destroy(options) - { - // for each webgl data entry, destroy the WebGLGraphicsData - for (const id in this._glDatas) - { - const data = this._glDatas[id]; - - if (data.destroy) - { - data.destroy(); - } - else - { - if (data.vertexBuffer) - { - data.vertexBuffer.destroy(); - data.vertexBuffer = null; - } - if (data.indexBuffer) - { - data.indexBuffer.destroy(); - data.indexBuffer = null; - } - if (data.uvBuffer) - { - data.uvBuffer.destroy(); - data.uvBuffer = null; - } - if (data.vao) - { - data.vao.destroy(); - data.vao = null; - } - } - } - - this._glDatas = null; - - this.geometry = null; - this.shader = null; - this.state = null; - - super.destroy(options); - } -} diff --git a/packages/mesh/src/Rope.js b/packages/mesh/src/Rope.js deleted file mode 100644 index b4f85d3..0000000 --- a/packages/mesh/src/Rope.js +++ /dev/null @@ -1,182 +0,0 @@ -import Mesh from './Mesh'; - -/** - * The rope allows you to draw a texture across several points and them manipulate these points - * - *```js - * for (let i = 0; i < 20; i++) { - * points.push(new PIXI.Point(i * 50, 0)); - * }; - * let rope = new PIXI.Rope(PIXI.Texture.from("snake.png"), points); - * ``` - * - * @class - * @extends PIXI.Mesh - * @memberof PIXI - * - */ -export default class Rope extends Mesh -{ - /** - * @param {PIXI.Texture} texture - The texture to use on the rope. - * @param {PIXI.Point[]} points - An array of {@link PIXI.Point} objects to construct this rope. - */ - constructor(texture, points) - { - super(texture, new Float32Array(points.length * 4), - new Float32Array(points.length * 4), - new Uint16Array(points.length * 2), - 5); - - /* - * @member {PIXI.Point[]} An array of points that determine the rope - */ - this.points = points; - this.refresh(); - } - /** - * Refreshes Rope indices and uvs - * @private - */ - _refresh() - { - const points = this.points; - - if (!points) return; - - const vertexBuffer = this.geometry.getAttribute('aVertexPosition'); - const uvBuffer = this.geometry.getAttribute('aTextureCoord'); - const indexBuffer = this.geometry.getIndex(); - - // if too little points, or texture hasn't got UVs set yet just move on. - if (points.length < 1 || !this.texture._uvs) - { - return; - } - - // if the number of points has changed we will need to recreate the arraybuffers - if (vertexBuffer.data.length / 4 !== points.length) - { - vertexBuffer.data = new Float32Array(points.length * 4); - uvBuffer.data = new Float32Array(points.length * 4); - indexBuffer.data = new Uint16Array(points.length * 2); - } - - const uvs = uvBuffer.data; - const indices = indexBuffer.data; - - uvs[0] = 0; - uvs[1] = 0; - uvs[2] = 0; - uvs[3] = 1; - - indices[0] = 0; - indices[1] = 1; - - const total = points.length; - - for (let i = 1; i < total; i++) - { - // time to do some smart drawing! - let index = i * 4; - const amount = i / (total - 1); - - uvs[index] = amount; - uvs[index + 1] = 0; - - uvs[index + 2] = amount; - uvs[index + 3] = 1; - - index = i * 2; - indices[index] = index; - indices[index + 1] = index + 1; - } - - // ensure that the changes are uploaded - uvBuffer.update(); - indexBuffer.update(); - - this.multiplyUvs(); - this.refreshVertices(); - } - - /** - * refreshes vertices of Rope mesh - */ - refreshVertices() - { - const points = this.points; - - if (points.length < 1) - { - return; - } - - let lastPoint = points[0]; - let nextPoint; - let perpX = 0; - let perpY = 0; - - // this.count -= 0.2; - - const vertices = this.vertices; - const total = points.length; - - for (let i = 0; i < total; i++) - { - const point = points[i]; - const index = i * 4; - - if (i < points.length - 1) - { - nextPoint = points[i + 1]; - } - else - { - nextPoint = point; - } - - perpY = -(nextPoint.x - lastPoint.x); - perpX = nextPoint.y - lastPoint.y; - - let ratio = (1 - (i / (total - 1))) * 10; - - if (ratio > 1) - { - ratio = 1; - } - - const perpLength = Math.sqrt((perpX * perpX) + (perpY * perpY)); - const num = this._texture.height / 2; // (20 + Math.abs(Math.sin((i + this.count) * 0.3) * 50) )* ratio; - - perpX /= perpLength; - perpY /= perpLength; - - perpX *= num; - perpY *= num; - - vertices[index] = point.x + perpX; - vertices[index + 1] = point.y + perpY; - vertices[index + 2] = point.x - perpX; - vertices[index + 3] = point.y - perpY; - - lastPoint = point; - } - - this.geometry.buffers[0].update(); - } - - /** - * Updates the object transform for rendering - * - * @private - */ - updateTransform() - { - if (this.autoUpdate) - { - this.refreshVertices(); - } - this.containerUpdateTransform(); - } -} diff --git a/packages/mesh/src/index.js b/packages/mesh/src/index.js index a245772..e14ab9f 100644 --- a/packages/mesh/src/index.js +++ b/packages/mesh/src/index.js @@ -1,6 +1,2 @@ export { default as Mesh } from './Mesh'; -export { default as RawMesh } from './RawMesh'; export { default as MeshRenderer } from './MeshRenderer'; -export { default as Plane } from './Plane'; -export { default as NineSlicePlane } from './NineSlicePlane'; -export { default as Rope } from './Rope'; diff --git a/packages/mesh/src/mesh.frag b/packages/mesh/src/mesh.frag deleted file mode 100644 index 6096983..0000000 --- a/packages/mesh/src/mesh.frag +++ /dev/null @@ -1,9 +0,0 @@ -varying vec2 vTextureCoord; -uniform vec4 uColor; - -uniform sampler2D uSampler; - -void main(void) -{ - gl_FragColor = texture2D(uSampler, vTextureCoord) * uColor; -} diff --git a/packages/mesh/src/mesh.vert b/packages/mesh/src/mesh.vert deleted file mode 100644 index 0526df9..0000000 --- a/packages/mesh/src/mesh.vert +++ /dev/null @@ -1,15 +0,0 @@ -attribute vec2 aVertexPosition; -attribute vec2 aTextureCoord; - -uniform mat3 projectionMatrix; -uniform mat3 translationMatrix; -uniform mat3 uTextureMatrix; - -varying vec2 vTextureCoord; - -void main(void) -{ - gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); - - vTextureCoord = (uTextureMatrix * vec3(aTextureCoord, 1.0)).xy; -} diff --git a/packages/mesh/test/.eslintrc.json b/packages/mesh/test/.eslintrc.json deleted file mode 100644 index 2ad8efb..0000000 --- a/packages/mesh/test/.eslintrc.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "globals": { - "expect": false, - "assert": false, - "sinon": false, - "PIXI": false - }, - "rules": { - "func-names": 0, - "no-unused-expressions": 0 - } -} \ No newline at end of file diff --git a/packages/mesh/test/Plane.js b/packages/mesh/test/Plane.js deleted file mode 100644 index f9b1c25..0000000 --- a/packages/mesh/test/Plane.js +++ /dev/null @@ -1,60 +0,0 @@ -const { Plane } = require('../'); -const { isWebGLSupported, skipHello } = require('@pixi/utils'); -const { Loader } = require('@pixi/loaders'); -const { Point } = require('@pixi/math'); -const { RenderTexture, Texture } = require('@pixi/core'); - -skipHello(); - -function withGL(fn) -{ - return isWebGLSupported() ? fn : undefined; -} - -// TODO: fix with webglrenderer -describe('PIXI.mesh.Plane', function () -{ - it.skip('should create a plane from an external image', withGL(function (done) - { - const loader = new Loader(); - - loader.add('testBitmap', `file://${__dirname}/resources/bitmap-1.png`) - .load(function (loader, resources) - { - const plane = new Plane(resources.testBitmap.texture, 100, 100); - - expect(plane.verticesX).to.equal(100); - expect(plane.verticesY).to.equal(100); - done(); - }); - })); - - it.skip('should create a new empty textured Plane', withGL(function () - { - const plane = new Plane(Texture.EMPTY, 100, 100); - - expect(plane.verticesX).to.equal(100); - expect(plane.verticesY).to.equal(100); - })); - - describe('containsPoint', function () - { - it.skip('should return true when point inside', withGL(function () - { - const point = new Point(10, 10); - const texture = new RenderTexture.create(20, 30); - const plane = new Plane(texture, 100, 100); - - expect(plane.containsPoint(point)).to.be.true; - })); - - it.skip('should return false when point outside', withGL(function () - { - const point = new Point(100, 100); - const texture = new RenderTexture.create(20, 30); - const plane = new Plane(texture, 100, 100); - - expect(plane.containsPoint(point)).to.be.false; - })); - }); -}); diff --git a/bundles/pixi.js/package.json b/bundles/pixi.js/package.json index 49c7276..177e059 100644 --- a/bundles/pixi.js/package.json +++ b/bundles/pixi.js/package.json @@ -49,6 +49,7 @@ "@pixi/loaders": "^5.0.0-alpha.2", "@pixi/math": "^5.0.0-alpha.2", "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/mesh-extras": "^5.0.0-alpha.2", "@pixi/mixin-cache-as-bitmap": "^5.0.0-alpha.2", "@pixi/mixin-get-child-by-name": "^5.0.0-alpha.2", "@pixi/mixin-get-global-position": "^5.0.0-alpha.2", diff --git a/bundles/pixi.js/src/deprecated.js b/bundles/pixi.js/src/deprecated.js index 147617c..dbebeb0 100644 --- a/bundles/pixi.js/src/deprecated.js +++ b/bundles/pixi.js/src/deprecated.js @@ -263,15 +263,15 @@ Object.defineProperties(PIXI.mesh, { /** * @class PIXI.mesh.Mesh - * @see PIXI.Mesh + * @see PIXI.Mesh2d * @deprecated since 5.0.0 */ Mesh: { get() { - warn('PIXI.mesh.Mesh has moved to PIXI.Mesh'); + warn('PIXI.mesh.Mesh has moved to PIXI.Mesh2d'); - return PIXI.Mesh; + return PIXI.Mesh2d; }, }, /** @@ -315,15 +315,15 @@ }, /** * @class PIXI.mesh.RawMesh - * @see PIXI.RawMesh + * @see PIXI.Mesh * @deprecated since 5.0.0 */ RawMesh: { get() { - warn('PIXI.mesh.RawMesh has moved to PIXI.RawMesh'); + warn('PIXI.mesh.RawMesh has moved to PIXI.Mesh'); - return PIXI.RawMesh; + return PIXI.Mesh; }, }, /** diff --git a/bundles/pixi.js/src/index.js b/bundles/pixi.js/src/index.js index a3a0d1b..6fdabf0 100644 --- a/bundles/pixi.js/src/index.js +++ b/bundles/pixi.js/src/index.js @@ -9,6 +9,7 @@ import * as loaders from '@pixi/loaders'; import * as math from '@pixi/math'; import * as mesh from '@pixi/mesh'; +import * as meshExtras from '@pixi/mesh-extras'; import * as particles from '@pixi/particles'; import * as prepare from '@pixi/prepare'; import * as sprite from '@pixi/sprite'; @@ -128,6 +129,7 @@ loaders, math, mesh, + meshExtras, particles, sprite, spriteAnimated, @@ -152,6 +154,7 @@ export * from '@pixi/loaders'; export * from '@pixi/math'; export * from '@pixi/mesh'; +export * from '@pixi/mesh-extras'; export * from '@pixi/particles'; export * from '@pixi/sprite'; export * from '@pixi/spritesheet'; diff --git a/package-lock.json b/package-lock.json index 7fe6db7..0814729 100644 --- a/package-lock.json +++ b/package-lock.json @@ -209,7 +209,7 @@ "argparse": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", - "integrity": "sha1-vNZ5HqWuCXJeF+WtmIE0zUCz2RE=", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", "dev": true, "requires": { "sprintf-js": "1.0.3" @@ -228,7 +228,7 @@ "arr-flatten": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz", - "integrity": "sha1-NgSLv/TntH4TZkQxbJlmnqWukfE=", + "integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==", "dev": true }, "arr-union": { @@ -297,7 +297,7 @@ "assertion-error": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", - "integrity": "sha1-5gtrDo8wG9l+U3UhW9pAbIURjAs=", + "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", "dev": true }, "async": { @@ -396,7 +396,7 @@ "brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha1-PH/L9SnYcibz0vUrlm/1Jx60Qd0=", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, "requires": { "balanced-match": "1.0.0", @@ -568,7 +568,7 @@ "circular-json": { "version": "0.3.3", "resolved": "https://registry.npmjs.org/circular-json/-/circular-json-0.3.3.tgz", - "integrity": "sha1-gVyZ6oT2gJUp0vRXkb34JxE1LWY=", + "integrity": "sha512-UZK3NBx2Mca+b5LsG7bY183pHWt5Y1xts4P3Pz7ENTwGVnJOUWbRb3ocjvX7hx9tq/yTAdclXm9sZ38gNuem4A==", "dev": true }, "cli-cursor": { @@ -638,7 +638,7 @@ "color-convert": { "version": "1.9.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.1.tgz", - "integrity": "sha1-wSYRB66y8pTr/+ye2eytUppgl+0=", + "integrity": "sha512-mjGanIiwQJskCC18rPR6OmrZ6fm2Lc7PeGFYwCmy5J34wC6F1PzdGL6xeMfmgicfYcNLGuVFA3WzXtIDCQSZxQ==", "dev": true, "requires": { "color-name": "1.1.3" @@ -1427,7 +1427,7 @@ "boom": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/boom/-/boom-5.2.0.tgz", - "integrity": "sha1-XdnabuOl8wIHdDYpDLcX0/SlTgI=", + "integrity": "sha512-Z5BTk6ZRe4tXXQlkqftmsAUANpXmuwlsF5Oov8ThoMbQRzdGTA1ngYRW160GexgOgjsFOKJz0LYhoNi+2AMBUw==", "dev": true, "requires": { "hoek": "4.2.1" @@ -1471,7 +1471,7 @@ "debug": { "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha1-XRKFFd8TT/Mn6QpMk/Tgd6U2NB8=", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", "dev": true, "requires": { "ms": "2.0.0" @@ -1585,7 +1585,7 @@ "doctrine": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", - "integrity": "sha1-XNAfwQFiG0LEzX9dGmYkNxbT850=", + "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", "dev": true, "requires": { "esutils": "2.0.2" @@ -1662,7 +1662,7 @@ "es6-promise": { "version": "4.2.4", "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.4.tgz", - "integrity": "sha1-3EIhwrFlGHYL2MOaUtjzVvwA7Sk=", + "integrity": "sha512-/NdNZVJg+uZgtm9eS3O6lrOLYmQag2DjdEXuPaHlZ6RuVqgqaVZfgYCepEIKsLqwdQArOPtC3XzRLqGGfT8KQQ==", "dev": true }, "escape-string-regexp": { @@ -1788,7 +1788,7 @@ "espree": { "version": "3.5.4", "resolved": "https://registry.npmjs.org/espree/-/espree-3.5.4.tgz", - "integrity": "sha1-sPRHGHyKi+2US4FaZgvd9d610ac=", + "integrity": "sha512-yAcIQxtmMiB/jL32dzEp2enBeidsB7xWPLNiw3IIkpVds1P+h7qF9YwJq1yUNzp2OKXgAprs4F61ih66UsoD1A==", "dev": true, "requires": { "acorn": "5.5.0", @@ -1798,7 +1798,7 @@ "esprima": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.0.tgz", - "integrity": "sha1-RJnt3NERDgshi6zy+n9/WfVcqAQ=", + "integrity": "sha512-oftTcaMu/EGrEIu904mWteKIv8vMuOgGYo7EhVJJN00R/EED9DCua/xxHRdYnKtcECzVg7xOWhflvJMnqcFZjw==", "dev": true }, "esquery": { @@ -1813,7 +1813,7 @@ "esrecurse": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.2.1.tgz", - "integrity": "sha1-AHo7n9vCs7uH5IeeoZyS/b05Qs8=", + "integrity": "sha512-64RBB++fIOAXPw3P9cy89qfMlvZEXZkqqJkjqqXIvzP5ezRZjW+lPWjw35UX/3EhUPFYbg5ER4JYgDw4007/DQ==", "dev": true, "requires": { "estraverse": "4.2.0" @@ -2024,7 +2024,7 @@ "find-root": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/find-root/-/find-root-1.1.0.tgz", - "integrity": "sha1-q8/Iunb3CMQql7PWhbfpRQv7nOQ=", + "integrity": "sha512-NKfW6bec6GfKc0SGx1e07QZY9PE99u0Bft/0rzSD5k3sO/vwkVUpDUKVm5Gpp5Ue3YfShPFTX2070tDs5kB9Ng==", "dev": true }, "find-up": { @@ -2103,7 +2103,7 @@ "supports-color": { "version": "5.3.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.3.0.tgz", - "integrity": "sha1-WySsFduA+pJ89SJ6SjP9PEx2dsA=", + "integrity": "sha512-0aP01LLIskjKs3lq52EC0aGBAJhLq7B2Rd8HC/DR/PtNNpcLilNmHC12O+hu0usQpo7wtHNRqtrhBwtDb0+dNg==", "dev": true, "requires": { "has-flag": "3.0.0" @@ -2567,7 +2567,7 @@ "glob": { "version": "7.1.2", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", - "integrity": "sha1-wZyd+aAocC1nhhI4SmVSQExjbRU=", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", "dev": true, "requires": { "fs.realpath": "1.0.0", @@ -2672,7 +2672,7 @@ "growl": { "version": "1.10.3", "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.3.tgz", - "integrity": "sha1-GSa6kM8+3+KttJJ/WIC8IsZseQ8=", + "integrity": "sha512-hKlsbA5Vu3xsh1Cg3J7jSmX/WaW6A5oBeqzM88oNbCRQFz+zUaXm6yxS4RVytp1scBoJzSYl4YAEOQIt6O8V1Q==", "dev": true }, "handlebars": { @@ -2738,7 +2738,7 @@ "hawk": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/hawk/-/hawk-6.0.2.tgz", - "integrity": "sha1-r02RTrBl+bXOTZ0RwcshJu7MMDg=", + "integrity": "sha512-miowhl2+U7Qle4vdLqDdPt9m09K6yZhkLDTWGoUiUzrQCn+mHHSmfJgAyGaLRZbPmTqfFFjRV1QWCW0VWUJBbQ==", "dev": true, "requires": { "boom": "4.3.1", @@ -2756,7 +2756,7 @@ "hoek": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/hoek/-/hoek-4.2.1.tgz", - "integrity": "sha1-ljRQKqEsRF3Vp8VzS1cruHOKrLs=", + "integrity": "sha512-QLg82fGkfnJ/4iy1xZ81/9SIJiq1NGFUMGs6ParyjBZr6jW2Ufj/snDqTHixNlHdPNwN2RLVD0Pi3igeK9+JfA==", "dev": true }, "home-path": { @@ -2791,7 +2791,7 @@ "ignore": { "version": "3.3.7", "resolved": "https://registry.npmjs.org/ignore/-/ignore-3.3.7.tgz", - "integrity": "sha1-YSKJv7PCIOGGpYEYYY1b6MG6sCE=", + "integrity": "sha512-YGG3ejvBNHRqu0559EOxxNFihD0AjpvHlC/pdGKd3X3ofe+CoJkYazwNJYTNebqpPKN+VVQbh4ZFn1DivMNuHA==", "dev": true }, "imurmurhash": { @@ -2828,7 +2828,7 @@ "ini": { "version": "1.3.5", "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", - "integrity": "sha1-7uJfVtscnsYIXgwid4CD9Zar+Sc=", + "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==", "dev": true }, "inquirer": { @@ -2901,7 +2901,7 @@ "is-buffer": { "version": "1.1.6", "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", - "integrity": "sha1-76ouqdqg16suoTqXsritUf776L4=", + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", "dev": true }, "is-builtin-module": { @@ -3054,7 +3054,7 @@ "is-resolvable": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/is-resolvable/-/is-resolvable-1.1.0.tgz", - "integrity": "sha1-+xj4fOH+uSUWnJpAfBkxijIG7Yg=", + "integrity": "sha512-qgDYXFSR5WvEfuS5dMj6oTMEbrrSaM0CrFk2Yiq/gXnBvD9pMa2jGXxyhGLfvhZpuMZe18CJpFxAt3CRs42NMg==", "dev": true }, "is-retry-allowed": { @@ -3204,7 +3204,7 @@ "js-yaml": { "version": "3.11.0", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.11.0.tgz", - "integrity": "sha1-WXwai9VxUvJtYizkEXhRpR9euu8=", + "integrity": "sha512-saJstZWv7oNeOyBh3+Dx1qWzhW0+e6/8eDzo7p5rDFqxntSztloLtuKu+Ejhtq82jsilwOIZYsCz+lIjthg1Hw==", "dev": true, "requires": { "argparse": "1.0.10", @@ -3324,7 +3324,7 @@ "just-extend": { "version": "1.1.27", "resolved": "https://registry.npmjs.org/just-extend/-/just-extend-1.1.27.tgz", - "integrity": "sha1-7G55QQ/5FORyZSq/oOYDwD1g6QU=", + "integrity": "sha512-mJVp13Ix6gFo3SBAy9U/kL+oeZqzlYYYLQBwXVBlVzIsZwBqGREnOro24oC/8s8aox+rJhtZ2DiQof++IrkA+g==", "dev": true }, "kind-of": { @@ -3703,7 +3703,7 @@ "lodash": { "version": "4.17.5", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.5.tgz", - "integrity": "sha1-maktZcAnLevoyWtgV7yPv6O+1RE=", + "integrity": "sha512-svL3uiZf1RwhH+cWrfZn3A4+U58wbP0tGVTLQPbjplZxZ8ROD9VLuNgsRniTlLe7OlSqR79RUehXgpBW/s0IQw==", "dev": true }, "lodash._reinterpolate": { @@ -3740,7 +3740,7 @@ "lolex": { "version": "2.3.2", "resolved": "https://registry.npmjs.org/lolex/-/lolex-2.3.2.tgz", - "integrity": "sha1-hflFBCUQO/nnpgZo6iXcQydMqAc=", + "integrity": "sha512-A5pN2tkFj7H0dGIAM6MFvHKMJcPnjZsOMvR7ujCjfgW5TbV6H9vb1PgxLtHvjqNZTHsUolz+6/WEO0N1xNx2ng==", "dev": true }, "longest": { @@ -3816,7 +3816,7 @@ "marked": { "version": "0.3.17", "resolved": "https://registry.npmjs.org/marked/-/marked-0.3.17.tgz", - "integrity": "sha1-YH8GZos8axJGso8T2nYRasGqLSs=", + "integrity": "sha512-+AKbNsjZl6jFfLPwHhWmGTqE009wTKn3RTmn9K8oUKHrX/abPJjtcRtXpYB/FFrwPJRUA86LX/de3T0knkPCmQ==", "dev": true }, "mem": { @@ -3896,13 +3896,13 @@ "mime-db": { "version": "1.33.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.33.0.tgz", - "integrity": "sha1-o0kgUKXLm2NFBUHjnZeI0icng9s=", + "integrity": "sha512-BHJ/EKruNIqJf/QahvxwQZXKygOQ256myeN/Ew+THcAa5q+PjyTTMMeNQC4DZw5AwfvelsUrA6B67NKMqXDbzQ==", "dev": true }, "mime-types": { "version": "2.1.18", "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.18.tgz", - "integrity": "sha1-bzI/YKg9ERRvgx/xH9ZuL+VQO7g=", + "integrity": "sha512-lc/aahn+t4/SWV/qcmumYjymLsWfN3ELhpmVuUFjgsORruuZPVSwAQryq+HHGvO/SI2KVX26bx+En+zhM8g8hQ==", "dev": true, "requires": { "mime-db": "1.33.0" @@ -3917,7 +3917,7 @@ "minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha1-UWbihkV/AzBgZL5Ul+jbsMPTIIM=", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "dev": true, "requires": { "brace-expansion": "1.1.11" @@ -4071,7 +4071,7 @@ "normalize-package-data": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.4.0.tgz", - "integrity": "sha1-EvlaMH1YNSB1oEkHuErIvpisAS8=", + "integrity": "sha512-9jjUFbTPfEy3R/ad/2oNbKtW9Hgovl5O1FvFWKkKblNXoN/Oou6+9+KKohPK13Yc3/TyunyWhJp6gvRNR/PPAw==", "dev": true, "requires": { "hosted-git-info": "2.5.0", @@ -4511,7 +4511,7 @@ "process-nextick-args": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", - "integrity": "sha1-o31zL0JxtKsa0HDTVQjoKQeI/6o=", + "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==", "dev": true }, "progress": { @@ -4584,7 +4584,7 @@ "qs": { "version": "6.5.1", "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.1.tgz", - "integrity": "sha1-NJzfbu+J7EXBLX1es/wMhwNDptg=", + "integrity": "sha512-eRzhrN1WSINYCDCbrz796z37LOe3m5tmW7RQf6oBntukAG1nmovJvhnwHHRMAfeoItc1m2Hk02WER2aQ/iqs+A==", "dev": true }, "quick-lru": { @@ -4596,7 +4596,7 @@ "randomatic": { "version": "1.1.7", "resolved": "https://registry.npmjs.org/randomatic/-/randomatic-1.1.7.tgz", - "integrity": "sha1-x6vpzIuHwLqodrGf3oP9RkeX44w=", + "integrity": "sha512-D5JUjPyJbaJDkuAazpVnSfVkLlpeO3wDlPROTMLGKG1zMFNFRgrciKo1ltz/AzNTkqE0HzDx655QOL51N06how==", "dev": true, "requires": { "is-number": "3.0.0", @@ -4701,7 +4701,7 @@ "regex-cache": { "version": "0.4.4", "resolved": "https://registry.npmjs.org/regex-cache/-/regex-cache-0.4.4.tgz", - "integrity": "sha1-db3FiioUls7EihKDW8VMjVYjNt0=", + "integrity": "sha512-nVIZwtCjkC9YgvWkpM55B5rBhBYRZhAaJbgcFYXXsHnbZ9UZI9nnVWYZpBlCqv9ho2eZryPnWrZGsOdPwVWXWQ==", "dev": true, "requires": { "is-equal-shallow": "0.1.3" @@ -4729,7 +4729,7 @@ "remap-istanbul": { "version": "0.10.1", "resolved": "https://registry.npmjs.org/remap-istanbul/-/remap-istanbul-0.10.1.tgz", - "integrity": "sha1-OqWN1QIdSZ8zbTulvzu7kcG4jjc=", + "integrity": "sha512-gsNQXs5kJLhErICSyYhzVZ++C8LBW8dgwr874Y2QvzAUS75zBlD/juZgXs39nbYJ09fZDlX2AVLVJAY2jbFJoQ==", "dev": true, "requires": { "amdefine": "1.0.1", @@ -4769,7 +4769,7 @@ "source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha1-dHIq8y6WFOnCh6jQu95IteLxomM=", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", "dev": true }, "through2": { @@ -4883,7 +4883,7 @@ "resolve": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.5.0.tgz", - "integrity": "sha1-HwmsznlsmnYlefMbLBzEw83fnzY=", + "integrity": "sha512-hgoSGrc3pjzAPHNBg+KnFcK2HwlHTs/YrAGUr6qgTVUZmXv1UEXXl0bZNBKMA9fud6lRYFdPGz0xXxycPzmmiw==", "dev": true, "requires": { "path-parse": "1.0.5" @@ -4924,7 +4924,7 @@ "rimraf": { "version": "2.6.2", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", - "integrity": "sha1-LtgVDSShbqhlHm1u8PR8QVjOejY=", + "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", "dev": true, "requires": { "glob": "7.1.2" @@ -5063,19 +5063,19 @@ "safe-buffer": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", - "integrity": "sha1-iTMSr2myEj3vcfV4iQAWce6yyFM=", + "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", "dev": true }, "samsam": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/samsam/-/samsam-1.3.0.tgz", - "integrity": "sha1-jR2TUOJWItow3j5EumkrUiGrfFA=", + "integrity": "sha512-1HwIYD/8UlOtFS3QO3w7ey+SdSDFE4HRNLZoZRYVQefrOY3l17epswImeB1ijgJFQJodIaHcwkp3r/myBjFVbg==", "dev": true }, "semver": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz", - "integrity": "sha1-3Eu8emyp2Rbe5dQ1FvAJK1j3uKs=", + "integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==", "dev": true }, "set-blocking": { @@ -5117,7 +5117,7 @@ "sinon-chai": { "version": "2.14.0", "resolved": "https://registry.npmjs.org/sinon-chai/-/sinon-chai-2.14.0.tgz", - "integrity": "sha1-2n3UzIPNaiYLZ8yg96n9riahIF0=", + "integrity": "sha512-9stIF1utB0ywNHNT7RgiXbdmen8QDCRsrTjw+G9TgKt1Yexjiv8TOWZ6WHsTPz57Yky3DIswZvEqX8fpuHNDtQ==", "dev": true }, "slash": { @@ -5146,7 +5146,7 @@ "sntp": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/sntp/-/sntp-2.1.0.tgz", - "integrity": "sha1-LGzsFP7cIiJznK+bXD2F0cxaLMg=", + "integrity": "sha512-FL1b58BDrqS3A11lJ0zEdnJ3UOKqVxawAkF3k7F0CVN7VQ34aZrV+G8BZ1WC9ZL7NyrwsW0oviwsWDgRuVYtJg==", "dev": true, "requires": { "hoek": "4.2.1" @@ -5203,7 +5203,7 @@ "spdx-correct": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.0.0.tgz", - "integrity": "sha1-BaW01xU6GVvJLDxCW2nzsqlSTII=", + "integrity": "sha512-N19o9z5cEyc8yQQPukRCZ9EUmb4HUpnrmaL/fxS2pBo2jbfcFRVuFZ/oFC+vZz0MNNk0h80iMn5/S6qGZOL5+g==", "dev": true, "requires": { "spdx-expression-parse": "3.0.0", @@ -5213,13 +5213,13 @@ "spdx-exceptions": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.1.0.tgz", - "integrity": "sha1-LHrmEFbHFKW5ubKyr30xHvXHj+k=", + "integrity": "sha512-4K1NsmrlCU1JJgUrtgEeTVyfx8VaYea9J9LvARxhbHtVtohPs/gFGG5yy49beySjlIMhhXZ4QqujIZEfS4l6Cg==", "dev": true }, "spdx-expression-parse": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.0.tgz", - "integrity": "sha1-meEZt6XaAOBUkcn6M4t5BII7QdA=", + "integrity": "sha512-Yg6D3XpRD4kkOmTpdgbUiEJFKghJH03fiC1OPll5h/0sO6neh2jqRDVHOQ4o/LMea0tgCkbMgea5ip/e+MkWyg==", "dev": true, "requires": { "spdx-exceptions": "2.1.0", @@ -5229,7 +5229,7 @@ "spdx-license-ids": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.0.tgz", - "integrity": "sha1-enzShHDMbToc/m1miG9rxDDTrIc=", + "integrity": "sha512-2+EPwgbnmOIl8HjGBXXMd9NAu02vLjOO1nWw4kmeRDFyHn+M/ETfHxQUK0oXg8ctgVnl9t3rosNVsZ1jG61nDA==", "dev": true }, "speedometer": { @@ -5566,7 +5566,7 @@ "tough-cookie": { "version": "2.3.4", "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.4.tgz", - "integrity": "sha1-7GDO44rGdQY//JelwYlwV47oNlU=", + "integrity": "sha512-TZ6TTfI5NtZnuyy/Kecv+CnoROnyXn2DN97LontgQpCwsX2XyLYCC0ENhYkehSOwAp8rTQKc/NUIF7BkQ5rKLA==", "dev": true, "requires": { "punycode": "1.4.1" @@ -5708,13 +5708,13 @@ "uuid": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.2.1.tgz", - "integrity": "sha1-EsUou51Y0LkmXZovbw/ovhf/HxQ=", + "integrity": "sha512-jZnMwlb9Iku/O3smGWvZhauCf6cvvpKi4BKRiliS3cxnI+Gz9j5MEpTz2UFuXiKPJocb7gnsLHwiS05ige5BEA==", "dev": true }, "validate-npm-package-license": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.3.tgz", - "integrity": "sha1-gWQ7y+8b3+zUYjeT3EZIlIupgzg=", + "integrity": "sha512-63ZOUnL4SIXj4L0NixR3L1lcjO38crAbgrTpl28t8jjrfuiOBL5Iygm+60qPs/KsZGzPNg6Smnc/oY16QTjF0g==", "dev": true, "requires": { "spdx-correct": "3.0.0", @@ -5750,7 +5750,7 @@ "which": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/which/-/which-1.3.0.tgz", - "integrity": "sha1-/wS9/AEO5UfXgL7DjhrBwnd9JTo=", + "integrity": "sha512-xcJpopdamTuY5duC/KnTTNBraPK54YwpenP4lzxU8H91GudWpFv38u0CKjclE1Wi2EH2EDz5LRcHcKbCIzqGyg==", "dev": true, "requires": { "isexe": "2.0.0" diff --git a/packages/canvas/canvas-mesh/package.json b/packages/canvas/canvas-mesh/package.json index 691cd2c..6744a17 100644 --- a/packages/canvas/canvas-mesh/package.json +++ b/packages/canvas/canvas-mesh/package.json @@ -24,6 +24,7 @@ "dependencies": { "@pixi/constants": "^5.0.0-alpha.2", "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/mesh-extras": "^5.0.0-alpha.2", "@pixi/settings": "^5.0.0-alpha.2" }, "devDependencies": { diff --git a/packages/canvas/canvas-mesh/src/Mesh.js b/packages/canvas/canvas-mesh/src/Mesh.js index 900a872..c43a74b 100644 --- a/packages/canvas/canvas-mesh/src/Mesh.js +++ b/packages/canvas/canvas-mesh/src/Mesh.js @@ -1,36 +1,14 @@ import { Mesh } from '@pixi/mesh'; -import { settings } from './settings'; - -// IMPORTANT: Please do NOT use this as a precedent to use `settings` after the object is created -// this was merely created to completely decouple canvas from the base Mesh class and we are -// unable to add `canvasPadding` in the constructor anymore, as the case was for PixiJS v4. /** - * Internal variable for `canvasPadding`. + * Renders the object using the Canvas renderer * * @private - * @memberof PIXI.Mesh - * @member {number} - * @default null - */ -Mesh.prototype._canvasPadding = null; - -/** - * Triangles in canvas mode are automatically antialiased, use this value to force triangles - * to overlap a bit with each other. To set the global default, set {@link PIXI.settings.MESH_CANVAS_PADDING} - * - * @see PIXI.settings.MESH_CANVAS_PADDING - * @member {number} canvasPadding + * @method _renderCanvas * @memberof PIXI.Mesh# - * @default 0 + * @param {PIXI.CanvasRenderer} renderer - The canvas renderer. */ -Object.defineProperty(Mesh.prototype, 'canvasPadding', { - get() - { - return this._canvasPadding !== null ? this._canvasPadding : settings.MESH_CANVAS_PADDING; - }, - set(value) - { - this._canvasPadding = value; - }, -}); +Mesh.prototype._renderCanvas = function _renderCanvas(renderer) +{ + renderer.plugins[this.pluginName].render(this); +}; diff --git a/packages/canvas/canvas-mesh/src/Mesh2d.js b/packages/canvas/canvas-mesh/src/Mesh2d.js new file mode 100644 index 0000000..d0bd80f --- /dev/null +++ b/packages/canvas/canvas-mesh/src/Mesh2d.js @@ -0,0 +1,36 @@ +import { Mesh2d } from '@pixi/mesh-extras'; +import { settings } from './settings'; + +// IMPORTANT: Please do NOT use this as a precedent to use `settings` after the object is created +// this was merely created to completely decouple canvas from the base Mesh class and we are +// unable to add `canvasPadding` in the constructor anymore, as the case was for PixiJS v4. + +/** + * Internal variable for `canvasPadding`. + * + * @private + * @memberof PIXI.Mesh2d + * @member {number} + * @default null + */ +Mesh2d.prototype._canvasPadding = null; + +/** + * Triangles in canvas mode are automatically antialiased, use this value to force triangles + * to overlap a bit with each other. To set the global default, set {@link PIXI.settings.MESH_CANVAS_PADDING} + * + * @see PIXI.settings.MESH_CANVAS_PADDING + * @member {number} canvasPadding + * @memberof PIXI.Mesh2d# + * @default 0 + */ +Object.defineProperty(Mesh2d.prototype, 'canvasPadding', { + get() + { + return this._canvasPadding !== null ? this._canvasPadding : settings.MESH_CANVAS_PADDING; + }, + set(value) + { + this._canvasPadding = value; + }, +}); diff --git a/packages/canvas/canvas-mesh/src/NineSlicePlane.js b/packages/canvas/canvas-mesh/src/NineSlicePlane.js index 09eaf9c..2fd5acc 100644 --- a/packages/canvas/canvas-mesh/src/NineSlicePlane.js +++ b/packages/canvas/canvas-mesh/src/NineSlicePlane.js @@ -1,4 +1,4 @@ -import { NineSlicePlane } from '@pixi/mesh'; +import { NineSlicePlane } from '@pixi/mesh-extras'; /** * Renders the object using the Canvas renderer diff --git a/packages/canvas/canvas-mesh/src/RawMesh.js b/packages/canvas/canvas-mesh/src/RawMesh.js deleted file mode 100644 index bf40184..0000000 --- a/packages/canvas/canvas-mesh/src/RawMesh.js +++ /dev/null @@ -1,14 +0,0 @@ -import { RawMesh } from '@pixi/mesh'; - -/** - * Renders the object using the Canvas renderer - * - * @private - * @method _renderCanvas - * @memberof PIXI.RawMesh# - * @param {PIXI.CanvasRenderer} renderer - The canvas renderer. - */ -RawMesh.prototype._renderCanvas = function _renderCanvas(renderer) -{ - renderer.plugins[this.pluginName].render(this); -}; diff --git a/packages/canvas/canvas-mesh/src/index.js b/packages/canvas/canvas-mesh/src/index.js index 2295016..f4fa31d 100644 --- a/packages/canvas/canvas-mesh/src/index.js +++ b/packages/canvas/canvas-mesh/src/index.js @@ -1,6 +1,6 @@ export { default as CanvasMeshRenderer } from './CanvasMeshRenderer'; import './settings'; -import './Mesh'; +import './Mesh2d'; import './NineSlicePlane'; -import './RawMesh'; +import './Mesh'; diff --git a/packages/canvas/canvas-mesh/src/settings.js b/packages/canvas/canvas-mesh/src/settings.js index 4cefb4c..e81b8e0 100644 --- a/packages/canvas/canvas-mesh/src/settings.js +++ b/packages/canvas/canvas-mesh/src/settings.js @@ -3,7 +3,7 @@ /** * Default `canvasPadding` for canvas-based Mesh rendering. * - * @see PIXI.Mesh#canvasPadding + * @see PIXI.Mesh2d#canvasPadding * @static * @constant * @memberof PIXI.settings diff --git a/packages/mesh-extras/LICENSE b/packages/mesh-extras/LICENSE new file mode 100644 index 0000000..148e3eb --- /dev/null +++ b/packages/mesh-extras/LICENSE @@ -0,0 +1,21 @@ +The MIT License + +Copyright (c) 2013-2018 Mathew Groves, Chad Engler + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/packages/mesh-extras/README.md b/packages/mesh-extras/README.md new file mode 100644 index 0000000..1d9b0e1 --- /dev/null +++ b/packages/mesh-extras/README.md @@ -0,0 +1,19 @@ +# @pixi/mesh-extras + +## Installation + +```bash +npm install @pixi/mesh-extras +``` + +## Usage + +```js +import { MeshRenderer } from '@pixi/mesh'; +import { Renderer } from '@pixi/core'; +import { Rope } from '@pixi/mesh-extras'; + +Renderer.registerPlugin('mesh', MeshRenderer); + +const rope = new Rope(); +``` \ No newline at end of file diff --git a/packages/mesh-extras/package.json b/packages/mesh-extras/package.json new file mode 100644 index 0000000..d134f64 --- /dev/null +++ b/packages/mesh-extras/package.json @@ -0,0 +1,38 @@ +{ + "name": "@pixi/mesh-extras", + "version": "5.0.0-alpha.2", + "main": "lib/mesh-extras.js", + "module": "lib/mesh-extras.es.js", + "description": "Custom Mesh display objects, like Rope and Plane", + "author": "Mat Groves", + "contributors": [ + "Matt Karl " + ], + "homepage": "http://pixijs.com/", + "bugs": "https://github.com/pixijs/pixi.js/issues", + "license": "MIT", + "repository": { + "type": "git", + "url": "https://github.com/pixijs/pixi.js.git" + }, + "publishConfig": { + "access": "public" + }, + "scripts": { + "test": "floss --path test" + }, + "files": [ + "lib" + ], + "dependencies": { + "@pixi/constants": "^5.0.0-alpha.2", + "@pixi/core": "^5.0.0-alpha.2", + "@pixi/math": "^5.0.0-alpha.2", + "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/utils": "^5.0.0-alpha.2" + }, + "devDependencies": { + "@pixi/loaders": "^5.0.0-alpha.2", + "floss": "^2.1.3" + } +} diff --git a/packages/mesh-extras/src/Mesh2d.js b/packages/mesh-extras/src/Mesh2d.js new file mode 100644 index 0000000..d113a5e --- /dev/null +++ b/packages/mesh-extras/src/Mesh2d.js @@ -0,0 +1,263 @@ +import { Mesh } from '@pixi/mesh'; +import { Geometry, Program, Shader, Texture, TextureMatrix } from '@pixi/core'; +import { Matrix } from '@pixi/math'; +import { BLEND_MODES } from '@pixi/constants'; +import { hex2rgb, premultiplyRgba } from '@pixi/utils'; +import vertex from './mesh.vert'; +import fragment from './mesh.frag'; + +let meshProgram; + +/** + * Base mesh class + * @class + * @extends PIXI.Container + * @memberof PIXI + */ +export default class Mesh2d extends Mesh +{ + /** + * @param {PIXI.Texture} [texture=Texture.EMPTY] - The texture to use + * @param {Float32Array} [vertices] - if you want to specify the vertices + * @param {Float32Array} [uvs] - if you want to specify the uvs + * @param {Uint16Array} [indices] - if you want to specify the indices + * @param {number} [drawMode] - the drawMode, can be any of the Mesh.DRAW_MODES consts + */ + constructor(texture = Texture.EMPTY, vertices, uvs, indices, drawMode) + { + const geometry = new Geometry(); + + if (!meshProgram) + { + meshProgram = new Program(vertex, fragment); + } + + geometry.addAttribute('aVertexPosition', vertices) + .addAttribute('aTextureCoord', uvs) + .addIndex(indices); + + geometry.getAttribute('aVertexPosition').static = false; + + const uniforms = { + uSampler: texture, + uTextureMatrix: Matrix.IDENTITY, + alpha: 1, + uColor: new Float32Array([1, 1, 1, 1]), + }; + + super(geometry, new Shader(meshProgram, uniforms), null, drawMode); + + /** + * The Uvs of the Mesh + * + * @member {Float32Array} + */ + this.uvs = geometry.getAttribute('aTextureCoord').data; + + /** + * An array of vertices + * + * @member {Float32Array} + */ + this.vertices = geometry.getAttribute('aVertexPosition').data; + + this.uniforms = uniforms; + + /** + * The texture of the Mesh + * + * @member {PIXI.Texture} + * @default PIXI.Texture.EMPTY + * @private + */ + this.texture = texture; + + /** + * The tint applied to the mesh. This is a [r,g,b] value. A value of [1,1,1] will remove any + * tint effect. + * + * @member {number} + * @private + */ + this._tintRGB = new Float32Array([1, 1, 1]); + + // Set default tint + this.tint = 0xFFFFFF; + + this.blendMode = BLEND_MODES.NORMAL; + + /** + * TextureMatrix instance for this Mesh, used to track Texture changes + * + * @member {PIXI.TextureMatrix} + * @readonly + */ + this.uvMatrix = new TextureMatrix(this._texture); + + /** + * whether or not upload uvMatrix to shader + * if its false, then uvs should be pre-multiplied + * if you change it for generated mesh, please call 'refresh(true)' + * @member {boolean} + * @default false + */ + this.uploadUvMatrix = false; + + /** + * Uploads vertices buffer every frame, like in PixiJS V3 and V4. + * + * @member {boolean} + * @default true + */ + this.autoUpdate = true; + } + + /** + * The tint applied to the Rope. This is a hex value. A value of + * 0xFFFFFF will remove any tint effect. + * + * @member {number} + * @memberof PIXI.Sprite# + * @default 0xFFFFFF + */ + get tint() + { + return this._tint; + } + + /** + * Sets the tint of the rope. + * + * @param {number} value - The value to set to. + */ + set tint(value) + { + this._tint = value; + + hex2rgb(this._tint, this._tintRGB); + } + + /** + * The blend mode to be applied to the sprite. Set to `PIXI.BLEND_MODES.NORMAL` to remove any blend mode. + * + * @member {number} + * @default PIXI.BLEND_MODES.NORMAL + * @see PIXI.BLEND_MODES + */ + get blendMode() + { + return this.state.blendMode; + } + + set blendMode(value) // eslint-disable-line require-jsdoc + { + this.state.blendMode = value; + } + + /** + * The texture that the mesh uses. + * + * @member {PIXI.Texture} + */ + get texture() + { + return this._texture; + } + + set texture(value) // eslint-disable-line require-jsdoc + { + if (this._texture === value) + { + return; + } + + this._texture = value; + this.uniforms.uSampler = this.texture; + + if (value) + { + // wait for the texture to load + if (value.baseTexture.valid) + { + this._onTextureUpdate(); + } + else + { + value.once('update', this._onTextureUpdate, this); + } + } + } + + _render(renderer) + { + const baseTex = this._texture.baseTexture; + + premultiplyRgba(this._tintRGB, this.worldAlpha, this.uniforms.uColor, baseTex.premultiplyAlpha); + super._render(renderer); + } + /** + * When the texture is updated, this event will fire to update the scale and frame + * + * @private + */ + _onTextureUpdate() + { + // constructor texture update stop + if (!this.uvMatrix) + { + return; + } + this.uvMatrix.texture = this._texture; + this.refresh(); + } + + /** + * multiplies uvs only if uploadUvMatrix is false + * call it after you change uvs manually + * make sure that texture is valid + */ + multiplyUvs() + { + if (!this.uploadUvMatrix) + { + this.uvMatrix.multiplyUvs(this.uvs); + } + } + + /** + * Refreshes uvs for generated meshes (rope, plane) + * sometimes refreshes vertices too + * + * @param {boolean} [forceUpdate=false] if true, matrices will be updated any case + */ + refresh(forceUpdate) + { + if (this.uvMatrix.update(forceUpdate)) + { + this._refresh(); + } + } + + /** + * Updates the object transform for rendering + * + * @private + */ + updateTransform() + { + if (this.autoUpdate) + { + this.geometry.buffers[0].update(); + } + this.containerUpdateTransform(); + } + + /** + * re-calculates mesh coords + * @private + */ + _refresh() + { + /* empty */ + } +} diff --git a/packages/mesh-extras/src/NineSlicePlane.js b/packages/mesh-extras/src/NineSlicePlane.js new file mode 100644 index 0000000..0bae92c --- /dev/null +++ b/packages/mesh-extras/src/NineSlicePlane.js @@ -0,0 +1,270 @@ +import Plane from './Plane'; + +const DEFAULT_BORDER_SIZE = 10; + +/** + * The NineSlicePlane allows you to stretch a texture using 9-slice scaling. The corners will remain unscaled (useful + * for buttons with rounded corners for example) and the other areas will be scaled horizontally and or vertically + * + *```js + * let Plane9 = new PIXI.NineSlicePlane(PIXI.Texture.from('BoxWithRoundedCorners.png'), 15, 15, 15, 15); + * ``` + *
+ *      A                          B
+ *    +---+----------------------+---+
+ *  C | 1 |          2           | 3 |
+ *    +---+----------------------+---+
+ *    |   |                      |   |
+ *    | 4 |          5           | 6 |
+ *    |   |                      |   |
+ *    +---+----------------------+---+
+ *  D | 7 |          8           | 9 |
+ *    +---+----------------------+---+
+
+ *  When changing this objects width and/or height:
+ *     areas 1 3 7 and 9 will remain unscaled.
+ *     areas 2 and 8 will be stretched horizontally
+ *     areas 4 and 6 will be stretched vertically
+ *     area 5 will be stretched both horizontally and vertically
+ * 
+ * + * @class + * @extends PIXI.Plane + * @memberof PIXI + * + */ +export default class NineSlicePlane extends Plane +{ + /** + * @param {PIXI.Texture} texture - The texture to use on the NineSlicePlane. + * @param {int} [leftWidth=10] size of the left vertical bar (A) + * @param {int} [topHeight=10] size of the top horizontal bar (C) + * @param {int} [rightWidth=10] size of the right vertical bar (B) + * @param {int} [bottomHeight=10] size of the bottom horizontal bar (D) + */ + constructor(texture, leftWidth, topHeight, rightWidth, bottomHeight) + { + super(texture, 4, 4); + + this._origWidth = texture.orig.width; + this._origHeight = texture.orig.height; + + /** + * The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._width = this._origWidth; + + /** + * The height of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._height = this._origHeight; + + /** + * The width of the left column (a) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._leftWidth = typeof leftWidth !== 'undefined' ? leftWidth : DEFAULT_BORDER_SIZE; + + /** + * The width of the right column (b) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._rightWidth = typeof rightWidth !== 'undefined' ? rightWidth : DEFAULT_BORDER_SIZE; + + /** + * The height of the top row (c) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._topHeight = typeof topHeight !== 'undefined' ? topHeight : DEFAULT_BORDER_SIZE; + + /** + * The height of the bottom row (d) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._bottomHeight = typeof bottomHeight !== 'undefined' ? bottomHeight : DEFAULT_BORDER_SIZE; + + this.refresh(true); + } + + /** + * Updates the horizontal vertices. + * + */ + updateHorizontalVertices() + { + const vertices = this.vertices; + + const h = this._topHeight + this._bottomHeight; + const scale = this._height > h ? 1.0 : this._height / h; + + vertices[9] = vertices[11] = vertices[13] = vertices[15] = this._topHeight * scale; + vertices[17] = vertices[19] = vertices[21] = vertices[23] = this._height - (this._bottomHeight * scale); + vertices[25] = vertices[27] = vertices[29] = vertices[31] = this._height; + } + + /** + * Updates the vertical vertices. + * + */ + updateVerticalVertices() + { + const vertices = this.vertices; + + const w = this._leftWidth + this._rightWidth; + const scale = this._width > w ? 1.0 : this._width / w; + + vertices[2] = vertices[10] = vertices[18] = vertices[26] = this._leftWidth * scale; + vertices[4] = vertices[12] = vertices[20] = vertices[28] = this._width - (this._rightWidth * scale); + vertices[6] = vertices[14] = vertices[22] = vertices[30] = this._width; + } + + /** + * The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + */ + get width() + { + return this._width; + } + + set width(value) // eslint-disable-line require-jsdoc + { + this._width = value; + this._refresh(); + } + + /** + * The height of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + */ + get height() + { + return this._height; + } + + set height(value) // eslint-disable-line require-jsdoc + { + this._height = value; + this._refresh(); + } + + /** + * The width of the left column + * + * @member {number} + */ + get leftWidth() + { + return this._leftWidth; + } + + set leftWidth(value) // eslint-disable-line require-jsdoc + { + this._leftWidth = value; + this._refresh(); + } + + /** + * The width of the right column + * + * @member {number} + */ + get rightWidth() + { + return this._rightWidth; + } + + set rightWidth(value) // eslint-disable-line require-jsdoc + { + this._rightWidth = value; + this._refresh(); + } + + /** + * The height of the top row + * + * @member {number} + */ + get topHeight() + { + return this._topHeight; + } + + set topHeight(value) // eslint-disable-line require-jsdoc + { + this._topHeight = value; + this._refresh(); + } + + /** + * The height of the bottom row + * + * @member {number} + */ + get bottomHeight() + { + return this._bottomHeight; + } + + set bottomHeight(value) // eslint-disable-line require-jsdoc + { + this._bottomHeight = value; + this._refresh(); + } + + /** + * Refreshes NineSlicePlane coords. All of them. + */ + _refresh() + { + super._refresh(); + + const uvs = this.uvs; + const texture = this._texture; + + this._origWidth = texture.orig.width; + this._origHeight = texture.orig.height; + + const _uvw = 1.0 / this._origWidth; + const _uvh = 1.0 / this._origHeight; + + uvs[0] = uvs[8] = uvs[16] = uvs[24] = 0; + uvs[1] = uvs[3] = uvs[5] = uvs[7] = 0; + uvs[6] = uvs[14] = uvs[22] = uvs[30] = 1; + uvs[25] = uvs[27] = uvs[29] = uvs[31] = 1; + + uvs[2] = uvs[10] = uvs[18] = uvs[26] = _uvw * this._leftWidth; + uvs[4] = uvs[12] = uvs[20] = uvs[28] = 1 - (_uvw * this._rightWidth); + uvs[9] = uvs[11] = uvs[13] = uvs[15] = _uvh * this._topHeight; + uvs[17] = uvs[19] = uvs[21] = uvs[23] = 1 - (_uvh * this._bottomHeight); + + this.updateHorizontalVertices(); + this.updateVerticalVertices(); + + this.geometry.buffers[1].update(); + + this.multiplyUvs(); + } +} diff --git a/packages/mesh-extras/src/Plane.js b/packages/mesh-extras/src/Plane.js new file mode 100644 index 0000000..1c240c4 --- /dev/null +++ b/packages/mesh-extras/src/Plane.js @@ -0,0 +1,100 @@ +import Mesh2d from './Mesh2d'; + +/** + * The Plane allows you to draw a texture across several points and them manipulate these points + * + *```js + * for (let i = 0; i < 20; i++) { + * points.push(new PIXI.Point(i * 50, 0)); + * }; + * let Plane = new PIXI.Plane(PIXI.Texture.from("snake.png"), points); + * ``` + * + * @class + * @extends PIXI.Mesh + * @memberof PIXI + * + */ +export default class Plane extends Mesh2d +{ + /** + * @param {PIXI.Texture} texture - The texture to use on the Plane. + * @param {number} verticesX - The number of vertices in the x-axis + * @param {number} verticesY - The number of vertices in the y-axis + * @param {object} [opts] - an options object - add meshWidth and meshHeight, temporary object for PixiJS v5 alpha + */ + constructor(texture, verticesX, verticesY, opts = {}) + { + super(texture, new Float32Array(1), new Float32Array(1), new Uint16Array(1), 4); + + this.verticesX = verticesX || 10; + this.verticesY = verticesY || 10; + + this.meshWidth = opts.meshWidth || 0; + this.meshHeight = opts.meshHeight || 0; + + this.refresh(); + } + + /** + * Refreshes plane coordinates + * @private + */ + _refresh() + { + const texture = this._texture; + const total = this.verticesX * this.verticesY; + const verts = []; + const uvs = []; + const indices = []; + + const segmentsX = this.verticesX - 1; + const segmentsY = this.verticesY - 1; + + const sizeX = (this.meshWidth || texture.width) / segmentsX; + const sizeY = (this.meshHeight || texture.height) / segmentsY; + + for (let i = 0; i < total; i++) + { + const x = (i % this.verticesX); + const y = ((i / this.verticesX) | 0); + + verts.push(x * sizeX, y * sizeY); + + uvs.push(x / segmentsX, y / segmentsY); + } + + // cons + + const totalSub = segmentsX * segmentsY; + + for (let i = 0; i < totalSub; i++) + { + const xpos = i % segmentsX; + const ypos = (i / segmentsX) | 0; + + const value = (ypos * this.verticesX) + xpos; + const value2 = (ypos * this.verticesX) + xpos + 1; + const value3 = ((ypos + 1) * this.verticesX) + xpos; + const value4 = ((ypos + 1) * this.verticesX) + xpos + 1; + + indices.push(value, value2, value3); + indices.push(value2, value4, value3); + } + + this.vertices = new Float32Array(verts); + this.uvs = new Float32Array(uvs); + this.indices = new Uint16Array(indices); + + this.geometry.buffers[0].data = this.vertices; + this.geometry.buffers[1].data = this.uvs; + this.geometry.indexBuffer.data = this.indices; + + // ensure that the changes are uploaded + this.geometry.buffers[0].update(); + this.geometry.buffers[1].update(); + this.geometry.indexBuffer.update(); + + this.multiplyUvs(); + } +} diff --git a/packages/mesh-extras/src/Rope.js b/packages/mesh-extras/src/Rope.js new file mode 100644 index 0000000..9cfde38 --- /dev/null +++ b/packages/mesh-extras/src/Rope.js @@ -0,0 +1,182 @@ +import Mesh2d from './Mesh2d'; + +/** + * The rope allows you to draw a texture across several points and them manipulate these points + * + *```js + * for (let i = 0; i < 20; i++) { + * points.push(new PIXI.Point(i * 50, 0)); + * }; + * let rope = new PIXI.Rope(PIXI.Texture.from("snake.png"), points); + * ``` + * + * @class + * @extends PIXI.Mesh + * @memberof PIXI + * + */ +export default class Rope extends Mesh2d +{ + /** + * @param {PIXI.Texture} texture - The texture to use on the rope. + * @param {PIXI.Point[]} points - An array of {@link PIXI.Point} objects to construct this rope. + */ + constructor(texture, points) + { + super(texture, new Float32Array(points.length * 4), + new Float32Array(points.length * 4), + new Uint16Array(points.length * 2), + 5); + + /* + * @member {PIXI.Point[]} An array of points that determine the rope + */ + this.points = points; + this.refresh(); + } + /** + * Refreshes Rope indices and uvs + * @private + */ + _refresh() + { + const points = this.points; + + if (!points) return; + + const vertexBuffer = this.geometry.getAttribute('aVertexPosition'); + const uvBuffer = this.geometry.getAttribute('aTextureCoord'); + const indexBuffer = this.geometry.getIndex(); + + // if too little points, or texture hasn't got UVs set yet just move on. + if (points.length < 1 || !this.texture._uvs) + { + return; + } + + // if the number of points has changed we will need to recreate the arraybuffers + if (vertexBuffer.data.length / 4 !== points.length) + { + vertexBuffer.data = new Float32Array(points.length * 4); + uvBuffer.data = new Float32Array(points.length * 4); + indexBuffer.data = new Uint16Array(points.length * 2); + } + + const uvs = uvBuffer.data; + const indices = indexBuffer.data; + + uvs[0] = 0; + uvs[1] = 0; + uvs[2] = 0; + uvs[3] = 1; + + indices[0] = 0; + indices[1] = 1; + + const total = points.length; + + for (let i = 1; i < total; i++) + { + // time to do some smart drawing! + let index = i * 4; + const amount = i / (total - 1); + + uvs[index] = amount; + uvs[index + 1] = 0; + + uvs[index + 2] = amount; + uvs[index + 3] = 1; + + index = i * 2; + indices[index] = index; + indices[index + 1] = index + 1; + } + + // ensure that the changes are uploaded + uvBuffer.update(); + indexBuffer.update(); + + this.multiplyUvs(); + this.refreshVertices(); + } + + /** + * refreshes vertices of Rope mesh + */ + refreshVertices() + { + const points = this.points; + + if (points.length < 1) + { + return; + } + + let lastPoint = points[0]; + let nextPoint; + let perpX = 0; + let perpY = 0; + + // this.count -= 0.2; + + const vertices = this.vertices; + const total = points.length; + + for (let i = 0; i < total; i++) + { + const point = points[i]; + const index = i * 4; + + if (i < points.length - 1) + { + nextPoint = points[i + 1]; + } + else + { + nextPoint = point; + } + + perpY = -(nextPoint.x - lastPoint.x); + perpX = nextPoint.y - lastPoint.y; + + let ratio = (1 - (i / (total - 1))) * 10; + + if (ratio > 1) + { + ratio = 1; + } + + const perpLength = Math.sqrt((perpX * perpX) + (perpY * perpY)); + const num = this._texture.height / 2; // (20 + Math.abs(Math.sin((i + this.count) * 0.3) * 50) )* ratio; + + perpX /= perpLength; + perpY /= perpLength; + + perpX *= num; + perpY *= num; + + vertices[index] = point.x + perpX; + vertices[index + 1] = point.y + perpY; + vertices[index + 2] = point.x - perpX; + vertices[index + 3] = point.y - perpY; + + lastPoint = point; + } + + this.geometry.buffers[0].update(); + } + + /** + * Updates the object transform for rendering + * + * @private + */ + updateTransform() + { + if (this.autoUpdate) + { + this.refreshVertices(); + } + this.containerUpdateTransform(); + } +} diff --git a/packages/mesh-extras/src/index.js b/packages/mesh-extras/src/index.js new file mode 100644 index 0000000..decf454 --- /dev/null +++ b/packages/mesh-extras/src/index.js @@ -0,0 +1,4 @@ +export { default as Mesh2d } from './Mesh2d'; +export { default as Plane } from './Plane'; +export { default as NineSlicePlane } from './NineSlicePlane'; +export { default as Rope } from './Rope'; diff --git a/packages/mesh-extras/src/mesh.frag b/packages/mesh-extras/src/mesh.frag new file mode 100644 index 0000000..6096983 --- /dev/null +++ b/packages/mesh-extras/src/mesh.frag @@ -0,0 +1,9 @@ +varying vec2 vTextureCoord; +uniform vec4 uColor; + +uniform sampler2D uSampler; + +void main(void) +{ + gl_FragColor = texture2D(uSampler, vTextureCoord) * uColor; +} diff --git a/packages/mesh-extras/src/mesh.vert b/packages/mesh-extras/src/mesh.vert new file mode 100644 index 0000000..0526df9 --- /dev/null +++ b/packages/mesh-extras/src/mesh.vert @@ -0,0 +1,15 @@ +attribute vec2 aVertexPosition; +attribute vec2 aTextureCoord; + +uniform mat3 projectionMatrix; +uniform mat3 translationMatrix; +uniform mat3 uTextureMatrix; + +varying vec2 vTextureCoord; + +void main(void) +{ + gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); + + vTextureCoord = (uTextureMatrix * vec3(aTextureCoord, 1.0)).xy; +} diff --git a/packages/mesh-extras/test/.eslintrc.json b/packages/mesh-extras/test/.eslintrc.json new file mode 100644 index 0000000..2ad8efb --- /dev/null +++ b/packages/mesh-extras/test/.eslintrc.json @@ -0,0 +1,12 @@ +{ + "globals": { + "expect": false, + "assert": false, + "sinon": false, + "PIXI": false + }, + "rules": { + "func-names": 0, + "no-unused-expressions": 0 + } +} \ No newline at end of file diff --git a/packages/mesh-extras/test/Plane.js b/packages/mesh-extras/test/Plane.js new file mode 100644 index 0000000..f9b1c25 --- /dev/null +++ b/packages/mesh-extras/test/Plane.js @@ -0,0 +1,60 @@ +const { Plane } = require('../'); +const { isWebGLSupported, skipHello } = require('@pixi/utils'); +const { Loader } = require('@pixi/loaders'); +const { Point } = require('@pixi/math'); +const { RenderTexture, Texture } = require('@pixi/core'); + +skipHello(); + +function withGL(fn) +{ + return isWebGLSupported() ? fn : undefined; +} + +// TODO: fix with webglrenderer +describe('PIXI.mesh.Plane', function () +{ + it.skip('should create a plane from an external image', withGL(function (done) + { + const loader = new Loader(); + + loader.add('testBitmap', `file://${__dirname}/resources/bitmap-1.png`) + .load(function (loader, resources) + { + const plane = new Plane(resources.testBitmap.texture, 100, 100); + + expect(plane.verticesX).to.equal(100); + expect(plane.verticesY).to.equal(100); + done(); + }); + })); + + it.skip('should create a new empty textured Plane', withGL(function () + { + const plane = new Plane(Texture.EMPTY, 100, 100); + + expect(plane.verticesX).to.equal(100); + expect(plane.verticesY).to.equal(100); + })); + + describe('containsPoint', function () + { + it.skip('should return true when point inside', withGL(function () + { + const point = new Point(10, 10); + const texture = new RenderTexture.create(20, 30); + const plane = new Plane(texture, 100, 100); + + expect(plane.containsPoint(point)).to.be.true; + })); + + it.skip('should return false when point outside', withGL(function () + { + const point = new Point(100, 100); + const texture = new RenderTexture.create(20, 30); + const plane = new Plane(texture, 100, 100); + + expect(plane.containsPoint(point)).to.be.false; + })); + }); +}); diff --git a/packages/mesh-extras/test/index.js b/packages/mesh-extras/test/index.js new file mode 100644 index 0000000..d767624 --- /dev/null +++ b/packages/mesh-extras/test/index.js @@ -0,0 +1 @@ +require('./Plane'); diff --git a/packages/mesh-extras/test/resources/bitmap-1.png b/packages/mesh-extras/test/resources/bitmap-1.png new file mode 100644 index 0000000..1284fb8 --- /dev/null +++ b/packages/mesh-extras/test/resources/bitmap-1.png Binary files differ diff --git a/packages/mesh/package.json b/packages/mesh/package.json index 8b1f8d9..10bd8e3 100644 --- a/packages/mesh/package.json +++ b/packages/mesh/package.json @@ -18,22 +18,16 @@ "publishConfig": { "access": "public" }, - "scripts": { - "test": "floss --path test" - }, "files": [ "lib" ], "dependencies": { - "@pixi/canvas-renderer": "^5.0.0-alpha.2", "@pixi/constants": "^5.0.0-alpha.2", "@pixi/core": "^5.0.0-alpha.2", "@pixi/display": "^5.0.0-alpha.2", - "@pixi/math": "^5.0.0-alpha.2", - "@pixi/utils": "^5.0.0-alpha.2" + "@pixi/math": "^5.0.0-alpha.2" }, "devDependencies": { - "@pixi/loaders": "^5.0.0-alpha.2", "floss": "^2.1.3" } } diff --git a/packages/mesh/src/Mesh.js b/packages/mesh/src/Mesh.js index e7c8f9e..1f35b7a 100644 --- a/packages/mesh/src/Mesh.js +++ b/packages/mesh/src/Mesh.js @@ -1,263 +1,220 @@ -import RawMesh from './RawMesh'; -import { Geometry, Program, Shader, Texture, TextureMatrix } from '@pixi/core'; -import { Matrix } from '@pixi/math'; -import { BLEND_MODES } from '@pixi/constants'; -import { hex2rgb, premultiplyRgba } from '@pixi/utils'; -import vertex from './mesh.vert'; -import fragment from './mesh.frag'; +import { State } from '@pixi/core'; +import { DRAW_MODES } from '@pixi/constants'; +import { Point, Polygon } from '@pixi/math'; +import { Container } from '@pixi/display'; -let meshProgram; +const tempPoint = new Point(); +const tempPolygon = new Polygon(); /** - * Base mesh class + * Base mesh class. + * The reason for this class is to empower you to have maximum flexibility to render any kind of webGL you can think of. + * This class assumes a certain level of webGL knowledge. + * If you know a bit this should abstract enough away to make you life easier! + * Pretty much ALL WebGL can be broken down into the following: + * Geometry - The structure and data for the mesh. This can include anything from positions, uvs, normals, colors etc.. + * Shader - This is the shader that pixi will render the geometry with. (attributes in the shader must match the geometry!) + * Uniforms - These are the values passed to the shader when the mesh is rendered. + * As a shader can be reused across multiple objects, it made sense to allow uniforms to exist outside of the shader + * State - This is the state of WebGL required to render the mesh. + * Through a combination of the above elements you can render anything you want, 2D or 3D! + * * @class * @extends PIXI.Container * @memberof PIXI */ -export default class Mesh extends RawMesh +export default class Mesh extends Container { /** - * @param {PIXI.Texture} [texture=Texture.EMPTY] - The texture to use - * @param {Float32Array} [vertices] - if you want to specify the vertices - * @param {Float32Array} [uvs] - if you want to specify the uvs - * @param {Uint16Array} [indices] - if you want to specify the indices - * @param {number} [drawMode] - the drawMode, can be any of the Mesh.DRAW_MODES consts + * @param {PIXI.Geometry} geometry the geometry the mesh will use + * @param {PIXI.Shader} shader the shader the mesh will use + * @param {PIXI.State} state the state that the webGL context is required to be in to render the mesh + * @param {number} drawMode the drawMode, can be any of the PIXI.DRAW_MODES consts */ - constructor(texture = Texture.EMPTY, vertices, uvs, indices, drawMode) + constructor(geometry, shader, state, drawMode = DRAW_MODES.TRIANGLES) { - const geometry = new Geometry(); - - if (!meshProgram) - { - meshProgram = new Program(vertex, fragment); - } - - geometry.addAttribute('aVertexPosition', vertices) - .addAttribute('aTextureCoord', uvs) - .addIndex(indices); - - geometry.getAttribute('aVertexPosition').static = false; - - const uniforms = { - uSampler: texture, - uTextureMatrix: Matrix.IDENTITY, - alpha: 1, - uColor: new Float32Array([1, 1, 1, 1]), - }; - - super(geometry, new Shader(meshProgram, uniforms), null, drawMode); + super(); /** - * The Uvs of the Mesh - * - * @member {Float32Array} + * the geometry the mesh will use + * @type {PIXI.Geometry} */ - this.uvs = geometry.getAttribute('aTextureCoord').data; + this.geometry = geometry; /** - * An array of vertices - * - * @member {Float32Array} + * the shader the mesh will use + * @type {PIXI.Shader} */ - this.vertices = geometry.getAttribute('aVertexPosition').data; - - this.uniforms = uniforms; + this.shader = shader; /** - * The texture of the Mesh - * - * @member {PIXI.Texture} - * @default PIXI.Texture.EMPTY - * @private + * the webGL state the mesh requires to render + * @type {PIXI.State} */ - this.texture = texture; + this.state = state || new State(); /** - * The tint applied to the mesh. This is a [r,g,b] value. A value of [1,1,1] will remove any - * tint effect. + * The way the Mesh should be drawn, can be any of the {@link PIXI.Mesh.DRAW_MODES} consts * * @member {number} + * @see PIXI.Mesh.DRAW_MODES + */ + this.drawMode = drawMode; + + /** + * The way uniforms that will be used by the mesh's shader. + * @member {Object} + */ + + /** + * A map of renderer IDs to webgl render data + * * @private + * @member {object} */ - this._tintRGB = new Float32Array([1, 1, 1]); - - // Set default tint - this.tint = 0xFFFFFF; - - this.blendMode = BLEND_MODES.NORMAL; + this._glDatas = {}; /** - * TextureMatrix instance for this Mesh, used to track Texture changes + * Plugin that is responsible for rendering this element. + * Allows to customize the rendering process without overriding '_render' & '_renderCanvas' methods. * - * @member {PIXI.TextureMatrix} - * @readonly + * @member {string} + * @default 'mesh' */ - this.uvMatrix = new TextureMatrix(this._texture); + this.pluginName = 'mesh'; - /** - * whether or not upload uvMatrix to shader - * if its false, then uvs should be pre-multiplied - * if you change it for generated mesh, please call 'refresh(true)' - * @member {boolean} - * @default false - */ - this.uploadUvMatrix = false; - - /** - * Uploads vertices buffer every frame, like in PixiJS V3 and V4. - * - * @member {boolean} - * @default true - */ - this.autoUpdate = true; + this.start = 0; + this.size = 0; } /** - * The tint applied to the Rope. This is a hex value. A value of - * 0xFFFFFF will remove any tint effect. + * Renders the object using the WebGL renderer * - * @member {number} - * @memberof PIXI.Sprite# - * @default 0xFFFFFF + * @param {PIXI.Renderer} renderer a reference to the WebGL renderer + * @private */ - get tint() + _render(renderer) { - return this._tint; + renderer.batch.setObjectRenderer(renderer.plugins[this.pluginName]); + renderer.plugins[this.pluginName].render(this); } /** - * Sets the tint of the rope. + * Updates the bounds of the mesh as a rectangle. The bounds calculation takes the worldTransform into account. + * there must be a aVertexPosition attribute present in the geometry for bounds to be calculated correctly. * - * @param {number} value - The value to set to. + * @private */ - set tint(value) + _calculateBounds() { - this._tint = value; - - hex2rgb(this._tint, this._tintRGB); - } - - /** - * The blend mode to be applied to the sprite. Set to `PIXI.BLEND_MODES.NORMAL` to remove any blend mode. - * - * @member {number} - * @default PIXI.BLEND_MODES.NORMAL - * @see PIXI.BLEND_MODES - */ - get blendMode() - { - return this.state.blendMode; - } - - set blendMode(value) // eslint-disable-line require-jsdoc - { - this.state.blendMode = value; - } - - /** - * The texture that the mesh uses. - * - * @member {PIXI.Texture} - */ - get texture() - { - return this._texture; - } - - set texture(value) // eslint-disable-line require-jsdoc - { - if (this._texture === value) + // The position property could be set manually? + if (this.geometry.attributes.aVertexPosition) { - return; + const vertices = this.geometry.getAttribute('aVertexPosition').data; + + // TODO - we can cache local bounds and use them if they are dirty (like graphics) + this._bounds.addVertices(this.transform, vertices, 0, vertices.length); + } + } + + /** + * Tests if a point is inside this mesh. Works only for TRIANGLE_MESH + * + * @param {PIXI.Point} point the point to test + * @return {boolean} the result of the test + */ + containsPoint(point) + { + if (!this.getBounds().contains(point.x, point.y)) + { + return false; } - this._texture = value; - this.uniforms.uSampler = this.texture; + this.worldTransform.applyInverse(point, tempPoint); - if (value) + const vertices = this.geometry.getAttribute('aVertexPosition').data; + + const points = tempPolygon.points; + const indices = this.geometry.getIndex().data; + const len = indices.length; + const step = this.drawMode === 4 ? 3 : 1; + + for (let i = 0; i + 2 < len; i += step) { - // wait for the texture to load - if (value.baseTexture.valid) + const ind0 = indices[i] * 2; + const ind1 = indices[i + 1] * 2; + const ind2 = indices[i + 2] * 2; + + points[0] = vertices[ind0]; + points[1] = vertices[ind0 + 1]; + points[2] = vertices[ind1]; + points[3] = vertices[ind1 + 1]; + points[4] = vertices[ind2]; + points[5] = vertices[ind2 + 1]; + + if (tempPolygon.contains(tempPoint.x, tempPoint.y)) { - this._onTextureUpdate(); + return true; + } + } + + return false; + } + + /** + * Destroys the Mesh object. + * + * @param {object|boolean} [options] - Options parameter. A boolean will act as if all + * options have been set to that value + * @param {boolean} [options.children=false] - if set to true, all the children will have + * their destroy method called as well. 'options' will be passed on to those calls. + * @param {boolean} [options.texture=false] - Only used for child Sprites if options.children is set to true + * Should it destroy the texture of the child sprite + * @param {boolean} [options.baseTexture=false] - Only used for child Sprites if options.children is set to true + * Should it destroy the base texture of the child sprite + */ + destroy(options) + { + // for each webgl data entry, destroy the WebGLGraphicsData + for (const id in this._glDatas) + { + const data = this._glDatas[id]; + + if (data.destroy) + { + data.destroy(); } else { - value.once('update', this._onTextureUpdate, this); + if (data.vertexBuffer) + { + data.vertexBuffer.destroy(); + data.vertexBuffer = null; + } + if (data.indexBuffer) + { + data.indexBuffer.destroy(); + data.indexBuffer = null; + } + if (data.uvBuffer) + { + data.uvBuffer.destroy(); + data.uvBuffer = null; + } + if (data.vao) + { + data.vao.destroy(); + data.vao = null; + } } } - } - _render(renderer) - { - const baseTex = this._texture.baseTexture; + this._glDatas = null; - premultiplyRgba(this._tintRGB, this.worldAlpha, this.uniforms.uColor, baseTex.premultiplyAlpha); - super._render(renderer); - } - /** - * When the texture is updated, this event will fire to update the scale and frame - * - * @private - */ - _onTextureUpdate() - { - // constructor texture update stop - if (!this.uvMatrix) - { - return; - } - this.uvMatrix.texture = this._texture; - this.refresh(); - } + this.geometry = null; + this.shader = null; + this.state = null; - /** - * multiplies uvs only if uploadUvMatrix is false - * call it after you change uvs manually - * make sure that texture is valid - */ - multiplyUvs() - { - if (!this.uploadUvMatrix) - { - this.uvMatrix.multiplyUvs(this.uvs); - } - } - - /** - * Refreshes uvs for generated meshes (rope, plane) - * sometimes refreshes vertices too - * - * @param {boolean} [forceUpdate=false] if true, matrices will be updated any case - */ - refresh(forceUpdate) - { - if (this.uvMatrix.update(forceUpdate)) - { - this._refresh(); - } - } - - /** - * Updates the object transform for rendering - * - * @private - */ - updateTransform() - { - if (this.autoUpdate) - { - this.geometry.buffers[0].update(); - } - this.containerUpdateTransform(); - } - - /** - * re-calculates mesh coords - * @private - */ - _refresh() - { - /* empty */ + super.destroy(options); } } diff --git a/packages/mesh/src/MeshRenderer.js b/packages/mesh/src/MeshRenderer.js index 12b159b..d7baf9b 100644 --- a/packages/mesh/src/MeshRenderer.js +++ b/packages/mesh/src/MeshRenderer.js @@ -36,7 +36,7 @@ /** * renders mesh * @private - * @param {PIXI.RawMesh} mesh mesh instance + * @param {PIXI.Mesh} mesh mesh instance */ render(mesh) { diff --git a/packages/mesh/src/NineSlicePlane.js b/packages/mesh/src/NineSlicePlane.js deleted file mode 100644 index 0bae92c..0000000 --- a/packages/mesh/src/NineSlicePlane.js +++ /dev/null @@ -1,270 +0,0 @@ -import Plane from './Plane'; - -const DEFAULT_BORDER_SIZE = 10; - -/** - * The NineSlicePlane allows you to stretch a texture using 9-slice scaling. The corners will remain unscaled (useful - * for buttons with rounded corners for example) and the other areas will be scaled horizontally and or vertically - * - *```js - * let Plane9 = new PIXI.NineSlicePlane(PIXI.Texture.from('BoxWithRoundedCorners.png'), 15, 15, 15, 15); - * ``` - *
- *      A                          B
- *    +---+----------------------+---+
- *  C | 1 |          2           | 3 |
- *    +---+----------------------+---+
- *    |   |                      |   |
- *    | 4 |          5           | 6 |
- *    |   |                      |   |
- *    +---+----------------------+---+
- *  D | 7 |          8           | 9 |
- *    +---+----------------------+---+
-
- *  When changing this objects width and/or height:
- *     areas 1 3 7 and 9 will remain unscaled.
- *     areas 2 and 8 will be stretched horizontally
- *     areas 4 and 6 will be stretched vertically
- *     area 5 will be stretched both horizontally and vertically
- * 
- * - * @class - * @extends PIXI.Plane - * @memberof PIXI - * - */ -export default class NineSlicePlane extends Plane -{ - /** - * @param {PIXI.Texture} texture - The texture to use on the NineSlicePlane. - * @param {int} [leftWidth=10] size of the left vertical bar (A) - * @param {int} [topHeight=10] size of the top horizontal bar (C) - * @param {int} [rightWidth=10] size of the right vertical bar (B) - * @param {int} [bottomHeight=10] size of the bottom horizontal bar (D) - */ - constructor(texture, leftWidth, topHeight, rightWidth, bottomHeight) - { - super(texture, 4, 4); - - this._origWidth = texture.orig.width; - this._origHeight = texture.orig.height; - - /** - * The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane - * - * @member {number} - * @memberof PIXI.NineSlicePlane# - * @override - */ - this._width = this._origWidth; - - /** - * The height of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane - * - * @member {number} - * @memberof PIXI.NineSlicePlane# - * @override - */ - this._height = this._origHeight; - - /** - * The width of the left column (a) - * - * @member {number} - * @memberof PIXI.NineSlicePlane# - * @override - */ - this._leftWidth = typeof leftWidth !== 'undefined' ? leftWidth : DEFAULT_BORDER_SIZE; - - /** - * The width of the right column (b) - * - * @member {number} - * @memberof PIXI.NineSlicePlane# - * @override - */ - this._rightWidth = typeof rightWidth !== 'undefined' ? rightWidth : DEFAULT_BORDER_SIZE; - - /** - * The height of the top row (c) - * - * @member {number} - * @memberof PIXI.NineSlicePlane# - * @override - */ - this._topHeight = typeof topHeight !== 'undefined' ? topHeight : DEFAULT_BORDER_SIZE; - - /** - * The height of the bottom row (d) - * - * @member {number} - * @memberof PIXI.NineSlicePlane# - * @override - */ - this._bottomHeight = typeof bottomHeight !== 'undefined' ? bottomHeight : DEFAULT_BORDER_SIZE; - - this.refresh(true); - } - - /** - * Updates the horizontal vertices. - * - */ - updateHorizontalVertices() - { - const vertices = this.vertices; - - const h = this._topHeight + this._bottomHeight; - const scale = this._height > h ? 1.0 : this._height / h; - - vertices[9] = vertices[11] = vertices[13] = vertices[15] = this._topHeight * scale; - vertices[17] = vertices[19] = vertices[21] = vertices[23] = this._height - (this._bottomHeight * scale); - vertices[25] = vertices[27] = vertices[29] = vertices[31] = this._height; - } - - /** - * Updates the vertical vertices. - * - */ - updateVerticalVertices() - { - const vertices = this.vertices; - - const w = this._leftWidth + this._rightWidth; - const scale = this._width > w ? 1.0 : this._width / w; - - vertices[2] = vertices[10] = vertices[18] = vertices[26] = this._leftWidth * scale; - vertices[4] = vertices[12] = vertices[20] = vertices[28] = this._width - (this._rightWidth * scale); - vertices[6] = vertices[14] = vertices[22] = vertices[30] = this._width; - } - - /** - * The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane - * - * @member {number} - */ - get width() - { - return this._width; - } - - set width(value) // eslint-disable-line require-jsdoc - { - this._width = value; - this._refresh(); - } - - /** - * The height of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane - * - * @member {number} - */ - get height() - { - return this._height; - } - - set height(value) // eslint-disable-line require-jsdoc - { - this._height = value; - this._refresh(); - } - - /** - * The width of the left column - * - * @member {number} - */ - get leftWidth() - { - return this._leftWidth; - } - - set leftWidth(value) // eslint-disable-line require-jsdoc - { - this._leftWidth = value; - this._refresh(); - } - - /** - * The width of the right column - * - * @member {number} - */ - get rightWidth() - { - return this._rightWidth; - } - - set rightWidth(value) // eslint-disable-line require-jsdoc - { - this._rightWidth = value; - this._refresh(); - } - - /** - * The height of the top row - * - * @member {number} - */ - get topHeight() - { - return this._topHeight; - } - - set topHeight(value) // eslint-disable-line require-jsdoc - { - this._topHeight = value; - this._refresh(); - } - - /** - * The height of the bottom row - * - * @member {number} - */ - get bottomHeight() - { - return this._bottomHeight; - } - - set bottomHeight(value) // eslint-disable-line require-jsdoc - { - this._bottomHeight = value; - this._refresh(); - } - - /** - * Refreshes NineSlicePlane coords. All of them. - */ - _refresh() - { - super._refresh(); - - const uvs = this.uvs; - const texture = this._texture; - - this._origWidth = texture.orig.width; - this._origHeight = texture.orig.height; - - const _uvw = 1.0 / this._origWidth; - const _uvh = 1.0 / this._origHeight; - - uvs[0] = uvs[8] = uvs[16] = uvs[24] = 0; - uvs[1] = uvs[3] = uvs[5] = uvs[7] = 0; - uvs[6] = uvs[14] = uvs[22] = uvs[30] = 1; - uvs[25] = uvs[27] = uvs[29] = uvs[31] = 1; - - uvs[2] = uvs[10] = uvs[18] = uvs[26] = _uvw * this._leftWidth; - uvs[4] = uvs[12] = uvs[20] = uvs[28] = 1 - (_uvw * this._rightWidth); - uvs[9] = uvs[11] = uvs[13] = uvs[15] = _uvh * this._topHeight; - uvs[17] = uvs[19] = uvs[21] = uvs[23] = 1 - (_uvh * this._bottomHeight); - - this.updateHorizontalVertices(); - this.updateVerticalVertices(); - - this.geometry.buffers[1].update(); - - this.multiplyUvs(); - } -} diff --git a/packages/mesh/src/Plane.js b/packages/mesh/src/Plane.js deleted file mode 100644 index c416b4c..0000000 --- a/packages/mesh/src/Plane.js +++ /dev/null @@ -1,100 +0,0 @@ -import Mesh from './Mesh'; - -/** - * The Plane allows you to draw a texture across several points and them manipulate these points - * - *```js - * for (let i = 0; i < 20; i++) { - * points.push(new PIXI.Point(i * 50, 0)); - * }; - * let Plane = new PIXI.Plane(PIXI.Texture.from("snake.png"), points); - * ``` - * - * @class - * @extends PIXI.Mesh - * @memberof PIXI - * - */ -export default class Plane extends Mesh -{ - /** - * @param {PIXI.Texture} texture - The texture to use on the Plane. - * @param {number} verticesX - The number of vertices in the x-axis - * @param {number} verticesY - The number of vertices in the y-axis - * @param {object} [opts] - an options object - add meshWidth and meshHeight, temporary object for PixiJS v5 alpha - */ - constructor(texture, verticesX, verticesY, opts = {}) - { - super(texture, new Float32Array(1), new Float32Array(1), new Uint16Array(1), 4); - - this.verticesX = verticesX || 10; - this.verticesY = verticesY || 10; - - this.meshWidth = opts.meshWidth || 0; - this.meshHeight = opts.meshHeight || 0; - - this.refresh(); - } - - /** - * Refreshes plane coordinates - * @private - */ - _refresh() - { - const texture = this._texture; - const total = this.verticesX * this.verticesY; - const verts = []; - const uvs = []; - const indices = []; - - const segmentsX = this.verticesX - 1; - const segmentsY = this.verticesY - 1; - - const sizeX = (this.meshWidth || texture.width) / segmentsX; - const sizeY = (this.meshHeight || texture.height) / segmentsY; - - for (let i = 0; i < total; i++) - { - const x = (i % this.verticesX); - const y = ((i / this.verticesX) | 0); - - verts.push(x * sizeX, y * sizeY); - - uvs.push(x / segmentsX, y / segmentsY); - } - - // cons - - const totalSub = segmentsX * segmentsY; - - for (let i = 0; i < totalSub; i++) - { - const xpos = i % segmentsX; - const ypos = (i / segmentsX) | 0; - - const value = (ypos * this.verticesX) + xpos; - const value2 = (ypos * this.verticesX) + xpos + 1; - const value3 = ((ypos + 1) * this.verticesX) + xpos; - const value4 = ((ypos + 1) * this.verticesX) + xpos + 1; - - indices.push(value, value2, value3); - indices.push(value2, value4, value3); - } - - this.vertices = new Float32Array(verts); - this.uvs = new Float32Array(uvs); - this.indices = new Uint16Array(indices); - - this.geometry.buffers[0].data = this.vertices; - this.geometry.buffers[1].data = this.uvs; - this.geometry.indexBuffer.data = this.indices; - - // ensure that the changes are uploaded - this.geometry.buffers[0].update(); - this.geometry.buffers[1].update(); - this.geometry.indexBuffer.update(); - - this.multiplyUvs(); - } -} diff --git a/packages/mesh/src/RawMesh.js b/packages/mesh/src/RawMesh.js deleted file mode 100644 index 7297e94..0000000 --- a/packages/mesh/src/RawMesh.js +++ /dev/null @@ -1,220 +0,0 @@ -import { State } from '@pixi/core'; -import { DRAW_MODES } from '@pixi/constants'; -import { Point, Polygon } from '@pixi/math'; -import { Container } from '@pixi/display'; - -const tempPoint = new Point(); -const tempPolygon = new Polygon(); - -/** - * Base mesh class. - * The reason for this class is to empower you to have maximum flexibility to render any kind of webGL you can think of. - * This class assumes a certain level of webGL knowledge. - * If you know a bit this should abstract enough away to make you life easier! - * Pretty much ALL WebGL can be broken down into the following: - * Geometry - The structure and data for the mesh. This can include anything from positions, uvs, normals, colors etc.. - * Shader - This is the shader that pixi will render the geometry with. (attributes in the shader must match the geometry!) - * Uniforms - These are the values passed to the shader when the mesh is rendered. - * As a shader can be reused across multiple objects, it made sense to allow uniforms to exist outside of the shader - * State - This is the state of WebGL required to render the mesh. - * Through a combination of the above elements you can render anything you want, 2D or 3D! - * - * @class - * @extends PIXI.Container - * @memberof PIXI - */ -export default class RawMesh extends Container -{ - /** - * @param {PIXI.Geometry} geometry the geometry the mesh will use - * @param {PIXI.Shader} shader the shader the mesh will use - * @param {PIXI.State} state the state that the webGL context is required to be in to render the mesh - * @param {number} drawMode the drawMode, can be any of the PIXI.DRAW_MODES consts - */ - constructor(geometry, shader, state, drawMode = DRAW_MODES.TRIANGLES) - { - super(); - - /** - * the geometry the mesh will use - * @type {PIXI.Geometry} - */ - this.geometry = geometry; - - /** - * the shader the mesh will use - * @type {PIXI.Shader} - */ - this.shader = shader; - - /** - * the webGL state the mesh requires to render - * @type {PIXI.State} - */ - this.state = state || new State(); - - /** - * The way the Mesh should be drawn, can be any of the {@link PIXI.RawMesh.DRAW_MODES} consts - * - * @member {number} - * @see PIXI.RawMesh.DRAW_MODES - */ - this.drawMode = drawMode; - - /** - * The way uniforms that will be used by the mesh's shader. - * @member {Object} - */ - - /** - * A map of renderer IDs to webgl render data - * - * @private - * @member {object} - */ - this._glDatas = {}; - - /** - * Plugin that is responsible for rendering this element. - * Allows to customize the rendering process without overriding '_render' & '_renderCanvas' methods. - * - * @member {string} - * @default 'mesh' - */ - this.pluginName = 'mesh'; - - this.start = 0; - this.size = 0; - } - - /** - * Renders the object using the WebGL renderer - * - * @param {PIXI.Renderer} renderer a reference to the WebGL renderer - * @private - */ - _render(renderer) - { - renderer.batch.setObjectRenderer(renderer.plugins[this.pluginName]); - renderer.plugins[this.pluginName].render(this); - } - - /** - * Updates the bounds of the mesh as a rectangle. The bounds calculation takes the worldTransform into account. - * there must be a aVertexPosition attribute present in the geometry for bounds to be calculated correctly. - * - * @private - */ - _calculateBounds() - { - // The position property could be set manually? - if (this.geometry.attributes.aVertexPosition) - { - const vertices = this.geometry.getAttribute('aVertexPosition').data; - - // TODO - we can cache local bounds and use them if they are dirty (like graphics) - this._bounds.addVertices(this.transform, vertices, 0, vertices.length); - } - } - - /** - * Tests if a point is inside this mesh. Works only for TRIANGLE_MESH - * - * @param {PIXI.Point} point the point to test - * @return {boolean} the result of the test - */ - containsPoint(point) - { - if (!this.getBounds().contains(point.x, point.y)) - { - return false; - } - - this.worldTransform.applyInverse(point, tempPoint); - - const vertices = this.geometry.getAttribute('aVertexPosition').data; - - const points = tempPolygon.points; - const indices = this.geometry.getIndex().data; - const len = indices.length; - const step = this.drawMode === 4 ? 3 : 1; - - for (let i = 0; i + 2 < len; i += step) - { - const ind0 = indices[i] * 2; - const ind1 = indices[i + 1] * 2; - const ind2 = indices[i + 2] * 2; - - points[0] = vertices[ind0]; - points[1] = vertices[ind0 + 1]; - points[2] = vertices[ind1]; - points[3] = vertices[ind1 + 1]; - points[4] = vertices[ind2]; - points[5] = vertices[ind2 + 1]; - - if (tempPolygon.contains(tempPoint.x, tempPoint.y)) - { - return true; - } - } - - return false; - } - - /** - * Destroys the RawMesh object. - * - * @param {object|boolean} [options] - Options parameter. A boolean will act as if all - * options have been set to that value - * @param {boolean} [options.children=false] - if set to true, all the children will have - * their destroy method called as well. 'options' will be passed on to those calls. - * @param {boolean} [options.texture=false] - Only used for child Sprites if options.children is set to true - * Should it destroy the texture of the child sprite - * @param {boolean} [options.baseTexture=false] - Only used for child Sprites if options.children is set to true - * Should it destroy the base texture of the child sprite - */ - destroy(options) - { - // for each webgl data entry, destroy the WebGLGraphicsData - for (const id in this._glDatas) - { - const data = this._glDatas[id]; - - if (data.destroy) - { - data.destroy(); - } - else - { - if (data.vertexBuffer) - { - data.vertexBuffer.destroy(); - data.vertexBuffer = null; - } - if (data.indexBuffer) - { - data.indexBuffer.destroy(); - data.indexBuffer = null; - } - if (data.uvBuffer) - { - data.uvBuffer.destroy(); - data.uvBuffer = null; - } - if (data.vao) - { - data.vao.destroy(); - data.vao = null; - } - } - } - - this._glDatas = null; - - this.geometry = null; - this.shader = null; - this.state = null; - - super.destroy(options); - } -} diff --git a/packages/mesh/src/Rope.js b/packages/mesh/src/Rope.js deleted file mode 100644 index b4f85d3..0000000 --- a/packages/mesh/src/Rope.js +++ /dev/null @@ -1,182 +0,0 @@ -import Mesh from './Mesh'; - -/** - * The rope allows you to draw a texture across several points and them manipulate these points - * - *```js - * for (let i = 0; i < 20; i++) { - * points.push(new PIXI.Point(i * 50, 0)); - * }; - * let rope = new PIXI.Rope(PIXI.Texture.from("snake.png"), points); - * ``` - * - * @class - * @extends PIXI.Mesh - * @memberof PIXI - * - */ -export default class Rope extends Mesh -{ - /** - * @param {PIXI.Texture} texture - The texture to use on the rope. - * @param {PIXI.Point[]} points - An array of {@link PIXI.Point} objects to construct this rope. - */ - constructor(texture, points) - { - super(texture, new Float32Array(points.length * 4), - new Float32Array(points.length * 4), - new Uint16Array(points.length * 2), - 5); - - /* - * @member {PIXI.Point[]} An array of points that determine the rope - */ - this.points = points; - this.refresh(); - } - /** - * Refreshes Rope indices and uvs - * @private - */ - _refresh() - { - const points = this.points; - - if (!points) return; - - const vertexBuffer = this.geometry.getAttribute('aVertexPosition'); - const uvBuffer = this.geometry.getAttribute('aTextureCoord'); - const indexBuffer = this.geometry.getIndex(); - - // if too little points, or texture hasn't got UVs set yet just move on. - if (points.length < 1 || !this.texture._uvs) - { - return; - } - - // if the number of points has changed we will need to recreate the arraybuffers - if (vertexBuffer.data.length / 4 !== points.length) - { - vertexBuffer.data = new Float32Array(points.length * 4); - uvBuffer.data = new Float32Array(points.length * 4); - indexBuffer.data = new Uint16Array(points.length * 2); - } - - const uvs = uvBuffer.data; - const indices = indexBuffer.data; - - uvs[0] = 0; - uvs[1] = 0; - uvs[2] = 0; - uvs[3] = 1; - - indices[0] = 0; - indices[1] = 1; - - const total = points.length; - - for (let i = 1; i < total; i++) - { - // time to do some smart drawing! - let index = i * 4; - const amount = i / (total - 1); - - uvs[index] = amount; - uvs[index + 1] = 0; - - uvs[index + 2] = amount; - uvs[index + 3] = 1; - - index = i * 2; - indices[index] = index; - indices[index + 1] = index + 1; - } - - // ensure that the changes are uploaded - uvBuffer.update(); - indexBuffer.update(); - - this.multiplyUvs(); - this.refreshVertices(); - } - - /** - * refreshes vertices of Rope mesh - */ - refreshVertices() - { - const points = this.points; - - if (points.length < 1) - { - return; - } - - let lastPoint = points[0]; - let nextPoint; - let perpX = 0; - let perpY = 0; - - // this.count -= 0.2; - - const vertices = this.vertices; - const total = points.length; - - for (let i = 0; i < total; i++) - { - const point = points[i]; - const index = i * 4; - - if (i < points.length - 1) - { - nextPoint = points[i + 1]; - } - else - { - nextPoint = point; - } - - perpY = -(nextPoint.x - lastPoint.x); - perpX = nextPoint.y - lastPoint.y; - - let ratio = (1 - (i / (total - 1))) * 10; - - if (ratio > 1) - { - ratio = 1; - } - - const perpLength = Math.sqrt((perpX * perpX) + (perpY * perpY)); - const num = this._texture.height / 2; // (20 + Math.abs(Math.sin((i + this.count) * 0.3) * 50) )* ratio; - - perpX /= perpLength; - perpY /= perpLength; - - perpX *= num; - perpY *= num; - - vertices[index] = point.x + perpX; - vertices[index + 1] = point.y + perpY; - vertices[index + 2] = point.x - perpX; - vertices[index + 3] = point.y - perpY; - - lastPoint = point; - } - - this.geometry.buffers[0].update(); - } - - /** - * Updates the object transform for rendering - * - * @private - */ - updateTransform() - { - if (this.autoUpdate) - { - this.refreshVertices(); - } - this.containerUpdateTransform(); - } -} diff --git a/packages/mesh/src/index.js b/packages/mesh/src/index.js index a245772..e14ab9f 100644 --- a/packages/mesh/src/index.js +++ b/packages/mesh/src/index.js @@ -1,6 +1,2 @@ export { default as Mesh } from './Mesh'; -export { default as RawMesh } from './RawMesh'; export { default as MeshRenderer } from './MeshRenderer'; -export { default as Plane } from './Plane'; -export { default as NineSlicePlane } from './NineSlicePlane'; -export { default as Rope } from './Rope'; diff --git a/packages/mesh/src/mesh.frag b/packages/mesh/src/mesh.frag deleted file mode 100644 index 6096983..0000000 --- a/packages/mesh/src/mesh.frag +++ /dev/null @@ -1,9 +0,0 @@ -varying vec2 vTextureCoord; -uniform vec4 uColor; - -uniform sampler2D uSampler; - -void main(void) -{ - gl_FragColor = texture2D(uSampler, vTextureCoord) * uColor; -} diff --git a/packages/mesh/src/mesh.vert b/packages/mesh/src/mesh.vert deleted file mode 100644 index 0526df9..0000000 --- a/packages/mesh/src/mesh.vert +++ /dev/null @@ -1,15 +0,0 @@ -attribute vec2 aVertexPosition; -attribute vec2 aTextureCoord; - -uniform mat3 projectionMatrix; -uniform mat3 translationMatrix; -uniform mat3 uTextureMatrix; - -varying vec2 vTextureCoord; - -void main(void) -{ - gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); - - vTextureCoord = (uTextureMatrix * vec3(aTextureCoord, 1.0)).xy; -} diff --git a/packages/mesh/test/.eslintrc.json b/packages/mesh/test/.eslintrc.json deleted file mode 100644 index 2ad8efb..0000000 --- a/packages/mesh/test/.eslintrc.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "globals": { - "expect": false, - "assert": false, - "sinon": false, - "PIXI": false - }, - "rules": { - "func-names": 0, - "no-unused-expressions": 0 - } -} \ No newline at end of file diff --git a/packages/mesh/test/Plane.js b/packages/mesh/test/Plane.js deleted file mode 100644 index f9b1c25..0000000 --- a/packages/mesh/test/Plane.js +++ /dev/null @@ -1,60 +0,0 @@ -const { Plane } = require('../'); -const { isWebGLSupported, skipHello } = require('@pixi/utils'); -const { Loader } = require('@pixi/loaders'); -const { Point } = require('@pixi/math'); -const { RenderTexture, Texture } = require('@pixi/core'); - -skipHello(); - -function withGL(fn) -{ - return isWebGLSupported() ? fn : undefined; -} - -// TODO: fix with webglrenderer -describe('PIXI.mesh.Plane', function () -{ - it.skip('should create a plane from an external image', withGL(function (done) - { - const loader = new Loader(); - - loader.add('testBitmap', `file://${__dirname}/resources/bitmap-1.png`) - .load(function (loader, resources) - { - const plane = new Plane(resources.testBitmap.texture, 100, 100); - - expect(plane.verticesX).to.equal(100); - expect(plane.verticesY).to.equal(100); - done(); - }); - })); - - it.skip('should create a new empty textured Plane', withGL(function () - { - const plane = new Plane(Texture.EMPTY, 100, 100); - - expect(plane.verticesX).to.equal(100); - expect(plane.verticesY).to.equal(100); - })); - - describe('containsPoint', function () - { - it.skip('should return true when point inside', withGL(function () - { - const point = new Point(10, 10); - const texture = new RenderTexture.create(20, 30); - const plane = new Plane(texture, 100, 100); - - expect(plane.containsPoint(point)).to.be.true; - })); - - it.skip('should return false when point outside', withGL(function () - { - const point = new Point(100, 100); - const texture = new RenderTexture.create(20, 30); - const plane = new Plane(texture, 100, 100); - - expect(plane.containsPoint(point)).to.be.false; - })); - }); -}); diff --git a/packages/mesh/test/index.js b/packages/mesh/test/index.js deleted file mode 100644 index d767624..0000000 --- a/packages/mesh/test/index.js +++ /dev/null @@ -1 +0,0 @@ -require('./Plane'); diff --git a/bundles/pixi.js/package.json b/bundles/pixi.js/package.json index 49c7276..177e059 100644 --- a/bundles/pixi.js/package.json +++ b/bundles/pixi.js/package.json @@ -49,6 +49,7 @@ "@pixi/loaders": "^5.0.0-alpha.2", "@pixi/math": "^5.0.0-alpha.2", "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/mesh-extras": "^5.0.0-alpha.2", "@pixi/mixin-cache-as-bitmap": "^5.0.0-alpha.2", "@pixi/mixin-get-child-by-name": "^5.0.0-alpha.2", "@pixi/mixin-get-global-position": "^5.0.0-alpha.2", diff --git a/bundles/pixi.js/src/deprecated.js b/bundles/pixi.js/src/deprecated.js index 147617c..dbebeb0 100644 --- a/bundles/pixi.js/src/deprecated.js +++ b/bundles/pixi.js/src/deprecated.js @@ -263,15 +263,15 @@ Object.defineProperties(PIXI.mesh, { /** * @class PIXI.mesh.Mesh - * @see PIXI.Mesh + * @see PIXI.Mesh2d * @deprecated since 5.0.0 */ Mesh: { get() { - warn('PIXI.mesh.Mesh has moved to PIXI.Mesh'); + warn('PIXI.mesh.Mesh has moved to PIXI.Mesh2d'); - return PIXI.Mesh; + return PIXI.Mesh2d; }, }, /** @@ -315,15 +315,15 @@ }, /** * @class PIXI.mesh.RawMesh - * @see PIXI.RawMesh + * @see PIXI.Mesh * @deprecated since 5.0.0 */ RawMesh: { get() { - warn('PIXI.mesh.RawMesh has moved to PIXI.RawMesh'); + warn('PIXI.mesh.RawMesh has moved to PIXI.Mesh'); - return PIXI.RawMesh; + return PIXI.Mesh; }, }, /** diff --git a/bundles/pixi.js/src/index.js b/bundles/pixi.js/src/index.js index a3a0d1b..6fdabf0 100644 --- a/bundles/pixi.js/src/index.js +++ b/bundles/pixi.js/src/index.js @@ -9,6 +9,7 @@ import * as loaders from '@pixi/loaders'; import * as math from '@pixi/math'; import * as mesh from '@pixi/mesh'; +import * as meshExtras from '@pixi/mesh-extras'; import * as particles from '@pixi/particles'; import * as prepare from '@pixi/prepare'; import * as sprite from '@pixi/sprite'; @@ -128,6 +129,7 @@ loaders, math, mesh, + meshExtras, particles, sprite, spriteAnimated, @@ -152,6 +154,7 @@ export * from '@pixi/loaders'; export * from '@pixi/math'; export * from '@pixi/mesh'; +export * from '@pixi/mesh-extras'; export * from '@pixi/particles'; export * from '@pixi/sprite'; export * from '@pixi/spritesheet'; diff --git a/package-lock.json b/package-lock.json index 7fe6db7..0814729 100644 --- a/package-lock.json +++ b/package-lock.json @@ -209,7 +209,7 @@ "argparse": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", - "integrity": "sha1-vNZ5HqWuCXJeF+WtmIE0zUCz2RE=", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", "dev": true, "requires": { "sprintf-js": "1.0.3" @@ -228,7 +228,7 @@ "arr-flatten": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz", - "integrity": "sha1-NgSLv/TntH4TZkQxbJlmnqWukfE=", + "integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==", "dev": true }, "arr-union": { @@ -297,7 +297,7 @@ "assertion-error": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", - "integrity": "sha1-5gtrDo8wG9l+U3UhW9pAbIURjAs=", + "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", "dev": true }, "async": { @@ -396,7 +396,7 @@ "brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha1-PH/L9SnYcibz0vUrlm/1Jx60Qd0=", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, "requires": { "balanced-match": "1.0.0", @@ -568,7 +568,7 @@ "circular-json": { "version": "0.3.3", "resolved": "https://registry.npmjs.org/circular-json/-/circular-json-0.3.3.tgz", - "integrity": "sha1-gVyZ6oT2gJUp0vRXkb34JxE1LWY=", + "integrity": "sha512-UZK3NBx2Mca+b5LsG7bY183pHWt5Y1xts4P3Pz7ENTwGVnJOUWbRb3ocjvX7hx9tq/yTAdclXm9sZ38gNuem4A==", "dev": true }, "cli-cursor": { @@ -638,7 +638,7 @@ "color-convert": { "version": "1.9.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.1.tgz", - "integrity": "sha1-wSYRB66y8pTr/+ye2eytUppgl+0=", + "integrity": "sha512-mjGanIiwQJskCC18rPR6OmrZ6fm2Lc7PeGFYwCmy5J34wC6F1PzdGL6xeMfmgicfYcNLGuVFA3WzXtIDCQSZxQ==", "dev": true, "requires": { "color-name": "1.1.3" @@ -1427,7 +1427,7 @@ "boom": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/boom/-/boom-5.2.0.tgz", - "integrity": "sha1-XdnabuOl8wIHdDYpDLcX0/SlTgI=", + "integrity": "sha512-Z5BTk6ZRe4tXXQlkqftmsAUANpXmuwlsF5Oov8ThoMbQRzdGTA1ngYRW160GexgOgjsFOKJz0LYhoNi+2AMBUw==", "dev": true, "requires": { "hoek": "4.2.1" @@ -1471,7 +1471,7 @@ "debug": { "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha1-XRKFFd8TT/Mn6QpMk/Tgd6U2NB8=", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", "dev": true, "requires": { "ms": "2.0.0" @@ -1585,7 +1585,7 @@ "doctrine": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", - "integrity": "sha1-XNAfwQFiG0LEzX9dGmYkNxbT850=", + "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", "dev": true, "requires": { "esutils": "2.0.2" @@ -1662,7 +1662,7 @@ "es6-promise": { "version": "4.2.4", "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.4.tgz", - "integrity": "sha1-3EIhwrFlGHYL2MOaUtjzVvwA7Sk=", + "integrity": "sha512-/NdNZVJg+uZgtm9eS3O6lrOLYmQag2DjdEXuPaHlZ6RuVqgqaVZfgYCepEIKsLqwdQArOPtC3XzRLqGGfT8KQQ==", "dev": true }, "escape-string-regexp": { @@ -1788,7 +1788,7 @@ "espree": { "version": "3.5.4", "resolved": "https://registry.npmjs.org/espree/-/espree-3.5.4.tgz", - "integrity": "sha1-sPRHGHyKi+2US4FaZgvd9d610ac=", + "integrity": "sha512-yAcIQxtmMiB/jL32dzEp2enBeidsB7xWPLNiw3IIkpVds1P+h7qF9YwJq1yUNzp2OKXgAprs4F61ih66UsoD1A==", "dev": true, "requires": { "acorn": "5.5.0", @@ -1798,7 +1798,7 @@ "esprima": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.0.tgz", - "integrity": "sha1-RJnt3NERDgshi6zy+n9/WfVcqAQ=", + "integrity": "sha512-oftTcaMu/EGrEIu904mWteKIv8vMuOgGYo7EhVJJN00R/EED9DCua/xxHRdYnKtcECzVg7xOWhflvJMnqcFZjw==", "dev": true }, "esquery": { @@ -1813,7 +1813,7 @@ "esrecurse": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.2.1.tgz", - "integrity": "sha1-AHo7n9vCs7uH5IeeoZyS/b05Qs8=", + "integrity": "sha512-64RBB++fIOAXPw3P9cy89qfMlvZEXZkqqJkjqqXIvzP5ezRZjW+lPWjw35UX/3EhUPFYbg5ER4JYgDw4007/DQ==", "dev": true, "requires": { "estraverse": "4.2.0" @@ -2024,7 +2024,7 @@ "find-root": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/find-root/-/find-root-1.1.0.tgz", - "integrity": "sha1-q8/Iunb3CMQql7PWhbfpRQv7nOQ=", + "integrity": "sha512-NKfW6bec6GfKc0SGx1e07QZY9PE99u0Bft/0rzSD5k3sO/vwkVUpDUKVm5Gpp5Ue3YfShPFTX2070tDs5kB9Ng==", "dev": true }, "find-up": { @@ -2103,7 +2103,7 @@ "supports-color": { "version": "5.3.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.3.0.tgz", - "integrity": "sha1-WySsFduA+pJ89SJ6SjP9PEx2dsA=", + "integrity": "sha512-0aP01LLIskjKs3lq52EC0aGBAJhLq7B2Rd8HC/DR/PtNNpcLilNmHC12O+hu0usQpo7wtHNRqtrhBwtDb0+dNg==", "dev": true, "requires": { "has-flag": "3.0.0" @@ -2567,7 +2567,7 @@ "glob": { "version": "7.1.2", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", - "integrity": "sha1-wZyd+aAocC1nhhI4SmVSQExjbRU=", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", "dev": true, "requires": { "fs.realpath": "1.0.0", @@ -2672,7 +2672,7 @@ "growl": { "version": "1.10.3", "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.3.tgz", - "integrity": "sha1-GSa6kM8+3+KttJJ/WIC8IsZseQ8=", + "integrity": "sha512-hKlsbA5Vu3xsh1Cg3J7jSmX/WaW6A5oBeqzM88oNbCRQFz+zUaXm6yxS4RVytp1scBoJzSYl4YAEOQIt6O8V1Q==", "dev": true }, "handlebars": { @@ -2738,7 +2738,7 @@ "hawk": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/hawk/-/hawk-6.0.2.tgz", - "integrity": "sha1-r02RTrBl+bXOTZ0RwcshJu7MMDg=", + "integrity": "sha512-miowhl2+U7Qle4vdLqDdPt9m09K6yZhkLDTWGoUiUzrQCn+mHHSmfJgAyGaLRZbPmTqfFFjRV1QWCW0VWUJBbQ==", "dev": true, "requires": { "boom": "4.3.1", @@ -2756,7 +2756,7 @@ "hoek": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/hoek/-/hoek-4.2.1.tgz", - "integrity": "sha1-ljRQKqEsRF3Vp8VzS1cruHOKrLs=", + "integrity": "sha512-QLg82fGkfnJ/4iy1xZ81/9SIJiq1NGFUMGs6ParyjBZr6jW2Ufj/snDqTHixNlHdPNwN2RLVD0Pi3igeK9+JfA==", "dev": true }, "home-path": { @@ -2791,7 +2791,7 @@ "ignore": { "version": "3.3.7", "resolved": "https://registry.npmjs.org/ignore/-/ignore-3.3.7.tgz", - "integrity": "sha1-YSKJv7PCIOGGpYEYYY1b6MG6sCE=", + "integrity": "sha512-YGG3ejvBNHRqu0559EOxxNFihD0AjpvHlC/pdGKd3X3ofe+CoJkYazwNJYTNebqpPKN+VVQbh4ZFn1DivMNuHA==", "dev": true }, "imurmurhash": { @@ -2828,7 +2828,7 @@ "ini": { "version": "1.3.5", "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", - "integrity": "sha1-7uJfVtscnsYIXgwid4CD9Zar+Sc=", + "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==", "dev": true }, "inquirer": { @@ -2901,7 +2901,7 @@ "is-buffer": { "version": "1.1.6", "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", - "integrity": "sha1-76ouqdqg16suoTqXsritUf776L4=", + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", "dev": true }, "is-builtin-module": { @@ -3054,7 +3054,7 @@ "is-resolvable": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/is-resolvable/-/is-resolvable-1.1.0.tgz", - "integrity": "sha1-+xj4fOH+uSUWnJpAfBkxijIG7Yg=", + "integrity": "sha512-qgDYXFSR5WvEfuS5dMj6oTMEbrrSaM0CrFk2Yiq/gXnBvD9pMa2jGXxyhGLfvhZpuMZe18CJpFxAt3CRs42NMg==", "dev": true }, "is-retry-allowed": { @@ -3204,7 +3204,7 @@ "js-yaml": { "version": "3.11.0", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.11.0.tgz", - "integrity": "sha1-WXwai9VxUvJtYizkEXhRpR9euu8=", + "integrity": "sha512-saJstZWv7oNeOyBh3+Dx1qWzhW0+e6/8eDzo7p5rDFqxntSztloLtuKu+Ejhtq82jsilwOIZYsCz+lIjthg1Hw==", "dev": true, "requires": { "argparse": "1.0.10", @@ -3324,7 +3324,7 @@ "just-extend": { "version": "1.1.27", "resolved": "https://registry.npmjs.org/just-extend/-/just-extend-1.1.27.tgz", - "integrity": "sha1-7G55QQ/5FORyZSq/oOYDwD1g6QU=", + "integrity": "sha512-mJVp13Ix6gFo3SBAy9U/kL+oeZqzlYYYLQBwXVBlVzIsZwBqGREnOro24oC/8s8aox+rJhtZ2DiQof++IrkA+g==", "dev": true }, "kind-of": { @@ -3703,7 +3703,7 @@ "lodash": { "version": "4.17.5", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.5.tgz", - "integrity": "sha1-maktZcAnLevoyWtgV7yPv6O+1RE=", + "integrity": "sha512-svL3uiZf1RwhH+cWrfZn3A4+U58wbP0tGVTLQPbjplZxZ8ROD9VLuNgsRniTlLe7OlSqR79RUehXgpBW/s0IQw==", "dev": true }, "lodash._reinterpolate": { @@ -3740,7 +3740,7 @@ "lolex": { "version": "2.3.2", "resolved": "https://registry.npmjs.org/lolex/-/lolex-2.3.2.tgz", - "integrity": "sha1-hflFBCUQO/nnpgZo6iXcQydMqAc=", + "integrity": "sha512-A5pN2tkFj7H0dGIAM6MFvHKMJcPnjZsOMvR7ujCjfgW5TbV6H9vb1PgxLtHvjqNZTHsUolz+6/WEO0N1xNx2ng==", "dev": true }, "longest": { @@ -3816,7 +3816,7 @@ "marked": { "version": "0.3.17", "resolved": "https://registry.npmjs.org/marked/-/marked-0.3.17.tgz", - "integrity": "sha1-YH8GZos8axJGso8T2nYRasGqLSs=", + "integrity": "sha512-+AKbNsjZl6jFfLPwHhWmGTqE009wTKn3RTmn9K8oUKHrX/abPJjtcRtXpYB/FFrwPJRUA86LX/de3T0knkPCmQ==", "dev": true }, "mem": { @@ -3896,13 +3896,13 @@ "mime-db": { "version": "1.33.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.33.0.tgz", - "integrity": "sha1-o0kgUKXLm2NFBUHjnZeI0icng9s=", + "integrity": "sha512-BHJ/EKruNIqJf/QahvxwQZXKygOQ256myeN/Ew+THcAa5q+PjyTTMMeNQC4DZw5AwfvelsUrA6B67NKMqXDbzQ==", "dev": true }, "mime-types": { "version": "2.1.18", "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.18.tgz", - "integrity": "sha1-bzI/YKg9ERRvgx/xH9ZuL+VQO7g=", + "integrity": "sha512-lc/aahn+t4/SWV/qcmumYjymLsWfN3ELhpmVuUFjgsORruuZPVSwAQryq+HHGvO/SI2KVX26bx+En+zhM8g8hQ==", "dev": true, "requires": { "mime-db": "1.33.0" @@ -3917,7 +3917,7 @@ "minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha1-UWbihkV/AzBgZL5Ul+jbsMPTIIM=", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "dev": true, "requires": { "brace-expansion": "1.1.11" @@ -4071,7 +4071,7 @@ "normalize-package-data": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.4.0.tgz", - "integrity": "sha1-EvlaMH1YNSB1oEkHuErIvpisAS8=", + "integrity": "sha512-9jjUFbTPfEy3R/ad/2oNbKtW9Hgovl5O1FvFWKkKblNXoN/Oou6+9+KKohPK13Yc3/TyunyWhJp6gvRNR/PPAw==", "dev": true, "requires": { "hosted-git-info": "2.5.0", @@ -4511,7 +4511,7 @@ "process-nextick-args": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", - "integrity": "sha1-o31zL0JxtKsa0HDTVQjoKQeI/6o=", + "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==", "dev": true }, "progress": { @@ -4584,7 +4584,7 @@ "qs": { "version": "6.5.1", "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.1.tgz", - "integrity": "sha1-NJzfbu+J7EXBLX1es/wMhwNDptg=", + "integrity": "sha512-eRzhrN1WSINYCDCbrz796z37LOe3m5tmW7RQf6oBntukAG1nmovJvhnwHHRMAfeoItc1m2Hk02WER2aQ/iqs+A==", "dev": true }, "quick-lru": { @@ -4596,7 +4596,7 @@ "randomatic": { "version": "1.1.7", "resolved": "https://registry.npmjs.org/randomatic/-/randomatic-1.1.7.tgz", - "integrity": "sha1-x6vpzIuHwLqodrGf3oP9RkeX44w=", + "integrity": "sha512-D5JUjPyJbaJDkuAazpVnSfVkLlpeO3wDlPROTMLGKG1zMFNFRgrciKo1ltz/AzNTkqE0HzDx655QOL51N06how==", "dev": true, "requires": { "is-number": "3.0.0", @@ -4701,7 +4701,7 @@ "regex-cache": { "version": "0.4.4", "resolved": "https://registry.npmjs.org/regex-cache/-/regex-cache-0.4.4.tgz", - "integrity": "sha1-db3FiioUls7EihKDW8VMjVYjNt0=", + "integrity": "sha512-nVIZwtCjkC9YgvWkpM55B5rBhBYRZhAaJbgcFYXXsHnbZ9UZI9nnVWYZpBlCqv9ho2eZryPnWrZGsOdPwVWXWQ==", "dev": true, "requires": { "is-equal-shallow": "0.1.3" @@ -4729,7 +4729,7 @@ "remap-istanbul": { "version": "0.10.1", "resolved": "https://registry.npmjs.org/remap-istanbul/-/remap-istanbul-0.10.1.tgz", - "integrity": "sha1-OqWN1QIdSZ8zbTulvzu7kcG4jjc=", + "integrity": "sha512-gsNQXs5kJLhErICSyYhzVZ++C8LBW8dgwr874Y2QvzAUS75zBlD/juZgXs39nbYJ09fZDlX2AVLVJAY2jbFJoQ==", "dev": true, "requires": { "amdefine": "1.0.1", @@ -4769,7 +4769,7 @@ "source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha1-dHIq8y6WFOnCh6jQu95IteLxomM=", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", "dev": true }, "through2": { @@ -4883,7 +4883,7 @@ "resolve": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.5.0.tgz", - "integrity": "sha1-HwmsznlsmnYlefMbLBzEw83fnzY=", + "integrity": "sha512-hgoSGrc3pjzAPHNBg+KnFcK2HwlHTs/YrAGUr6qgTVUZmXv1UEXXl0bZNBKMA9fud6lRYFdPGz0xXxycPzmmiw==", "dev": true, "requires": { "path-parse": "1.0.5" @@ -4924,7 +4924,7 @@ "rimraf": { "version": "2.6.2", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", - "integrity": "sha1-LtgVDSShbqhlHm1u8PR8QVjOejY=", + "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", "dev": true, "requires": { "glob": "7.1.2" @@ -5063,19 +5063,19 @@ "safe-buffer": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", - "integrity": "sha1-iTMSr2myEj3vcfV4iQAWce6yyFM=", + "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", "dev": true }, "samsam": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/samsam/-/samsam-1.3.0.tgz", - "integrity": "sha1-jR2TUOJWItow3j5EumkrUiGrfFA=", + "integrity": "sha512-1HwIYD/8UlOtFS3QO3w7ey+SdSDFE4HRNLZoZRYVQefrOY3l17epswImeB1ijgJFQJodIaHcwkp3r/myBjFVbg==", "dev": true }, "semver": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz", - "integrity": "sha1-3Eu8emyp2Rbe5dQ1FvAJK1j3uKs=", + "integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==", "dev": true }, "set-blocking": { @@ -5117,7 +5117,7 @@ "sinon-chai": { "version": "2.14.0", "resolved": "https://registry.npmjs.org/sinon-chai/-/sinon-chai-2.14.0.tgz", - "integrity": "sha1-2n3UzIPNaiYLZ8yg96n9riahIF0=", + "integrity": "sha512-9stIF1utB0ywNHNT7RgiXbdmen8QDCRsrTjw+G9TgKt1Yexjiv8TOWZ6WHsTPz57Yky3DIswZvEqX8fpuHNDtQ==", "dev": true }, "slash": { @@ -5146,7 +5146,7 @@ "sntp": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/sntp/-/sntp-2.1.0.tgz", - "integrity": "sha1-LGzsFP7cIiJznK+bXD2F0cxaLMg=", + "integrity": "sha512-FL1b58BDrqS3A11lJ0zEdnJ3UOKqVxawAkF3k7F0CVN7VQ34aZrV+G8BZ1WC9ZL7NyrwsW0oviwsWDgRuVYtJg==", "dev": true, "requires": { "hoek": "4.2.1" @@ -5203,7 +5203,7 @@ "spdx-correct": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.0.0.tgz", - "integrity": "sha1-BaW01xU6GVvJLDxCW2nzsqlSTII=", + "integrity": "sha512-N19o9z5cEyc8yQQPukRCZ9EUmb4HUpnrmaL/fxS2pBo2jbfcFRVuFZ/oFC+vZz0MNNk0h80iMn5/S6qGZOL5+g==", "dev": true, "requires": { "spdx-expression-parse": "3.0.0", @@ -5213,13 +5213,13 @@ "spdx-exceptions": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.1.0.tgz", - "integrity": "sha1-LHrmEFbHFKW5ubKyr30xHvXHj+k=", + "integrity": "sha512-4K1NsmrlCU1JJgUrtgEeTVyfx8VaYea9J9LvARxhbHtVtohPs/gFGG5yy49beySjlIMhhXZ4QqujIZEfS4l6Cg==", "dev": true }, "spdx-expression-parse": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.0.tgz", - "integrity": "sha1-meEZt6XaAOBUkcn6M4t5BII7QdA=", + "integrity": "sha512-Yg6D3XpRD4kkOmTpdgbUiEJFKghJH03fiC1OPll5h/0sO6neh2jqRDVHOQ4o/LMea0tgCkbMgea5ip/e+MkWyg==", "dev": true, "requires": { "spdx-exceptions": "2.1.0", @@ -5229,7 +5229,7 @@ "spdx-license-ids": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.0.tgz", - "integrity": "sha1-enzShHDMbToc/m1miG9rxDDTrIc=", + "integrity": "sha512-2+EPwgbnmOIl8HjGBXXMd9NAu02vLjOO1nWw4kmeRDFyHn+M/ETfHxQUK0oXg8ctgVnl9t3rosNVsZ1jG61nDA==", "dev": true }, "speedometer": { @@ -5566,7 +5566,7 @@ "tough-cookie": { "version": "2.3.4", "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.4.tgz", - "integrity": "sha1-7GDO44rGdQY//JelwYlwV47oNlU=", + "integrity": "sha512-TZ6TTfI5NtZnuyy/Kecv+CnoROnyXn2DN97LontgQpCwsX2XyLYCC0ENhYkehSOwAp8rTQKc/NUIF7BkQ5rKLA==", "dev": true, "requires": { "punycode": "1.4.1" @@ -5708,13 +5708,13 @@ "uuid": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.2.1.tgz", - "integrity": "sha1-EsUou51Y0LkmXZovbw/ovhf/HxQ=", + "integrity": "sha512-jZnMwlb9Iku/O3smGWvZhauCf6cvvpKi4BKRiliS3cxnI+Gz9j5MEpTz2UFuXiKPJocb7gnsLHwiS05ige5BEA==", "dev": true }, "validate-npm-package-license": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.3.tgz", - "integrity": "sha1-gWQ7y+8b3+zUYjeT3EZIlIupgzg=", + "integrity": "sha512-63ZOUnL4SIXj4L0NixR3L1lcjO38crAbgrTpl28t8jjrfuiOBL5Iygm+60qPs/KsZGzPNg6Smnc/oY16QTjF0g==", "dev": true, "requires": { "spdx-correct": "3.0.0", @@ -5750,7 +5750,7 @@ "which": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/which/-/which-1.3.0.tgz", - "integrity": "sha1-/wS9/AEO5UfXgL7DjhrBwnd9JTo=", + "integrity": "sha512-xcJpopdamTuY5duC/KnTTNBraPK54YwpenP4lzxU8H91GudWpFv38u0CKjclE1Wi2EH2EDz5LRcHcKbCIzqGyg==", "dev": true, "requires": { "isexe": "2.0.0" diff --git a/packages/canvas/canvas-mesh/package.json b/packages/canvas/canvas-mesh/package.json index 691cd2c..6744a17 100644 --- a/packages/canvas/canvas-mesh/package.json +++ b/packages/canvas/canvas-mesh/package.json @@ -24,6 +24,7 @@ "dependencies": { "@pixi/constants": "^5.0.0-alpha.2", "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/mesh-extras": "^5.0.0-alpha.2", "@pixi/settings": "^5.0.0-alpha.2" }, "devDependencies": { diff --git a/packages/canvas/canvas-mesh/src/Mesh.js b/packages/canvas/canvas-mesh/src/Mesh.js index 900a872..c43a74b 100644 --- a/packages/canvas/canvas-mesh/src/Mesh.js +++ b/packages/canvas/canvas-mesh/src/Mesh.js @@ -1,36 +1,14 @@ import { Mesh } from '@pixi/mesh'; -import { settings } from './settings'; - -// IMPORTANT: Please do NOT use this as a precedent to use `settings` after the object is created -// this was merely created to completely decouple canvas from the base Mesh class and we are -// unable to add `canvasPadding` in the constructor anymore, as the case was for PixiJS v4. /** - * Internal variable for `canvasPadding`. + * Renders the object using the Canvas renderer * * @private - * @memberof PIXI.Mesh - * @member {number} - * @default null - */ -Mesh.prototype._canvasPadding = null; - -/** - * Triangles in canvas mode are automatically antialiased, use this value to force triangles - * to overlap a bit with each other. To set the global default, set {@link PIXI.settings.MESH_CANVAS_PADDING} - * - * @see PIXI.settings.MESH_CANVAS_PADDING - * @member {number} canvasPadding + * @method _renderCanvas * @memberof PIXI.Mesh# - * @default 0 + * @param {PIXI.CanvasRenderer} renderer - The canvas renderer. */ -Object.defineProperty(Mesh.prototype, 'canvasPadding', { - get() - { - return this._canvasPadding !== null ? this._canvasPadding : settings.MESH_CANVAS_PADDING; - }, - set(value) - { - this._canvasPadding = value; - }, -}); +Mesh.prototype._renderCanvas = function _renderCanvas(renderer) +{ + renderer.plugins[this.pluginName].render(this); +}; diff --git a/packages/canvas/canvas-mesh/src/Mesh2d.js b/packages/canvas/canvas-mesh/src/Mesh2d.js new file mode 100644 index 0000000..d0bd80f --- /dev/null +++ b/packages/canvas/canvas-mesh/src/Mesh2d.js @@ -0,0 +1,36 @@ +import { Mesh2d } from '@pixi/mesh-extras'; +import { settings } from './settings'; + +// IMPORTANT: Please do NOT use this as a precedent to use `settings` after the object is created +// this was merely created to completely decouple canvas from the base Mesh class and we are +// unable to add `canvasPadding` in the constructor anymore, as the case was for PixiJS v4. + +/** + * Internal variable for `canvasPadding`. + * + * @private + * @memberof PIXI.Mesh2d + * @member {number} + * @default null + */ +Mesh2d.prototype._canvasPadding = null; + +/** + * Triangles in canvas mode are automatically antialiased, use this value to force triangles + * to overlap a bit with each other. To set the global default, set {@link PIXI.settings.MESH_CANVAS_PADDING} + * + * @see PIXI.settings.MESH_CANVAS_PADDING + * @member {number} canvasPadding + * @memberof PIXI.Mesh2d# + * @default 0 + */ +Object.defineProperty(Mesh2d.prototype, 'canvasPadding', { + get() + { + return this._canvasPadding !== null ? this._canvasPadding : settings.MESH_CANVAS_PADDING; + }, + set(value) + { + this._canvasPadding = value; + }, +}); diff --git a/packages/canvas/canvas-mesh/src/NineSlicePlane.js b/packages/canvas/canvas-mesh/src/NineSlicePlane.js index 09eaf9c..2fd5acc 100644 --- a/packages/canvas/canvas-mesh/src/NineSlicePlane.js +++ b/packages/canvas/canvas-mesh/src/NineSlicePlane.js @@ -1,4 +1,4 @@ -import { NineSlicePlane } from '@pixi/mesh'; +import { NineSlicePlane } from '@pixi/mesh-extras'; /** * Renders the object using the Canvas renderer diff --git a/packages/canvas/canvas-mesh/src/RawMesh.js b/packages/canvas/canvas-mesh/src/RawMesh.js deleted file mode 100644 index bf40184..0000000 --- a/packages/canvas/canvas-mesh/src/RawMesh.js +++ /dev/null @@ -1,14 +0,0 @@ -import { RawMesh } from '@pixi/mesh'; - -/** - * Renders the object using the Canvas renderer - * - * @private - * @method _renderCanvas - * @memberof PIXI.RawMesh# - * @param {PIXI.CanvasRenderer} renderer - The canvas renderer. - */ -RawMesh.prototype._renderCanvas = function _renderCanvas(renderer) -{ - renderer.plugins[this.pluginName].render(this); -}; diff --git a/packages/canvas/canvas-mesh/src/index.js b/packages/canvas/canvas-mesh/src/index.js index 2295016..f4fa31d 100644 --- a/packages/canvas/canvas-mesh/src/index.js +++ b/packages/canvas/canvas-mesh/src/index.js @@ -1,6 +1,6 @@ export { default as CanvasMeshRenderer } from './CanvasMeshRenderer'; import './settings'; -import './Mesh'; +import './Mesh2d'; import './NineSlicePlane'; -import './RawMesh'; +import './Mesh'; diff --git a/packages/canvas/canvas-mesh/src/settings.js b/packages/canvas/canvas-mesh/src/settings.js index 4cefb4c..e81b8e0 100644 --- a/packages/canvas/canvas-mesh/src/settings.js +++ b/packages/canvas/canvas-mesh/src/settings.js @@ -3,7 +3,7 @@ /** * Default `canvasPadding` for canvas-based Mesh rendering. * - * @see PIXI.Mesh#canvasPadding + * @see PIXI.Mesh2d#canvasPadding * @static * @constant * @memberof PIXI.settings diff --git a/packages/mesh-extras/LICENSE b/packages/mesh-extras/LICENSE new file mode 100644 index 0000000..148e3eb --- /dev/null +++ b/packages/mesh-extras/LICENSE @@ -0,0 +1,21 @@ +The MIT License + +Copyright (c) 2013-2018 Mathew Groves, Chad Engler + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/packages/mesh-extras/README.md b/packages/mesh-extras/README.md new file mode 100644 index 0000000..1d9b0e1 --- /dev/null +++ b/packages/mesh-extras/README.md @@ -0,0 +1,19 @@ +# @pixi/mesh-extras + +## Installation + +```bash +npm install @pixi/mesh-extras +``` + +## Usage + +```js +import { MeshRenderer } from '@pixi/mesh'; +import { Renderer } from '@pixi/core'; +import { Rope } from '@pixi/mesh-extras'; + +Renderer.registerPlugin('mesh', MeshRenderer); + +const rope = new Rope(); +``` \ No newline at end of file diff --git a/packages/mesh-extras/package.json b/packages/mesh-extras/package.json new file mode 100644 index 0000000..d134f64 --- /dev/null +++ b/packages/mesh-extras/package.json @@ -0,0 +1,38 @@ +{ + "name": "@pixi/mesh-extras", + "version": "5.0.0-alpha.2", + "main": "lib/mesh-extras.js", + "module": "lib/mesh-extras.es.js", + "description": "Custom Mesh display objects, like Rope and Plane", + "author": "Mat Groves", + "contributors": [ + "Matt Karl " + ], + "homepage": "http://pixijs.com/", + "bugs": "https://github.com/pixijs/pixi.js/issues", + "license": "MIT", + "repository": { + "type": "git", + "url": "https://github.com/pixijs/pixi.js.git" + }, + "publishConfig": { + "access": "public" + }, + "scripts": { + "test": "floss --path test" + }, + "files": [ + "lib" + ], + "dependencies": { + "@pixi/constants": "^5.0.0-alpha.2", + "@pixi/core": "^5.0.0-alpha.2", + "@pixi/math": "^5.0.0-alpha.2", + "@pixi/mesh": "^5.0.0-alpha.2", + "@pixi/utils": "^5.0.0-alpha.2" + }, + "devDependencies": { + "@pixi/loaders": "^5.0.0-alpha.2", + "floss": "^2.1.3" + } +} diff --git a/packages/mesh-extras/src/Mesh2d.js b/packages/mesh-extras/src/Mesh2d.js new file mode 100644 index 0000000..d113a5e --- /dev/null +++ b/packages/mesh-extras/src/Mesh2d.js @@ -0,0 +1,263 @@ +import { Mesh } from '@pixi/mesh'; +import { Geometry, Program, Shader, Texture, TextureMatrix } from '@pixi/core'; +import { Matrix } from '@pixi/math'; +import { BLEND_MODES } from '@pixi/constants'; +import { hex2rgb, premultiplyRgba } from '@pixi/utils'; +import vertex from './mesh.vert'; +import fragment from './mesh.frag'; + +let meshProgram; + +/** + * Base mesh class + * @class + * @extends PIXI.Container + * @memberof PIXI + */ +export default class Mesh2d extends Mesh +{ + /** + * @param {PIXI.Texture} [texture=Texture.EMPTY] - The texture to use + * @param {Float32Array} [vertices] - if you want to specify the vertices + * @param {Float32Array} [uvs] - if you want to specify the uvs + * @param {Uint16Array} [indices] - if you want to specify the indices + * @param {number} [drawMode] - the drawMode, can be any of the Mesh.DRAW_MODES consts + */ + constructor(texture = Texture.EMPTY, vertices, uvs, indices, drawMode) + { + const geometry = new Geometry(); + + if (!meshProgram) + { + meshProgram = new Program(vertex, fragment); + } + + geometry.addAttribute('aVertexPosition', vertices) + .addAttribute('aTextureCoord', uvs) + .addIndex(indices); + + geometry.getAttribute('aVertexPosition').static = false; + + const uniforms = { + uSampler: texture, + uTextureMatrix: Matrix.IDENTITY, + alpha: 1, + uColor: new Float32Array([1, 1, 1, 1]), + }; + + super(geometry, new Shader(meshProgram, uniforms), null, drawMode); + + /** + * The Uvs of the Mesh + * + * @member {Float32Array} + */ + this.uvs = geometry.getAttribute('aTextureCoord').data; + + /** + * An array of vertices + * + * @member {Float32Array} + */ + this.vertices = geometry.getAttribute('aVertexPosition').data; + + this.uniforms = uniforms; + + /** + * The texture of the Mesh + * + * @member {PIXI.Texture} + * @default PIXI.Texture.EMPTY + * @private + */ + this.texture = texture; + + /** + * The tint applied to the mesh. This is a [r,g,b] value. A value of [1,1,1] will remove any + * tint effect. + * + * @member {number} + * @private + */ + this._tintRGB = new Float32Array([1, 1, 1]); + + // Set default tint + this.tint = 0xFFFFFF; + + this.blendMode = BLEND_MODES.NORMAL; + + /** + * TextureMatrix instance for this Mesh, used to track Texture changes + * + * @member {PIXI.TextureMatrix} + * @readonly + */ + this.uvMatrix = new TextureMatrix(this._texture); + + /** + * whether or not upload uvMatrix to shader + * if its false, then uvs should be pre-multiplied + * if you change it for generated mesh, please call 'refresh(true)' + * @member {boolean} + * @default false + */ + this.uploadUvMatrix = false; + + /** + * Uploads vertices buffer every frame, like in PixiJS V3 and V4. + * + * @member {boolean} + * @default true + */ + this.autoUpdate = true; + } + + /** + * The tint applied to the Rope. This is a hex value. A value of + * 0xFFFFFF will remove any tint effect. + * + * @member {number} + * @memberof PIXI.Sprite# + * @default 0xFFFFFF + */ + get tint() + { + return this._tint; + } + + /** + * Sets the tint of the rope. + * + * @param {number} value - The value to set to. + */ + set tint(value) + { + this._tint = value; + + hex2rgb(this._tint, this._tintRGB); + } + + /** + * The blend mode to be applied to the sprite. Set to `PIXI.BLEND_MODES.NORMAL` to remove any blend mode. + * + * @member {number} + * @default PIXI.BLEND_MODES.NORMAL + * @see PIXI.BLEND_MODES + */ + get blendMode() + { + return this.state.blendMode; + } + + set blendMode(value) // eslint-disable-line require-jsdoc + { + this.state.blendMode = value; + } + + /** + * The texture that the mesh uses. + * + * @member {PIXI.Texture} + */ + get texture() + { + return this._texture; + } + + set texture(value) // eslint-disable-line require-jsdoc + { + if (this._texture === value) + { + return; + } + + this._texture = value; + this.uniforms.uSampler = this.texture; + + if (value) + { + // wait for the texture to load + if (value.baseTexture.valid) + { + this._onTextureUpdate(); + } + else + { + value.once('update', this._onTextureUpdate, this); + } + } + } + + _render(renderer) + { + const baseTex = this._texture.baseTexture; + + premultiplyRgba(this._tintRGB, this.worldAlpha, this.uniforms.uColor, baseTex.premultiplyAlpha); + super._render(renderer); + } + /** + * When the texture is updated, this event will fire to update the scale and frame + * + * @private + */ + _onTextureUpdate() + { + // constructor texture update stop + if (!this.uvMatrix) + { + return; + } + this.uvMatrix.texture = this._texture; + this.refresh(); + } + + /** + * multiplies uvs only if uploadUvMatrix is false + * call it after you change uvs manually + * make sure that texture is valid + */ + multiplyUvs() + { + if (!this.uploadUvMatrix) + { + this.uvMatrix.multiplyUvs(this.uvs); + } + } + + /** + * Refreshes uvs for generated meshes (rope, plane) + * sometimes refreshes vertices too + * + * @param {boolean} [forceUpdate=false] if true, matrices will be updated any case + */ + refresh(forceUpdate) + { + if (this.uvMatrix.update(forceUpdate)) + { + this._refresh(); + } + } + + /** + * Updates the object transform for rendering + * + * @private + */ + updateTransform() + { + if (this.autoUpdate) + { + this.geometry.buffers[0].update(); + } + this.containerUpdateTransform(); + } + + /** + * re-calculates mesh coords + * @private + */ + _refresh() + { + /* empty */ + } +} diff --git a/packages/mesh-extras/src/NineSlicePlane.js b/packages/mesh-extras/src/NineSlicePlane.js new file mode 100644 index 0000000..0bae92c --- /dev/null +++ b/packages/mesh-extras/src/NineSlicePlane.js @@ -0,0 +1,270 @@ +import Plane from './Plane'; + +const DEFAULT_BORDER_SIZE = 10; + +/** + * The NineSlicePlane allows you to stretch a texture using 9-slice scaling. The corners will remain unscaled (useful + * for buttons with rounded corners for example) and the other areas will be scaled horizontally and or vertically + * + *```js + * let Plane9 = new PIXI.NineSlicePlane(PIXI.Texture.from('BoxWithRoundedCorners.png'), 15, 15, 15, 15); + * ``` + *
+ *      A                          B
+ *    +---+----------------------+---+
+ *  C | 1 |          2           | 3 |
+ *    +---+----------------------+---+
+ *    |   |                      |   |
+ *    | 4 |          5           | 6 |
+ *    |   |                      |   |
+ *    +---+----------------------+---+
+ *  D | 7 |          8           | 9 |
+ *    +---+----------------------+---+
+
+ *  When changing this objects width and/or height:
+ *     areas 1 3 7 and 9 will remain unscaled.
+ *     areas 2 and 8 will be stretched horizontally
+ *     areas 4 and 6 will be stretched vertically
+ *     area 5 will be stretched both horizontally and vertically
+ * 
+ * + * @class + * @extends PIXI.Plane + * @memberof PIXI + * + */ +export default class NineSlicePlane extends Plane +{ + /** + * @param {PIXI.Texture} texture - The texture to use on the NineSlicePlane. + * @param {int} [leftWidth=10] size of the left vertical bar (A) + * @param {int} [topHeight=10] size of the top horizontal bar (C) + * @param {int} [rightWidth=10] size of the right vertical bar (B) + * @param {int} [bottomHeight=10] size of the bottom horizontal bar (D) + */ + constructor(texture, leftWidth, topHeight, rightWidth, bottomHeight) + { + super(texture, 4, 4); + + this._origWidth = texture.orig.width; + this._origHeight = texture.orig.height; + + /** + * The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._width = this._origWidth; + + /** + * The height of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._height = this._origHeight; + + /** + * The width of the left column (a) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._leftWidth = typeof leftWidth !== 'undefined' ? leftWidth : DEFAULT_BORDER_SIZE; + + /** + * The width of the right column (b) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._rightWidth = typeof rightWidth !== 'undefined' ? rightWidth : DEFAULT_BORDER_SIZE; + + /** + * The height of the top row (c) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._topHeight = typeof topHeight !== 'undefined' ? topHeight : DEFAULT_BORDER_SIZE; + + /** + * The height of the bottom row (d) + * + * @member {number} + * @memberof PIXI.NineSlicePlane# + * @override + */ + this._bottomHeight = typeof bottomHeight !== 'undefined' ? bottomHeight : DEFAULT_BORDER_SIZE; + + this.refresh(true); + } + + /** + * Updates the horizontal vertices. + * + */ + updateHorizontalVertices() + { + const vertices = this.vertices; + + const h = this._topHeight + this._bottomHeight; + const scale = this._height > h ? 1.0 : this._height / h; + + vertices[9] = vertices[11] = vertices[13] = vertices[15] = this._topHeight * scale; + vertices[17] = vertices[19] = vertices[21] = vertices[23] = this._height - (this._bottomHeight * scale); + vertices[25] = vertices[27] = vertices[29] = vertices[31] = this._height; + } + + /** + * Updates the vertical vertices. + * + */ + updateVerticalVertices() + { + const vertices = this.vertices; + + const w = this._leftWidth + this._rightWidth; + const scale = this._width > w ? 1.0 : this._width / w; + + vertices[2] = vertices[10] = vertices[18] = vertices[26] = this._leftWidth * scale; + vertices[4] = vertices[12] = vertices[20] = vertices[28] = this._width - (this._rightWidth * scale); + vertices[6] = vertices[14] = vertices[22] = vertices[30] = this._width; + } + + /** + * The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + */ + get width() + { + return this._width; + } + + set width(value) // eslint-disable-line require-jsdoc + { + this._width = value; + this._refresh(); + } + + /** + * The height of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane + * + * @member {number} + */ + get height() + { + return this._height; + } + + set height(value) // eslint-disable-line require-jsdoc + { + this._height = value; + this._refresh(); + } + + /** + * The width of the left column + * + * @member {number} + */ + get leftWidth() + { + return this._leftWidth; + } + + set leftWidth(value) // eslint-disable-line require-jsdoc + { + this._leftWidth = value; + this._refresh(); + } + + /** + * The width of the right column + * + * @member {number} + */ + get rightWidth() + { + return this._rightWidth; + } + + set rightWidth(value) // eslint-disable-line require-jsdoc + { + this._rightWidth = value; + this._refresh(); + } + + /** + * The height of the top row + * + * @member {number} + */ + get topHeight() + { + return this._topHeight; + } + + set topHeight(value) // eslint-disable-line require-jsdoc + { + this._topHeight = value; + this._refresh(); + } + + /** + * The height of the bottom row + * + * @member {number} + */ + get bottomHeight() + { + return this._bottomHeight; + } + + set bottomHeight(value) // eslint-disable-line require-jsdoc + { + this._bottomHeight = value; + this._refresh(); + } + + /** + * Refreshes NineSlicePlane coords. All of them. + */ + _refresh() + { + super._refresh(); + + const uvs = this.uvs; + const texture = this._texture; + + this._origWidth = texture.orig.width; + this._origHeight = texture.orig.height; + + const _uvw = 1.0 / this._origWidth; + const _uvh = 1.0 / this._origHeight; + + uvs[0] = uvs[8] = uvs[16] = uvs[24] = 0; + uvs[1] = uvs[3] = uvs[5] = uvs[7] = 0; + uvs[6] = uvs[14] = uvs[22] = uvs[30] = 1; + uvs[25] = uvs[27] = uvs[29] = uvs[31] = 1; + + uvs[2] = uvs[10] = uvs[18] = uvs[26] = _uvw * this._leftWidth; + uvs[4] = uvs[12] = uvs[20] = uvs[28] = 1 - (_uvw * this._rightWidth); + uvs[9] = uvs[11] = uvs[13] = uvs[15] = _uvh * this._topHeight; + uvs[17] = uvs[19] = uvs[21] = uvs[23] = 1 - (_uvh * this._bottomHeight); + + this.updateHorizontalVertices(); + this.updateVerticalVertices(); + + this.geometry.buffers[1].update(); + + this.multiplyUvs(); + } +} diff --git a/packages/mesh-extras/src/Plane.js b/packages/mesh-extras/src/Plane.js new file mode 100644 index 0000000..1c240c4 --- /dev/null +++ b/packages/mesh-extras/src/Plane.js @@ -0,0 +1,100 @@ +import Mesh2d from './Mesh2d'; + +/** + * The Plane allows you to draw a texture across several points and them manipulate these points + * + *```js + * for (let i = 0; i < 20; i++) { + * points.push(new PIXI.Point(i * 50, 0)); + * }; + * let Plane = new PIXI.Plane(PIXI.Texture.from("snake.png"), points); + * ``` + * + * @class + * @extends PIXI.Mesh + * @memberof PIXI + * + */ +export default class Plane extends Mesh2d +{ + /** + * @param {PIXI.Texture} texture - The texture to use on the Plane. + * @param {number} verticesX - The number of vertices in the x-axis + * @param {number} verticesY - The number of vertices in the y-axis + * @param {object} [opts] - an options object - add meshWidth and meshHeight, temporary object for PixiJS v5 alpha + */ + constructor(texture, verticesX, verticesY, opts = {}) + { + super(texture, new Float32Array(1), new Float32Array(1), new Uint16Array(1), 4); + + this.verticesX = verticesX || 10; + this.verticesY = verticesY || 10; + + this.meshWidth = opts.meshWidth || 0; + this.meshHeight = opts.meshHeight || 0; + + this.refresh(); + } + + /** + * Refreshes plane coordinates + * @private + */ + _refresh() + { + const texture = this._texture; + const total = this.verticesX * this.verticesY; + const verts = []; + const uvs = []; + const indices = []; + + const segmentsX = this.verticesX - 1; + const segmentsY = this.verticesY - 1; + + const sizeX = (this.meshWidth || texture.width) / segmentsX; + const sizeY = (this.meshHeight || texture.height) / segmentsY; + + for (let i = 0; i < total; i++) + { + const x = (i % this.verticesX); + const y = ((i / this.verticesX) | 0); + + verts.push(x * sizeX, y * sizeY); + + uvs.push(x / segmentsX, y / segmentsY); + } + + // cons + + const totalSub = segmentsX * segmentsY; + + for (let i = 0; i < totalSub; i++) + { + const xpos = i % segmentsX; + const ypos = (i / segmentsX) | 0; + + const value = (ypos * this.verticesX) + xpos; + const value2 = (ypos * this.verticesX) + xpos + 1; + const value3 = ((ypos + 1) * this.verticesX) + xpos; + const value4 = ((ypos + 1) * this.verticesX) + xpos + 1; + + indices.push(value, value2, value3); + indices.push(value2, value4, value3); + } + + this.vertices = new Float32Array(verts); + this.uvs = new Float32Array(uvs); + this.indices = new Uint16Array(indices); + + this.geometry.buffers[0].data = this.vertices; + this.geometry.buffers[1].data = this.uvs; + this.geometry.indexBuffer.data = this.indices; + + // ensure that the changes are uploaded + this.geometry.buffers[0].update(); + this.geometry.buffers[1].update(); + this.geometry.indexBuffer.update(); + + this.multiplyUvs(); + } +} diff --git a/packages/mesh-extras/src/Rope.js b/packages/mesh-extras/src/Rope.js new file mode 100644 index 0000000..9cfde38 --- /dev/null +++ b/packages/mesh-extras/src/Rope.js @@ -0,0 +1,182 @@ +import Mesh2d from './Mesh2d'; + +/** + * The rope allows you to draw a texture across several points and them manipulate these points + * + *```js + * for (let i = 0; i < 20; i++) { + * points.push(new PIXI.Point(i * 50, 0)); + * }; + * let rope = new PIXI.Rope(PIXI.Texture.from("snake.png"), points); + * ``` + * + * @class + * @extends PIXI.Mesh + * @memberof PIXI + * + */ +export default class Rope extends Mesh2d +{ + /** + * @param {PIXI.Texture} texture - The texture to use on the rope. + * @param {PIXI.Point[]} points - An array of {@link PIXI.Point} objects to construct this rope. + */ + constructor(texture, points) + { + super(texture, new Float32Array(points.length * 4), + new Float32Array(points.length * 4), + new Uint16Array(points.length * 2), + 5); + + /* + * @member {PIXI.Point[]} An array of points that determine the rope + */ + this.points = points; + this.refresh(); + } + /** + * Refreshes Rope indices and uvs + * @private + */ + _refresh() + { + const points = this.points; + + if (!points) return; + + const vertexBuffer = this.geometry.getAttribute('aVertexPosition'); + const uvBuffer = this.geometry.getAttribute('aTextureCoord'); + const indexBuffer = this.geometry.getIndex(); + + // if too little points, or texture hasn't got UVs set yet just move on. + if (points.length < 1 || !this.texture._uvs) + { + return; + } + + // if the number of points has changed we will need to recreate the arraybuffers + if (vertexBuffer.data.length / 4 !== points.length) + { + vertexBuffer.data = new Float32Array(points.length * 4); + uvBuffer.data = new Float32Array(points.length * 4); + indexBuffer.data = new Uint16Array(points.length * 2); + } + + const uvs = uvBuffer.data; + const indices = indexBuffer.data; + + uvs[0] = 0; + uvs[1] = 0; + uvs[2] = 0; + uvs[3] = 1; + + indices[0] = 0; + indices[1] = 1; + + const total = points.length; + + for (let i = 1; i < total; i++) + { + // time to do some smart drawing! + let index = i * 4; + const amount = i / (total - 1); + + uvs[index] = amount; + uvs[index + 1] = 0; + + uvs[index + 2] = amount; + uvs[index + 3] = 1; + + index = i * 2; + indices[index] = index; + indices[index + 1] = index + 1; + } + + // ensure that the changes are uploaded + uvBuffer.update(); + indexBuffer.update(); + + this.multiplyUvs(); + this.refreshVertices(); + } + + /** + * refreshes vertices of Rope mesh + */ + refreshVertices() + { + const points = this.points; + + if (points.length < 1) + { + return; + } + + let lastPoint = points[0]; + let nextPoint; + let perpX = 0; + let perpY = 0; + + // this.count -= 0.2; + + const vertices = this.vertices; + const total = points.length; + + for (let i = 0; i < total; i++) + { + const point = points[i]; + const index = i * 4; + + if (i < points.length - 1) + { + nextPoint = points[i + 1]; + } + else + { + nextPoint = point; + } + + perpY = -(nextPoint.x - lastPoint.x); + perpX = nextPoint.y - lastPoint.y; + + let ratio = (1 - (i / (total - 1))) * 10; + + if (ratio > 1) + { + ratio = 1; + } + + const perpLength = Math.sqrt((perpX * perpX) + (perpY * perpY)); + const num = this._texture.height / 2; // (20 + Math.abs(Math.sin((i + this.count) * 0.3) * 50) )* ratio; + + perpX /= perpLength; + perpY /= perpLength; + + perpX *= num; + perpY *= num; + + vertices[index] = point.x + perpX; + vertices[index + 1] = point.y + perpY; + vertices[index + 2] = point.x - perpX; + vertices[index + 3] = point.y - perpY; + + lastPoint = point; + } + + this.geometry.buffers[0].update(); + } + + /** + * Updates the object transform for rendering + * + * @private + */ + updateTransform() + { + if (this.autoUpdate) + { + this.refreshVertices(); + } + this.containerUpdateTransform(); + } +} diff --git a/packages/mesh-extras/src/index.js b/packages/mesh-extras/src/index.js new file mode 100644 index 0000000..decf454 --- /dev/null +++ b/packages/mesh-extras/src/index.js @@ -0,0 +1,4 @@ +export { default as Mesh2d } from './Mesh2d'; +export { default as Plane } from './Plane'; +export { default as NineSlicePlane } from './NineSlicePlane'; +export { default as Rope } from './Rope'; diff --git a/packages/mesh-extras/src/mesh.frag b/packages/mesh-extras/src/mesh.frag new file mode 100644 index 0000000..6096983 --- /dev/null +++ b/packages/mesh-extras/src/mesh.frag @@ -0,0 +1,9 @@ +varying vec2 vTextureCoord; +uniform vec4 uColor; + +uniform sampler2D uSampler; + +void main(void) +{ + gl_FragColor = texture2D(uSampler, vTextureCoord) * uColor; +} diff --git a/packages/mesh-extras/src/mesh.vert b/packages/mesh-extras/src/mesh.vert new file mode 100644 index 0000000..0526df9 --- /dev/null +++ b/packages/mesh-extras/src/mesh.vert @@ -0,0 +1,15 @@ +attribute vec2 aVertexPosition; +attribute vec2 aTextureCoord; + +uniform mat3 projectionMatrix; +uniform mat3 translationMatrix; +uniform mat3 uTextureMatrix; + +varying vec2 vTextureCoord; + +void main(void) +{ + gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); + + vTextureCoord = (uTextureMatrix * vec3(aTextureCoord, 1.0)).xy; +} diff --git a/packages/mesh-extras/test/.eslintrc.json b/packages/mesh-extras/test/.eslintrc.json new file mode 100644 index 0000000..2ad8efb --- /dev/null +++ b/packages/mesh-extras/test/.eslintrc.json @@ -0,0 +1,12 @@ +{ + "globals": { + "expect": false, + "assert": false, + "sinon": false, + "PIXI": false + }, + "rules": { + "func-names": 0, + "no-unused-expressions": 0 + } +} \ No newline at end of file diff --git a/packages/mesh-extras/test/Plane.js b/packages/mesh-extras/test/Plane.js new file mode 100644 index 0000000..f9b1c25 --- /dev/null +++ b/packages/mesh-extras/test/Plane.js @@ -0,0 +1,60 @@ +const { Plane } = require('../'); +const { isWebGLSupported, skipHello } = require('@pixi/utils'); +const { Loader } = require('@pixi/loaders'); +const { Point } = require('@pixi/math'); +const { RenderTexture, Texture } = require('@pixi/core'); + +skipHello(); + +function withGL(fn) +{ + return isWebGLSupported() ? fn : undefined; +} + +// TODO: fix with webglrenderer +describe('PIXI.mesh.Plane', function () +{ + it.skip('should create a plane from an external image', withGL(function (done) + { + const loader = new Loader(); + + loader.add('testBitmap', `file://${__dirname}/resources/bitmap-1.png`) + .load(function (loader, resources) + { + const plane = new Plane(resources.testBitmap.texture, 100, 100); + + expect(plane.verticesX).to.equal(100); + expect(plane.verticesY).to.equal(100); + done(); + }); + })); + + it.skip('should create a new empty textured Plane', withGL(function () + { + const plane = new Plane(Texture.EMPTY, 100, 100); + + expect(plane.verticesX).to.equal(100); + expect(plane.verticesY).to.equal(100); + })); + + describe('containsPoint', function () + { + it.skip('should return true when point inside', withGL(function () + { + const point = new Point(10, 10); + const texture = new RenderTexture.create(20, 30); + const plane = new Plane(texture, 100, 100); + + expect(plane.containsPoint(point)).to.be.true; + })); + + it.skip('should return false when point outside', withGL(function () + { + const point = new Point(100, 100); + const texture = new RenderTexture.create(20, 30); + const plane = new Plane(texture, 100, 100); + + expect(plane.containsPoint(point)).to.be.false; + })); + }); +}); diff --git a/packages/mesh-extras/test/index.js b/packages/mesh-extras/test/index.js new file mode 100644 index 0000000..d767624 --- /dev/null +++ b/packages/mesh-extras/test/index.js @@ -0,0 +1 @@ +require('./Plane'); diff --git a/packages/mesh-extras/test/resources/bitmap-1.png b/packages/mesh-extras/test/resources/bitmap-1.png new file mode 100644 index 0000000..1284fb8 --- /dev/null +++ b/packages/mesh-extras/test/resources/bitmap-1.png Binary files differ diff --git a/packages/mesh/package.json b/packages/mesh/package.json index 8b1f8d9..10bd8e3 100644 --- a/packages/mesh/package.json +++ b/packages/mesh/package.json @@ -18,22 +18,16 @@ "publishConfig": { "access": "public" }, - "scripts": { - "test": "floss --path test" - }, "files": [ "lib" ], "dependencies": { - "@pixi/canvas-renderer": "^5.0.0-alpha.2", "@pixi/constants": "^5.0.0-alpha.2", "@pixi/core": "^5.0.0-alpha.2", "@pixi/display": "^5.0.0-alpha.2", - "@pixi/math": "^5.0.0-alpha.2", - "@pixi/utils": "^5.0.0-alpha.2" + "@pixi/math": "^5.0.0-alpha.2" }, "devDependencies": { - "@pixi/loaders": "^5.0.0-alpha.2", "floss": "^2.1.3" } } diff --git a/packages/mesh/src/Mesh.js b/packages/mesh/src/Mesh.js index e7c8f9e..1f35b7a 100644 --- a/packages/mesh/src/Mesh.js +++ b/packages/mesh/src/Mesh.js @@ -1,263 +1,220 @@ -import RawMesh from './RawMesh'; -import { Geometry, Program, Shader, Texture, TextureMatrix } from '@pixi/core'; -import { Matrix } from '@pixi/math'; -import { BLEND_MODES } from '@pixi/constants'; -import { hex2rgb, premultiplyRgba } from '@pixi/utils'; -import vertex from './mesh.vert'; -import fragment from './mesh.frag'; +import { State } from '@pixi/core'; +import { DRAW_MODES } from '@pixi/constants'; +import { Point, Polygon } from '@pixi/math'; +import { Container } from '@pixi/display'; -let meshProgram; +const tempPoint = new Point(); +const tempPolygon = new Polygon(); /** - * Base mesh class + * Base mesh class. + * The reason for this class is to empower you to have maximum flexibility to render any kind of webGL you can think of. + * This class assumes a certain level of webGL knowledge. + * If you know a bit this should abstract enough away to make you life easier! + * Pretty much ALL WebGL can be broken down into the following: + * Geometry - The structure and data for the mesh. This can include anything from positions, uvs, normals, colors etc.. + * Shader - This is the shader that pixi will render the geometry with. (attributes in the shader must match the geometry!) + * Uniforms - These are the values passed to the shader when the mesh is rendered. + * As a shader can be reused across multiple objects, it made sense to allow uniforms to exist outside of the shader + * State - This is the state of WebGL required to render the mesh. + * Through a combination of the above elements you can render anything you want, 2D or 3D! + * * @class * @extends PIXI.Container * @memberof PIXI */ -export default class Mesh extends RawMesh +export default class Mesh extends Container { /** - * @param {PIXI.Texture} [texture=Texture.EMPTY] - The texture to use - * @param {Float32Array} [vertices] - if you want to specify the vertices - * @param {Float32Array} [uvs] - if you want to specify the uvs - * @param {Uint16Array} [indices] - if you want to specify the indices - * @param {number} [drawMode] - the drawMode, can be any of the Mesh.DRAW_MODES consts + * @param {PIXI.Geometry} geometry the geometry the mesh will use + * @param {PIXI.Shader} shader the shader the mesh will use + * @param {PIXI.State} state the state that the webGL context is required to be in to render the mesh + * @param {number} drawMode the drawMode, can be any of the PIXI.DRAW_MODES consts */ - constructor(texture = Texture.EMPTY, vertices, uvs, indices, drawMode) + constructor(geometry, shader, state, drawMode = DRAW_MODES.TRIANGLES) { - const geometry = new Geometry(); - - if (!meshProgram) - { - meshProgram = new Program(vertex, fragment); - } - - geometry.addAttribute('aVertexPosition', vertices) - .addAttribute('aTextureCoord', uvs) - .addIndex(indices); - - geometry.getAttribute('aVertexPosition').static = false; - - const uniforms = { - uSampler: texture, - uTextureMatrix: Matrix.IDENTITY, - alpha: 1, - uColor: new Float32Array([1, 1, 1, 1]), - }; - - super(geometry, new Shader(meshProgram, uniforms), null, drawMode); + super(); /** - * The Uvs of the Mesh - * - * @member {Float32Array} + * the geometry the mesh will use + * @type {PIXI.Geometry} */ - this.uvs = geometry.getAttribute('aTextureCoord').data; + this.geometry = geometry; /** - * An array of vertices - * - * @member {Float32Array} + * the shader the mesh will use + * @type {PIXI.Shader} */ - this.vertices = geometry.getAttribute('aVertexPosition').data; - - this.uniforms = uniforms; + this.shader = shader; /** - * The texture of the Mesh - * - * @member {PIXI.Texture} - * @default PIXI.Texture.EMPTY - * @private + * the webGL state the mesh requires to render + * @type {PIXI.State} */ - this.texture = texture; + this.state = state || new State(); /** - * The tint applied to the mesh. This is a [r,g,b] value. A value of [1,1,1] will remove any - * tint effect. + * The way the Mesh should be drawn, can be any of the {@link PIXI.Mesh.DRAW_MODES} consts * * @member {number} + * @see PIXI.Mesh.DRAW_MODES + */ + this.drawMode = drawMode; + + /** + * The way uniforms that will be used by the mesh's shader. + * @member {Object} + */ + + /** + * A map of renderer IDs to webgl render data + * * @private + * @member {object} */ - this._tintRGB = new Float32Array([1, 1, 1]); - - // Set default tint - this.tint = 0xFFFFFF; - - this.blendMode = BLEND_MODES.NORMAL; + this._glDatas = {}; /** - * TextureMatrix instance for this Mesh, used to track Texture changes + * Plugin that is responsible for rendering this element. + * Allows to customize the rendering process without overriding '_render' & '_renderCanvas' methods. * - * @member {PIXI.TextureMatrix} - * @readonly + * @member {string} + * @default 'mesh' */ - this.uvMatrix = new TextureMatrix(this._texture); + this.pluginName = 'mesh'; - /** - * whether or not upload uvMatrix to shader - * if its false, then uvs should be pre-multiplied - * if you change it for generated mesh, please call 'refresh(true)' - * @member {boolean} - * @default false - */ - this.uploadUvMatrix = false; - - /** - * Uploads vertices buffer every frame, like in PixiJS V3 and V4. - * - * @member {boolean} - * @default true - */ - this.autoUpdate = true; + this.start = 0; + this.size = 0; } /** - * The tint applied to the Rope. This is a hex value. A value of - * 0xFFFFFF will remove any tint effect. + * Renders the object using the WebGL renderer * - * @member {number} - * @memberof PIXI.Sprite# - * @default 0xFFFFFF + * @param {PIXI.Renderer} renderer a reference to the WebGL renderer + * @private */ - get tint() + _render(renderer) { - return this._tint; + renderer.batch.setObjectRenderer(renderer.plugins[this.pluginName]); + renderer.plugins[this.pluginName].render(this); } /** - * Sets the tint of the rope. + * Updates the bounds of the mesh as a rectangle. The bounds calculation takes the worldTransform into account. + * there must be a aVertexPosition attribute present in the geometry for bounds to be calculated correctly. * - * @param {number} value - The value to set to. + * @private */ - set tint(value) + _calculateBounds() { - this._tint = value; - - hex2rgb(this._tint, this._tintRGB); - } - - /** - * The blend mode to be applied to the sprite. Set to `PIXI.BLEND_MODES.NORMAL` to remove any blend mode. - * - * @member {number} - * @default PIXI.BLEND_MODES.NORMAL - * @see PIXI.BLEND_MODES - */ - get blendMode() - { - return this.state.blendMode; - } - - set blendMode(value) // eslint-disable-line require-jsdoc - { - this.state.blendMode = value; - } - - /** - * The texture that the mesh uses. - * - * @member {PIXI.Texture} - */ - get texture() - { - return this._texture; - } - - set texture(value) // eslint-disable-line require-jsdoc - { - if (this._texture === value) + // The position property could be set manually? + if (this.geometry.attributes.aVertexPosition) { - return; + const vertices = this.geometry.getAttribute('aVertexPosition').data; + + // TODO - we can cache local bounds and use them if they are dirty (like graphics) + this._bounds.addVertices(this.transform, vertices, 0, vertices.length); + } + } + + /** + * Tests if a point is inside this mesh. Works only for TRIANGLE_MESH + * + * @param {PIXI.Point} point the point to test + * @return {boolean} the result of the test + */ + containsPoint(point) + { + if (!this.getBounds().contains(point.x, point.y)) + { + return false; } - this._texture = value; - this.uniforms.uSampler = this.texture; + this.worldTransform.applyInverse(point, tempPoint); - if (value) + const vertices = this.geometry.getAttribute('aVertexPosition').data; + + const points = tempPolygon.points; + const indices = this.geometry.getIndex().data; + const len = indices.length; + const step = this.drawMode === 4 ? 3 : 1; + + for (let i = 0; i + 2 < len; i += step) { - // wait for the texture to load - if (value.baseTexture.valid) + const ind0 = indices[i] * 2; + const ind1 = indices[i + 1] * 2; + const ind2 = indices[i + 2] * 2; + + points[0] = vertices[ind0]; + points[1] = vertices[ind0 + 1]; + points[2] = vertices[ind1]; + points[3] = vertices[ind1 + 1]; + points[4] = vertices[ind2]; + points[5] = vertices[ind2 + 1]; + + if (tempPolygon.contains(tempPoint.x, tempPoint.y)) { - this._onTextureUpdate(); + return true; + } + } + + return false; + } + + /** + * Destroys the Mesh object. + * + * @param {object|boolean} [options] - Options parameter. A boolean will act as if all + * options have been set to that value + * @param {boolean} [options.children=false] - if set to true, all the children will have + * their destroy method called as well. 'options' will be passed on to those calls. + * @param {boolean} [options.texture=false] - Only used for child Sprites if options.children is set to true + * Should it destroy the texture of the child sprite + * @param {boolean} [options.baseTexture=false] - Only used for child Sprites if options.children is set to true + * Should it destroy the base texture of the child sprite + */ + destroy(options) + { + // for each webgl data entry, destroy the WebGLGraphicsData + for (const id in this._glDatas) + { + const data = this._glDatas[id]; + + if (data.destroy) + { + data.destroy(); } else { - value.once('update', this._onTextureUpdate, this); + if (data.vertexBuffer) + { + data.vertexBuffer.destroy(); + data.vertexBuffer = null; + } + if (data.indexBuffer) + { + data.indexBuffer.destroy(); + data.indexBuffer = null; + } + if (data.uvBuffer) + { + data.uvBuffer.destroy(); + data.uvBuffer = null; + } + if (data.vao) + { + data.vao.destroy(); + data.vao = null; + } } } - } - _render(renderer) - { - const baseTex = this._texture.baseTexture; + this._glDatas = null; - premultiplyRgba(this._tintRGB, this.worldAlpha, this.uniforms.uColor, baseTex.premultiplyAlpha); - super._render(renderer); - } - /** - * When the texture is updated, this event will fire to update the scale and frame - * - * @private - */ - _onTextureUpdate() - { - // constructor texture update stop - if (!this.uvMatrix) - { - return; - } - this.uvMatrix.texture = this._texture; - this.refresh(); - } + this.geometry = null; + this.shader = null; + this.state = null; - /** - * multiplies uvs only if uploadUvMatrix is false - * call it after you change uvs manually - * make sure that texture is valid - */ - multiplyUvs() - { - if (!this.uploadUvMatrix) - { - this.uvMatrix.multiplyUvs(this.uvs); - } - } - - /** - * Refreshes uvs for generated meshes (rope, plane) - * sometimes refreshes vertices too - * - * @param {boolean} [forceUpdate=false] if true, matrices will be updated any case - */ - refresh(forceUpdate) - { - if (this.uvMatrix.update(forceUpdate)) - { - this._refresh(); - } - } - - /** - * Updates the object transform for rendering - * - * @private - */ - updateTransform() - { - if (this.autoUpdate) - { - this.geometry.buffers[0].update(); - } - this.containerUpdateTransform(); - } - - /** - * re-calculates mesh coords - * @private - */ - _refresh() - { - /* empty */ + super.destroy(options); } } diff --git a/packages/mesh/src/MeshRenderer.js b/packages/mesh/src/MeshRenderer.js index 12b159b..d7baf9b 100644 --- a/packages/mesh/src/MeshRenderer.js +++ b/packages/mesh/src/MeshRenderer.js @@ -36,7 +36,7 @@ /** * renders mesh * @private - * @param {PIXI.RawMesh} mesh mesh instance + * @param {PIXI.Mesh} mesh mesh instance */ render(mesh) { diff --git a/packages/mesh/src/NineSlicePlane.js b/packages/mesh/src/NineSlicePlane.js deleted file mode 100644 index 0bae92c..0000000 --- a/packages/mesh/src/NineSlicePlane.js +++ /dev/null @@ -1,270 +0,0 @@ -import Plane from './Plane'; - -const DEFAULT_BORDER_SIZE = 10; - -/** - * The NineSlicePlane allows you to stretch a texture using 9-slice scaling. The corners will remain unscaled (useful - * for buttons with rounded corners for example) and the other areas will be scaled horizontally and or vertically - * - *```js - * let Plane9 = new PIXI.NineSlicePlane(PIXI.Texture.from('BoxWithRoundedCorners.png'), 15, 15, 15, 15); - * ``` - *
- *      A                          B
- *    +---+----------------------+---+
- *  C | 1 |          2           | 3 |
- *    +---+----------------------+---+
- *    |   |                      |   |
- *    | 4 |          5           | 6 |
- *    |   |                      |   |
- *    +---+----------------------+---+
- *  D | 7 |          8           | 9 |
- *    +---+----------------------+---+
-
- *  When changing this objects width and/or height:
- *     areas 1 3 7 and 9 will remain unscaled.
- *     areas 2 and 8 will be stretched horizontally
- *     areas 4 and 6 will be stretched vertically
- *     area 5 will be stretched both horizontally and vertically
- * 
- * - * @class - * @extends PIXI.Plane - * @memberof PIXI - * - */ -export default class NineSlicePlane extends Plane -{ - /** - * @param {PIXI.Texture} texture - The texture to use on the NineSlicePlane. - * @param {int} [leftWidth=10] size of the left vertical bar (A) - * @param {int} [topHeight=10] size of the top horizontal bar (C) - * @param {int} [rightWidth=10] size of the right vertical bar (B) - * @param {int} [bottomHeight=10] size of the bottom horizontal bar (D) - */ - constructor(texture, leftWidth, topHeight, rightWidth, bottomHeight) - { - super(texture, 4, 4); - - this._origWidth = texture.orig.width; - this._origHeight = texture.orig.height; - - /** - * The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane - * - * @member {number} - * @memberof PIXI.NineSlicePlane# - * @override - */ - this._width = this._origWidth; - - /** - * The height of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane - * - * @member {number} - * @memberof PIXI.NineSlicePlane# - * @override - */ - this._height = this._origHeight; - - /** - * The width of the left column (a) - * - * @member {number} - * @memberof PIXI.NineSlicePlane# - * @override - */ - this._leftWidth = typeof leftWidth !== 'undefined' ? leftWidth : DEFAULT_BORDER_SIZE; - - /** - * The width of the right column (b) - * - * @member {number} - * @memberof PIXI.NineSlicePlane# - * @override - */ - this._rightWidth = typeof rightWidth !== 'undefined' ? rightWidth : DEFAULT_BORDER_SIZE; - - /** - * The height of the top row (c) - * - * @member {number} - * @memberof PIXI.NineSlicePlane# - * @override - */ - this._topHeight = typeof topHeight !== 'undefined' ? topHeight : DEFAULT_BORDER_SIZE; - - /** - * The height of the bottom row (d) - * - * @member {number} - * @memberof PIXI.NineSlicePlane# - * @override - */ - this._bottomHeight = typeof bottomHeight !== 'undefined' ? bottomHeight : DEFAULT_BORDER_SIZE; - - this.refresh(true); - } - - /** - * Updates the horizontal vertices. - * - */ - updateHorizontalVertices() - { - const vertices = this.vertices; - - const h = this._topHeight + this._bottomHeight; - const scale = this._height > h ? 1.0 : this._height / h; - - vertices[9] = vertices[11] = vertices[13] = vertices[15] = this._topHeight * scale; - vertices[17] = vertices[19] = vertices[21] = vertices[23] = this._height - (this._bottomHeight * scale); - vertices[25] = vertices[27] = vertices[29] = vertices[31] = this._height; - } - - /** - * Updates the vertical vertices. - * - */ - updateVerticalVertices() - { - const vertices = this.vertices; - - const w = this._leftWidth + this._rightWidth; - const scale = this._width > w ? 1.0 : this._width / w; - - vertices[2] = vertices[10] = vertices[18] = vertices[26] = this._leftWidth * scale; - vertices[4] = vertices[12] = vertices[20] = vertices[28] = this._width - (this._rightWidth * scale); - vertices[6] = vertices[14] = vertices[22] = vertices[30] = this._width; - } - - /** - * The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane - * - * @member {number} - */ - get width() - { - return this._width; - } - - set width(value) // eslint-disable-line require-jsdoc - { - this._width = value; - this._refresh(); - } - - /** - * The height of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane - * - * @member {number} - */ - get height() - { - return this._height; - } - - set height(value) // eslint-disable-line require-jsdoc - { - this._height = value; - this._refresh(); - } - - /** - * The width of the left column - * - * @member {number} - */ - get leftWidth() - { - return this._leftWidth; - } - - set leftWidth(value) // eslint-disable-line require-jsdoc - { - this._leftWidth = value; - this._refresh(); - } - - /** - * The width of the right column - * - * @member {number} - */ - get rightWidth() - { - return this._rightWidth; - } - - set rightWidth(value) // eslint-disable-line require-jsdoc - { - this._rightWidth = value; - this._refresh(); - } - - /** - * The height of the top row - * - * @member {number} - */ - get topHeight() - { - return this._topHeight; - } - - set topHeight(value) // eslint-disable-line require-jsdoc - { - this._topHeight = value; - this._refresh(); - } - - /** - * The height of the bottom row - * - * @member {number} - */ - get bottomHeight() - { - return this._bottomHeight; - } - - set bottomHeight(value) // eslint-disable-line require-jsdoc - { - this._bottomHeight = value; - this._refresh(); - } - - /** - * Refreshes NineSlicePlane coords. All of them. - */ - _refresh() - { - super._refresh(); - - const uvs = this.uvs; - const texture = this._texture; - - this._origWidth = texture.orig.width; - this._origHeight = texture.orig.height; - - const _uvw = 1.0 / this._origWidth; - const _uvh = 1.0 / this._origHeight; - - uvs[0] = uvs[8] = uvs[16] = uvs[24] = 0; - uvs[1] = uvs[3] = uvs[5] = uvs[7] = 0; - uvs[6] = uvs[14] = uvs[22] = uvs[30] = 1; - uvs[25] = uvs[27] = uvs[29] = uvs[31] = 1; - - uvs[2] = uvs[10] = uvs[18] = uvs[26] = _uvw * this._leftWidth; - uvs[4] = uvs[12] = uvs[20] = uvs[28] = 1 - (_uvw * this._rightWidth); - uvs[9] = uvs[11] = uvs[13] = uvs[15] = _uvh * this._topHeight; - uvs[17] = uvs[19] = uvs[21] = uvs[23] = 1 - (_uvh * this._bottomHeight); - - this.updateHorizontalVertices(); - this.updateVerticalVertices(); - - this.geometry.buffers[1].update(); - - this.multiplyUvs(); - } -} diff --git a/packages/mesh/src/Plane.js b/packages/mesh/src/Plane.js deleted file mode 100644 index c416b4c..0000000 --- a/packages/mesh/src/Plane.js +++ /dev/null @@ -1,100 +0,0 @@ -import Mesh from './Mesh'; - -/** - * The Plane allows you to draw a texture across several points and them manipulate these points - * - *```js - * for (let i = 0; i < 20; i++) { - * points.push(new PIXI.Point(i * 50, 0)); - * }; - * let Plane = new PIXI.Plane(PIXI.Texture.from("snake.png"), points); - * ``` - * - * @class - * @extends PIXI.Mesh - * @memberof PIXI - * - */ -export default class Plane extends Mesh -{ - /** - * @param {PIXI.Texture} texture - The texture to use on the Plane. - * @param {number} verticesX - The number of vertices in the x-axis - * @param {number} verticesY - The number of vertices in the y-axis - * @param {object} [opts] - an options object - add meshWidth and meshHeight, temporary object for PixiJS v5 alpha - */ - constructor(texture, verticesX, verticesY, opts = {}) - { - super(texture, new Float32Array(1), new Float32Array(1), new Uint16Array(1), 4); - - this.verticesX = verticesX || 10; - this.verticesY = verticesY || 10; - - this.meshWidth = opts.meshWidth || 0; - this.meshHeight = opts.meshHeight || 0; - - this.refresh(); - } - - /** - * Refreshes plane coordinates - * @private - */ - _refresh() - { - const texture = this._texture; - const total = this.verticesX * this.verticesY; - const verts = []; - const uvs = []; - const indices = []; - - const segmentsX = this.verticesX - 1; - const segmentsY = this.verticesY - 1; - - const sizeX = (this.meshWidth || texture.width) / segmentsX; - const sizeY = (this.meshHeight || texture.height) / segmentsY; - - for (let i = 0; i < total; i++) - { - const x = (i % this.verticesX); - const y = ((i / this.verticesX) | 0); - - verts.push(x * sizeX, y * sizeY); - - uvs.push(x / segmentsX, y / segmentsY); - } - - // cons - - const totalSub = segmentsX * segmentsY; - - for (let i = 0; i < totalSub; i++) - { - const xpos = i % segmentsX; - const ypos = (i / segmentsX) | 0; - - const value = (ypos * this.verticesX) + xpos; - const value2 = (ypos * this.verticesX) + xpos + 1; - const value3 = ((ypos + 1) * this.verticesX) + xpos; - const value4 = ((ypos + 1) * this.verticesX) + xpos + 1; - - indices.push(value, value2, value3); - indices.push(value2, value4, value3); - } - - this.vertices = new Float32Array(verts); - this.uvs = new Float32Array(uvs); - this.indices = new Uint16Array(indices); - - this.geometry.buffers[0].data = this.vertices; - this.geometry.buffers[1].data = this.uvs; - this.geometry.indexBuffer.data = this.indices; - - // ensure that the changes are uploaded - this.geometry.buffers[0].update(); - this.geometry.buffers[1].update(); - this.geometry.indexBuffer.update(); - - this.multiplyUvs(); - } -} diff --git a/packages/mesh/src/RawMesh.js b/packages/mesh/src/RawMesh.js deleted file mode 100644 index 7297e94..0000000 --- a/packages/mesh/src/RawMesh.js +++ /dev/null @@ -1,220 +0,0 @@ -import { State } from '@pixi/core'; -import { DRAW_MODES } from '@pixi/constants'; -import { Point, Polygon } from '@pixi/math'; -import { Container } from '@pixi/display'; - -const tempPoint = new Point(); -const tempPolygon = new Polygon(); - -/** - * Base mesh class. - * The reason for this class is to empower you to have maximum flexibility to render any kind of webGL you can think of. - * This class assumes a certain level of webGL knowledge. - * If you know a bit this should abstract enough away to make you life easier! - * Pretty much ALL WebGL can be broken down into the following: - * Geometry - The structure and data for the mesh. This can include anything from positions, uvs, normals, colors etc.. - * Shader - This is the shader that pixi will render the geometry with. (attributes in the shader must match the geometry!) - * Uniforms - These are the values passed to the shader when the mesh is rendered. - * As a shader can be reused across multiple objects, it made sense to allow uniforms to exist outside of the shader - * State - This is the state of WebGL required to render the mesh. - * Through a combination of the above elements you can render anything you want, 2D or 3D! - * - * @class - * @extends PIXI.Container - * @memberof PIXI - */ -export default class RawMesh extends Container -{ - /** - * @param {PIXI.Geometry} geometry the geometry the mesh will use - * @param {PIXI.Shader} shader the shader the mesh will use - * @param {PIXI.State} state the state that the webGL context is required to be in to render the mesh - * @param {number} drawMode the drawMode, can be any of the PIXI.DRAW_MODES consts - */ - constructor(geometry, shader, state, drawMode = DRAW_MODES.TRIANGLES) - { - super(); - - /** - * the geometry the mesh will use - * @type {PIXI.Geometry} - */ - this.geometry = geometry; - - /** - * the shader the mesh will use - * @type {PIXI.Shader} - */ - this.shader = shader; - - /** - * the webGL state the mesh requires to render - * @type {PIXI.State} - */ - this.state = state || new State(); - - /** - * The way the Mesh should be drawn, can be any of the {@link PIXI.RawMesh.DRAW_MODES} consts - * - * @member {number} - * @see PIXI.RawMesh.DRAW_MODES - */ - this.drawMode = drawMode; - - /** - * The way uniforms that will be used by the mesh's shader. - * @member {Object} - */ - - /** - * A map of renderer IDs to webgl render data - * - * @private - * @member {object} - */ - this._glDatas = {}; - - /** - * Plugin that is responsible for rendering this element. - * Allows to customize the rendering process without overriding '_render' & '_renderCanvas' methods. - * - * @member {string} - * @default 'mesh' - */ - this.pluginName = 'mesh'; - - this.start = 0; - this.size = 0; - } - - /** - * Renders the object using the WebGL renderer - * - * @param {PIXI.Renderer} renderer a reference to the WebGL renderer - * @private - */ - _render(renderer) - { - renderer.batch.setObjectRenderer(renderer.plugins[this.pluginName]); - renderer.plugins[this.pluginName].render(this); - } - - /** - * Updates the bounds of the mesh as a rectangle. The bounds calculation takes the worldTransform into account. - * there must be a aVertexPosition attribute present in the geometry for bounds to be calculated correctly. - * - * @private - */ - _calculateBounds() - { - // The position property could be set manually? - if (this.geometry.attributes.aVertexPosition) - { - const vertices = this.geometry.getAttribute('aVertexPosition').data; - - // TODO - we can cache local bounds and use them if they are dirty (like graphics) - this._bounds.addVertices(this.transform, vertices, 0, vertices.length); - } - } - - /** - * Tests if a point is inside this mesh. Works only for TRIANGLE_MESH - * - * @param {PIXI.Point} point the point to test - * @return {boolean} the result of the test - */ - containsPoint(point) - { - if (!this.getBounds().contains(point.x, point.y)) - { - return false; - } - - this.worldTransform.applyInverse(point, tempPoint); - - const vertices = this.geometry.getAttribute('aVertexPosition').data; - - const points = tempPolygon.points; - const indices = this.geometry.getIndex().data; - const len = indices.length; - const step = this.drawMode === 4 ? 3 : 1; - - for (let i = 0; i + 2 < len; i += step) - { - const ind0 = indices[i] * 2; - const ind1 = indices[i + 1] * 2; - const ind2 = indices[i + 2] * 2; - - points[0] = vertices[ind0]; - points[1] = vertices[ind0 + 1]; - points[2] = vertices[ind1]; - points[3] = vertices[ind1 + 1]; - points[4] = vertices[ind2]; - points[5] = vertices[ind2 + 1]; - - if (tempPolygon.contains(tempPoint.x, tempPoint.y)) - { - return true; - } - } - - return false; - } - - /** - * Destroys the RawMesh object. - * - * @param {object|boolean} [options] - Options parameter. A boolean will act as if all - * options have been set to that value - * @param {boolean} [options.children=false] - if set to true, all the children will have - * their destroy method called as well. 'options' will be passed on to those calls. - * @param {boolean} [options.texture=false] - Only used for child Sprites if options.children is set to true - * Should it destroy the texture of the child sprite - * @param {boolean} [options.baseTexture=false] - Only used for child Sprites if options.children is set to true - * Should it destroy the base texture of the child sprite - */ - destroy(options) - { - // for each webgl data entry, destroy the WebGLGraphicsData - for (const id in this._glDatas) - { - const data = this._glDatas[id]; - - if (data.destroy) - { - data.destroy(); - } - else - { - if (data.vertexBuffer) - { - data.vertexBuffer.destroy(); - data.vertexBuffer = null; - } - if (data.indexBuffer) - { - data.indexBuffer.destroy(); - data.indexBuffer = null; - } - if (data.uvBuffer) - { - data.uvBuffer.destroy(); - data.uvBuffer = null; - } - if (data.vao) - { - data.vao.destroy(); - data.vao = null; - } - } - } - - this._glDatas = null; - - this.geometry = null; - this.shader = null; - this.state = null; - - super.destroy(options); - } -} diff --git a/packages/mesh/src/Rope.js b/packages/mesh/src/Rope.js deleted file mode 100644 index b4f85d3..0000000 --- a/packages/mesh/src/Rope.js +++ /dev/null @@ -1,182 +0,0 @@ -import Mesh from './Mesh'; - -/** - * The rope allows you to draw a texture across several points and them manipulate these points - * - *```js - * for (let i = 0; i < 20; i++) { - * points.push(new PIXI.Point(i * 50, 0)); - * }; - * let rope = new PIXI.Rope(PIXI.Texture.from("snake.png"), points); - * ``` - * - * @class - * @extends PIXI.Mesh - * @memberof PIXI - * - */ -export default class Rope extends Mesh -{ - /** - * @param {PIXI.Texture} texture - The texture to use on the rope. - * @param {PIXI.Point[]} points - An array of {@link PIXI.Point} objects to construct this rope. - */ - constructor(texture, points) - { - super(texture, new Float32Array(points.length * 4), - new Float32Array(points.length * 4), - new Uint16Array(points.length * 2), - 5); - - /* - * @member {PIXI.Point[]} An array of points that determine the rope - */ - this.points = points; - this.refresh(); - } - /** - * Refreshes Rope indices and uvs - * @private - */ - _refresh() - { - const points = this.points; - - if (!points) return; - - const vertexBuffer = this.geometry.getAttribute('aVertexPosition'); - const uvBuffer = this.geometry.getAttribute('aTextureCoord'); - const indexBuffer = this.geometry.getIndex(); - - // if too little points, or texture hasn't got UVs set yet just move on. - if (points.length < 1 || !this.texture._uvs) - { - return; - } - - // if the number of points has changed we will need to recreate the arraybuffers - if (vertexBuffer.data.length / 4 !== points.length) - { - vertexBuffer.data = new Float32Array(points.length * 4); - uvBuffer.data = new Float32Array(points.length * 4); - indexBuffer.data = new Uint16Array(points.length * 2); - } - - const uvs = uvBuffer.data; - const indices = indexBuffer.data; - - uvs[0] = 0; - uvs[1] = 0; - uvs[2] = 0; - uvs[3] = 1; - - indices[0] = 0; - indices[1] = 1; - - const total = points.length; - - for (let i = 1; i < total; i++) - { - // time to do some smart drawing! - let index = i * 4; - const amount = i / (total - 1); - - uvs[index] = amount; - uvs[index + 1] = 0; - - uvs[index + 2] = amount; - uvs[index + 3] = 1; - - index = i * 2; - indices[index] = index; - indices[index + 1] = index + 1; - } - - // ensure that the changes are uploaded - uvBuffer.update(); - indexBuffer.update(); - - this.multiplyUvs(); - this.refreshVertices(); - } - - /** - * refreshes vertices of Rope mesh - */ - refreshVertices() - { - const points = this.points; - - if (points.length < 1) - { - return; - } - - let lastPoint = points[0]; - let nextPoint; - let perpX = 0; - let perpY = 0; - - // this.count -= 0.2; - - const vertices = this.vertices; - const total = points.length; - - for (let i = 0; i < total; i++) - { - const point = points[i]; - const index = i * 4; - - if (i < points.length - 1) - { - nextPoint = points[i + 1]; - } - else - { - nextPoint = point; - } - - perpY = -(nextPoint.x - lastPoint.x); - perpX = nextPoint.y - lastPoint.y; - - let ratio = (1 - (i / (total - 1))) * 10; - - if (ratio > 1) - { - ratio = 1; - } - - const perpLength = Math.sqrt((perpX * perpX) + (perpY * perpY)); - const num = this._texture.height / 2; // (20 + Math.abs(Math.sin((i + this.count) * 0.3) * 50) )* ratio; - - perpX /= perpLength; - perpY /= perpLength; - - perpX *= num; - perpY *= num; - - vertices[index] = point.x + perpX; - vertices[index + 1] = point.y + perpY; - vertices[index + 2] = point.x - perpX; - vertices[index + 3] = point.y - perpY; - - lastPoint = point; - } - - this.geometry.buffers[0].update(); - } - - /** - * Updates the object transform for rendering - * - * @private - */ - updateTransform() - { - if (this.autoUpdate) - { - this.refreshVertices(); - } - this.containerUpdateTransform(); - } -} diff --git a/packages/mesh/src/index.js b/packages/mesh/src/index.js index a245772..e14ab9f 100644 --- a/packages/mesh/src/index.js +++ b/packages/mesh/src/index.js @@ -1,6 +1,2 @@ export { default as Mesh } from './Mesh'; -export { default as RawMesh } from './RawMesh'; export { default as MeshRenderer } from './MeshRenderer'; -export { default as Plane } from './Plane'; -export { default as NineSlicePlane } from './NineSlicePlane'; -export { default as Rope } from './Rope'; diff --git a/packages/mesh/src/mesh.frag b/packages/mesh/src/mesh.frag deleted file mode 100644 index 6096983..0000000 --- a/packages/mesh/src/mesh.frag +++ /dev/null @@ -1,9 +0,0 @@ -varying vec2 vTextureCoord; -uniform vec4 uColor; - -uniform sampler2D uSampler; - -void main(void) -{ - gl_FragColor = texture2D(uSampler, vTextureCoord) * uColor; -} diff --git a/packages/mesh/src/mesh.vert b/packages/mesh/src/mesh.vert deleted file mode 100644 index 0526df9..0000000 --- a/packages/mesh/src/mesh.vert +++ /dev/null @@ -1,15 +0,0 @@ -attribute vec2 aVertexPosition; -attribute vec2 aTextureCoord; - -uniform mat3 projectionMatrix; -uniform mat3 translationMatrix; -uniform mat3 uTextureMatrix; - -varying vec2 vTextureCoord; - -void main(void) -{ - gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); - - vTextureCoord = (uTextureMatrix * vec3(aTextureCoord, 1.0)).xy; -} diff --git a/packages/mesh/test/.eslintrc.json b/packages/mesh/test/.eslintrc.json deleted file mode 100644 index 2ad8efb..0000000 --- a/packages/mesh/test/.eslintrc.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "globals": { - "expect": false, - "assert": false, - "sinon": false, - "PIXI": false - }, - "rules": { - "func-names": 0, - "no-unused-expressions": 0 - } -} \ No newline at end of file diff --git a/packages/mesh/test/Plane.js b/packages/mesh/test/Plane.js deleted file mode 100644 index f9b1c25..0000000 --- a/packages/mesh/test/Plane.js +++ /dev/null @@ -1,60 +0,0 @@ -const { Plane } = require('../'); -const { isWebGLSupported, skipHello } = require('@pixi/utils'); -const { Loader } = require('@pixi/loaders'); -const { Point } = require('@pixi/math'); -const { RenderTexture, Texture } = require('@pixi/core'); - -skipHello(); - -function withGL(fn) -{ - return isWebGLSupported() ? fn : undefined; -} - -// TODO: fix with webglrenderer -describe('PIXI.mesh.Plane', function () -{ - it.skip('should create a plane from an external image', withGL(function (done) - { - const loader = new Loader(); - - loader.add('testBitmap', `file://${__dirname}/resources/bitmap-1.png`) - .load(function (loader, resources) - { - const plane = new Plane(resources.testBitmap.texture, 100, 100); - - expect(plane.verticesX).to.equal(100); - expect(plane.verticesY).to.equal(100); - done(); - }); - })); - - it.skip('should create a new empty textured Plane', withGL(function () - { - const plane = new Plane(Texture.EMPTY, 100, 100); - - expect(plane.verticesX).to.equal(100); - expect(plane.verticesY).to.equal(100); - })); - - describe('containsPoint', function () - { - it.skip('should return true when point inside', withGL(function () - { - const point = new Point(10, 10); - const texture = new RenderTexture.create(20, 30); - const plane = new Plane(texture, 100, 100); - - expect(plane.containsPoint(point)).to.be.true; - })); - - it.skip('should return false when point outside', withGL(function () - { - const point = new Point(100, 100); - const texture = new RenderTexture.create(20, 30); - const plane = new Plane(texture, 100, 100); - - expect(plane.containsPoint(point)).to.be.false; - })); - }); -}); diff --git a/packages/mesh/test/index.js b/packages/mesh/test/index.js deleted file mode 100644 index d767624..0000000 --- a/packages/mesh/test/index.js +++ /dev/null @@ -1 +0,0 @@ -require('./Plane'); diff --git a/packages/mesh/test/resources/bitmap-1.png b/packages/mesh/test/resources/bitmap-1.png deleted file mode 100644 index 1284fb8..0000000 --- a/packages/mesh/test/resources/bitmap-1.png +++ /dev/null Binary files differ