New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@pixi/mesh-extras

Package Overview
Dependencies
Maintainers
1
Versions
121
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pixi/mesh-extras - npm Package Compare versions

Comparing version 5.2.4 to 5.3.0

930

dist/mesh-extras.js
/*!
* @pixi/mesh-extras - v5.2.4
* Compiled Sun, 03 May 2020 22:38:52 UTC
* @pixi/mesh-extras - v5.3.0
* Compiled Thu, 18 Jun 2020 23:27:40 UTC
*

@@ -12,25 +12,208 @@ * @pixi/mesh-extras is licensed under the MIT License.

var PlaneGeometry = /*@__PURE__*/(function (MeshGeometry) {
function PlaneGeometry(width, height, segWidth, segHeight)
{
if ( width === void 0 ) width = 100;
if ( height === void 0 ) height = 100;
if ( segWidth === void 0 ) segWidth = 10;
if ( segHeight === void 0 ) segHeight = 10;
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
MeshGeometry.call(this);
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
this.segWidth = segWidth;
this.segHeight = segHeight;
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/* global Reflect, Promise */
this.width = width;
this.height = height;
var extendStatics = function(d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) { if (b.hasOwnProperty(p)) { d[p] = b[p]; } } };
return extendStatics(d, b);
};
this.build();
function __extends(d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
}
var __assign = function() {
__assign = Object.assign || function __assign(t) {
var arguments$1 = arguments;
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments$1[i];
for (var p in s) { if (Object.prototype.hasOwnProperty.call(s, p)) { t[p] = s[p]; } }
}
return t;
};
return __assign.apply(this, arguments);
};
function __rest(s, e) {
var t = {};
for (var p in s) { if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
{ t[p] = s[p]; } }
if (s != null && typeof Object.getOwnPropertySymbols === "function")
{ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { if (e.indexOf(p[i]) < 0)
{ t[p[i]] = s[p[i]]; } } }
return t;
}
function __decorate(decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") { r = Reflect.decorate(decorators, target, key, desc); }
else { for (var i = decorators.length - 1; i >= 0; i--) { if (d = decorators[i]) { r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; } } }
return c > 3 && r && Object.defineProperty(target, key, r), r;
}
function __param(paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); }
}
function __metadata(metadataKey, metadataValue) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") { return Reflect.metadata(metadataKey, metadataValue); }
}
function __awaiter(thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
}
function __generator(thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) { throw t[1]; } return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) { throw new TypeError("Generator is already executing."); }
while (_) { try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) { return t; }
if (y = 0, t) { op = [op[0] & 2, t.value]; }
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) { _.ops.pop(); }
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } }
if (op[0] & 5) { throw op[1]; } return { value: op[0] ? op[1] : void 0, done: true };
}
}
if ( MeshGeometry ) PlaneGeometry.__proto__ = MeshGeometry;
PlaneGeometry.prototype = Object.create( MeshGeometry && MeshGeometry.prototype );
PlaneGeometry.prototype.constructor = PlaneGeometry;
function __exportStar(m, exports) {
for (var p in m) { if (!exports.hasOwnProperty(p)) { exports[p] = m[p]; } }
}
function __values(o) {
var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
if (m) { return m.call(o); }
return {
next: function () {
if (o && i >= o.length) { o = void 0; }
return { value: o && o[i++], done: !o };
}
};
}
function __read(o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) { return o; }
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) { ar.push(r.value); }
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) { m.call(i); }
}
finally { if (e) { throw e.error; } }
}
return ar;
}
function __spread() {
var arguments$1 = arguments;
for (var ar = [], i = 0; i < arguments.length; i++)
{ ar = ar.concat(__read(arguments$1[i])); }
return ar;
}
function __await(v) {
return this instanceof __await ? (this.v = v, this) : new __await(v);
}
function __asyncGenerator(thisArg, _arguments, generator) {
if (!Symbol.asyncIterator) { throw new TypeError("Symbol.asyncIterator is not defined."); }
var g = generator.apply(thisArg, _arguments || []), i, q = [];
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
function verb(n) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } }
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
function fulfill(value) { resume("next", value); }
function reject(value) { resume("throw", value); }
function settle(f, v) { if (f(v), q.shift(), q.length) { resume(q[0][0], q[0][1]); } }
}
function __asyncDelegator(o) {
var i, p;
return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
}
function __asyncValues(o) {
if (!Symbol.asyncIterator) { throw new TypeError("Symbol.asyncIterator is not defined."); }
var m = o[Symbol.asyncIterator], i;
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
}
function __makeTemplateObject(cooked, raw) {
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
return cooked;
};
function __importStar(mod) {
if (mod && mod.__esModule) { return mod; }
var result = {};
if (mod != null) { for (var k in mod) { if (Object.hasOwnProperty.call(mod, k)) { result[k] = mod[k]; } } }
result.default = mod;
return result;
}
function __importDefault(mod) {
return (mod && mod.__esModule) ? mod : { default: mod };
}
var PlaneGeometry = /** @class */ (function (_super) {
__extends(PlaneGeometry, _super);
function PlaneGeometry(width, height, segWidth, segHeight) {
if (width === void 0) { width = 100; }
if (height === void 0) { height = 100; }
if (segWidth === void 0) { segWidth = 10; }
if (segHeight === void 0) { segHeight = 10; }
var _this = _super.call(this) || this;
_this.segWidth = segWidth;
_this.segHeight = segHeight;
_this.width = width;
_this.height = height;
_this.build();
return _this;
}
/**

@@ -40,4 +223,3 @@ * Refreshes plane coordinates

*/
PlaneGeometry.prototype.build = function build ()
{
PlaneGeometry.prototype.build = function () {
var total = this.segWidth * this.segHeight;

@@ -47,25 +229,16 @@ var verts = [];

var indices = [];
var segmentsX = this.segWidth - 1;
var segmentsY = this.segHeight - 1;
var sizeX = (this.width) / segmentsX;
var sizeY = (this.height) / segmentsY;
for (var i = 0; i < total; i++)
{
for (var i = 0; i < total; i++) {
var x = (i % this.segWidth);
var y = ((i / this.segWidth) | 0);
verts.push(x * sizeX, y * sizeY);
uvs.push(x / segmentsX, y / segmentsY);
}
var totalSub = segmentsX * segmentsY;
for (var i$1 = 0; i$1 < totalSub; i$1++)
{
var xpos = i$1 % segmentsX;
var ypos = (i$1 / segmentsX) | 0;
for (var i = 0; i < totalSub; i++) {
var xpos = i % segmentsX;
var ypos = (i / segmentsX) | 0;
var value = (ypos * this.segWidth) + xpos;

@@ -75,11 +248,7 @@ var value2 = (ypos * this.segWidth) + xpos + 1;

var value4 = ((ypos + 1) * this.segWidth) + xpos + 1;
indices.push(value, value2, value3,
value2, value4, value3);
indices.push(value, value2, value3, value2, value4, value3);
}
this.buffers[0].data = new Float32Array(verts);
this.buffers[1].data = new Float32Array(uvs);
this.indexBuffer.data = new Uint16Array(indices);
// ensure that the changes are uploaded

@@ -90,3 +259,2 @@ this.buffers[0].update();

};
return PlaneGeometry;

@@ -110,12 +278,19 @@ }(mesh.MeshGeometry));

*/
var RopeGeometry = /*@__PURE__*/(function (MeshGeometry) {
function RopeGeometry(width, points, textureScale)
{
if ( width === void 0 ) width = 200;
if ( textureScale === void 0 ) textureScale = 0;
MeshGeometry.call(this, new Float32Array(points.length * 4),
new Float32Array(points.length * 4),
new Uint16Array((points.length - 1) * 6));
var RopeGeometry = /** @class */ (function (_super) {
__extends(RopeGeometry, _super);
/**
* @param {number} [width=200] - The width (i.e., thickness) of the rope.
* @param {PIXI.Point[]} [points] - An array of {@link PIXI.Point} objects to construct this rope.
* @param {number} [textureScale=0] - By default the rope texture will be stretched to match
* rope length. If textureScale is positive this value will be treated as a scaling
* factor and the texture will preserve its aspect ratio instead. To create a tiling rope
* set baseTexture.wrapMode to {@link PIXI.WRAP_MODES.REPEAT} and use a power of two texture,
* then set textureScale=1 to keep the original texture pixel size.
* In order to reduce alpha channel artifacts provide a larger texture and downsample -
* i.e. set textureScale=0.5 to scale it down twice.
*/
function RopeGeometry(width, points, textureScale) {
if (width === void 0) { width = 200; }
if (textureScale === void 0) { textureScale = 0; }
var _this = _super.call(this, new Float32Array(points.length * 4), new Float32Array(points.length * 4), new Uint16Array((points.length - 1) * 6)) || this;
/**

@@ -125,4 +300,3 @@ * An array of points that determine the rope

*/
this.points = points;
_this.points = points;
/**

@@ -133,4 +307,3 @@ * The width (i.e., thickness) of the rope.

*/
this.width = width;
_this._width = width;
/**

@@ -141,10 +314,18 @@ * Rope texture scale, if zero then the rope texture is stretched.

*/
this.textureScale = textureScale;
this.build();
_this.textureScale = textureScale;
_this.build();
return _this;
}
if ( MeshGeometry ) RopeGeometry.__proto__ = MeshGeometry;
RopeGeometry.prototype = Object.create( MeshGeometry && MeshGeometry.prototype );
RopeGeometry.prototype.constructor = RopeGeometry;
Object.defineProperty(RopeGeometry.prototype, "width", {
/**
* The width (i.e., thickness) of the rope.
* @member {number}
* @readOnly
*/
get: function () {
return this._width;
},
enumerable: false,
configurable: true
});
/**

@@ -154,21 +335,15 @@ * Refreshes Rope indices and uvs

*/
RopeGeometry.prototype.build = function build ()
{
RopeGeometry.prototype.build = function () {
var points = this.points;
if (!points) { return; }
if (!points)
{ return; }
var vertexBuffer = this.getBuffer('aVertexPosition');
var uvBuffer = this.getBuffer('aTextureCoord');
var indexBuffer = this.getIndex();
// if too little points, or texture hasn't got UVs set yet just move on.
if (points.length < 1)
{
if (points.length < 1) {
return;
}
// if the number of points has changed we will need to recreate the arraybuffers
if (vertexBuffer.data.length / 4 !== points.length)
{
if (vertexBuffer.data.length / 4 !== points.length) {
vertexBuffer.data = new Float32Array(points.length * 4);

@@ -178,6 +353,4 @@ uvBuffer.data = new Float32Array(points.length * 4);

}
var uvs = uvBuffer.data;
var indices = indexBuffer.data;
uvs[0] = 0;

@@ -187,15 +360,10 @@ uvs[1] = 0;

uvs[3] = 1;
var amount = 0;
var prev = points[0];
var textureWidth = this.width * this.textureScale;
var textureWidth = this._width * this.textureScale;
var total = points.length; // - 1;
for (var i = 0; i < total; i++)
{
for (var i = 0; i < total; i++) {
// time to do some smart drawing!
var index = i * 4;
if (this.textureScale > 0)
{
if (this.textureScale > 0) {
// calculate pixel distance from previous point

@@ -205,53 +373,37 @@ var dx = prev.x - points[i].x;

var distance = Math.sqrt((dx * dx) + (dy * dy));
prev = points[i];
amount += distance / textureWidth;
}
else
{
else {
// stretch texture
amount = i / (total - 1);
}
uvs[index] = amount;
uvs[index + 1] = 0;
uvs[index + 2] = amount;
uvs[index + 3] = 1;
}
var indexCount = 0;
for (var i$1 = 0; i$1 < total - 1; i$1++)
{
var index$1 = i$1 * 2;
indices[indexCount++] = index$1;
indices[indexCount++] = index$1 + 1;
indices[indexCount++] = index$1 + 2;
indices[indexCount++] = index$1 + 2;
indices[indexCount++] = index$1 + 1;
indices[indexCount++] = index$1 + 3;
for (var i = 0; i < total - 1; i++) {
var index = i * 2;
indices[indexCount++] = index;
indices[indexCount++] = index + 1;
indices[indexCount++] = index + 2;
indices[indexCount++] = index + 2;
indices[indexCount++] = index + 1;
indices[indexCount++] = index + 3;
}
// ensure that the changes are uploaded
uvBuffer.update();
indexBuffer.update();
this.updateVertices();
};
/**
* refreshes vertices of Rope mesh
*/
RopeGeometry.prototype.updateVertices = function updateVertices ()
{
RopeGeometry.prototype.updateVertices = function () {
var points = this.points;
if (points.length < 1)
{
if (points.length < 1) {
return;
}
var lastPoint = points[0];

@@ -261,39 +413,25 @@ var nextPoint;

var perpY = 0;
var vertices = this.buffers[0].data;
var total = points.length;
for (var i = 0; i < total; i++)
{
for (var i = 0; i < total; i++) {
var point = points[i];
var index = i * 4;
if (i < points.length - 1)
{
if (i < points.length - 1) {
nextPoint = points[i + 1];
}
else
{
else {
nextPoint = point;
}
perpY = -(nextPoint.x - lastPoint.x);
perpX = nextPoint.y - lastPoint.y;
var ratio = (1 - (i / (total - 1))) * 10;
if (ratio > 1)
{
if (ratio > 1) {
ratio = 1;
}
var perpLength = Math.sqrt((perpX * perpX) + (perpY * perpY));
var num = this.textureScale > 0 ? this.textureScale * this.width / 2 : this.width / 2;
var num = this.textureScale > 0 ? this.textureScale * this._width / 2 : this._width / 2;
perpX /= perpLength;
perpY /= perpLength;
perpX *= num;
perpY *= num;
vertices[index] = point.x + perpX;

@@ -303,21 +441,14 @@ vertices[index + 1] = point.y + perpY;

vertices[index + 3] = point.y - perpY;
lastPoint = point;
}
this.buffers[0].update();
};
RopeGeometry.prototype.update = function update ()
{
if (this.textureScale > 0)
{
RopeGeometry.prototype.update = function () {
if (this.textureScale > 0) {
this.build(); // we need to update UVs
}
else
{
else {
this.updateVertices();
}
};
return RopeGeometry;

@@ -341,17 +472,21 @@ }(mesh.MeshGeometry));

*/
var SimpleRope = /*@__PURE__*/(function (Mesh) {
function SimpleRope(texture, points, textureScale)
{
if ( textureScale === void 0 ) textureScale = 0;
var SimpleRope = /** @class */ (function (_super) {
__extends(SimpleRope, _super);
/**
* @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.
* @param {number} [textureScale=0] - Optional. Positive values scale rope texture
* keeping its aspect ratio. You can reduce alpha channel artifacts by providing a larger texture
* and downsampling here. If set to zero, texture will be streched instead.
*/
function SimpleRope(texture, points, textureScale) {
if (textureScale === void 0) { textureScale = 0; }
var _this = this;
var ropeGeometry = new RopeGeometry(texture.height, points, textureScale);
var meshMaterial = new mesh.MeshMaterial(texture);
if (textureScale > 0)
{
if (textureScale > 0) {
// attempt to set UV wrapping, will fail on non-power of two textures
texture.baseTexture.wrapMode = constants.WRAP_MODES.REPEAT;
}
Mesh.call(this, ropeGeometry, meshMaterial);
_this = _super.call(this, ropeGeometry, meshMaterial) || this;
/**

@@ -362,21 +497,13 @@ * re-calculate vertices by rope points each frame

*/
this.autoUpdate = true;
_this.autoUpdate = true;
return _this;
}
if ( Mesh ) SimpleRope.__proto__ = Mesh;
SimpleRope.prototype = Object.create( Mesh && Mesh.prototype );
SimpleRope.prototype.constructor = SimpleRope;
SimpleRope.prototype._render = function _render (renderer)
{
if (this.autoUpdate
|| this.geometry.width !== this.shader.texture.height)
{
this.geometry.width = this.shader.texture.height;
this.geometry.update();
SimpleRope.prototype._render = function (renderer) {
var geometry = this.geometry;
if (this.autoUpdate || geometry._width !== this.shader.texture.height) {
geometry._width = this.shader.texture.height;
geometry.update();
}
Mesh.prototype._render.call(this, renderer);
_super.prototype._render.call(this, renderer);
};
return SimpleRope;

@@ -400,20 +527,18 @@ }(mesh.Mesh));

*/
var SimplePlane = /*@__PURE__*/(function (Mesh) {
function SimplePlane(texture, verticesX, verticesY)
{
var SimplePlane = /** @class */ (function (_super) {
__extends(SimplePlane, _super);
/**
* @param {PIXI.Texture} texture - The texture to use on the SimplePlane.
* @param {number} verticesX - The number of vertices in the x-axis
* @param {number} verticesY - The number of vertices in the y-axis
*/
function SimplePlane(texture, verticesX, verticesY) {
var _this = this;
var planeGeometry = new PlaneGeometry(texture.width, texture.height, verticesX, verticesY);
var meshMaterial = new mesh.MeshMaterial(core.Texture.WHITE);
Mesh.call(this, planeGeometry, meshMaterial);
_this = _super.call(this, planeGeometry, meshMaterial) || this;
// lets call the setter to ensure all necessary updates are performed
this.texture = texture;
_this.texture = texture;
return _this;
}
if ( Mesh ) SimplePlane.__proto__ = Mesh;
SimplePlane.prototype = Object.create( Mesh && Mesh.prototype );
SimplePlane.prototype.constructor = SimplePlane;
var prototypeAccessors = { texture: { configurable: true } };
/**

@@ -423,53 +548,38 @@ * Method used for overrides, to do something in case texture frame was changed.

*/
SimplePlane.prototype.textureUpdated = function textureUpdated ()
{
SimplePlane.prototype.textureUpdated = function () {
this._textureID = this.shader.texture._updateID;
this.geometry.width = this.shader.texture.width;
this.geometry.height = this.shader.texture.height;
this.geometry.build();
var geometry = this.geometry;
geometry.width = this.shader.texture.width;
geometry.height = this.shader.texture.height;
geometry.build();
};
prototypeAccessors.texture.set = function (value)
{
// Track texture same way sprite does.
// For generated meshes like NineSlicePlane it can change the geometry.
// Unfortunately, this method might not work if you directly change texture in material.
if (this.shader.texture === value)
{
return;
}
this.shader.texture = value;
this._textureID = -1;
if (value.baseTexture.valid)
{
Object.defineProperty(SimplePlane.prototype, "texture", {
get: function () {
return this.shader.texture;
},
set: function (value) {
// Track texture same way sprite does.
// For generated meshes like NineSlicePlane it can change the geometry.
// Unfortunately, this method might not work if you directly change texture in material.
if (this.shader.texture === value) {
return;
}
this.shader.texture = value;
this._textureID = -1;
if (value.baseTexture.valid) {
this.textureUpdated();
}
else {
value.once('update', this.textureUpdated, this);
}
},
enumerable: false,
configurable: true
});
SimplePlane.prototype._render = function (renderer) {
if (this._textureID !== this.shader.texture._updateID) {
this.textureUpdated();
}
else
{
value.once('update', this.textureUpdated, this);
}
_super.prototype._render.call(this, renderer);
};
prototypeAccessors.texture.get = function ()
{
return this.shader.texture;
};
SimplePlane.prototype._render = function _render (renderer)
{
if (this._textureID !== this.shader.texture._updateID)
{
this.textureUpdated();
}
Mesh.prototype._render.call(this, renderer);
};
Object.defineProperties( SimplePlane.prototype, prototypeAccessors );
return SimplePlane;

@@ -486,15 +596,18 @@ }(mesh.Mesh));

*/
var SimpleMesh = /*@__PURE__*/(function (Mesh) {
function SimpleMesh(texture, vertices, uvs, indices, drawMode)
{
if ( texture === void 0 ) texture = core.Texture.EMPTY;
var SimpleMesh = /** @class */ (function (_super) {
__extends(SimpleMesh, _super);
/**
* @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
*/
function SimpleMesh(texture, vertices, uvs, indices, drawMode) {
if (texture === void 0) { texture = core.Texture.EMPTY; }
var _this = this;
var geometry = new mesh.MeshGeometry(vertices, uvs, indices);
geometry.getBuffer('aVertexPosition').static = false;
var meshMaterial = new mesh.MeshMaterial(texture);
Mesh.call(this, geometry, meshMaterial, null, drawMode);
_this = _super.call(this, geometry, meshMaterial, null, drawMode) || this;
/**

@@ -504,36 +617,25 @@ * upload vertices buffer each frame

*/
this.autoUpdate = true;
_this.autoUpdate = true;
return _this;
}
if ( Mesh ) SimpleMesh.__proto__ = Mesh;
SimpleMesh.prototype = Object.create( Mesh && Mesh.prototype );
SimpleMesh.prototype.constructor = SimpleMesh;
var prototypeAccessors = { vertices: { configurable: true } };
/**
* Collection of vertices data.
* @member {Float32Array}
*/
prototypeAccessors.vertices.get = function ()
{
return this.geometry.getBuffer('aVertexPosition').data;
};
prototypeAccessors.vertices.set = function (value)
{
this.geometry.getBuffer('aVertexPosition').data = value;
};
SimpleMesh.prototype._render = function _render (renderer)
{
if (this.autoUpdate)
{
Object.defineProperty(SimpleMesh.prototype, "vertices", {
/**
* Collection of vertices data.
* @member {Float32Array}
*/
get: function () {
return this.geometry.getBuffer('aVertexPosition').data;
},
set: function (value) {
this.geometry.getBuffer('aVertexPosition').data = value;
},
enumerable: false,
configurable: true
});
SimpleMesh.prototype._render = function (renderer) {
if (this.autoUpdate) {
this.geometry.getBuffer('aVertexPosition').update();
}
Mesh.prototype._render.call(this, renderer);
_super.prototype._render.call(this, renderer);
};
Object.defineProperties( SimpleMesh.prototype, prototypeAccessors );
return SimpleMesh;

@@ -543,3 +645,2 @@ }(mesh.Mesh));

var DEFAULT_BORDER_SIZE = 10;
/**

@@ -576,10 +677,19 @@ * The NineSlicePlane allows you to stretch a texture using 9-slice scaling. The corners will remain unscaled (useful

*/
var NineSlicePlane = /*@__PURE__*/(function (SimplePlane) {
function NineSlicePlane(texture, leftWidth, topHeight, rightWidth, bottomHeight)
{
SimplePlane.call(this, core.Texture.WHITE, 4, 4);
this._origWidth = texture.orig.width;
this._origHeight = texture.orig.height;
var NineSlicePlane = /** @class */ (function (_super) {
__extends(NineSlicePlane, _super);
/**
* @param {PIXI.Texture} texture - The texture to use on the NineSlicePlane.
* @param {number} [leftWidth=10] - size of the left vertical bar (A)
* @param {number} [topHeight=10] - size of the top horizontal bar (C)
* @param {number} [rightWidth=10] - size of the right vertical bar (B)
* @param {number} [bottomHeight=10] - size of the bottom horizontal bar (D)
*/
function NineSlicePlane(texture, leftWidth, topHeight, rightWidth, bottomHeight) {
if (leftWidth === void 0) { leftWidth = DEFAULT_BORDER_SIZE; }
if (topHeight === void 0) { topHeight = DEFAULT_BORDER_SIZE; }
if (rightWidth === void 0) { rightWidth = DEFAULT_BORDER_SIZE; }
if (bottomHeight === void 0) { bottomHeight = DEFAULT_BORDER_SIZE; }
var _this = _super.call(this, core.Texture.WHITE, 4, 4) || this;
_this._origWidth = texture.orig.width;
_this._origHeight = texture.orig.height;
/**

@@ -591,4 +701,3 @@ * The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane

*/
this._width = this._origWidth;
_this._width = _this._origWidth;
/**

@@ -600,4 +709,3 @@ * The height of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane

*/
this._height = this._origHeight;
_this._height = _this._origHeight;
/**

@@ -609,4 +717,3 @@ * The width of the left column (a)

*/
this._leftWidth = typeof leftWidth !== 'undefined' ? leftWidth : DEFAULT_BORDER_SIZE;
_this._leftWidth = leftWidth;
/**

@@ -618,4 +725,3 @@ * The width of the right column (b)

*/
this._rightWidth = typeof rightWidth !== 'undefined' ? rightWidth : DEFAULT_BORDER_SIZE;
_this._rightWidth = rightWidth;
/**

@@ -627,4 +733,3 @@ * The height of the top row (c)

*/
this._topHeight = typeof topHeight !== 'undefined' ? topHeight : DEFAULT_BORDER_SIZE;
_this._topHeight = topHeight;
/**

@@ -636,30 +741,21 @@ * The height of the bottom row (d)

*/
this._bottomHeight = typeof bottomHeight !== 'undefined' ? bottomHeight : DEFAULT_BORDER_SIZE;
_this._bottomHeight = bottomHeight;
// lets call the setter to ensure all necessary updates are performed
this.texture = texture;
_this.texture = texture;
return _this;
}
if ( SimplePlane ) NineSlicePlane.__proto__ = SimplePlane;
NineSlicePlane.prototype = Object.create( SimplePlane && SimplePlane.prototype );
NineSlicePlane.prototype.constructor = NineSlicePlane;
var prototypeAccessors = { vertices: { configurable: true },width: { configurable: true },height: { configurable: true },leftWidth: { configurable: true },rightWidth: { configurable: true },topHeight: { configurable: true },bottomHeight: { configurable: true } };
NineSlicePlane.prototype.textureUpdated = function textureUpdated ()
{
NineSlicePlane.prototype.textureUpdated = function () {
this._textureID = this.shader.texture._updateID;
this._refresh();
};
prototypeAccessors.vertices.get = function ()
{
return this.geometry.getBuffer('aVertexPosition').data;
};
prototypeAccessors.vertices.set = function (value)
{
this.geometry.getBuffer('aVertexPosition').data = value;
};
Object.defineProperty(NineSlicePlane.prototype, "vertices", {
get: function () {
return this.geometry.getBuffer('aVertexPosition').data;
},
set: function (value) {
this.geometry.getBuffer('aVertexPosition').data = value;
},
enumerable: false,
configurable: true
});
/**

@@ -669,8 +765,5 @@ * Updates the horizontal vertices.

*/
NineSlicePlane.prototype.updateHorizontalVertices = function updateHorizontalVertices ()
{
NineSlicePlane.prototype.updateHorizontalVertices = function () {
var vertices = this.vertices;
var scale = this._getMinScale();
vertices[9] = vertices[11] = vertices[13] = vertices[15] = this._topHeight * scale;

@@ -680,3 +773,2 @@ vertices[17] = vertices[19] = vertices[21] = vertices[23] = this._height - (this._bottomHeight * scale);

};
/**

@@ -686,8 +778,5 @@ * Updates the vertical vertices.

*/
NineSlicePlane.prototype.updateVerticalVertices = function updateVerticalVertices ()
{
NineSlicePlane.prototype.updateVerticalVertices = function () {
var vertices = this.vertices;
var scale = this._getMinScale();
vertices[2] = vertices[10] = vertices[18] = vertices[26] = this._leftWidth * scale;

@@ -697,3 +786,2 @@ vertices[4] = vertices[12] = vertices[20] = vertices[28] = this._width - (this._rightWidth * scale);

};
/**

@@ -705,126 +793,116 @@ * Returns the smaller of a set of vertical and horizontal scale of nine slice corners.

*/
NineSlicePlane.prototype._getMinScale = function _getMinScale ()
{
NineSlicePlane.prototype._getMinScale = function () {
var w = this._leftWidth + this._rightWidth;
var scaleW = this._width > w ? 1.0 : this._width / w;
var h = this._topHeight + this._bottomHeight;
var scaleH = this._height > h ? 1.0 : this._height / h;
var scale = Math.min(scaleW, scaleH);
return scale;
};
Object.defineProperty(NineSlicePlane.prototype, "width", {
/**
* The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane
*
* @member {number}
*/
get: function () {
return this._width;
},
set: function (value) {
this._width = value;
this._refresh();
},
enumerable: false,
configurable: true
});
Object.defineProperty(NineSlicePlane.prototype, "height", {
/**
* The height of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane
*
* @member {number}
*/
get: function () {
return this._height;
},
set: function (value) {
this._height = value;
this._refresh();
},
enumerable: false,
configurable: true
});
Object.defineProperty(NineSlicePlane.prototype, "leftWidth", {
/**
* The width of the left column
*
* @member {number}
*/
get: function () {
return this._leftWidth;
},
set: function (value) {
this._leftWidth = value;
this._refresh();
},
enumerable: false,
configurable: true
});
Object.defineProperty(NineSlicePlane.prototype, "rightWidth", {
/**
* The width of the right column
*
* @member {number}
*/
get: function () {
return this._rightWidth;
},
set: function (value) {
this._rightWidth = value;
this._refresh();
},
enumerable: false,
configurable: true
});
Object.defineProperty(NineSlicePlane.prototype, "topHeight", {
/**
* The height of the top row
*
* @member {number}
*/
get: function () {
return this._topHeight;
},
set: function (value) {
this._topHeight = value;
this._refresh();
},
enumerable: false,
configurable: true
});
Object.defineProperty(NineSlicePlane.prototype, "bottomHeight", {
/**
* The height of the bottom row
*
* @member {number}
*/
get: function () {
return this._bottomHeight;
},
set: function (value) {
this._bottomHeight = value;
this._refresh();
},
enumerable: false,
configurable: true
});
/**
* The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane
*
* @member {number}
*/
prototypeAccessors.width.get = function ()
{
return this._width;
};
prototypeAccessors.width.set = function (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}
*/
prototypeAccessors.height.get = function ()
{
return this._height;
};
prototypeAccessors.height.set = function (value) // eslint-disable-line require-jsdoc
{
this._height = value;
this._refresh();
};
/**
* The width of the left column
*
* @member {number}
*/
prototypeAccessors.leftWidth.get = function ()
{
return this._leftWidth;
};
prototypeAccessors.leftWidth.set = function (value) // eslint-disable-line require-jsdoc
{
this._leftWidth = value;
this._refresh();
};
/**
* The width of the right column
*
* @member {number}
*/
prototypeAccessors.rightWidth.get = function ()
{
return this._rightWidth;
};
prototypeAccessors.rightWidth.set = function (value) // eslint-disable-line require-jsdoc
{
this._rightWidth = value;
this._refresh();
};
/**
* The height of the top row
*
* @member {number}
*/
prototypeAccessors.topHeight.get = function ()
{
return this._topHeight;
};
prototypeAccessors.topHeight.set = function (value) // eslint-disable-line require-jsdoc
{
this._topHeight = value;
this._refresh();
};
/**
* The height of the bottom row
*
* @member {number}
*/
prototypeAccessors.bottomHeight.get = function ()
{
return this._bottomHeight;
};
prototypeAccessors.bottomHeight.set = function (value) // eslint-disable-line require-jsdoc
{
this._bottomHeight = value;
this._refresh();
};
/**
* Refreshes NineSlicePlane coords. All of them.
*/
NineSlicePlane.prototype._refresh = function _refresh ()
{
NineSlicePlane.prototype._refresh = function () {
var texture = this.texture;
var uvs = this.geometry.buffers[1].data;
this._origWidth = texture.orig.width;
this._origHeight = texture.orig.height;
var _uvw = 1.0 / this._origWidth;
var _uvh = 1.0 / this._origHeight;
uvs[0] = uvs[8] = uvs[16] = uvs[24] = 0;

@@ -834,3 +912,2 @@ uvs[1] = uvs[3] = uvs[5] = uvs[7] = 0;

uvs[25] = uvs[27] = uvs[29] = uvs[31] = 1;
uvs[2] = uvs[10] = uvs[18] = uvs[26] = _uvw * this._leftWidth;

@@ -840,12 +917,7 @@ uvs[4] = uvs[12] = uvs[20] = uvs[28] = 1 - (_uvw * this._rightWidth);

uvs[17] = uvs[19] = uvs[21] = uvs[23] = 1 - (_uvh * this._bottomHeight);
this.updateHorizontalVertices();
this.updateVerticalVertices();
this.geometry.buffers[0].update();
this.geometry.buffers[1].update();
};
Object.defineProperties( NineSlicePlane.prototype, prototypeAccessors );
return NineSlicePlane;

@@ -852,0 +924,0 @@ }(SimplePlane));

/*!
* @pixi/mesh-extras - v5.2.4
* Compiled Sun, 03 May 2020 22:38:52 UTC
* @pixi/mesh-extras - v5.3.0
* Compiled Thu, 18 Jun 2020 23:27:40 UTC
*

@@ -8,3 +8,3 @@ * @pixi/mesh-extras is licensed under the MIT License.

*/
this.PIXI=this.PIXI||{};var _pixi_mesh_extras=function(t,e,i,r){"use strict";var h=function(t){function e(e,i,r,h){void 0===e&&(e=100),void 0===i&&(i=100),void 0===r&&(r=10),void 0===h&&(h=10),t.call(this),this.segWidth=r,this.segHeight=h,this.width=e,this.height=i,this.build()}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.build=function(){for(var t=this.segWidth*this.segHeight,e=[],i=[],r=[],h=this.segWidth-1,o=this.segHeight-1,s=this.width/h,a=this.height/o,n=0;n<t;n++){var u=n%this.segWidth,d=n/this.segWidth|0;e.push(u*s,d*a),i.push(u/h,d/o)}for(var p=h*o,g=0;g<p;g++){var c=g%h,f=g/h|0,_=f*this.segWidth+c,l=f*this.segWidth+c+1,y=(f+1)*this.segWidth+c,x=(f+1)*this.segWidth+c+1;r.push(_,l,y,l,x,y)}this.buffers[0].data=new Float32Array(e),this.buffers[1].data=new Float32Array(i),this.indexBuffer.data=new Uint16Array(r),this.buffers[0].update(),this.buffers[1].update(),this.indexBuffer.update()},e}(e.MeshGeometry),o=function(t){function e(e,i,r){void 0===e&&(e=200),void 0===r&&(r=0),t.call(this,new Float32Array(4*i.length),new Float32Array(4*i.length),new Uint16Array(6*(i.length-1))),this.points=i,this.width=e,this.textureScale=r,this.build()}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.build=function(){var t=this.points;if(t){var e=this.getBuffer("aVertexPosition"),i=this.getBuffer("aTextureCoord"),r=this.getIndex();if(!(t.length<1)){e.data.length/4!==t.length&&(e.data=new Float32Array(4*t.length),i.data=new Float32Array(4*t.length),r.data=new Uint16Array(6*(t.length-1)));var h=i.data,o=r.data;h[0]=0,h[1]=0,h[2]=0,h[3]=1;for(var s=0,a=t[0],n=this.width*this.textureScale,u=t.length,d=0;d<u;d++){var p=4*d;if(this.textureScale>0){var g=a.x-t[d].x,c=a.y-t[d].y,f=Math.sqrt(g*g+c*c);a=t[d],s+=f/n}else s=d/(u-1);h[p]=s,h[p+1]=0,h[p+2]=s,h[p+3]=1}for(var _=0,l=0;l<u-1;l++){var y=2*l;o[_++]=y,o[_++]=y+1,o[_++]=y+2,o[_++]=y+2,o[_++]=y+1,o[_++]=y+3}i.update(),r.update(),this.updateVertices()}}},e.prototype.updateVertices=function(){var t=this.points;if(!(t.length<1)){for(var e,i=t[0],r=0,h=0,o=this.buffers[0].data,s=t.length,a=0;a<s;a++){var n=t[a],u=4*a;h=-((e=a<t.length-1?t[a+1]:n).x-i.x),r=e.y-i.y;var d=10*(1-a/(s-1));d>1&&(d=1);var p=Math.sqrt(r*r+h*h),g=this.textureScale>0?this.textureScale*this.width/2:this.width/2;r/=p,h/=p,r*=g,h*=g,o[u]=n.x+r,o[u+1]=n.y+h,o[u+2]=n.x-r,o[u+3]=n.y-h,i=n}this.buffers[0].update()}},e.prototype.update=function(){this.textureScale>0?this.build():this.updateVertices()},e}(e.MeshGeometry),s=function(t){function r(r,h,s){void 0===s&&(s=0);var a=new o(r.height,h,s),n=new e.MeshMaterial(r);s>0&&(r.baseTexture.wrapMode=i.WRAP_MODES.REPEAT),t.call(this,a,n),this.autoUpdate=!0}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.prototype._render=function(e){(this.autoUpdate||this.geometry.width!==this.shader.texture.height)&&(this.geometry.width=this.shader.texture.height,this.geometry.update()),t.prototype._render.call(this,e)},r}(e.Mesh),a=function(t){function i(i,o,s){var a=new h(i.width,i.height,o,s),n=new e.MeshMaterial(r.Texture.WHITE);t.call(this,a,n),this.texture=i}t&&(i.__proto__=t),i.prototype=Object.create(t&&t.prototype),i.prototype.constructor=i;var o={texture:{configurable:!0}};return i.prototype.textureUpdated=function(){this._textureID=this.shader.texture._updateID,this.geometry.width=this.shader.texture.width,this.geometry.height=this.shader.texture.height,this.geometry.build()},o.texture.set=function(t){this.shader.texture!==t&&(this.shader.texture=t,this._textureID=-1,t.baseTexture.valid?this.textureUpdated():t.once("update",this.textureUpdated,this))},o.texture.get=function(){return this.shader.texture},i.prototype._render=function(e){this._textureID!==this.shader.texture._updateID&&this.textureUpdated(),t.prototype._render.call(this,e)},Object.defineProperties(i.prototype,o),i}(e.Mesh),n=function(t){function i(i,h,o,s,a){void 0===i&&(i=r.Texture.EMPTY);var n=new e.MeshGeometry(h,o,s);n.getBuffer("aVertexPosition").static=!1;var u=new e.MeshMaterial(i);t.call(this,n,u,null,a),this.autoUpdate=!0}t&&(i.__proto__=t),i.prototype=Object.create(t&&t.prototype),i.prototype.constructor=i;var h={vertices:{configurable:!0}};return h.vertices.get=function(){return this.geometry.getBuffer("aVertexPosition").data},h.vertices.set=function(t){this.geometry.getBuffer("aVertexPosition").data=t},i.prototype._render=function(e){this.autoUpdate&&this.geometry.getBuffer("aVertexPosition").update(),t.prototype._render.call(this,e)},Object.defineProperties(i.prototype,h),i}(e.Mesh),u=10,d=function(t){function e(e,i,h,o,s){t.call(this,r.Texture.WHITE,4,4),this._origWidth=e.orig.width,this._origHeight=e.orig.height,this._width=this._origWidth,this._height=this._origHeight,this._leftWidth=void 0!==i?i:u,this._rightWidth=void 0!==o?o:u,this._topHeight=void 0!==h?h:u,this._bottomHeight=void 0!==s?s:u,this.texture=e}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={vertices:{configurable:!0},width:{configurable:!0},height:{configurable:!0},leftWidth:{configurable:!0},rightWidth:{configurable:!0},topHeight:{configurable:!0},bottomHeight:{configurable:!0}};return e.prototype.textureUpdated=function(){this._textureID=this.shader.texture._updateID,this._refresh()},i.vertices.get=function(){return this.geometry.getBuffer("aVertexPosition").data},i.vertices.set=function(t){this.geometry.getBuffer("aVertexPosition").data=t},e.prototype.updateHorizontalVertices=function(){var t=this.vertices,e=this._getMinScale();t[9]=t[11]=t[13]=t[15]=this._topHeight*e,t[17]=t[19]=t[21]=t[23]=this._height-this._bottomHeight*e,t[25]=t[27]=t[29]=t[31]=this._height},e.prototype.updateVerticalVertices=function(){var t=this.vertices,e=this._getMinScale();t[2]=t[10]=t[18]=t[26]=this._leftWidth*e,t[4]=t[12]=t[20]=t[28]=this._width-this._rightWidth*e,t[6]=t[14]=t[22]=t[30]=this._width},e.prototype._getMinScale=function(){var t=this._leftWidth+this._rightWidth,e=this._width>t?1:this._width/t,i=this._topHeight+this._bottomHeight,r=this._height>i?1:this._height/i;return Math.min(e,r)},i.width.get=function(){return this._width},i.width.set=function(t){this._width=t,this._refresh()},i.height.get=function(){return this._height},i.height.set=function(t){this._height=t,this._refresh()},i.leftWidth.get=function(){return this._leftWidth},i.leftWidth.set=function(t){this._leftWidth=t,this._refresh()},i.rightWidth.get=function(){return this._rightWidth},i.rightWidth.set=function(t){this._rightWidth=t,this._refresh()},i.topHeight.get=function(){return this._topHeight},i.topHeight.set=function(t){this._topHeight=t,this._refresh()},i.bottomHeight.get=function(){return this._bottomHeight},i.bottomHeight.set=function(t){this._bottomHeight=t,this._refresh()},e.prototype._refresh=function(){var t=this.texture,e=this.geometry.buffers[1].data;this._origWidth=t.orig.width,this._origHeight=t.orig.height;var i=1/this._origWidth,r=1/this._origHeight;e[0]=e[8]=e[16]=e[24]=0,e[1]=e[3]=e[5]=e[7]=0,e[6]=e[14]=e[22]=e[30]=1,e[25]=e[27]=e[29]=e[31]=1,e[2]=e[10]=e[18]=e[26]=i*this._leftWidth,e[4]=e[12]=e[20]=e[28]=1-i*this._rightWidth,e[9]=e[11]=e[13]=e[15]=r*this._topHeight,e[17]=e[19]=e[21]=e[23]=1-r*this._bottomHeight,this.updateHorizontalVertices(),this.updateVerticalVertices(),this.geometry.buffers[0].update(),this.geometry.buffers[1].update()},Object.defineProperties(e.prototype,i),e}(a);return t.NineSlicePlane=d,t.PlaneGeometry=h,t.RopeGeometry=o,t.SimpleMesh=n,t.SimplePlane=a,t.SimpleRope=s,t}({},PIXI,PIXI,PIXI);Object.assign(this.PIXI,_pixi_mesh_extras);
this.PIXI=this.PIXI||{};var _pixi_mesh_extras=function(t,e,i,r){"use strict";var h=function(t,e){return(h=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])})(t,e)};function o(t,e){function i(){this.constructor=t}h(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}var s=function(t){function e(e,i,r,h){void 0===e&&(e=100),void 0===i&&(i=100),void 0===r&&(r=10),void 0===h&&(h=10);var o=t.call(this)||this;return o.segWidth=r,o.segHeight=h,o.width=e,o.height=i,o.build(),o}return o(e,t),e.prototype.build=function(){for(var t=this.segWidth*this.segHeight,e=[],i=[],r=[],h=this.segWidth-1,o=this.segHeight-1,s=this.width/h,n=this.height/o,a=0;a<t;a++){var u=a%this.segWidth,d=a/this.segWidth|0;e.push(u*s,d*n),i.push(u/h,d/o)}var f=h*o;for(a=0;a<f;a++){var g=a%h,p=a/h|0,c=p*this.segWidth+g,l=p*this.segWidth+g+1,_=(p+1)*this.segWidth+g,y=(p+1)*this.segWidth+g+1;r.push(c,l,_,l,y,_)}this.buffers[0].data=new Float32Array(e),this.buffers[1].data=new Float32Array(i),this.indexBuffer.data=new Uint16Array(r),this.buffers[0].update(),this.buffers[1].update(),this.indexBuffer.update()},e}(e.MeshGeometry),n=function(t){function e(e,i,r){void 0===e&&(e=200),void 0===r&&(r=0);var h=t.call(this,new Float32Array(4*i.length),new Float32Array(4*i.length),new Uint16Array(6*(i.length-1)))||this;return h.points=i,h._width=e,h.textureScale=r,h.build(),h}return o(e,t),Object.defineProperty(e.prototype,"width",{get:function(){return this._width},enumerable:!1,configurable:!0}),e.prototype.build=function(){var t=this.points;if(t){var e=this.getBuffer("aVertexPosition"),i=this.getBuffer("aTextureCoord"),r=this.getIndex();if(!(t.length<1)){e.data.length/4!==t.length&&(e.data=new Float32Array(4*t.length),i.data=new Float32Array(4*t.length),r.data=new Uint16Array(6*(t.length-1)));var h=i.data,o=r.data;h[0]=0,h[1]=0,h[2]=0,h[3]=1;for(var s=0,n=t[0],a=this._width*this.textureScale,u=t.length,d=0;d<u;d++){var f=4*d;if(this.textureScale>0){var g=n.x-t[d].x,p=n.y-t[d].y,c=Math.sqrt(g*g+p*p);n=t[d],s+=c/a}else s=d/(u-1);h[f]=s,h[f+1]=0,h[f+2]=s,h[f+3]=1}var l=0;for(d=0;d<u-1;d++){f=2*d;o[l++]=f,o[l++]=f+1,o[l++]=f+2,o[l++]=f+2,o[l++]=f+1,o[l++]=f+3}i.update(),r.update(),this.updateVertices()}}},e.prototype.updateVertices=function(){var t=this.points;if(!(t.length<1)){for(var e,i=t[0],r=0,h=0,o=this.buffers[0].data,s=t.length,n=0;n<s;n++){var a=t[n],u=4*n;h=-((e=n<t.length-1?t[n+1]:a).x-i.x),r=e.y-i.y;var d=10*(1-n/(s-1));d>1&&(d=1);var f=Math.sqrt(r*r+h*h),g=this.textureScale>0?this.textureScale*this._width/2:this._width/2;r/=f,h/=f,r*=g,h*=g,o[u]=a.x+r,o[u+1]=a.y+h,o[u+2]=a.x-r,o[u+3]=a.y-h,i=a}this.buffers[0].update()}},e.prototype.update=function(){this.textureScale>0?this.build():this.updateVertices()},e}(e.MeshGeometry),a=function(t){function r(r,h,o){void 0===o&&(o=0);var s=this,a=new n(r.height,h,o),u=new e.MeshMaterial(r);return o>0&&(r.baseTexture.wrapMode=i.WRAP_MODES.REPEAT),(s=t.call(this,a,u)||this).autoUpdate=!0,s}return o(r,t),r.prototype._render=function(e){var i=this.geometry;(this.autoUpdate||i._width!==this.shader.texture.height)&&(i._width=this.shader.texture.height,i.update()),t.prototype._render.call(this,e)},r}(e.Mesh),u=function(t){function i(i,h,o){var n=this,a=new s(i.width,i.height,h,o),u=new e.MeshMaterial(r.Texture.WHITE);return(n=t.call(this,a,u)||this).texture=i,n}return o(i,t),i.prototype.textureUpdated=function(){this._textureID=this.shader.texture._updateID;var t=this.geometry;t.width=this.shader.texture.width,t.height=this.shader.texture.height,t.build()},Object.defineProperty(i.prototype,"texture",{get:function(){return this.shader.texture},set:function(t){this.shader.texture!==t&&(this.shader.texture=t,this._textureID=-1,t.baseTexture.valid?this.textureUpdated():t.once("update",this.textureUpdated,this))},enumerable:!1,configurable:!0}),i.prototype._render=function(e){this._textureID!==this.shader.texture._updateID&&this.textureUpdated(),t.prototype._render.call(this,e)},i}(e.Mesh),d=function(t){function i(i,h,o,s,n){void 0===i&&(i=r.Texture.EMPTY);var a=this,u=new e.MeshGeometry(h,o,s);u.getBuffer("aVertexPosition").static=!1;var d=new e.MeshMaterial(i);return(a=t.call(this,u,d,null,n)||this).autoUpdate=!0,a}return o(i,t),Object.defineProperty(i.prototype,"vertices",{get:function(){return this.geometry.getBuffer("aVertexPosition").data},set:function(t){this.geometry.getBuffer("aVertexPosition").data=t},enumerable:!1,configurable:!0}),i.prototype._render=function(e){this.autoUpdate&&this.geometry.getBuffer("aVertexPosition").update(),t.prototype._render.call(this,e)},i}(e.Mesh),f=10,g=function(t){function e(e,i,h,o,s){void 0===i&&(i=f),void 0===h&&(h=f),void 0===o&&(o=f),void 0===s&&(s=f);var n=t.call(this,r.Texture.WHITE,4,4)||this;return n._origWidth=e.orig.width,n._origHeight=e.orig.height,n._width=n._origWidth,n._height=n._origHeight,n._leftWidth=i,n._rightWidth=o,n._topHeight=h,n._bottomHeight=s,n.texture=e,n}return o(e,t),e.prototype.textureUpdated=function(){this._textureID=this.shader.texture._updateID,this._refresh()},Object.defineProperty(e.prototype,"vertices",{get:function(){return this.geometry.getBuffer("aVertexPosition").data},set:function(t){this.geometry.getBuffer("aVertexPosition").data=t},enumerable:!1,configurable:!0}),e.prototype.updateHorizontalVertices=function(){var t=this.vertices,e=this._getMinScale();t[9]=t[11]=t[13]=t[15]=this._topHeight*e,t[17]=t[19]=t[21]=t[23]=this._height-this._bottomHeight*e,t[25]=t[27]=t[29]=t[31]=this._height},e.prototype.updateVerticalVertices=function(){var t=this.vertices,e=this._getMinScale();t[2]=t[10]=t[18]=t[26]=this._leftWidth*e,t[4]=t[12]=t[20]=t[28]=this._width-this._rightWidth*e,t[6]=t[14]=t[22]=t[30]=this._width},e.prototype._getMinScale=function(){var t=this._leftWidth+this._rightWidth,e=this._width>t?1:this._width/t,i=this._topHeight+this._bottomHeight,r=this._height>i?1:this._height/i;return Math.min(e,r)},Object.defineProperty(e.prototype,"width",{get:function(){return this._width},set:function(t){this._width=t,this._refresh()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"height",{get:function(){return this._height},set:function(t){this._height=t,this._refresh()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"leftWidth",{get:function(){return this._leftWidth},set:function(t){this._leftWidth=t,this._refresh()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"rightWidth",{get:function(){return this._rightWidth},set:function(t){this._rightWidth=t,this._refresh()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"topHeight",{get:function(){return this._topHeight},set:function(t){this._topHeight=t,this._refresh()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"bottomHeight",{get:function(){return this._bottomHeight},set:function(t){this._bottomHeight=t,this._refresh()},enumerable:!1,configurable:!0}),e.prototype._refresh=function(){var t=this.texture,e=this.geometry.buffers[1].data;this._origWidth=t.orig.width,this._origHeight=t.orig.height;var i=1/this._origWidth,r=1/this._origHeight;e[0]=e[8]=e[16]=e[24]=0,e[1]=e[3]=e[5]=e[7]=0,e[6]=e[14]=e[22]=e[30]=1,e[25]=e[27]=e[29]=e[31]=1,e[2]=e[10]=e[18]=e[26]=i*this._leftWidth,e[4]=e[12]=e[20]=e[28]=1-i*this._rightWidth,e[9]=e[11]=e[13]=e[15]=r*this._topHeight,e[17]=e[19]=e[21]=e[23]=1-r*this._bottomHeight,this.updateHorizontalVertices(),this.updateVerticalVertices(),this.geometry.buffers[0].update(),this.geometry.buffers[1].update()},e}(u);return t.NineSlicePlane=g,t.PlaneGeometry=s,t.RopeGeometry=n,t.SimpleMesh=d,t.SimplePlane=u,t.SimpleRope=a,t}({},PIXI,PIXI,PIXI);Object.assign(this.PIXI,_pixi_mesh_extras);
//# sourceMappingURL=mesh-extras.min.js.map
/*!
* @pixi/mesh-extras - v5.2.4
* Compiled Sun, 03 May 2020 22:38:52 UTC
* @pixi/mesh-extras - v5.3.0
* Compiled Thu, 18 Jun 2020 23:27:40 UTC
*

@@ -8,29 +8,50 @@ * @pixi/mesh-extras is licensed under the MIT License.

*/
import { MeshGeometry, Mesh, MeshMaterial } from '@pixi/mesh';
import { MeshGeometry, MeshMaterial, Mesh } from '@pixi/mesh';
import { WRAP_MODES } from '@pixi/constants';
import { Texture } from '@pixi/core';
var PlaneGeometry = /*@__PURE__*/(function (MeshGeometry) {
function PlaneGeometry(width, height, segWidth, segHeight)
{
if ( width === void 0 ) width = 100;
if ( height === void 0 ) height = 100;
if ( segWidth === void 0 ) segWidth = 10;
if ( segHeight === void 0 ) segHeight = 10;
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
MeshGeometry.call(this);
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
this.segWidth = segWidth;
this.segHeight = segHeight;
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/* global Reflect, Promise */
this.width = width;
this.height = height;
var extendStatics = function(d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) { if (b.hasOwnProperty(p)) { d[p] = b[p]; } } };
return extendStatics(d, b);
};
this.build();
function __extends(d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
}
var PlaneGeometry = /** @class */ (function (_super) {
__extends(PlaneGeometry, _super);
function PlaneGeometry(width, height, segWidth, segHeight) {
if (width === void 0) { width = 100; }
if (height === void 0) { height = 100; }
if (segWidth === void 0) { segWidth = 10; }
if (segHeight === void 0) { segHeight = 10; }
var _this = _super.call(this) || this;
_this.segWidth = segWidth;
_this.segHeight = segHeight;
_this.width = width;
_this.height = height;
_this.build();
return _this;
}
if ( MeshGeometry ) PlaneGeometry.__proto__ = MeshGeometry;
PlaneGeometry.prototype = Object.create( MeshGeometry && MeshGeometry.prototype );
PlaneGeometry.prototype.constructor = PlaneGeometry;
/**

@@ -40,4 +61,3 @@ * Refreshes plane coordinates

*/
PlaneGeometry.prototype.build = function build ()
{
PlaneGeometry.prototype.build = function () {
var total = this.segWidth * this.segHeight;

@@ -47,25 +67,16 @@ var verts = [];

var indices = [];
var segmentsX = this.segWidth - 1;
var segmentsY = this.segHeight - 1;
var sizeX = (this.width) / segmentsX;
var sizeY = (this.height) / segmentsY;
for (var i = 0; i < total; i++)
{
for (var i = 0; i < total; i++) {
var x = (i % this.segWidth);
var y = ((i / this.segWidth) | 0);
verts.push(x * sizeX, y * sizeY);
uvs.push(x / segmentsX, y / segmentsY);
}
var totalSub = segmentsX * segmentsY;
for (var i$1 = 0; i$1 < totalSub; i$1++)
{
var xpos = i$1 % segmentsX;
var ypos = (i$1 / segmentsX) | 0;
for (var i = 0; i < totalSub; i++) {
var xpos = i % segmentsX;
var ypos = (i / segmentsX) | 0;
var value = (ypos * this.segWidth) + xpos;

@@ -75,11 +86,7 @@ var value2 = (ypos * this.segWidth) + xpos + 1;

var value4 = ((ypos + 1) * this.segWidth) + xpos + 1;
indices.push(value, value2, value3,
value2, value4, value3);
indices.push(value, value2, value3, value2, value4, value3);
}
this.buffers[0].data = new Float32Array(verts);
this.buffers[1].data = new Float32Array(uvs);
this.indexBuffer.data = new Uint16Array(indices);
// ensure that the changes are uploaded

@@ -90,3 +97,2 @@ this.buffers[0].update();

};
return PlaneGeometry;

@@ -110,12 +116,19 @@ }(MeshGeometry));

*/
var RopeGeometry = /*@__PURE__*/(function (MeshGeometry) {
function RopeGeometry(width, points, textureScale)
{
if ( width === void 0 ) width = 200;
if ( textureScale === void 0 ) textureScale = 0;
MeshGeometry.call(this, new Float32Array(points.length * 4),
new Float32Array(points.length * 4),
new Uint16Array((points.length - 1) * 6));
var RopeGeometry = /** @class */ (function (_super) {
__extends(RopeGeometry, _super);
/**
* @param {number} [width=200] - The width (i.e., thickness) of the rope.
* @param {PIXI.Point[]} [points] - An array of {@link PIXI.Point} objects to construct this rope.
* @param {number} [textureScale=0] - By default the rope texture will be stretched to match
* rope length. If textureScale is positive this value will be treated as a scaling
* factor and the texture will preserve its aspect ratio instead. To create a tiling rope
* set baseTexture.wrapMode to {@link PIXI.WRAP_MODES.REPEAT} and use a power of two texture,
* then set textureScale=1 to keep the original texture pixel size.
* In order to reduce alpha channel artifacts provide a larger texture and downsample -
* i.e. set textureScale=0.5 to scale it down twice.
*/
function RopeGeometry(width, points, textureScale) {
if (width === void 0) { width = 200; }
if (textureScale === void 0) { textureScale = 0; }
var _this = _super.call(this, new Float32Array(points.length * 4), new Float32Array(points.length * 4), new Uint16Array((points.length - 1) * 6)) || this;
/**

@@ -125,4 +138,3 @@ * An array of points that determine the rope

*/
this.points = points;
_this.points = points;
/**

@@ -133,4 +145,3 @@ * The width (i.e., thickness) of the rope.

*/
this.width = width;
_this._width = width;
/**

@@ -141,10 +152,18 @@ * Rope texture scale, if zero then the rope texture is stretched.

*/
this.textureScale = textureScale;
this.build();
_this.textureScale = textureScale;
_this.build();
return _this;
}
if ( MeshGeometry ) RopeGeometry.__proto__ = MeshGeometry;
RopeGeometry.prototype = Object.create( MeshGeometry && MeshGeometry.prototype );
RopeGeometry.prototype.constructor = RopeGeometry;
Object.defineProperty(RopeGeometry.prototype, "width", {
/**
* The width (i.e., thickness) of the rope.
* @member {number}
* @readOnly
*/
get: function () {
return this._width;
},
enumerable: false,
configurable: true
});
/**

@@ -154,21 +173,15 @@ * Refreshes Rope indices and uvs

*/
RopeGeometry.prototype.build = function build ()
{
RopeGeometry.prototype.build = function () {
var points = this.points;
if (!points) { return; }
if (!points)
{ return; }
var vertexBuffer = this.getBuffer('aVertexPosition');
var uvBuffer = this.getBuffer('aTextureCoord');
var indexBuffer = this.getIndex();
// if too little points, or texture hasn't got UVs set yet just move on.
if (points.length < 1)
{
if (points.length < 1) {
return;
}
// if the number of points has changed we will need to recreate the arraybuffers
if (vertexBuffer.data.length / 4 !== points.length)
{
if (vertexBuffer.data.length / 4 !== points.length) {
vertexBuffer.data = new Float32Array(points.length * 4);

@@ -178,6 +191,4 @@ uvBuffer.data = new Float32Array(points.length * 4);

}
var uvs = uvBuffer.data;
var indices = indexBuffer.data;
uvs[0] = 0;

@@ -187,15 +198,10 @@ uvs[1] = 0;

uvs[3] = 1;
var amount = 0;
var prev = points[0];
var textureWidth = this.width * this.textureScale;
var textureWidth = this._width * this.textureScale;
var total = points.length; // - 1;
for (var i = 0; i < total; i++)
{
for (var i = 0; i < total; i++) {
// time to do some smart drawing!
var index = i * 4;
if (this.textureScale > 0)
{
if (this.textureScale > 0) {
// calculate pixel distance from previous point

@@ -205,53 +211,37 @@ var dx = prev.x - points[i].x;

var distance = Math.sqrt((dx * dx) + (dy * dy));
prev = points[i];
amount += distance / textureWidth;
}
else
{
else {
// stretch texture
amount = i / (total - 1);
}
uvs[index] = amount;
uvs[index + 1] = 0;
uvs[index + 2] = amount;
uvs[index + 3] = 1;
}
var indexCount = 0;
for (var i$1 = 0; i$1 < total - 1; i$1++)
{
var index$1 = i$1 * 2;
indices[indexCount++] = index$1;
indices[indexCount++] = index$1 + 1;
indices[indexCount++] = index$1 + 2;
indices[indexCount++] = index$1 + 2;
indices[indexCount++] = index$1 + 1;
indices[indexCount++] = index$1 + 3;
for (var i = 0; i < total - 1; i++) {
var index = i * 2;
indices[indexCount++] = index;
indices[indexCount++] = index + 1;
indices[indexCount++] = index + 2;
indices[indexCount++] = index + 2;
indices[indexCount++] = index + 1;
indices[indexCount++] = index + 3;
}
// ensure that the changes are uploaded
uvBuffer.update();
indexBuffer.update();
this.updateVertices();
};
/**
* refreshes vertices of Rope mesh
*/
RopeGeometry.prototype.updateVertices = function updateVertices ()
{
RopeGeometry.prototype.updateVertices = function () {
var points = this.points;
if (points.length < 1)
{
if (points.length < 1) {
return;
}
var lastPoint = points[0];

@@ -261,32 +251,21 @@ var nextPoint;

var perpY = 0;
var vertices = this.buffers[0].data;
var total = points.length;
for (var i = 0; i < total; i++)
{
for (var i = 0; i < total; i++) {
var point = points[i];
var index = i * 4;
if (i < points.length - 1)
{
if (i < points.length - 1) {
nextPoint = points[i + 1];
}
else
{
else {
nextPoint = point;
}
perpY = -(nextPoint.x - lastPoint.x);
perpX = nextPoint.y - lastPoint.y;
var perpLength = Math.sqrt((perpX * perpX) + (perpY * perpY));
var num = this.textureScale > 0 ? this.textureScale * this.width / 2 : this.width / 2;
var num = this.textureScale > 0 ? this.textureScale * this._width / 2 : this._width / 2;
perpX /= perpLength;
perpY /= perpLength;
perpX *= num;
perpY *= num;
vertices[index] = point.x + perpX;

@@ -296,21 +275,14 @@ vertices[index + 1] = point.y + perpY;

vertices[index + 3] = point.y - perpY;
lastPoint = point;
}
this.buffers[0].update();
};
RopeGeometry.prototype.update = function update ()
{
if (this.textureScale > 0)
{
RopeGeometry.prototype.update = function () {
if (this.textureScale > 0) {
this.build(); // we need to update UVs
}
else
{
else {
this.updateVertices();
}
};
return RopeGeometry;

@@ -334,17 +306,21 @@ }(MeshGeometry));

*/
var SimpleRope = /*@__PURE__*/(function (Mesh) {
function SimpleRope(texture, points, textureScale)
{
if ( textureScale === void 0 ) textureScale = 0;
var SimpleRope = /** @class */ (function (_super) {
__extends(SimpleRope, _super);
/**
* @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.
* @param {number} [textureScale=0] - Optional. Positive values scale rope texture
* keeping its aspect ratio. You can reduce alpha channel artifacts by providing a larger texture
* and downsampling here. If set to zero, texture will be streched instead.
*/
function SimpleRope(texture, points, textureScale) {
if (textureScale === void 0) { textureScale = 0; }
var _this = this;
var ropeGeometry = new RopeGeometry(texture.height, points, textureScale);
var meshMaterial = new MeshMaterial(texture);
if (textureScale > 0)
{
if (textureScale > 0) {
// attempt to set UV wrapping, will fail on non-power of two textures
texture.baseTexture.wrapMode = WRAP_MODES.REPEAT;
}
Mesh.call(this, ropeGeometry, meshMaterial);
_this = _super.call(this, ropeGeometry, meshMaterial) || this;
/**

@@ -355,21 +331,13 @@ * re-calculate vertices by rope points each frame

*/
this.autoUpdate = true;
_this.autoUpdate = true;
return _this;
}
if ( Mesh ) SimpleRope.__proto__ = Mesh;
SimpleRope.prototype = Object.create( Mesh && Mesh.prototype );
SimpleRope.prototype.constructor = SimpleRope;
SimpleRope.prototype._render = function _render (renderer)
{
if (this.autoUpdate
|| this.geometry.width !== this.shader.texture.height)
{
this.geometry.width = this.shader.texture.height;
this.geometry.update();
SimpleRope.prototype._render = function (renderer) {
var geometry = this.geometry;
if (this.autoUpdate || geometry._width !== this.shader.texture.height) {
geometry._width = this.shader.texture.height;
geometry.update();
}
Mesh.prototype._render.call(this, renderer);
_super.prototype._render.call(this, renderer);
};
return SimpleRope;

@@ -393,20 +361,18 @@ }(Mesh));

*/
var SimplePlane = /*@__PURE__*/(function (Mesh) {
function SimplePlane(texture, verticesX, verticesY)
{
var SimplePlane = /** @class */ (function (_super) {
__extends(SimplePlane, _super);
/**
* @param {PIXI.Texture} texture - The texture to use on the SimplePlane.
* @param {number} verticesX - The number of vertices in the x-axis
* @param {number} verticesY - The number of vertices in the y-axis
*/
function SimplePlane(texture, verticesX, verticesY) {
var _this = this;
var planeGeometry = new PlaneGeometry(texture.width, texture.height, verticesX, verticesY);
var meshMaterial = new MeshMaterial(Texture.WHITE);
Mesh.call(this, planeGeometry, meshMaterial);
_this = _super.call(this, planeGeometry, meshMaterial) || this;
// lets call the setter to ensure all necessary updates are performed
this.texture = texture;
_this.texture = texture;
return _this;
}
if ( Mesh ) SimplePlane.__proto__ = Mesh;
SimplePlane.prototype = Object.create( Mesh && Mesh.prototype );
SimplePlane.prototype.constructor = SimplePlane;
var prototypeAccessors = { texture: { configurable: true } };
/**

@@ -416,53 +382,38 @@ * Method used for overrides, to do something in case texture frame was changed.

*/
SimplePlane.prototype.textureUpdated = function textureUpdated ()
{
SimplePlane.prototype.textureUpdated = function () {
this._textureID = this.shader.texture._updateID;
this.geometry.width = this.shader.texture.width;
this.geometry.height = this.shader.texture.height;
this.geometry.build();
var geometry = this.geometry;
geometry.width = this.shader.texture.width;
geometry.height = this.shader.texture.height;
geometry.build();
};
prototypeAccessors.texture.set = function (value)
{
// Track texture same way sprite does.
// For generated meshes like NineSlicePlane it can change the geometry.
// Unfortunately, this method might not work if you directly change texture in material.
if (this.shader.texture === value)
{
return;
}
this.shader.texture = value;
this._textureID = -1;
if (value.baseTexture.valid)
{
Object.defineProperty(SimplePlane.prototype, "texture", {
get: function () {
return this.shader.texture;
},
set: function (value) {
// Track texture same way sprite does.
// For generated meshes like NineSlicePlane it can change the geometry.
// Unfortunately, this method might not work if you directly change texture in material.
if (this.shader.texture === value) {
return;
}
this.shader.texture = value;
this._textureID = -1;
if (value.baseTexture.valid) {
this.textureUpdated();
}
else {
value.once('update', this.textureUpdated, this);
}
},
enumerable: false,
configurable: true
});
SimplePlane.prototype._render = function (renderer) {
if (this._textureID !== this.shader.texture._updateID) {
this.textureUpdated();
}
else
{
value.once('update', this.textureUpdated, this);
}
_super.prototype._render.call(this, renderer);
};
prototypeAccessors.texture.get = function ()
{
return this.shader.texture;
};
SimplePlane.prototype._render = function _render (renderer)
{
if (this._textureID !== this.shader.texture._updateID)
{
this.textureUpdated();
}
Mesh.prototype._render.call(this, renderer);
};
Object.defineProperties( SimplePlane.prototype, prototypeAccessors );
return SimplePlane;

@@ -479,15 +430,18 @@ }(Mesh));

*/
var SimpleMesh = /*@__PURE__*/(function (Mesh) {
function SimpleMesh(texture, vertices, uvs, indices, drawMode)
{
if ( texture === void 0 ) texture = Texture.EMPTY;
var SimpleMesh = /** @class */ (function (_super) {
__extends(SimpleMesh, _super);
/**
* @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
*/
function SimpleMesh(texture, vertices, uvs, indices, drawMode) {
if (texture === void 0) { texture = Texture.EMPTY; }
var _this = this;
var geometry = new MeshGeometry(vertices, uvs, indices);
geometry.getBuffer('aVertexPosition').static = false;
var meshMaterial = new MeshMaterial(texture);
Mesh.call(this, geometry, meshMaterial, null, drawMode);
_this = _super.call(this, geometry, meshMaterial, null, drawMode) || this;
/**

@@ -497,36 +451,25 @@ * upload vertices buffer each frame

*/
this.autoUpdate = true;
_this.autoUpdate = true;
return _this;
}
if ( Mesh ) SimpleMesh.__proto__ = Mesh;
SimpleMesh.prototype = Object.create( Mesh && Mesh.prototype );
SimpleMesh.prototype.constructor = SimpleMesh;
var prototypeAccessors = { vertices: { configurable: true } };
/**
* Collection of vertices data.
* @member {Float32Array}
*/
prototypeAccessors.vertices.get = function ()
{
return this.geometry.getBuffer('aVertexPosition').data;
};
prototypeAccessors.vertices.set = function (value)
{
this.geometry.getBuffer('aVertexPosition').data = value;
};
SimpleMesh.prototype._render = function _render (renderer)
{
if (this.autoUpdate)
{
Object.defineProperty(SimpleMesh.prototype, "vertices", {
/**
* Collection of vertices data.
* @member {Float32Array}
*/
get: function () {
return this.geometry.getBuffer('aVertexPosition').data;
},
set: function (value) {
this.geometry.getBuffer('aVertexPosition').data = value;
},
enumerable: false,
configurable: true
});
SimpleMesh.prototype._render = function (renderer) {
if (this.autoUpdate) {
this.geometry.getBuffer('aVertexPosition').update();
}
Mesh.prototype._render.call(this, renderer);
_super.prototype._render.call(this, renderer);
};
Object.defineProperties( SimpleMesh.prototype, prototypeAccessors );
return SimpleMesh;

@@ -536,3 +479,2 @@ }(Mesh));

var DEFAULT_BORDER_SIZE = 10;
/**

@@ -569,10 +511,19 @@ * The NineSlicePlane allows you to stretch a texture using 9-slice scaling. The corners will remain unscaled (useful

*/
var NineSlicePlane = /*@__PURE__*/(function (SimplePlane) {
function NineSlicePlane(texture, leftWidth, topHeight, rightWidth, bottomHeight)
{
SimplePlane.call(this, Texture.WHITE, 4, 4);
this._origWidth = texture.orig.width;
this._origHeight = texture.orig.height;
var NineSlicePlane = /** @class */ (function (_super) {
__extends(NineSlicePlane, _super);
/**
* @param {PIXI.Texture} texture - The texture to use on the NineSlicePlane.
* @param {number} [leftWidth=10] - size of the left vertical bar (A)
* @param {number} [topHeight=10] - size of the top horizontal bar (C)
* @param {number} [rightWidth=10] - size of the right vertical bar (B)
* @param {number} [bottomHeight=10] - size of the bottom horizontal bar (D)
*/
function NineSlicePlane(texture, leftWidth, topHeight, rightWidth, bottomHeight) {
if (leftWidth === void 0) { leftWidth = DEFAULT_BORDER_SIZE; }
if (topHeight === void 0) { topHeight = DEFAULT_BORDER_SIZE; }
if (rightWidth === void 0) { rightWidth = DEFAULT_BORDER_SIZE; }
if (bottomHeight === void 0) { bottomHeight = DEFAULT_BORDER_SIZE; }
var _this = _super.call(this, Texture.WHITE, 4, 4) || this;
_this._origWidth = texture.orig.width;
_this._origHeight = texture.orig.height;
/**

@@ -584,4 +535,3 @@ * The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane

*/
this._width = this._origWidth;
_this._width = _this._origWidth;
/**

@@ -593,4 +543,3 @@ * The height of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane

*/
this._height = this._origHeight;
_this._height = _this._origHeight;
/**

@@ -602,4 +551,3 @@ * The width of the left column (a)

*/
this._leftWidth = typeof leftWidth !== 'undefined' ? leftWidth : DEFAULT_BORDER_SIZE;
_this._leftWidth = leftWidth;
/**

@@ -611,4 +559,3 @@ * The width of the right column (b)

*/
this._rightWidth = typeof rightWidth !== 'undefined' ? rightWidth : DEFAULT_BORDER_SIZE;
_this._rightWidth = rightWidth;
/**

@@ -620,4 +567,3 @@ * The height of the top row (c)

*/
this._topHeight = typeof topHeight !== 'undefined' ? topHeight : DEFAULT_BORDER_SIZE;
_this._topHeight = topHeight;
/**

@@ -629,30 +575,21 @@ * The height of the bottom row (d)

*/
this._bottomHeight = typeof bottomHeight !== 'undefined' ? bottomHeight : DEFAULT_BORDER_SIZE;
_this._bottomHeight = bottomHeight;
// lets call the setter to ensure all necessary updates are performed
this.texture = texture;
_this.texture = texture;
return _this;
}
if ( SimplePlane ) NineSlicePlane.__proto__ = SimplePlane;
NineSlicePlane.prototype = Object.create( SimplePlane && SimplePlane.prototype );
NineSlicePlane.prototype.constructor = NineSlicePlane;
var prototypeAccessors = { vertices: { configurable: true },width: { configurable: true },height: { configurable: true },leftWidth: { configurable: true },rightWidth: { configurable: true },topHeight: { configurable: true },bottomHeight: { configurable: true } };
NineSlicePlane.prototype.textureUpdated = function textureUpdated ()
{
NineSlicePlane.prototype.textureUpdated = function () {
this._textureID = this.shader.texture._updateID;
this._refresh();
};
prototypeAccessors.vertices.get = function ()
{
return this.geometry.getBuffer('aVertexPosition').data;
};
prototypeAccessors.vertices.set = function (value)
{
this.geometry.getBuffer('aVertexPosition').data = value;
};
Object.defineProperty(NineSlicePlane.prototype, "vertices", {
get: function () {
return this.geometry.getBuffer('aVertexPosition').data;
},
set: function (value) {
this.geometry.getBuffer('aVertexPosition').data = value;
},
enumerable: false,
configurable: true
});
/**

@@ -662,8 +599,5 @@ * Updates the horizontal vertices.

*/
NineSlicePlane.prototype.updateHorizontalVertices = function updateHorizontalVertices ()
{
NineSlicePlane.prototype.updateHorizontalVertices = function () {
var vertices = this.vertices;
var scale = this._getMinScale();
vertices[9] = vertices[11] = vertices[13] = vertices[15] = this._topHeight * scale;

@@ -673,3 +607,2 @@ vertices[17] = vertices[19] = vertices[21] = vertices[23] = this._height - (this._bottomHeight * scale);

};
/**

@@ -679,8 +612,5 @@ * Updates the vertical vertices.

*/
NineSlicePlane.prototype.updateVerticalVertices = function updateVerticalVertices ()
{
NineSlicePlane.prototype.updateVerticalVertices = function () {
var vertices = this.vertices;
var scale = this._getMinScale();
vertices[2] = vertices[10] = vertices[18] = vertices[26] = this._leftWidth * scale;

@@ -690,3 +620,2 @@ vertices[4] = vertices[12] = vertices[20] = vertices[28] = this._width - (this._rightWidth * scale);

};
/**

@@ -698,126 +627,116 @@ * Returns the smaller of a set of vertical and horizontal scale of nine slice corners.

*/
NineSlicePlane.prototype._getMinScale = function _getMinScale ()
{
NineSlicePlane.prototype._getMinScale = function () {
var w = this._leftWidth + this._rightWidth;
var scaleW = this._width > w ? 1.0 : this._width / w;
var h = this._topHeight + this._bottomHeight;
var scaleH = this._height > h ? 1.0 : this._height / h;
var scale = Math.min(scaleW, scaleH);
return scale;
};
Object.defineProperty(NineSlicePlane.prototype, "width", {
/**
* The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane
*
* @member {number}
*/
get: function () {
return this._width;
},
set: function (value) {
this._width = value;
this._refresh();
},
enumerable: false,
configurable: true
});
Object.defineProperty(NineSlicePlane.prototype, "height", {
/**
* The height of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane
*
* @member {number}
*/
get: function () {
return this._height;
},
set: function (value) {
this._height = value;
this._refresh();
},
enumerable: false,
configurable: true
});
Object.defineProperty(NineSlicePlane.prototype, "leftWidth", {
/**
* The width of the left column
*
* @member {number}
*/
get: function () {
return this._leftWidth;
},
set: function (value) {
this._leftWidth = value;
this._refresh();
},
enumerable: false,
configurable: true
});
Object.defineProperty(NineSlicePlane.prototype, "rightWidth", {
/**
* The width of the right column
*
* @member {number}
*/
get: function () {
return this._rightWidth;
},
set: function (value) {
this._rightWidth = value;
this._refresh();
},
enumerable: false,
configurable: true
});
Object.defineProperty(NineSlicePlane.prototype, "topHeight", {
/**
* The height of the top row
*
* @member {number}
*/
get: function () {
return this._topHeight;
},
set: function (value) {
this._topHeight = value;
this._refresh();
},
enumerable: false,
configurable: true
});
Object.defineProperty(NineSlicePlane.prototype, "bottomHeight", {
/**
* The height of the bottom row
*
* @member {number}
*/
get: function () {
return this._bottomHeight;
},
set: function (value) {
this._bottomHeight = value;
this._refresh();
},
enumerable: false,
configurable: true
});
/**
* The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane
*
* @member {number}
*/
prototypeAccessors.width.get = function ()
{
return this._width;
};
prototypeAccessors.width.set = function (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}
*/
prototypeAccessors.height.get = function ()
{
return this._height;
};
prototypeAccessors.height.set = function (value) // eslint-disable-line require-jsdoc
{
this._height = value;
this._refresh();
};
/**
* The width of the left column
*
* @member {number}
*/
prototypeAccessors.leftWidth.get = function ()
{
return this._leftWidth;
};
prototypeAccessors.leftWidth.set = function (value) // eslint-disable-line require-jsdoc
{
this._leftWidth = value;
this._refresh();
};
/**
* The width of the right column
*
* @member {number}
*/
prototypeAccessors.rightWidth.get = function ()
{
return this._rightWidth;
};
prototypeAccessors.rightWidth.set = function (value) // eslint-disable-line require-jsdoc
{
this._rightWidth = value;
this._refresh();
};
/**
* The height of the top row
*
* @member {number}
*/
prototypeAccessors.topHeight.get = function ()
{
return this._topHeight;
};
prototypeAccessors.topHeight.set = function (value) // eslint-disable-line require-jsdoc
{
this._topHeight = value;
this._refresh();
};
/**
* The height of the bottom row
*
* @member {number}
*/
prototypeAccessors.bottomHeight.get = function ()
{
return this._bottomHeight;
};
prototypeAccessors.bottomHeight.set = function (value) // eslint-disable-line require-jsdoc
{
this._bottomHeight = value;
this._refresh();
};
/**
* Refreshes NineSlicePlane coords. All of them.
*/
NineSlicePlane.prototype._refresh = function _refresh ()
{
NineSlicePlane.prototype._refresh = function () {
var texture = this.texture;
var uvs = this.geometry.buffers[1].data;
this._origWidth = texture.orig.width;
this._origHeight = texture.orig.height;
var _uvw = 1.0 / this._origWidth;
var _uvh = 1.0 / this._origHeight;
uvs[0] = uvs[8] = uvs[16] = uvs[24] = 0;

@@ -827,3 +746,2 @@ uvs[1] = uvs[3] = uvs[5] = uvs[7] = 0;

uvs[25] = uvs[27] = uvs[29] = uvs[31] = 1;
uvs[2] = uvs[10] = uvs[18] = uvs[26] = _uvw * this._leftWidth;

@@ -833,12 +751,7 @@ uvs[4] = uvs[12] = uvs[20] = uvs[28] = 1 - (_uvw * this._rightWidth);

uvs[17] = uvs[19] = uvs[21] = uvs[23] = 1 - (_uvh * this._bottomHeight);
this.updateHorizontalVertices();
this.updateVerticalVertices();
this.geometry.buffers[0].update();
this.geometry.buffers[1].update();
};
Object.defineProperties( NineSlicePlane.prototype, prototypeAccessors );
return NineSlicePlane;

@@ -845,0 +758,0 @@ }(SimplePlane));

/*!
* @pixi/mesh-extras - v5.2.4
* Compiled Sun, 03 May 2020 22:38:52 UTC
* @pixi/mesh-extras - v5.3.0
* Compiled Thu, 18 Jun 2020 23:27:40 UTC
*

@@ -16,25 +16,46 @@ * @pixi/mesh-extras is licensed under the MIT License.

var PlaneGeometry = /*@__PURE__*/(function (MeshGeometry) {
function PlaneGeometry(width, height, segWidth, segHeight)
{
if ( width === void 0 ) width = 100;
if ( height === void 0 ) height = 100;
if ( segWidth === void 0 ) segWidth = 10;
if ( segHeight === void 0 ) segHeight = 10;
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
MeshGeometry.call(this);
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
this.segWidth = segWidth;
this.segHeight = segHeight;
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/* global Reflect, Promise */
this.width = width;
this.height = height;
var extendStatics = function(d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) { if (b.hasOwnProperty(p)) { d[p] = b[p]; } } };
return extendStatics(d, b);
};
this.build();
function __extends(d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
}
var PlaneGeometry = /** @class */ (function (_super) {
__extends(PlaneGeometry, _super);
function PlaneGeometry(width, height, segWidth, segHeight) {
if (width === void 0) { width = 100; }
if (height === void 0) { height = 100; }
if (segWidth === void 0) { segWidth = 10; }
if (segHeight === void 0) { segHeight = 10; }
var _this = _super.call(this) || this;
_this.segWidth = segWidth;
_this.segHeight = segHeight;
_this.width = width;
_this.height = height;
_this.build();
return _this;
}
if ( MeshGeometry ) PlaneGeometry.__proto__ = MeshGeometry;
PlaneGeometry.prototype = Object.create( MeshGeometry && MeshGeometry.prototype );
PlaneGeometry.prototype.constructor = PlaneGeometry;
/**

@@ -44,4 +65,3 @@ * Refreshes plane coordinates

*/
PlaneGeometry.prototype.build = function build ()
{
PlaneGeometry.prototype.build = function () {
var total = this.segWidth * this.segHeight;

@@ -51,25 +71,16 @@ var verts = [];

var indices = [];
var segmentsX = this.segWidth - 1;
var segmentsY = this.segHeight - 1;
var sizeX = (this.width) / segmentsX;
var sizeY = (this.height) / segmentsY;
for (var i = 0; i < total; i++)
{
for (var i = 0; i < total; i++) {
var x = (i % this.segWidth);
var y = ((i / this.segWidth) | 0);
verts.push(x * sizeX, y * sizeY);
uvs.push(x / segmentsX, y / segmentsY);
}
var totalSub = segmentsX * segmentsY;
for (var i$1 = 0; i$1 < totalSub; i$1++)
{
var xpos = i$1 % segmentsX;
var ypos = (i$1 / segmentsX) | 0;
for (var i = 0; i < totalSub; i++) {
var xpos = i % segmentsX;
var ypos = (i / segmentsX) | 0;
var value = (ypos * this.segWidth) + xpos;

@@ -79,11 +90,7 @@ var value2 = (ypos * this.segWidth) + xpos + 1;

var value4 = ((ypos + 1) * this.segWidth) + xpos + 1;
indices.push(value, value2, value3,
value2, value4, value3);
indices.push(value, value2, value3, value2, value4, value3);
}
this.buffers[0].data = new Float32Array(verts);
this.buffers[1].data = new Float32Array(uvs);
this.indexBuffer.data = new Uint16Array(indices);
// ensure that the changes are uploaded

@@ -94,3 +101,2 @@ this.buffers[0].update();

};
return PlaneGeometry;

@@ -114,12 +120,19 @@ }(mesh.MeshGeometry));

*/
var RopeGeometry = /*@__PURE__*/(function (MeshGeometry) {
function RopeGeometry(width, points, textureScale)
{
if ( width === void 0 ) width = 200;
if ( textureScale === void 0 ) textureScale = 0;
MeshGeometry.call(this, new Float32Array(points.length * 4),
new Float32Array(points.length * 4),
new Uint16Array((points.length - 1) * 6));
var RopeGeometry = /** @class */ (function (_super) {
__extends(RopeGeometry, _super);
/**
* @param {number} [width=200] - The width (i.e., thickness) of the rope.
* @param {PIXI.Point[]} [points] - An array of {@link PIXI.Point} objects to construct this rope.
* @param {number} [textureScale=0] - By default the rope texture will be stretched to match
* rope length. If textureScale is positive this value will be treated as a scaling
* factor and the texture will preserve its aspect ratio instead. To create a tiling rope
* set baseTexture.wrapMode to {@link PIXI.WRAP_MODES.REPEAT} and use a power of two texture,
* then set textureScale=1 to keep the original texture pixel size.
* In order to reduce alpha channel artifacts provide a larger texture and downsample -
* i.e. set textureScale=0.5 to scale it down twice.
*/
function RopeGeometry(width, points, textureScale) {
if (width === void 0) { width = 200; }
if (textureScale === void 0) { textureScale = 0; }
var _this = _super.call(this, new Float32Array(points.length * 4), new Float32Array(points.length * 4), new Uint16Array((points.length - 1) * 6)) || this;
/**

@@ -129,4 +142,3 @@ * An array of points that determine the rope

*/
this.points = points;
_this.points = points;
/**

@@ -137,4 +149,3 @@ * The width (i.e., thickness) of the rope.

*/
this.width = width;
_this._width = width;
/**

@@ -145,10 +156,18 @@ * Rope texture scale, if zero then the rope texture is stretched.

*/
this.textureScale = textureScale;
this.build();
_this.textureScale = textureScale;
_this.build();
return _this;
}
if ( MeshGeometry ) RopeGeometry.__proto__ = MeshGeometry;
RopeGeometry.prototype = Object.create( MeshGeometry && MeshGeometry.prototype );
RopeGeometry.prototype.constructor = RopeGeometry;
Object.defineProperty(RopeGeometry.prototype, "width", {
/**
* The width (i.e., thickness) of the rope.
* @member {number}
* @readOnly
*/
get: function () {
return this._width;
},
enumerable: false,
configurable: true
});
/**

@@ -158,21 +177,15 @@ * Refreshes Rope indices and uvs

*/
RopeGeometry.prototype.build = function build ()
{
RopeGeometry.prototype.build = function () {
var points = this.points;
if (!points) { return; }
if (!points)
{ return; }
var vertexBuffer = this.getBuffer('aVertexPosition');
var uvBuffer = this.getBuffer('aTextureCoord');
var indexBuffer = this.getIndex();
// if too little points, or texture hasn't got UVs set yet just move on.
if (points.length < 1)
{
if (points.length < 1) {
return;
}
// if the number of points has changed we will need to recreate the arraybuffers
if (vertexBuffer.data.length / 4 !== points.length)
{
if (vertexBuffer.data.length / 4 !== points.length) {
vertexBuffer.data = new Float32Array(points.length * 4);

@@ -182,6 +195,4 @@ uvBuffer.data = new Float32Array(points.length * 4);

}
var uvs = uvBuffer.data;
var indices = indexBuffer.data;
uvs[0] = 0;

@@ -191,15 +202,10 @@ uvs[1] = 0;

uvs[3] = 1;
var amount = 0;
var prev = points[0];
var textureWidth = this.width * this.textureScale;
var textureWidth = this._width * this.textureScale;
var total = points.length; // - 1;
for (var i = 0; i < total; i++)
{
for (var i = 0; i < total; i++) {
// time to do some smart drawing!
var index = i * 4;
if (this.textureScale > 0)
{
if (this.textureScale > 0) {
// calculate pixel distance from previous point

@@ -209,53 +215,37 @@ var dx = prev.x - points[i].x;

var distance = Math.sqrt((dx * dx) + (dy * dy));
prev = points[i];
amount += distance / textureWidth;
}
else
{
else {
// stretch texture
amount = i / (total - 1);
}
uvs[index] = amount;
uvs[index + 1] = 0;
uvs[index + 2] = amount;
uvs[index + 3] = 1;
}
var indexCount = 0;
for (var i$1 = 0; i$1 < total - 1; i$1++)
{
var index$1 = i$1 * 2;
indices[indexCount++] = index$1;
indices[indexCount++] = index$1 + 1;
indices[indexCount++] = index$1 + 2;
indices[indexCount++] = index$1 + 2;
indices[indexCount++] = index$1 + 1;
indices[indexCount++] = index$1 + 3;
for (var i = 0; i < total - 1; i++) {
var index = i * 2;
indices[indexCount++] = index;
indices[indexCount++] = index + 1;
indices[indexCount++] = index + 2;
indices[indexCount++] = index + 2;
indices[indexCount++] = index + 1;
indices[indexCount++] = index + 3;
}
// ensure that the changes are uploaded
uvBuffer.update();
indexBuffer.update();
this.updateVertices();
};
/**
* refreshes vertices of Rope mesh
*/
RopeGeometry.prototype.updateVertices = function updateVertices ()
{
RopeGeometry.prototype.updateVertices = function () {
var points = this.points;
if (points.length < 1)
{
if (points.length < 1) {
return;
}
var lastPoint = points[0];

@@ -265,32 +255,21 @@ var nextPoint;

var perpY = 0;
var vertices = this.buffers[0].data;
var total = points.length;
for (var i = 0; i < total; i++)
{
for (var i = 0; i < total; i++) {
var point = points[i];
var index = i * 4;
if (i < points.length - 1)
{
if (i < points.length - 1) {
nextPoint = points[i + 1];
}
else
{
else {
nextPoint = point;
}
perpY = -(nextPoint.x - lastPoint.x);
perpX = nextPoint.y - lastPoint.y;
var perpLength = Math.sqrt((perpX * perpX) + (perpY * perpY));
var num = this.textureScale > 0 ? this.textureScale * this.width / 2 : this.width / 2;
var num = this.textureScale > 0 ? this.textureScale * this._width / 2 : this._width / 2;
perpX /= perpLength;
perpY /= perpLength;
perpX *= num;
perpY *= num;
vertices[index] = point.x + perpX;

@@ -300,21 +279,14 @@ vertices[index + 1] = point.y + perpY;

vertices[index + 3] = point.y - perpY;
lastPoint = point;
}
this.buffers[0].update();
};
RopeGeometry.prototype.update = function update ()
{
if (this.textureScale > 0)
{
RopeGeometry.prototype.update = function () {
if (this.textureScale > 0) {
this.build(); // we need to update UVs
}
else
{
else {
this.updateVertices();
}
};
return RopeGeometry;

@@ -338,17 +310,21 @@ }(mesh.MeshGeometry));

*/
var SimpleRope = /*@__PURE__*/(function (Mesh) {
function SimpleRope(texture, points, textureScale)
{
if ( textureScale === void 0 ) textureScale = 0;
var SimpleRope = /** @class */ (function (_super) {
__extends(SimpleRope, _super);
/**
* @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.
* @param {number} [textureScale=0] - Optional. Positive values scale rope texture
* keeping its aspect ratio. You can reduce alpha channel artifacts by providing a larger texture
* and downsampling here. If set to zero, texture will be streched instead.
*/
function SimpleRope(texture, points, textureScale) {
if (textureScale === void 0) { textureScale = 0; }
var _this = this;
var ropeGeometry = new RopeGeometry(texture.height, points, textureScale);
var meshMaterial = new mesh.MeshMaterial(texture);
if (textureScale > 0)
{
if (textureScale > 0) {
// attempt to set UV wrapping, will fail on non-power of two textures
texture.baseTexture.wrapMode = constants.WRAP_MODES.REPEAT;
}
Mesh.call(this, ropeGeometry, meshMaterial);
_this = _super.call(this, ropeGeometry, meshMaterial) || this;
/**

@@ -359,21 +335,13 @@ * re-calculate vertices by rope points each frame

*/
this.autoUpdate = true;
_this.autoUpdate = true;
return _this;
}
if ( Mesh ) SimpleRope.__proto__ = Mesh;
SimpleRope.prototype = Object.create( Mesh && Mesh.prototype );
SimpleRope.prototype.constructor = SimpleRope;
SimpleRope.prototype._render = function _render (renderer)
{
if (this.autoUpdate
|| this.geometry.width !== this.shader.texture.height)
{
this.geometry.width = this.shader.texture.height;
this.geometry.update();
SimpleRope.prototype._render = function (renderer) {
var geometry = this.geometry;
if (this.autoUpdate || geometry._width !== this.shader.texture.height) {
geometry._width = this.shader.texture.height;
geometry.update();
}
Mesh.prototype._render.call(this, renderer);
_super.prototype._render.call(this, renderer);
};
return SimpleRope;

@@ -397,20 +365,18 @@ }(mesh.Mesh));

*/
var SimplePlane = /*@__PURE__*/(function (Mesh) {
function SimplePlane(texture, verticesX, verticesY)
{
var SimplePlane = /** @class */ (function (_super) {
__extends(SimplePlane, _super);
/**
* @param {PIXI.Texture} texture - The texture to use on the SimplePlane.
* @param {number} verticesX - The number of vertices in the x-axis
* @param {number} verticesY - The number of vertices in the y-axis
*/
function SimplePlane(texture, verticesX, verticesY) {
var _this = this;
var planeGeometry = new PlaneGeometry(texture.width, texture.height, verticesX, verticesY);
var meshMaterial = new mesh.MeshMaterial(core.Texture.WHITE);
Mesh.call(this, planeGeometry, meshMaterial);
_this = _super.call(this, planeGeometry, meshMaterial) || this;
// lets call the setter to ensure all necessary updates are performed
this.texture = texture;
_this.texture = texture;
return _this;
}
if ( Mesh ) SimplePlane.__proto__ = Mesh;
SimplePlane.prototype = Object.create( Mesh && Mesh.prototype );
SimplePlane.prototype.constructor = SimplePlane;
var prototypeAccessors = { texture: { configurable: true } };
/**

@@ -420,53 +386,38 @@ * Method used for overrides, to do something in case texture frame was changed.

*/
SimplePlane.prototype.textureUpdated = function textureUpdated ()
{
SimplePlane.prototype.textureUpdated = function () {
this._textureID = this.shader.texture._updateID;
this.geometry.width = this.shader.texture.width;
this.geometry.height = this.shader.texture.height;
this.geometry.build();
var geometry = this.geometry;
geometry.width = this.shader.texture.width;
geometry.height = this.shader.texture.height;
geometry.build();
};
prototypeAccessors.texture.set = function (value)
{
// Track texture same way sprite does.
// For generated meshes like NineSlicePlane it can change the geometry.
// Unfortunately, this method might not work if you directly change texture in material.
if (this.shader.texture === value)
{
return;
}
this.shader.texture = value;
this._textureID = -1;
if (value.baseTexture.valid)
{
Object.defineProperty(SimplePlane.prototype, "texture", {
get: function () {
return this.shader.texture;
},
set: function (value) {
// Track texture same way sprite does.
// For generated meshes like NineSlicePlane it can change the geometry.
// Unfortunately, this method might not work if you directly change texture in material.
if (this.shader.texture === value) {
return;
}
this.shader.texture = value;
this._textureID = -1;
if (value.baseTexture.valid) {
this.textureUpdated();
}
else {
value.once('update', this.textureUpdated, this);
}
},
enumerable: false,
configurable: true
});
SimplePlane.prototype._render = function (renderer) {
if (this._textureID !== this.shader.texture._updateID) {
this.textureUpdated();
}
else
{
value.once('update', this.textureUpdated, this);
}
_super.prototype._render.call(this, renderer);
};
prototypeAccessors.texture.get = function ()
{
return this.shader.texture;
};
SimplePlane.prototype._render = function _render (renderer)
{
if (this._textureID !== this.shader.texture._updateID)
{
this.textureUpdated();
}
Mesh.prototype._render.call(this, renderer);
};
Object.defineProperties( SimplePlane.prototype, prototypeAccessors );
return SimplePlane;

@@ -483,15 +434,18 @@ }(mesh.Mesh));

*/
var SimpleMesh = /*@__PURE__*/(function (Mesh) {
function SimpleMesh(texture, vertices, uvs, indices, drawMode)
{
if ( texture === void 0 ) texture = core.Texture.EMPTY;
var SimpleMesh = /** @class */ (function (_super) {
__extends(SimpleMesh, _super);
/**
* @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
*/
function SimpleMesh(texture, vertices, uvs, indices, drawMode) {
if (texture === void 0) { texture = core.Texture.EMPTY; }
var _this = this;
var geometry = new mesh.MeshGeometry(vertices, uvs, indices);
geometry.getBuffer('aVertexPosition').static = false;
var meshMaterial = new mesh.MeshMaterial(texture);
Mesh.call(this, geometry, meshMaterial, null, drawMode);
_this = _super.call(this, geometry, meshMaterial, null, drawMode) || this;
/**

@@ -501,36 +455,25 @@ * upload vertices buffer each frame

*/
this.autoUpdate = true;
_this.autoUpdate = true;
return _this;
}
if ( Mesh ) SimpleMesh.__proto__ = Mesh;
SimpleMesh.prototype = Object.create( Mesh && Mesh.prototype );
SimpleMesh.prototype.constructor = SimpleMesh;
var prototypeAccessors = { vertices: { configurable: true } };
/**
* Collection of vertices data.
* @member {Float32Array}
*/
prototypeAccessors.vertices.get = function ()
{
return this.geometry.getBuffer('aVertexPosition').data;
};
prototypeAccessors.vertices.set = function (value)
{
this.geometry.getBuffer('aVertexPosition').data = value;
};
SimpleMesh.prototype._render = function _render (renderer)
{
if (this.autoUpdate)
{
Object.defineProperty(SimpleMesh.prototype, "vertices", {
/**
* Collection of vertices data.
* @member {Float32Array}
*/
get: function () {
return this.geometry.getBuffer('aVertexPosition').data;
},
set: function (value) {
this.geometry.getBuffer('aVertexPosition').data = value;
},
enumerable: false,
configurable: true
});
SimpleMesh.prototype._render = function (renderer) {
if (this.autoUpdate) {
this.geometry.getBuffer('aVertexPosition').update();
}
Mesh.prototype._render.call(this, renderer);
_super.prototype._render.call(this, renderer);
};
Object.defineProperties( SimpleMesh.prototype, prototypeAccessors );
return SimpleMesh;

@@ -540,3 +483,2 @@ }(mesh.Mesh));

var DEFAULT_BORDER_SIZE = 10;
/**

@@ -573,10 +515,19 @@ * The NineSlicePlane allows you to stretch a texture using 9-slice scaling. The corners will remain unscaled (useful

*/
var NineSlicePlane = /*@__PURE__*/(function (SimplePlane) {
function NineSlicePlane(texture, leftWidth, topHeight, rightWidth, bottomHeight)
{
SimplePlane.call(this, core.Texture.WHITE, 4, 4);
this._origWidth = texture.orig.width;
this._origHeight = texture.orig.height;
var NineSlicePlane = /** @class */ (function (_super) {
__extends(NineSlicePlane, _super);
/**
* @param {PIXI.Texture} texture - The texture to use on the NineSlicePlane.
* @param {number} [leftWidth=10] - size of the left vertical bar (A)
* @param {number} [topHeight=10] - size of the top horizontal bar (C)
* @param {number} [rightWidth=10] - size of the right vertical bar (B)
* @param {number} [bottomHeight=10] - size of the bottom horizontal bar (D)
*/
function NineSlicePlane(texture, leftWidth, topHeight, rightWidth, bottomHeight) {
if (leftWidth === void 0) { leftWidth = DEFAULT_BORDER_SIZE; }
if (topHeight === void 0) { topHeight = DEFAULT_BORDER_SIZE; }
if (rightWidth === void 0) { rightWidth = DEFAULT_BORDER_SIZE; }
if (bottomHeight === void 0) { bottomHeight = DEFAULT_BORDER_SIZE; }
var _this = _super.call(this, core.Texture.WHITE, 4, 4) || this;
_this._origWidth = texture.orig.width;
_this._origHeight = texture.orig.height;
/**

@@ -588,4 +539,3 @@ * The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane

*/
this._width = this._origWidth;
_this._width = _this._origWidth;
/**

@@ -597,4 +547,3 @@ * The height of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane

*/
this._height = this._origHeight;
_this._height = _this._origHeight;
/**

@@ -606,4 +555,3 @@ * The width of the left column (a)

*/
this._leftWidth = typeof leftWidth !== 'undefined' ? leftWidth : DEFAULT_BORDER_SIZE;
_this._leftWidth = leftWidth;
/**

@@ -615,4 +563,3 @@ * The width of the right column (b)

*/
this._rightWidth = typeof rightWidth !== 'undefined' ? rightWidth : DEFAULT_BORDER_SIZE;
_this._rightWidth = rightWidth;
/**

@@ -624,4 +571,3 @@ * The height of the top row (c)

*/
this._topHeight = typeof topHeight !== 'undefined' ? topHeight : DEFAULT_BORDER_SIZE;
_this._topHeight = topHeight;
/**

@@ -633,30 +579,21 @@ * The height of the bottom row (d)

*/
this._bottomHeight = typeof bottomHeight !== 'undefined' ? bottomHeight : DEFAULT_BORDER_SIZE;
_this._bottomHeight = bottomHeight;
// lets call the setter to ensure all necessary updates are performed
this.texture = texture;
_this.texture = texture;
return _this;
}
if ( SimplePlane ) NineSlicePlane.__proto__ = SimplePlane;
NineSlicePlane.prototype = Object.create( SimplePlane && SimplePlane.prototype );
NineSlicePlane.prototype.constructor = NineSlicePlane;
var prototypeAccessors = { vertices: { configurable: true },width: { configurable: true },height: { configurable: true },leftWidth: { configurable: true },rightWidth: { configurable: true },topHeight: { configurable: true },bottomHeight: { configurable: true } };
NineSlicePlane.prototype.textureUpdated = function textureUpdated ()
{
NineSlicePlane.prototype.textureUpdated = function () {
this._textureID = this.shader.texture._updateID;
this._refresh();
};
prototypeAccessors.vertices.get = function ()
{
return this.geometry.getBuffer('aVertexPosition').data;
};
prototypeAccessors.vertices.set = function (value)
{
this.geometry.getBuffer('aVertexPosition').data = value;
};
Object.defineProperty(NineSlicePlane.prototype, "vertices", {
get: function () {
return this.geometry.getBuffer('aVertexPosition').data;
},
set: function (value) {
this.geometry.getBuffer('aVertexPosition').data = value;
},
enumerable: false,
configurable: true
});
/**

@@ -666,8 +603,5 @@ * Updates the horizontal vertices.

*/
NineSlicePlane.prototype.updateHorizontalVertices = function updateHorizontalVertices ()
{
NineSlicePlane.prototype.updateHorizontalVertices = function () {
var vertices = this.vertices;
var scale = this._getMinScale();
vertices[9] = vertices[11] = vertices[13] = vertices[15] = this._topHeight * scale;

@@ -677,3 +611,2 @@ vertices[17] = vertices[19] = vertices[21] = vertices[23] = this._height - (this._bottomHeight * scale);

};
/**

@@ -683,8 +616,5 @@ * Updates the vertical vertices.

*/
NineSlicePlane.prototype.updateVerticalVertices = function updateVerticalVertices ()
{
NineSlicePlane.prototype.updateVerticalVertices = function () {
var vertices = this.vertices;
var scale = this._getMinScale();
vertices[2] = vertices[10] = vertices[18] = vertices[26] = this._leftWidth * scale;

@@ -694,3 +624,2 @@ vertices[4] = vertices[12] = vertices[20] = vertices[28] = this._width - (this._rightWidth * scale);

};
/**

@@ -702,126 +631,116 @@ * Returns the smaller of a set of vertical and horizontal scale of nine slice corners.

*/
NineSlicePlane.prototype._getMinScale = function _getMinScale ()
{
NineSlicePlane.prototype._getMinScale = function () {
var w = this._leftWidth + this._rightWidth;
var scaleW = this._width > w ? 1.0 : this._width / w;
var h = this._topHeight + this._bottomHeight;
var scaleH = this._height > h ? 1.0 : this._height / h;
var scale = Math.min(scaleW, scaleH);
return scale;
};
Object.defineProperty(NineSlicePlane.prototype, "width", {
/**
* The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane
*
* @member {number}
*/
get: function () {
return this._width;
},
set: function (value) {
this._width = value;
this._refresh();
},
enumerable: false,
configurable: true
});
Object.defineProperty(NineSlicePlane.prototype, "height", {
/**
* The height of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane
*
* @member {number}
*/
get: function () {
return this._height;
},
set: function (value) {
this._height = value;
this._refresh();
},
enumerable: false,
configurable: true
});
Object.defineProperty(NineSlicePlane.prototype, "leftWidth", {
/**
* The width of the left column
*
* @member {number}
*/
get: function () {
return this._leftWidth;
},
set: function (value) {
this._leftWidth = value;
this._refresh();
},
enumerable: false,
configurable: true
});
Object.defineProperty(NineSlicePlane.prototype, "rightWidth", {
/**
* The width of the right column
*
* @member {number}
*/
get: function () {
return this._rightWidth;
},
set: function (value) {
this._rightWidth = value;
this._refresh();
},
enumerable: false,
configurable: true
});
Object.defineProperty(NineSlicePlane.prototype, "topHeight", {
/**
* The height of the top row
*
* @member {number}
*/
get: function () {
return this._topHeight;
},
set: function (value) {
this._topHeight = value;
this._refresh();
},
enumerable: false,
configurable: true
});
Object.defineProperty(NineSlicePlane.prototype, "bottomHeight", {
/**
* The height of the bottom row
*
* @member {number}
*/
get: function () {
return this._bottomHeight;
},
set: function (value) {
this._bottomHeight = value;
this._refresh();
},
enumerable: false,
configurable: true
});
/**
* The width of the NineSlicePlane, setting this will actually modify the vertices and UV's of this plane
*
* @member {number}
*/
prototypeAccessors.width.get = function ()
{
return this._width;
};
prototypeAccessors.width.set = function (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}
*/
prototypeAccessors.height.get = function ()
{
return this._height;
};
prototypeAccessors.height.set = function (value) // eslint-disable-line require-jsdoc
{
this._height = value;
this._refresh();
};
/**
* The width of the left column
*
* @member {number}
*/
prototypeAccessors.leftWidth.get = function ()
{
return this._leftWidth;
};
prototypeAccessors.leftWidth.set = function (value) // eslint-disable-line require-jsdoc
{
this._leftWidth = value;
this._refresh();
};
/**
* The width of the right column
*
* @member {number}
*/
prototypeAccessors.rightWidth.get = function ()
{
return this._rightWidth;
};
prototypeAccessors.rightWidth.set = function (value) // eslint-disable-line require-jsdoc
{
this._rightWidth = value;
this._refresh();
};
/**
* The height of the top row
*
* @member {number}
*/
prototypeAccessors.topHeight.get = function ()
{
return this._topHeight;
};
prototypeAccessors.topHeight.set = function (value) // eslint-disable-line require-jsdoc
{
this._topHeight = value;
this._refresh();
};
/**
* The height of the bottom row
*
* @member {number}
*/
prototypeAccessors.bottomHeight.get = function ()
{
return this._bottomHeight;
};
prototypeAccessors.bottomHeight.set = function (value) // eslint-disable-line require-jsdoc
{
this._bottomHeight = value;
this._refresh();
};
/**
* Refreshes NineSlicePlane coords. All of them.
*/
NineSlicePlane.prototype._refresh = function _refresh ()
{
NineSlicePlane.prototype._refresh = function () {
var texture = this.texture;
var uvs = this.geometry.buffers[1].data;
this._origWidth = texture.orig.width;
this._origHeight = texture.orig.height;
var _uvw = 1.0 / this._origWidth;
var _uvh = 1.0 / this._origHeight;
uvs[0] = uvs[8] = uvs[16] = uvs[24] = 0;

@@ -831,3 +750,2 @@ uvs[1] = uvs[3] = uvs[5] = uvs[7] = 0;

uvs[25] = uvs[27] = uvs[29] = uvs[31] = 1;
uvs[2] = uvs[10] = uvs[18] = uvs[26] = _uvw * this._leftWidth;

@@ -837,12 +755,7 @@ uvs[4] = uvs[12] = uvs[20] = uvs[28] = 1 - (_uvw * this._rightWidth);

uvs[17] = uvs[19] = uvs[21] = uvs[23] = 1 - (_uvh * this._bottomHeight);
this.updateHorizontalVertices();
this.updateVerticalVertices();
this.geometry.buffers[0].update();
this.geometry.buffers[1].update();
};
Object.defineProperties( NineSlicePlane.prototype, prototypeAccessors );
return NineSlicePlane;

@@ -849,0 +762,0 @@ }(SimplePlane));

{
"name": "@pixi/mesh-extras",
"version": "5.2.4",
"version": "5.3.0",
"main": "lib/mesh-extras.js",

@@ -27,12 +27,12 @@ "module": "lib/mesh-extras.es.js",

"dependencies": {
"@pixi/constants": "5.2.4",
"@pixi/core": "5.2.4",
"@pixi/math": "5.2.4",
"@pixi/mesh": "5.2.4",
"@pixi/utils": "5.2.4"
"@pixi/constants": "5.3.0",
"@pixi/core": "5.3.0",
"@pixi/math": "5.3.0",
"@pixi/mesh": "5.3.0",
"@pixi/utils": "5.3.0"
},
"devDependencies": {
"@pixi/loaders": "5.2.4"
"@pixi/loaders": "5.3.0"
},
"gitHead": "71c6b3b2061af4a4f3a95a265d46e933b8befc2c"
"gitHead": "a9b7b32a9c0aeb3d9c42ef04b2c2a39be1cd0880"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc