diff --git a/dist/iwmlib.3rdparty.js b/dist/iwmlib.3rdparty.js index 2a87cce..5563110 100644 --- a/dist/iwmlib.3rdparty.js +++ b/dist/iwmlib.3rdparty.js @@ -11719,13 +11719,12 @@ var PIXI = (function (exports) { * TODO - Optimization pass! */ DisplayObject.prototype.updateTransform = function updateTransform () - {if(this.transform){ + { this.transform.updateTransform(this.parent.transform); // multiply the alphas.. this.worldAlpha = this.alpha * this.parent.worldAlpha; - this._bounds.updateID++; - }else console.error("Could not update transform on,", this) + this._bounds.updateID++; }; /** @@ -11741,8 +11740,7 @@ var PIXI = (function (exports) { } else { - if(this.transform){ - this.transform.updateTransform(this._tempDisplayObjectParent.transform);}else console.error("Could not update transform on,", this) + this.transform.updateTransform(this._tempDisplayObjectParent.transform); } }; @@ -12383,6 +12381,7 @@ var PIXI = (function (exports) { child.parent = this; this.sortDirty = true; + // ensure child transform will be recalculated child.transform._parentID = -1; this.children.push(child); @@ -49893,7 +49892,9 @@ var pixi_compressed_textures; } } pixi_compressed_textures.RegisterCompressedLoader = RegisterCompressedLoader; - function detectExtensions(renderer, resolution) { + pixi_compressed_textures.defaultDetectedExtensions = ['.png', '.jpg', '.json', '.atlas']; + function detectExtensions(renderer, resolution, defaultResolution) { + if (defaultResolution === void 0) { defaultResolution = 1; } var extensions = []; if (renderer instanceof PIXI.Renderer) { renderer.texture.initCompressed(); @@ -49909,16 +49910,20 @@ var pixi_compressed_textures; if (data.etc1) extensions.push('.etc1'); } - resolution = resolution || renderer.resolution; - var res = "@" + resolution + "x"; var ext = extensions.slice(0); - while (ext.length > 0) { - extensions.push(res + ext.pop()); + var resolutions = [resolution || renderer.resolution]; + if (defaultResolution) { + resolutions.push(defaultResolution); + } + for (var i = 0; i < resolutions.length; i++) { + var res = "@" + resolutions[i] + "x"; + for (var j = 0; j < ext.length; j++) { + extensions.push(res + ext[j]); + } + for (var j = 0; j < pixi_compressed_textures.defaultDetectedExtensions.length; j++) { + extensions.push(res + pixi_compressed_textures.defaultDetectedExtensions[j]); + } } - extensions.push(res + ".png"); - extensions.push(res + ".jpg"); - extensions.push(res + ".json"); - extensions.push(res + ".atlas"); return extensions; } pixi_compressed_textures.detectExtensions = detectExtensions; @@ -50005,9 +50010,6 @@ var pixi_compressed_textures; k = url.lastIndexOf("."); if (k >= 0) { resource._baseUrl = url.substring(0, k); - if (k >= 4 && url.substring(k - 3, 3) === '@1x') { - resource._baseUrl = url.substring(0, k); - } } else { return next(); @@ -50095,2090 +50097,2090 @@ this.PIXI = this.PIXI || {}; (function (exports, pixi) { 'use strict'; - /** - * A single node in a PropertyList. - */ - var PropertyNode = /** @class */ (function () { - /** - * @param value The value for this node - * @param time The time for this node, between 0-1 - * @param [ease] Custom ease for this list. Only relevant for the first node. - */ - function PropertyNode(value, time, ease) { - this.value = value; - this.time = time; - this.next = null; - this.isStepped = false; - if (ease) { - this.ease = typeof ease == "function" ? ease : exports.ParticleUtils.generateEase(ease); - } - else { - this.ease = null; - } - } - /** - * Creates a list of property values from a data object {list, isStepped} with a list of objects in - * the form {value, time}. Alternatively, the data object can be in the deprecated form of - * {start, end}. - * @param data The data for the list. - * @param data.list The array of value and time objects. - * @param data.isStepped If the list is stepped rather than interpolated. - * @param data.ease Custom ease for this list. - * @return The first node in the list - */ - PropertyNode.createList = function (data) { - if ("list" in data) { - var array = data.list; - var node = void 0, first = void 0; - var _a = array[0], value = _a.value, time = _a.time; - first = node = new PropertyNode(typeof value === 'string' ? exports.ParticleUtils.hexToRGB(value) : value, time, data.ease); - //only set up subsequent nodes if there are a bunch or the 2nd one is different from the first - if (array.length > 2 || (array.length === 2 && array[1].value !== value)) { - for (var i = 1; i < array.length; ++i) { - var _b = array[i], value_1 = _b.value, time_1 = _b.time; - node.next = new PropertyNode(typeof value_1 === 'string' ? exports.ParticleUtils.hexToRGB(value_1) : value_1, time_1); - node = node.next; - } - } - first.isStepped = !!data.isStepped; - return first; - } - else { - //Handle deprecated version here - var start = new PropertyNode(typeof data.start === 'string' ? exports.ParticleUtils.hexToRGB(data.start) : data.start, 0); - //only set up a next value if it is different from the starting value - if (data.end !== data.start) - start.next = new PropertyNode(typeof data.end === 'string' ? exports.ParticleUtils.hexToRGB(data.end) : data.end, 1); - return start; - } - }; - return PropertyNode; + /** + * A single node in a PropertyList. + */ + var PropertyNode = /** @class */ (function () { + /** + * @param value The value for this node + * @param time The time for this node, between 0-1 + * @param [ease] Custom ease for this list. Only relevant for the first node. + */ + function PropertyNode(value, time, ease) { + this.value = value; + this.time = time; + this.next = null; + this.isStepped = false; + if (ease) { + this.ease = typeof ease == "function" ? ease : exports.ParticleUtils.generateEase(ease); + } + else { + this.ease = null; + } + } + /** + * Creates a list of property values from a data object {list, isStepped} with a list of objects in + * the form {value, time}. Alternatively, the data object can be in the deprecated form of + * {start, end}. + * @param data The data for the list. + * @param data.list The array of value and time objects. + * @param data.isStepped If the list is stepped rather than interpolated. + * @param data.ease Custom ease for this list. + * @return The first node in the list + */ + PropertyNode.createList = function (data) { + if ("list" in data) { + var array = data.list; + var node = void 0, first = void 0; + var _a = array[0], value = _a.value, time = _a.time; + first = node = new PropertyNode(typeof value === 'string' ? exports.ParticleUtils.hexToRGB(value) : value, time, data.ease); + //only set up subsequent nodes if there are a bunch or the 2nd one is different from the first + if (array.length > 2 || (array.length === 2 && array[1].value !== value)) { + for (var i = 1; i < array.length; ++i) { + var _b = array[i], value_1 = _b.value, time_1 = _b.time; + node.next = new PropertyNode(typeof value_1 === 'string' ? exports.ParticleUtils.hexToRGB(value_1) : value_1, time_1); + node = node.next; + } + } + first.isStepped = !!data.isStepped; + return first; + } + else { + //Handle deprecated version here + var start = new PropertyNode(typeof data.start === 'string' ? exports.ParticleUtils.hexToRGB(data.start) : data.start, 0); + //only set up a next value if it is different from the starting value + if (data.end !== data.start) + start.next = new PropertyNode(typeof data.end === 'string' ? exports.ParticleUtils.hexToRGB(data.end) : data.end, 1); + return start; + } + }; + return PropertyNode; }()); - // get Texture.from()/Texture.fromImage(), in V4 and V5 friendly methods - /** - * @hidden - */ - var TextureFromString; - // to avoid Rollup transforming our import, save pixi namespace in a variable - var pixiNS = pixi; - if (parseInt(/^(\d+)\./.exec(pixi.VERSION)[1]) < 5) { - TextureFromString = pixiNS.Texture.fromImage; - } - else { - TextureFromString = pixiNS.Texture.from; - } - function GetTextureFromString(s) { - return TextureFromString(s); - } - (function (ParticleUtils) { - /** - * If errors and warnings should be logged within the library. - */ - ParticleUtils.verbose = false; - ParticleUtils.DEG_TO_RADS = Math.PI / 180; - /** - * Rotates a point by a given angle. - * @param angle The angle to rotate by in degrees - * @param p The point to rotate around 0,0. - */ - function rotatePoint(angle, p) { - if (!angle) - return; - angle *= ParticleUtils.DEG_TO_RADS; - var s = Math.sin(angle); - var c = Math.cos(angle); - var xnew = p.x * c - p.y * s; - var ynew = p.x * s + p.y * c; - p.x = xnew; - p.y = ynew; - } - ParticleUtils.rotatePoint = rotatePoint; - /** - * Combines separate color components (0-255) into a single uint color. - * @param r The red value of the color - * @param g The green value of the color - * @param b The blue value of the color - * @return The color in the form of 0xRRGGBB - */ - function combineRGBComponents(r, g, b /*, a*/) { - return /*a << 24 |*/ r << 16 | g << 8 | b; - } - ParticleUtils.combineRGBComponents = combineRGBComponents; - /** - * Reduces the point to a length of 1. - * @param point The point to normalize - */ - function normalize(point) { - var oneOverLen = 1 / ParticleUtils.length(point); - point.x *= oneOverLen; - point.y *= oneOverLen; - } - ParticleUtils.normalize = normalize; - /** - * Multiplies the x and y values of this point by a value. - * @param point The point to scaleBy - * @param value The value to scale by. - */ - function scaleBy(point, value) { - point.x *= value; - point.y *= value; - } - ParticleUtils.scaleBy = scaleBy; - /** - * Returns the length (or magnitude) of this point. - * @param point The point to measure length - * @return The length of this point. - */ - function length(point) { - return Math.sqrt(point.x * point.x + point.y * point.y); - } - ParticleUtils.length = length; - /** - * Converts a hex string from "#AARRGGBB", "#RRGGBB", "0xAARRGGBB", "0xRRGGBB", - * "AARRGGBB", or "RRGGBB" to an object of ints of 0-255, as - * {r, g, b, (a)}. - * @param color The input color string. - * @param output An object to put the output in. If omitted, a new object is created. - * @return The object with r, g, and b properties, possibly with an a property. - */ - function hexToRGB(color, output) { - if (!output) - output = {}; - if (color.charAt(0) == "#") - color = color.substr(1); - else if (color.indexOf("0x") === 0) - color = color.substr(2); - var alpha; - if (color.length == 8) { - alpha = color.substr(0, 2); - color = color.substr(2); - } - output.r = parseInt(color.substr(0, 2), 16); //Red - output.g = parseInt(color.substr(2, 2), 16); //Green - output.b = parseInt(color.substr(4, 2), 16); //Blue - if (alpha) - output.a = parseInt(alpha, 16); - return output; - } - ParticleUtils.hexToRGB = hexToRGB; - /** - * Generates a custom ease function, based on the GreenSock custom ease, as demonstrated - * by the related tool at http://www.greensock.com/customease/. - * @param segments An array of segments, as created by - * http://www.greensock.com/customease/. - * @return A function that calculates the percentage of change at - * a given point in time (0-1 inclusive). - */ - function generateEase(segments) { - var qty = segments.length; - var oneOverQty = 1 / qty; - /* - * Calculates the percentage of change at a given point in time (0-1 inclusive). - * @param {Number} time The time of the ease, 0-1 inclusive. - * @return {Number} The percentage of the change, 0-1 inclusive (unless your - * ease goes outside those bounds). - */ - return function (time) { - var t, s; - var i = (qty * time) | 0; //do a quick floor operation - t = (time - (i * oneOverQty)) * qty; - s = segments[i] || segments[qty - 1]; - return (s.s + t * (2 * (1 - t) * (s.cp - s.s) + t * (s.e - s.s))); - }; - } - ParticleUtils.generateEase = generateEase; - /** - * Gets a blend mode, ensuring that it is valid. - * @param name The name of the blend mode to get. - * @return The blend mode as specified in the PIXI.BLEND_MODES enumeration. - */ - function getBlendMode(name) { - if (!name) - return pixi.BLEND_MODES.NORMAL; - name = name.toUpperCase(); - while (name.indexOf(" ") >= 0) - name = name.replace(" ", "_"); - return pixi.BLEND_MODES[name] || pixi.BLEND_MODES.NORMAL; - } - ParticleUtils.getBlendMode = getBlendMode; - /** - * Converts a list of {value, time} objects starting at time 0 and ending at time 1 into an evenly - * spaced stepped list of PropertyNodes for color values. This is primarily to handle conversion of - * linear gradients to fewer colors, allowing for some optimization for Canvas2d fallbacks. - * @param list The list of data to convert. - * @param [numSteps=10] The number of steps to use. - * @return The blend mode as specified in the PIXI.blendModes enumeration. - */ - function createSteppedGradient(list, numSteps) { - if (numSteps === void 0) { numSteps = 10; } - if (typeof numSteps !== 'number' || numSteps <= 0) - numSteps = 10; - var first = new PropertyNode(ParticleUtils.hexToRGB(list[0].value), list[0].time); - first.isStepped = true; - var currentNode = first; - var current = list[0]; - var nextIndex = 1; - var next = list[nextIndex]; - for (var i = 1; i < numSteps; ++i) { - var lerp = i / numSteps; - //ensure we are on the right segment, if multiple - while (lerp > next.time) { - current = next; - next = list[++nextIndex]; - } - //convert the lerp value to the segment range - lerp = (lerp - current.time) / (next.time - current.time); - var curVal = ParticleUtils.hexToRGB(current.value); - var nextVal = ParticleUtils.hexToRGB(next.value); - var output = { - r: (nextVal.r - curVal.r) * lerp + curVal.r, - g: (nextVal.g - curVal.g) * lerp + curVal.g, - b: (nextVal.b - curVal.b) * lerp + curVal.b, - }; - currentNode.next = new PropertyNode(output, i / numSteps); - currentNode = currentNode.next; - } - //we don't need to have a PropertyNode for time of 1, because in a stepped version at that point - //the particle has died of old age - return first; - } - ParticleUtils.createSteppedGradient = createSteppedGradient; + // get Texture.from()/Texture.fromImage(), in V4 and V5 friendly methods + /** + * @hidden + */ + var TextureFromString; + // to avoid Rollup transforming our import, save pixi namespace in a variable + var pixiNS = pixi; + if (parseInt(/^(\d+)\./.exec(pixi.VERSION)[1]) < 5) { + TextureFromString = pixiNS.Texture.fromImage; + } + else { + TextureFromString = pixiNS.Texture.from; + } + function GetTextureFromString(s) { + return TextureFromString(s); + } + (function (ParticleUtils) { + /** + * If errors and warnings should be logged within the library. + */ + ParticleUtils.verbose = false; + ParticleUtils.DEG_TO_RADS = Math.PI / 180; + /** + * Rotates a point by a given angle. + * @param angle The angle to rotate by in degrees + * @param p The point to rotate around 0,0. + */ + function rotatePoint(angle, p) { + if (!angle) + return; + angle *= ParticleUtils.DEG_TO_RADS; + var s = Math.sin(angle); + var c = Math.cos(angle); + var xnew = p.x * c - p.y * s; + var ynew = p.x * s + p.y * c; + p.x = xnew; + p.y = ynew; + } + ParticleUtils.rotatePoint = rotatePoint; + /** + * Combines separate color components (0-255) into a single uint color. + * @param r The red value of the color + * @param g The green value of the color + * @param b The blue value of the color + * @return The color in the form of 0xRRGGBB + */ + function combineRGBComponents(r, g, b /*, a*/) { + return /*a << 24 |*/ r << 16 | g << 8 | b; + } + ParticleUtils.combineRGBComponents = combineRGBComponents; + /** + * Reduces the point to a length of 1. + * @param point The point to normalize + */ + function normalize(point) { + var oneOverLen = 1 / ParticleUtils.length(point); + point.x *= oneOverLen; + point.y *= oneOverLen; + } + ParticleUtils.normalize = normalize; + /** + * Multiplies the x and y values of this point by a value. + * @param point The point to scaleBy + * @param value The value to scale by. + */ + function scaleBy(point, value) { + point.x *= value; + point.y *= value; + } + ParticleUtils.scaleBy = scaleBy; + /** + * Returns the length (or magnitude) of this point. + * @param point The point to measure length + * @return The length of this point. + */ + function length(point) { + return Math.sqrt(point.x * point.x + point.y * point.y); + } + ParticleUtils.length = length; + /** + * Converts a hex string from "#AARRGGBB", "#RRGGBB", "0xAARRGGBB", "0xRRGGBB", + * "AARRGGBB", or "RRGGBB" to an object of ints of 0-255, as + * {r, g, b, (a)}. + * @param color The input color string. + * @param output An object to put the output in. If omitted, a new object is created. + * @return The object with r, g, and b properties, possibly with an a property. + */ + function hexToRGB(color, output) { + if (!output) + output = {}; + if (color.charAt(0) == "#") + color = color.substr(1); + else if (color.indexOf("0x") === 0) + color = color.substr(2); + var alpha; + if (color.length == 8) { + alpha = color.substr(0, 2); + color = color.substr(2); + } + output.r = parseInt(color.substr(0, 2), 16); //Red + output.g = parseInt(color.substr(2, 2), 16); //Green + output.b = parseInt(color.substr(4, 2), 16); //Blue + if (alpha) + output.a = parseInt(alpha, 16); + return output; + } + ParticleUtils.hexToRGB = hexToRGB; + /** + * Generates a custom ease function, based on the GreenSock custom ease, as demonstrated + * by the related tool at http://www.greensock.com/customease/. + * @param segments An array of segments, as created by + * http://www.greensock.com/customease/. + * @return A function that calculates the percentage of change at + * a given point in time (0-1 inclusive). + */ + function generateEase(segments) { + var qty = segments.length; + var oneOverQty = 1 / qty; + /* + * Calculates the percentage of change at a given point in time (0-1 inclusive). + * @param {Number} time The time of the ease, 0-1 inclusive. + * @return {Number} The percentage of the change, 0-1 inclusive (unless your + * ease goes outside those bounds). + */ + return function (time) { + var t, s; + var i = (qty * time) | 0; //do a quick floor operation + t = (time - (i * oneOverQty)) * qty; + s = segments[i] || segments[qty - 1]; + return (s.s + t * (2 * (1 - t) * (s.cp - s.s) + t * (s.e - s.s))); + }; + } + ParticleUtils.generateEase = generateEase; + /** + * Gets a blend mode, ensuring that it is valid. + * @param name The name of the blend mode to get. + * @return The blend mode as specified in the PIXI.BLEND_MODES enumeration. + */ + function getBlendMode(name) { + if (!name) + return pixi.BLEND_MODES.NORMAL; + name = name.toUpperCase(); + while (name.indexOf(" ") >= 0) + name = name.replace(" ", "_"); + return pixi.BLEND_MODES[name] || pixi.BLEND_MODES.NORMAL; + } + ParticleUtils.getBlendMode = getBlendMode; + /** + * Converts a list of {value, time} objects starting at time 0 and ending at time 1 into an evenly + * spaced stepped list of PropertyNodes for color values. This is primarily to handle conversion of + * linear gradients to fewer colors, allowing for some optimization for Canvas2d fallbacks. + * @param list The list of data to convert. + * @param [numSteps=10] The number of steps to use. + * @return The blend mode as specified in the PIXI.blendModes enumeration. + */ + function createSteppedGradient(list, numSteps) { + if (numSteps === void 0) { numSteps = 10; } + if (typeof numSteps !== 'number' || numSteps <= 0) + numSteps = 10; + var first = new PropertyNode(ParticleUtils.hexToRGB(list[0].value), list[0].time); + first.isStepped = true; + var currentNode = first; + var current = list[0]; + var nextIndex = 1; + var next = list[nextIndex]; + for (var i = 1; i < numSteps; ++i) { + var lerp = i / numSteps; + //ensure we are on the right segment, if multiple + while (lerp > next.time) { + current = next; + next = list[++nextIndex]; + } + //convert the lerp value to the segment range + lerp = (lerp - current.time) / (next.time - current.time); + var curVal = ParticleUtils.hexToRGB(current.value); + var nextVal = ParticleUtils.hexToRGB(next.value); + var output = { + r: (nextVal.r - curVal.r) * lerp + curVal.r, + g: (nextVal.g - curVal.g) * lerp + curVal.g, + b: (nextVal.b - curVal.b) * lerp + curVal.b, + }; + currentNode.next = new PropertyNode(output, i / numSteps); + currentNode = currentNode.next; + } + //we don't need to have a PropertyNode for time of 1, because in a stepped version at that point + //the particle has died of old age + return first; + } + ParticleUtils.createSteppedGradient = createSteppedGradient; })(exports.ParticleUtils || (exports.ParticleUtils = {})); - /*! ***************************************************************************** - 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 - - 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. - - See the Apache Version 2.0 License for specific language governing permissions - and limitations under the License. - ***************************************************************************** */ - /* global Reflect, Promise */ - - 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); - }; - - function __extends(d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + /*! ***************************************************************************** + 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 + + 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. + + See the Apache Version 2.0 License for specific language governing permissions + and limitations under the License. + ***************************************************************************** */ + /* global Reflect, Promise */ + + 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); + }; + + 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) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[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 }; + } + } + + 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() { + for (var ar = [], i = 0; i < arguments.length; i++) + ar = ar.concat(__read(arguments[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 __assign = function() { - __assign = Object.assign || function __assign(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { - s = arguments[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; + /** + * Singly linked list container for keeping track of interpolated properties for particles. + * Each Particle will have one of these for each interpolated property. + */ + var PropertyList = /** @class */ (function () { + /** + * @param isColor If this list handles color values + */ + function PropertyList(isColor) { + if (isColor === void 0) { isColor = false; } + this.current = null; + this.next = null; + this.isColor = !!isColor; + this.interpolate = null; + this.ease = null; + } + /** + * Resets the list for use. + * @param first The first node in the list. + * @param first.isStepped If the values should be stepped instead of interpolated linearly. + */ + PropertyList.prototype.reset = function (first) { + this.current = first; + this.next = first.next; + var isSimple = this.next && this.next.time >= 1; + if (isSimple) { + this.interpolate = this.isColor ? intColorSimple : intValueSimple; + } + else if (first.isStepped) { + this.interpolate = this.isColor ? intColorStepped : intValueStepped; + } + else { + this.interpolate = this.isColor ? intColorComplex : intValueComplex; + } + this.ease = this.current.ease; + }; + return PropertyList; + }()); + function intValueSimple(lerp) { + if (this.ease) + lerp = this.ease(lerp); + return (this.next.value - this.current.value) * lerp + this.current.value; + } + function intColorSimple(lerp) { + if (this.ease) + lerp = this.ease(lerp); + var curVal = this.current.value, nextVal = this.next.value; + var r = (nextVal.r - curVal.r) * lerp + curVal.r; + var g = (nextVal.g - curVal.g) * lerp + curVal.g; + var b = (nextVal.b - curVal.b) * lerp + curVal.b; + return exports.ParticleUtils.combineRGBComponents(r, g, b); + } + function intValueComplex(lerp) { + if (this.ease) + lerp = this.ease(lerp); + //make sure we are on the right segment + while (lerp > this.next.time) { + this.current = this.next; + this.next = this.next.next; + } + //convert the lerp value to the segment range + lerp = (lerp - this.current.time) / (this.next.time - this.current.time); + return (this.next.value - this.current.value) * lerp + this.current.value; + } + function intColorComplex(lerp) { + if (this.ease) + lerp = this.ease(lerp); + //make sure we are on the right segment + while (lerp > this.next.time) { + this.current = this.next; + this.next = this.next.next; + } + //convert the lerp value to the segment range + lerp = (lerp - this.current.time) / (this.next.time - this.current.time); + var curVal = this.current.value, nextVal = this.next.value; + var r = (nextVal.r - curVal.r) * lerp + curVal.r; + var g = (nextVal.g - curVal.g) * lerp + curVal.g; + var b = (nextVal.b - curVal.b) * lerp + curVal.b; + return exports.ParticleUtils.combineRGBComponents(r, g, b); + } + function intValueStepped(lerp) { + if (this.ease) + lerp = this.ease(lerp); + //make sure we are on the right segment + while (this.next && lerp > this.next.time) { + this.current = this.next; + this.next = this.next.next; + } + return this.current.value; + } + function intColorStepped(lerp) { + if (this.ease) + lerp = this.ease(lerp); + //make sure we are on the right segment + while (this.next && lerp > this.next.time) { + this.current = this.next; + this.next = this.next.next; + } + var curVal = this.current.value; + return exports.ParticleUtils.combineRGBComponents(curVal.r, curVal.g, curVal.b); } - 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 }; - } - } - - 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() { - for (var ar = [], i = 0; i < arguments.length; i++) - ar = ar.concat(__read(arguments[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 }; - } - - /** - * Singly linked list container for keeping track of interpolated properties for particles. - * Each Particle will have one of these for each interpolated property. - */ - var PropertyList = /** @class */ (function () { - /** - * @param isColor If this list handles color values - */ - function PropertyList(isColor) { - if (isColor === void 0) { isColor = false; } - this.current = null; - this.next = null; - this.isColor = !!isColor; - this.interpolate = null; - this.ease = null; - } - /** - * Resets the list for use. - * @param first The first node in the list. - * @param first.isStepped If the values should be stepped instead of interpolated linearly. - */ - PropertyList.prototype.reset = function (first) { - this.current = first; - this.next = first.next; - var isSimple = this.next && this.next.time >= 1; - if (isSimple) { - this.interpolate = this.isColor ? intColorSimple : intValueSimple; - } - else if (first.isStepped) { - this.interpolate = this.isColor ? intColorStepped : intValueStepped; - } - else { - this.interpolate = this.isColor ? intColorComplex : intValueComplex; - } - this.ease = this.current.ease; - }; - return PropertyList; - }()); - function intValueSimple(lerp) { - if (this.ease) - lerp = this.ease(lerp); - return (this.next.value - this.current.value) * lerp + this.current.value; - } - function intColorSimple(lerp) { - if (this.ease) - lerp = this.ease(lerp); - var curVal = this.current.value, nextVal = this.next.value; - var r = (nextVal.r - curVal.r) * lerp + curVal.r; - var g = (nextVal.g - curVal.g) * lerp + curVal.g; - var b = (nextVal.b - curVal.b) * lerp + curVal.b; - return exports.ParticleUtils.combineRGBComponents(r, g, b); - } - function intValueComplex(lerp) { - if (this.ease) - lerp = this.ease(lerp); - //make sure we are on the right segment - while (lerp > this.next.time) { - this.current = this.next; - this.next = this.next.next; - } - //convert the lerp value to the segment range - lerp = (lerp - this.current.time) / (this.next.time - this.current.time); - return (this.next.value - this.current.value) * lerp + this.current.value; - } - function intColorComplex(lerp) { - if (this.ease) - lerp = this.ease(lerp); - //make sure we are on the right segment - while (lerp > this.next.time) { - this.current = this.next; - this.next = this.next.next; - } - //convert the lerp value to the segment range - lerp = (lerp - this.current.time) / (this.next.time - this.current.time); - var curVal = this.current.value, nextVal = this.next.value; - var r = (nextVal.r - curVal.r) * lerp + curVal.r; - var g = (nextVal.g - curVal.g) * lerp + curVal.g; - var b = (nextVal.b - curVal.b) * lerp + curVal.b; - return exports.ParticleUtils.combineRGBComponents(r, g, b); - } - function intValueStepped(lerp) { - if (this.ease) - lerp = this.ease(lerp); - //make sure we are on the right segment - while (this.next && lerp > this.next.time) { - this.current = this.next; - this.next = this.next.next; - } - return this.current.value; - } - function intColorStepped(lerp) { - if (this.ease) - lerp = this.ease(lerp); - //make sure we are on the right segment - while (this.next && lerp > this.next.time) { - this.current = this.next; - this.next = this.next.next; - } - var curVal = this.current.value; - return exports.ParticleUtils.combineRGBComponents(curVal.r, curVal.g, curVal.b); - } - - /** - * An individual particle image. You shouldn't have to deal with these. - */ - var Particle = /** @class */ (function (_super) { - __extends(Particle, _super); - /** - * @param {PIXI.particles.Emitter} emitter The emitter that controls this particle. - */ - function Particle(emitter) { - var _this = - //start off the sprite with a blank texture, since we are going to replace it - //later when the particle is initialized. - _super.call(this) || this; - _this.emitter = emitter; - //particles should be centered - _this.anchor.x = _this.anchor.y = 0.5; - _this.velocity = new pixi.Point(); - _this.rotationSpeed = 0; - _this.rotationAcceleration = 0; - _this.maxLife = 0; - _this.age = 0; - _this.ease = null; - _this.extraData = null; - _this.alphaList = new PropertyList(); - _this.speedList = new PropertyList(); - _this.speedMultiplier = 1; - _this.acceleration = new pixi.Point(); - _this.maxSpeed = NaN; - _this.scaleList = new PropertyList(); - _this.scaleMultiplier = 1; - _this.colorList = new PropertyList(true); - _this._doAlpha = false; - _this._doScale = false; - _this._doSpeed = false; - _this._doAcceleration = false; - _this._doColor = false; - _this._doNormalMovement = false; - _this._oneOverLife = 0; - _this.next = null; - _this.prev = null; - //save often used functions on the instance instead of the prototype for better speed - _this.init = _this.init; - _this.Particle_init = Particle.prototype.init; - _this.update = _this.update; - _this.Particle_update = Particle.prototype.update; - _this.Sprite_destroy = _super.prototype.destroy; - _this.Particle_destroy = Particle.prototype.destroy; - _this.applyArt = _this.applyArt; - _this.kill = _this.kill; - return _this; - } - /** - * Initializes the particle for use, based on the properties that have to - * have been set already on the particle. - */ - Particle.prototype.init = function () { - //reset the age - this.age = 0; - //set up the velocity based on the start speed and rotation - this.velocity.x = this.speedList.current.value * this.speedMultiplier; - this.velocity.y = 0; - exports.ParticleUtils.rotatePoint(this.rotation, this.velocity); - if (this.noRotation) { - this.rotation = 0; - } - else { - //convert rotation to Radians from Degrees - this.rotation *= exports.ParticleUtils.DEG_TO_RADS; - } - //convert rotation speed to Radians from Degrees - this.rotationSpeed *= exports.ParticleUtils.DEG_TO_RADS; - this.rotationAcceleration *= exports.ParticleUtils.DEG_TO_RADS; - //set alpha to inital alpha - this.alpha = this.alphaList.current.value; - //set scale to initial scale - this.scale.x = this.scale.y = this.scaleList.current.value; - //figure out what we need to interpolate - this._doAlpha = !!this.alphaList.current.next; - this._doSpeed = !!this.speedList.current.next; - this._doScale = !!this.scaleList.current.next; - this._doColor = !!this.colorList.current.next; - this._doAcceleration = this.acceleration.x !== 0 || this.acceleration.y !== 0; - //_doNormalMovement can be cancelled by subclasses - this._doNormalMovement = this._doSpeed || this.speedList.current.value !== 0 || this._doAcceleration; - //save our lerp helper - this._oneOverLife = 1 / this.maxLife; - //set the inital color - var color = this.colorList.current.value; - this.tint = exports.ParticleUtils.combineRGBComponents(color.r, color.g, color.b); - //ensure visibility - this.visible = true; - }; - /** - * Sets the texture for the particle. This can be overridden to allow - * for an animated particle. - * @param art The texture to set. - */ - Particle.prototype.applyArt = function (art) { - this.texture = art || pixi.Texture.EMPTY; - }; - /** - * Updates the particle. - * @param delta Time elapsed since the previous frame, in __seconds__. - * @return The standard interpolation multiplier (0-1) used for all - * relevant particle properties. A value of -1 means the particle - * died of old age instead. - */ - Particle.prototype.update = function (delta) { - //increase age - this.age += delta; - //recycle particle if it is too old - if (this.age >= this.maxLife || this.age < 0) { - this.kill(); - return -1; - } - //determine our interpolation value - var lerp = this.age * this._oneOverLife; //lifetime / maxLife; - if (this.ease) { - if (this.ease.length == 4) { - //the t, b, c, d parameters that some tween libraries use - //(time, initial value, end value, duration) - lerp = this.ease(lerp, 0, 1, 1); - } - else { - //the simplified version that we like that takes - //one parameter, time from 0-1. TweenJS eases provide this usage. - lerp = this.ease(lerp); - } - } - //interpolate alpha - if (this._doAlpha) - this.alpha = this.alphaList.interpolate(lerp); - //interpolate scale - if (this._doScale) { - var scale = this.scaleList.interpolate(lerp) * this.scaleMultiplier; - this.scale.x = this.scale.y = scale; - } - //handle movement - if (this._doNormalMovement) { - var deltaX = void 0; - var deltaY = void 0; - //interpolate speed - if (this._doSpeed) { - var speed = this.speedList.interpolate(lerp) * this.speedMultiplier; - exports.ParticleUtils.normalize(this.velocity); - exports.ParticleUtils.scaleBy(this.velocity, speed); - deltaX = this.velocity.x * delta; - deltaY = this.velocity.y * delta; - } - else if (this._doAcceleration) { - var oldVX = this.velocity.x; - var oldVY = this.velocity.y; - this.velocity.x += this.acceleration.x * delta; - this.velocity.y += this.acceleration.y * delta; - if (this.maxSpeed) { - var currentSpeed = exports.ParticleUtils.length(this.velocity); - //if we are going faster than we should, clamp at the max speed - //DO NOT recalculate vector length - if (currentSpeed > this.maxSpeed) { - exports.ParticleUtils.scaleBy(this.velocity, this.maxSpeed / currentSpeed); - } - } - // calculate position delta by the midpoint between our old velocity and our new velocity - deltaX = (oldVX + this.velocity.x) / 2 * delta; - deltaY = (oldVY + this.velocity.y) / 2 * delta; - } - else { - deltaX = this.velocity.x * delta; - deltaY = this.velocity.y * delta; - } - //adjust position based on velocity - this.position.x += deltaX; - this.position.y += deltaY; - } - //interpolate color - if (this._doColor) { - this.tint = this.colorList.interpolate(lerp); - } - //update rotation - if (this.rotationAcceleration !== 0) { - var newRotationSpeed = this.rotationSpeed + this.rotationAcceleration * delta; - this.rotation += (this.rotationSpeed + newRotationSpeed) / 2 * delta; - this.rotationSpeed = newRotationSpeed; - } - else if (this.rotationSpeed !== 0) { - this.rotation += this.rotationSpeed * delta; - } - else if (this.acceleration && !this.noRotation) { - this.rotation = Math.atan2(this.velocity.y, this.velocity.x); // + Math.PI / 2; - } - return lerp; - }; - /** - * Kills the particle, removing it from the display list - * and telling the emitter to recycle it. - */ - Particle.prototype.kill = function () { - this.emitter.recycle(this); - }; - /** - * Destroys the particle, removing references and preventing future use. - */ - Particle.prototype.destroy = function () { - if (this.parent) - this.parent.removeChild(this); - this.Sprite_destroy(); - this.emitter = this.velocity = this.colorList = this.scaleList = this.alphaList = - this.speedList = this.ease = this.next = this.prev = null; - }; - /** - * Checks over the art that was passed to the Emitter's init() function, to do any special - * modifications to prepare it ahead of time. - * @param art The array of art data. For Particle, it should be an array of - * Textures. Any strings in the array will be converted to - * Textures via Texture.from(). - * @return The art, after any needed modifications. - */ - Particle.parseArt = function (art) { - //convert any strings to Textures. - var i; - for (i = art.length; i >= 0; --i) { - if (typeof art[i] == "string") - art[i] = GetTextureFromString(art[i]); - } - //particles from different base textures will be slower in WebGL than if they - //were from one spritesheet - if (exports.ParticleUtils.verbose) { - for (i = art.length - 1; i > 0; --i) { - if (art[i].baseTexture != art[i - 1].baseTexture) { - if (window.console) - console.warn("PixiParticles: using particle textures from different images may hinder performance in WebGL"); - break; - } - } - } - return art; - }; - /** - * Parses extra emitter data to ensure it is set up for this particle class. - * Particle does nothing to the extra data. - * @param extraData The extra data from the particle config. - * @return The parsed extra data. - */ - Particle.parseData = function (extraData) { - return extraData; - }; - return Particle; + /** + * An individual particle image. You shouldn't have to deal with these. + */ + var Particle = /** @class */ (function (_super) { + __extends(Particle, _super); + /** + * @param {PIXI.particles.Emitter} emitter The emitter that controls this particle. + */ + function Particle(emitter) { + var _this = + //start off the sprite with a blank texture, since we are going to replace it + //later when the particle is initialized. + _super.call(this) || this; + _this.emitter = emitter; + //particles should be centered + _this.anchor.x = _this.anchor.y = 0.5; + _this.velocity = new pixi.Point(); + _this.rotationSpeed = 0; + _this.rotationAcceleration = 0; + _this.maxLife = 0; + _this.age = 0; + _this.ease = null; + _this.extraData = null; + _this.alphaList = new PropertyList(); + _this.speedList = new PropertyList(); + _this.speedMultiplier = 1; + _this.acceleration = new pixi.Point(); + _this.maxSpeed = NaN; + _this.scaleList = new PropertyList(); + _this.scaleMultiplier = 1; + _this.colorList = new PropertyList(true); + _this._doAlpha = false; + _this._doScale = false; + _this._doSpeed = false; + _this._doAcceleration = false; + _this._doColor = false; + _this._doNormalMovement = false; + _this._oneOverLife = 0; + _this.next = null; + _this.prev = null; + //save often used functions on the instance instead of the prototype for better speed + _this.init = _this.init; + _this.Particle_init = Particle.prototype.init; + _this.update = _this.update; + _this.Particle_update = Particle.prototype.update; + _this.Sprite_destroy = _super.prototype.destroy; + _this.Particle_destroy = Particle.prototype.destroy; + _this.applyArt = _this.applyArt; + _this.kill = _this.kill; + return _this; + } + /** + * Initializes the particle for use, based on the properties that have to + * have been set already on the particle. + */ + Particle.prototype.init = function () { + //reset the age + this.age = 0; + //set up the velocity based on the start speed and rotation + this.velocity.x = this.speedList.current.value * this.speedMultiplier; + this.velocity.y = 0; + exports.ParticleUtils.rotatePoint(this.rotation, this.velocity); + if (this.noRotation) { + this.rotation = 0; + } + else { + //convert rotation to Radians from Degrees + this.rotation *= exports.ParticleUtils.DEG_TO_RADS; + } + //convert rotation speed to Radians from Degrees + this.rotationSpeed *= exports.ParticleUtils.DEG_TO_RADS; + this.rotationAcceleration *= exports.ParticleUtils.DEG_TO_RADS; + //set alpha to inital alpha + this.alpha = this.alphaList.current.value; + //set scale to initial scale + this.scale.x = this.scale.y = this.scaleList.current.value; + //figure out what we need to interpolate + this._doAlpha = !!this.alphaList.current.next; + this._doSpeed = !!this.speedList.current.next; + this._doScale = !!this.scaleList.current.next; + this._doColor = !!this.colorList.current.next; + this._doAcceleration = this.acceleration.x !== 0 || this.acceleration.y !== 0; + //_doNormalMovement can be cancelled by subclasses + this._doNormalMovement = this._doSpeed || this.speedList.current.value !== 0 || this._doAcceleration; + //save our lerp helper + this._oneOverLife = 1 / this.maxLife; + //set the inital color + var color = this.colorList.current.value; + this.tint = exports.ParticleUtils.combineRGBComponents(color.r, color.g, color.b); + //ensure visibility + this.visible = true; + }; + /** + * Sets the texture for the particle. This can be overridden to allow + * for an animated particle. + * @param art The texture to set. + */ + Particle.prototype.applyArt = function (art) { + this.texture = art || pixi.Texture.EMPTY; + }; + /** + * Updates the particle. + * @param delta Time elapsed since the previous frame, in __seconds__. + * @return The standard interpolation multiplier (0-1) used for all + * relevant particle properties. A value of -1 means the particle + * died of old age instead. + */ + Particle.prototype.update = function (delta) { + //increase age + this.age += delta; + //recycle particle if it is too old + if (this.age >= this.maxLife || this.age < 0) { + this.kill(); + return -1; + } + //determine our interpolation value + var lerp = this.age * this._oneOverLife; //lifetime / maxLife; + if (this.ease) { + if (this.ease.length == 4) { + //the t, b, c, d parameters that some tween libraries use + //(time, initial value, end value, duration) + lerp = this.ease(lerp, 0, 1, 1); + } + else { + //the simplified version that we like that takes + //one parameter, time from 0-1. TweenJS eases provide this usage. + lerp = this.ease(lerp); + } + } + //interpolate alpha + if (this._doAlpha) + this.alpha = this.alphaList.interpolate(lerp); + //interpolate scale + if (this._doScale) { + var scale = this.scaleList.interpolate(lerp) * this.scaleMultiplier; + this.scale.x = this.scale.y = scale; + } + //handle movement + if (this._doNormalMovement) { + var deltaX = void 0; + var deltaY = void 0; + //interpolate speed + if (this._doSpeed) { + var speed = this.speedList.interpolate(lerp) * this.speedMultiplier; + exports.ParticleUtils.normalize(this.velocity); + exports.ParticleUtils.scaleBy(this.velocity, speed); + deltaX = this.velocity.x * delta; + deltaY = this.velocity.y * delta; + } + else if (this._doAcceleration) { + var oldVX = this.velocity.x; + var oldVY = this.velocity.y; + this.velocity.x += this.acceleration.x * delta; + this.velocity.y += this.acceleration.y * delta; + if (this.maxSpeed) { + var currentSpeed = exports.ParticleUtils.length(this.velocity); + //if we are going faster than we should, clamp at the max speed + //DO NOT recalculate vector length + if (currentSpeed > this.maxSpeed) { + exports.ParticleUtils.scaleBy(this.velocity, this.maxSpeed / currentSpeed); + } + } + // calculate position delta by the midpoint between our old velocity and our new velocity + deltaX = (oldVX + this.velocity.x) / 2 * delta; + deltaY = (oldVY + this.velocity.y) / 2 * delta; + } + else { + deltaX = this.velocity.x * delta; + deltaY = this.velocity.y * delta; + } + //adjust position based on velocity + this.position.x += deltaX; + this.position.y += deltaY; + } + //interpolate color + if (this._doColor) { + this.tint = this.colorList.interpolate(lerp); + } + //update rotation + if (this.rotationAcceleration !== 0) { + var newRotationSpeed = this.rotationSpeed + this.rotationAcceleration * delta; + this.rotation += (this.rotationSpeed + newRotationSpeed) / 2 * delta; + this.rotationSpeed = newRotationSpeed; + } + else if (this.rotationSpeed !== 0) { + this.rotation += this.rotationSpeed * delta; + } + else if (this.acceleration && !this.noRotation) { + this.rotation = Math.atan2(this.velocity.y, this.velocity.x); // + Math.PI / 2; + } + return lerp; + }; + /** + * Kills the particle, removing it from the display list + * and telling the emitter to recycle it. + */ + Particle.prototype.kill = function () { + this.emitter.recycle(this); + }; + /** + * Destroys the particle, removing references and preventing future use. + */ + Particle.prototype.destroy = function () { + if (this.parent) + this.parent.removeChild(this); + this.Sprite_destroy(); + this.emitter = this.velocity = this.colorList = this.scaleList = this.alphaList = + this.speedList = this.ease = this.next = this.prev = null; + }; + /** + * Checks over the art that was passed to the Emitter's init() function, to do any special + * modifications to prepare it ahead of time. + * @param art The array of art data. For Particle, it should be an array of + * Textures. Any strings in the array will be converted to + * Textures via Texture.from(). + * @return The art, after any needed modifications. + */ + Particle.parseArt = function (art) { + //convert any strings to Textures. + var i; + for (i = art.length; i >= 0; --i) { + if (typeof art[i] == "string") + art[i] = GetTextureFromString(art[i]); + } + //particles from different base textures will be slower in WebGL than if they + //were from one spritesheet + if (exports.ParticleUtils.verbose) { + for (i = art.length - 1; i > 0; --i) { + if (art[i].baseTexture != art[i - 1].baseTexture) { + if (window.console) + console.warn("PixiParticles: using particle textures from different images may hinder performance in WebGL"); + break; + } + } + } + return art; + }; + /** + * Parses extra emitter data to ensure it is set up for this particle class. + * Particle does nothing to the extra data. + * @param extraData The extra data from the particle config. + * @return The parsed extra data. + */ + Particle.parseData = function (extraData) { + return extraData; + }; + return Particle; }(pixi.Sprite)); - /** - * Chain of line segments for generating spawn positions. - */ - var PolygonalChain = /** @class */ (function () { - /** - * @param data Point data for polygon chains. Either a list of points for a single chain, or a list of chains. - */ - function PolygonalChain(data) { - this.segments = []; - this.countingLengths = []; - this.totalLength = 0; - this.init(data); - } - /** - * @param data Point data for polygon chains. Either a list of points for a single chain, or a list of chains. - */ - PolygonalChain.prototype.init = function (data) { - // if data is not present, set up a segment of length 0 - if (!data || !data.length) { - this.segments.push({ p1: { x: 0, y: 0 }, p2: { x: 0, y: 0 }, l: 0 }); - } - else { - if (Array.isArray(data[0])) { - // list of segment chains, each defined as a list of points - for (var i = 0; i < data.length; ++i) { - // loop through the chain, connecting points - var chain = data[i]; - var prevPoint = chain[0]; - for (var j = 1; j < chain.length; ++j) { - var second = chain[j]; - this.segments.push({ p1: prevPoint, p2: second, l: 0 }); - prevPoint = second; - } - } - } - else { - var prevPoint = data[0]; - // list of points - for (var i = 1; i < data.length; ++i) { - var second = data[i]; - this.segments.push({ p1: prevPoint, p2: second, l: 0 }); - prevPoint = second; - } - } - } - // now go through our segments to calculate the lengths so that we - // can set up a nice weighted random distribution - for (var i = 0; i < this.segments.length; ++i) { - var _a = this.segments[i], p1 = _a.p1, p2 = _a.p2; - var segLength = Math.sqrt((p2.x - p1.x) * (p2.x - p1.x) + (p2.y - p1.y) * (p2.y - p1.y)); - // save length so we can turn a random number into a 0-1 interpolation value later - this.segments[i].l = segLength; - this.totalLength += segLength; - // keep track of the length so far, counting up - this.countingLengths.push(this.totalLength); - } - }; - /** - * Gets a random point in the chain. - * @param out The point to store the selected position in. - */ - PolygonalChain.prototype.getRandomPoint = function (out) { - // select a random spot in the length of the chain - var rand = Math.random() * this.totalLength; - var chosenSeg; - var lerp; - // if only one segment, it wins - if (this.segments.length === 1) { - chosenSeg = this.segments[0]; - lerp = rand; - } - else { - // otherwise, go through countingLengths until we have determined - // which segment we chose - for (var i = 0; i < this.countingLengths.length; ++i) { - if (rand < this.countingLengths[i]) { - chosenSeg = this.segments[i]; - // set lerp equal to the length into that segment (i.e. the remainder after subtracting all the segments before it) - lerp = i === 0 ? rand : rand - this.countingLengths[i - 1]; - break; - } - } - } - // divide lerp by the segment length, to result in a 0-1 number. - lerp /= chosenSeg.l || 1; - var p1 = chosenSeg.p1, p2 = chosenSeg.p2; - // now calculate the position in the segment that the lerp value represents - out.x = p1.x + lerp * (p2.x - p1.x); - out.y = p1.y + lerp * (p2.y - p1.y); - }; - return PolygonalChain; + /** + * Chain of line segments for generating spawn positions. + */ + var PolygonalChain = /** @class */ (function () { + /** + * @param data Point data for polygon chains. Either a list of points for a single chain, or a list of chains. + */ + function PolygonalChain(data) { + this.segments = []; + this.countingLengths = []; + this.totalLength = 0; + this.init(data); + } + /** + * @param data Point data for polygon chains. Either a list of points for a single chain, or a list of chains. + */ + PolygonalChain.prototype.init = function (data) { + // if data is not present, set up a segment of length 0 + if (!data || !data.length) { + this.segments.push({ p1: { x: 0, y: 0 }, p2: { x: 0, y: 0 }, l: 0 }); + } + else { + if (Array.isArray(data[0])) { + // list of segment chains, each defined as a list of points + for (var i = 0; i < data.length; ++i) { + // loop through the chain, connecting points + var chain = data[i]; + var prevPoint = chain[0]; + for (var j = 1; j < chain.length; ++j) { + var second = chain[j]; + this.segments.push({ p1: prevPoint, p2: second, l: 0 }); + prevPoint = second; + } + } + } + else { + var prevPoint = data[0]; + // list of points + for (var i = 1; i < data.length; ++i) { + var second = data[i]; + this.segments.push({ p1: prevPoint, p2: second, l: 0 }); + prevPoint = second; + } + } + } + // now go through our segments to calculate the lengths so that we + // can set up a nice weighted random distribution + for (var i = 0; i < this.segments.length; ++i) { + var _a = this.segments[i], p1 = _a.p1, p2 = _a.p2; + var segLength = Math.sqrt((p2.x - p1.x) * (p2.x - p1.x) + (p2.y - p1.y) * (p2.y - p1.y)); + // save length so we can turn a random number into a 0-1 interpolation value later + this.segments[i].l = segLength; + this.totalLength += segLength; + // keep track of the length so far, counting up + this.countingLengths.push(this.totalLength); + } + }; + /** + * Gets a random point in the chain. + * @param out The point to store the selected position in. + */ + PolygonalChain.prototype.getRandomPoint = function (out) { + // select a random spot in the length of the chain + var rand = Math.random() * this.totalLength; + var chosenSeg; + var lerp; + // if only one segment, it wins + if (this.segments.length === 1) { + chosenSeg = this.segments[0]; + lerp = rand; + } + else { + // otherwise, go through countingLengths until we have determined + // which segment we chose + for (var i = 0; i < this.countingLengths.length; ++i) { + if (rand < this.countingLengths[i]) { + chosenSeg = this.segments[i]; + // set lerp equal to the length into that segment (i.e. the remainder after subtracting all the segments before it) + lerp = i === 0 ? rand : rand - this.countingLengths[i - 1]; + break; + } + } + } + // divide lerp by the segment length, to result in a 0-1 number. + lerp /= chosenSeg.l || 1; + var p1 = chosenSeg.p1, p2 = chosenSeg.p2; + // now calculate the position in the segment that the lerp value represents + out.x = p1.x + lerp * (p2.x - p1.x); + out.y = p1.y + lerp * (p2.y - p1.y); + }; + return PolygonalChain; }()); - // get the shared ticker, in V4 and V5 friendly methods - /** - * @hidden - */ - var ticker; - // to avoid Rollup transforming our import, save pixi namespace in a variable - var pixiNS$1 = pixi; - if (parseInt(/^(\d+)\./.exec(pixi.VERSION)[1]) < 5) { - ticker = pixiNS$1.ticker.shared; - } - else { - ticker = pixiNS$1.Ticker.shared; - } - /** - * @hidden - */ - var helperPoint = new pixi.Point(); - /** - * A particle emitter. - */ - var Emitter = /** @class */ (function () { - /** - * @param particleParent The container to add the particles to. - * @param particleImages A texture or array of textures to use - * for the particles. Strings will be turned - * into textures via Texture.fromImage(). - * @param config A configuration object containing settings for the emitter. - * @param config.emit If config.emit is explicitly passed as false, the - * Emitter will start disabled. - * @param config.autoUpdate If config.autoUpdate is explicitly passed as - * true, the Emitter will automatically call - * update via the PIXI shared ticker. - */ - function Emitter(particleParent, particleImages, config) { - /** - * A number keeping index of currently applied image. Used to emit arts in order. - */ - this._currentImageIndex = -1; - this._particleConstructor = Particle; - //properties for individual particles - this.particleImages = null; - this.startAlpha = null; - this.startSpeed = null; - this.minimumSpeedMultiplier = 1; - this.acceleration = null; - this.maxSpeed = NaN; - this.startScale = null; - this.minimumScaleMultiplier = 1; - this.startColor = null; - this.minLifetime = 0; - this.maxLifetime = 0; - this.minStartRotation = 0; - this.maxStartRotation = 0; - this.noRotation = false; - this.minRotationSpeed = 0; - this.maxRotationSpeed = 0; - this.particleBlendMode = 0; - this.customEase = null; - this.extraData = null; - //properties for spawning particles - this._frequency = 1; - this.spawnChance = 1; - this.maxParticles = 1000; - this.emitterLifetime = -1; - this.spawnPos = null; - this.spawnType = null; - this._spawnFunc = null; - this.spawnRect = null; - this.spawnCircle = null; - this.spawnPolygonalChain = null; - this.particlesPerWave = 1; - this.particleSpacing = 0; - this.angleStart = 0; - //emitter properties - this.rotation = 0; - this.ownerPos = null; - this._prevEmitterPos = null; - this._prevPosIsValid = false; - this._posChanged = false; - this._parent = null; - this.addAtBack = false; - this.particleCount = 0; - this._emit = false; - this._spawnTimer = 0; - this._emitterLife = -1; - this._activeParticlesFirst = null; - this._activeParticlesLast = null; - this._poolFirst = null; - this._origConfig = null; - this._origArt = null; - this._autoUpdate = false; - this._currentImageIndex = -1; - this._destroyWhenComplete = false; - this._completeCallback = null; - //set the initial parent - this.parent = particleParent; - if (particleImages && config) - this.init(particleImages, config); - //save often used functions on the instance instead of the prototype for better speed - this.recycle = this.recycle; - this.update = this.update; - this.rotate = this.rotate; - this.updateSpawnPos = this.updateSpawnPos; - this.updateOwnerPos = this.updateOwnerPos; - } - Object.defineProperty(Emitter.prototype, "orderedArt", { - /** - * If the emitter is using particle art in order as provided in `particleImages`. - * Effective only when `particleImages` has multiple art options. - * This is particularly useful ensuring that each art shows up once, in case you need to emit a body in an order. - * For example: dragon - [Head, body1, body2, ..., tail] - */ - get: function () { return this._currentImageIndex !== -1; }, - set: function (value) { - this._currentImageIndex = value ? 0 : -1; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Emitter.prototype, "frequency", { - /** - * Time between particle spawns in seconds. If this value is not a number greater than 0, - * it will be set to 1 (particle per second) to prevent infinite loops. - */ - get: function () { return this._frequency; }, - set: function (value) { - //do some error checking to prevent infinite loops - if (typeof value == "number" && value > 0) - this._frequency = value; - else - this._frequency = 1; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Emitter.prototype, "particleConstructor", { - /** - * The constructor used to create new particles. The default is - * the built in Particle class. Setting this will dump any active or - * pooled particles, if the emitter has already been used. - */ - get: function () { return this._particleConstructor; }, - set: function (value) { - if (value != this._particleConstructor) { - this._particleConstructor = value; - //clean up existing particles - this.cleanup(); - //scrap all the particles - for (var particle = this._poolFirst; particle; particle = particle.next) { - particle.destroy(); - } - this._poolFirst = null; - //re-initialize the emitter so that the new constructor can do anything it needs to - if (this._origConfig && this._origArt) - this.init(this._origArt, this._origConfig); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Emitter.prototype, "parent", { - /** - * The container to add particles to. Settings this will dump any active particles. - */ - get: function () { return this._parent; }, - set: function (value) { - this.cleanup(); - this._parent = value; - }, - enumerable: true, - configurable: true - }); - /** - * Sets up the emitter based on the config settings. - * @param art A texture or array of textures to use for the particles. - * @param config A configuration object containing settings for the emitter. - */ - Emitter.prototype.init = function (art, config) { - if (!art || !config) - return; - //clean up any existing particles - this.cleanup(); - //store the original config and particle images, in case we need to re-initialize - //when the particle constructor is changed - this._origConfig = config; - this._origArt = art; - //set up the array of data, also ensuring that it is an array - art = Array.isArray(art) ? art.slice() : [art]; - //run the art through the particle class's parsing function - var partClass = this._particleConstructor; - this.particleImages = partClass.parseArt ? partClass.parseArt(art) : art; - /////////////////////////// - // Particle Properties // - /////////////////////////// - //set up the alpha - if (config.alpha) { - this.startAlpha = PropertyNode.createList(config.alpha); - } - else - this.startAlpha = new PropertyNode(1, 0); - //set up the speed - if (config.speed) { - this.startSpeed = PropertyNode.createList(config.speed); - this.minimumSpeedMultiplier = ('minimumSpeedMultiplier' in config ? config.minimumSpeedMultiplier : config.speed.minimumSpeedMultiplier) || 1; - } - else { - this.minimumSpeedMultiplier = 1; - this.startSpeed = new PropertyNode(0, 0); - } - //set up acceleration - var acceleration = config.acceleration; - if (acceleration && (acceleration.x || acceleration.y)) { - //make sure we disable speed interpolation - this.startSpeed.next = null; - this.acceleration = new pixi.Point(acceleration.x, acceleration.y); - this.maxSpeed = config.maxSpeed || NaN; - } - else - this.acceleration = new pixi.Point(); - //set up the scale - if (config.scale) { - this.startScale = PropertyNode.createList(config.scale); - this.minimumScaleMultiplier = ('minimumScaleMultiplier' in config ? config.minimumScaleMultiplier : config.scale.minimumScaleMultiplier) || 1; - } - else { - this.startScale = new PropertyNode(1, 0); - this.minimumScaleMultiplier = 1; - } - //set up the color - if (config.color) { - this.startColor = PropertyNode.createList(config.color); - } - else { - this.startColor = new PropertyNode({ r: 0xFF, g: 0xFF, b: 0xFF }, 0); - } - //set up the start rotation - if (config.startRotation) { - this.minStartRotation = config.startRotation.min; - this.maxStartRotation = config.startRotation.max; - } - else - this.minStartRotation = this.maxStartRotation = 0; - if (config.noRotation && - (this.minStartRotation || this.maxStartRotation)) { - this.noRotation = !!config.noRotation; - } - else - this.noRotation = false; - //set up the rotation speed - if (config.rotationSpeed) { - this.minRotationSpeed = config.rotationSpeed.min; - this.maxRotationSpeed = config.rotationSpeed.max; - } - else - this.minRotationSpeed = this.maxRotationSpeed = 0; - this.rotationAcceleration = config.rotationAcceleration || 0; - //set up the lifetime - this.minLifetime = config.lifetime.min; - this.maxLifetime = config.lifetime.max; - //get the blend mode - this.particleBlendMode = exports.ParticleUtils.getBlendMode(config.blendMode); - //use the custom ease if provided - if (config.ease) { - this.customEase = typeof config.ease == "function" ? - config.ease : exports.ParticleUtils.generateEase(config.ease); - } - else - this.customEase = null; - //set up the extra data, running it through the particle class's parseData function. - if (partClass.parseData) - this.extraData = partClass.parseData(config.extraData); - else - this.extraData = config.extraData || null; - ////////////////////////// - // Emitter Properties // - ////////////////////////// - //reset spawn type specific settings - this.spawnRect = this.spawnCircle = null; - this.particlesPerWave = 1; - if (config.particlesPerWave && config.particlesPerWave > 1) - this.particlesPerWave = config.particlesPerWave; - this.particleSpacing = 0; - this.angleStart = 0; - //determine the spawn function to use - this.parseSpawnType(config); - //set the spawning frequency - this.frequency = config.frequency; - this.spawnChance = (typeof config.spawnChance === 'number' && config.spawnChance > 0) ? config.spawnChance : 1; - //set the emitter lifetime - this.emitterLifetime = config.emitterLifetime || -1; - //set the max particles - this.maxParticles = config.maxParticles > 0 ? config.maxParticles : 1000; - //determine if we should add the particle at the back of the list or not - this.addAtBack = !!config.addAtBack; - //reset the emitter position and rotation variables - this.rotation = 0; - this.ownerPos = new pixi.Point(); - this.spawnPos = new pixi.Point(config.pos.x, config.pos.y); - this.initAdditional(art, config); - this._prevEmitterPos = this.spawnPos.clone(); - //previous emitter position is invalid and should not be used for interpolation - this._prevPosIsValid = false; - //start emitting - this._spawnTimer = 0; - this.emit = config.emit === undefined ? true : !!config.emit; - this.autoUpdate = !!config.autoUpdate; - this.orderedArt = !!config.orderedArt; - }; - /** - * Sets up additional parameters to the emitter from config settings. - * Using for parsing additional parameters on classes that extend from Emitter - * @param art A texture or array of textures to use for the particles. - * @param config A configuration object containing settings for the emitter. - */ - Emitter.prototype.initAdditional = function (art, config) { - }; - /** - * Parsing emitter spawn type from config settings. - * Place for override and add new kind of spawn type - * @param config A configuration object containing settings for the emitter. - */ - Emitter.prototype.parseSpawnType = function (config) { - var spawnCircle; - switch (config.spawnType) { - case "rect": - this.spawnType = "rect"; - this._spawnFunc = this._spawnRect; - var spawnRect = config.spawnRect; - this.spawnRect = new pixi.Rectangle(spawnRect.x, spawnRect.y, spawnRect.w, spawnRect.h); - break; - case "circle": - this.spawnType = "circle"; - this._spawnFunc = this._spawnCircle; - spawnCircle = config.spawnCircle; - this.spawnCircle = new pixi.Circle(spawnCircle.x, spawnCircle.y, spawnCircle.r); - break; - case "ring": - this.spawnType = "ring"; - this._spawnFunc = this._spawnRing; - spawnCircle = config.spawnCircle; - this.spawnCircle = new pixi.Circle(spawnCircle.x, spawnCircle.y, spawnCircle.r); - this.spawnCircle.minRadius = spawnCircle.minR; - break; - case "burst": - this.spawnType = "burst"; - this._spawnFunc = this._spawnBurst; - this.particleSpacing = config.particleSpacing; - this.angleStart = config.angleStart ? config.angleStart : 0; - break; - case "point": - this.spawnType = "point"; - this._spawnFunc = this._spawnPoint; - break; - case "polygonalChain": - this.spawnType = "polygonalChain"; - this._spawnFunc = this._spawnPolygonalChain; - this.spawnPolygonalChain = new PolygonalChain(config.spawnPolygon); - break; - default: - this.spawnType = "point"; - this._spawnFunc = this._spawnPoint; - break; - } - }; - /** - * Recycles an individual particle. For internal use only. - * @param particle The particle to recycle. - * @internal - */ - Emitter.prototype.recycle = function (particle) { - if (particle.next) - particle.next.prev = particle.prev; - if (particle.prev) - particle.prev.next = particle.next; - if (particle == this._activeParticlesLast) - this._activeParticlesLast = particle.prev; - if (particle == this._activeParticlesFirst) - this._activeParticlesFirst = particle.next; - //add to pool - particle.prev = null; - particle.next = this._poolFirst; - this._poolFirst = particle; - //remove child from display, or make it invisible if it is in a ParticleContainer - if (particle.parent) - particle.parent.removeChild(particle); - //decrease count - --this.particleCount; - }; - /** - * Sets the rotation of the emitter to a new value. - * @param newRot The new rotation, in degrees. - */ - Emitter.prototype.rotate = function (newRot) { - if (this.rotation == newRot) - return; - //caclulate the difference in rotation for rotating spawnPos - var diff = newRot - this.rotation; - this.rotation = newRot; - //rotate spawnPos - exports.ParticleUtils.rotatePoint(diff, this.spawnPos); - //mark the position as having changed - this._posChanged = true; - }; - /** - * Changes the spawn position of the emitter. - * @param x The new x value of the spawn position for the emitter. - * @param y The new y value of the spawn position for the emitter. - */ - Emitter.prototype.updateSpawnPos = function (x, y) { - this._posChanged = true; - this.spawnPos.x = x; - this.spawnPos.y = y; - }; - /** - * Changes the position of the emitter's owner. You should call this if you are adding - * particles to the world container that your emitter's owner is moving around in. - * @param x The new x value of the emitter's owner. - * @param y The new y value of the emitter's owner. - */ - Emitter.prototype.updateOwnerPos = function (x, y) { - this._posChanged = true; - this.ownerPos.x = x; - this.ownerPos.y = y; - }; - /** - * Prevents emitter position interpolation in the next update. - * This should be used if you made a major position change of your emitter's owner - * that was not normal movement. - */ - Emitter.prototype.resetPositionTracking = function () { - this._prevPosIsValid = false; - }; - Object.defineProperty(Emitter.prototype, "emit", { - /** - * If particles should be emitted during update() calls. Setting this to false - * stops new particles from being created, but allows existing ones to die out. - */ - get: function () { return this._emit; }, - set: function (value) { - this._emit = !!value; - this._emitterLife = this.emitterLifetime; - }, - enumerable: true, - configurable: true - }); - ; - Object.defineProperty(Emitter.prototype, "autoUpdate", { - /** - * If the update function is called automatically from the shared ticker. - * Setting this to false requires calling the update function manually. - */ - get: function () { return this._autoUpdate; }, - set: function (value) { - if (this._autoUpdate && !value) { - ticker.remove(this.update, this); - } - else if (!this._autoUpdate && value) { - ticker.add(this.update, this); - } - this._autoUpdate = !!value; - }, - enumerable: true, - configurable: true - }); - /** - * Starts emitting particles, sets autoUpdate to true, and sets up the Emitter to destroy itself - * when particle emission is complete. - * @param callback Callback for when emission is complete (all particles have died off) - */ - Emitter.prototype.playOnceAndDestroy = function (callback) { - this.autoUpdate = true; - this.emit = true; - this._destroyWhenComplete = true; - this._completeCallback = callback; - }; - /** - * Starts emitting particles and optionally calls a callback when particle emission is complete. - * @param callback Callback for when emission is complete (all particles have died off) - */ - Emitter.prototype.playOnce = function (callback) { - this.emit = true; - this._completeCallback = callback; - }; - /** - * Updates all particles spawned by this emitter and emits new ones. - * @param delta Time elapsed since the previous frame, in __seconds__. - */ - Emitter.prototype.update = function (delta) { - if (this._autoUpdate) { - delta = delta / pixi.settings.TARGET_FPMS / 1000; - } - //if we don't have a parent to add particles to, then don't do anything. - //this also works as a isDestroyed check - if (!this._parent) - return; - //update existing particles - var i, particle, next; - for (particle = this._activeParticlesFirst; particle; particle = next) { - next = particle.next; - particle.update(delta); - } - var prevX, prevY; - //if the previous position is valid, store these for later interpolation - if (this._prevPosIsValid) { - prevX = this._prevEmitterPos.x; - prevY = this._prevEmitterPos.y; - } - //store current position of the emitter as local variables - var curX = this.ownerPos.x + this.spawnPos.x; - var curY = this.ownerPos.y + this.spawnPos.y; - //spawn new particles - if (this._emit) { - //decrease spawn timer - this._spawnTimer -= delta < 0 ? 0 : delta; - //while _spawnTimer < 0, we have particles to spawn - while (this._spawnTimer <= 0) { - //determine if the emitter should stop spawning - if (this._emitterLife > 0) { - this._emitterLife -= this._frequency; - if (this._emitterLife <= 0) { - this._spawnTimer = 0; - this._emitterLife = 0; - this.emit = false; - break; - } - } - //determine if we have hit the particle limit - if (this.particleCount >= this.maxParticles) { - this._spawnTimer += this._frequency; - continue; - } - //determine the particle lifetime - var lifetime = void 0; - if (this.minLifetime == this.maxLifetime) - lifetime = this.minLifetime; - else - lifetime = Math.random() * (this.maxLifetime - this.minLifetime) + this.minLifetime; - //only make the particle if it wouldn't immediately destroy itself - if (-this._spawnTimer < lifetime) { - //If the position has changed and this isn't the first spawn, - //interpolate the spawn position - var emitPosX = void 0, emitPosY = void 0; - if (this._prevPosIsValid && this._posChanged) { - //1 - _spawnTimer / delta, but _spawnTimer is negative - var lerp = 1 + this._spawnTimer / delta; - emitPosX = (curX - prevX) * lerp + prevX; - emitPosY = (curY - prevY) * lerp + prevY; - } - else //otherwise just set to the spawn position - { - emitPosX = curX; - emitPosY = curY; - } - //create enough particles to fill the wave (non-burst types have a wave of 1) - i = 0; - for (var len = Math.min(this.particlesPerWave, this.maxParticles - this.particleCount); i < len; ++i) { - //see if we actually spawn one - if (this.spawnChance < 1 && Math.random() >= this.spawnChance) - continue; - //create particle - var p = void 0; - if (this._poolFirst) { - p = this._poolFirst; - this._poolFirst = this._poolFirst.next; - p.next = null; - } - else { - p = new this.particleConstructor(this); - } - //set a random texture if we have more than one - if (this.particleImages.length > 1) { - // if using ordered art - if (this._currentImageIndex !== -1) { - // get current art index, then increment for the next particle - p.applyArt(this.particleImages[this._currentImageIndex++]); - // loop around if needed - if (this._currentImageIndex < 0 || this._currentImageIndex >= this.particleImages.length) { - this._currentImageIndex = 0; - } - } - // otherwise grab a random one - else { - p.applyArt(this.particleImages[Math.floor(Math.random() * this.particleImages.length)]); - } - } - else { - //if they are actually the same texture, a standard particle - //will quit early from the texture setting in setTexture(). - p.applyArt(this.particleImages[0]); - } - //set up the start and end values - p.alphaList.reset(this.startAlpha); - if (this.minimumSpeedMultiplier != 1) { - p.speedMultiplier = Math.random() * (1 - this.minimumSpeedMultiplier) + this.minimumSpeedMultiplier; - } - p.speedList.reset(this.startSpeed); - p.acceleration.x = this.acceleration.x; - p.acceleration.y = this.acceleration.y; - p.maxSpeed = this.maxSpeed; - if (this.minimumScaleMultiplier != 1) { - p.scaleMultiplier = Math.random() * (1 - this.minimumScaleMultiplier) + this.minimumScaleMultiplier; - } - p.scaleList.reset(this.startScale); - p.colorList.reset(this.startColor); - //randomize the rotation speed - if (this.minRotationSpeed == this.maxRotationSpeed) - p.rotationSpeed = this.minRotationSpeed; - else - p.rotationSpeed = Math.random() * (this.maxRotationSpeed - this.minRotationSpeed) + this.minRotationSpeed; - p.rotationAcceleration = this.rotationAcceleration; - p.noRotation = this.noRotation; - //set up the lifetime - p.maxLife = lifetime; - //set the blend mode - p.blendMode = this.particleBlendMode; - //set the custom ease, if any - p.ease = this.customEase; - //set the extra data, if any - p.extraData = this.extraData; - //set additional properties to particle - this.applyAdditionalProperties(p); - //call the proper function to handle rotation and position of particle - this._spawnFunc(p, emitPosX, emitPosY, i); - //initialize particle - p.init(); - //update the particle by the time passed, so the particles are spread out properly - p.update(-this._spawnTimer); //we want a positive delta, because a negative delta messes things up - //add the particle to the display list - if (!p.parent) { - if (this.addAtBack) - this._parent.addChildAt(p, 0); - else - this._parent.addChild(p); - } - else { - //kind of hacky, but performance friendly - //shuffle children to correct place - var children = this._parent.children; - //avoid using splice if possible - if (children[0] == p) - children.shift(); - else if (children[children.length - 1] == p) - children.pop(); - else { - var index = children.indexOf(p); - children.splice(index, 1); - } - if (this.addAtBack) - children.unshift(p); - else - children.push(p); - } - //add particle to list of active particles - if (this._activeParticlesLast) { - this._activeParticlesLast.next = p; - p.prev = this._activeParticlesLast; - this._activeParticlesLast = p; - } - else { - this._activeParticlesLast = this._activeParticlesFirst = p; - } - ++this.particleCount; - } - } - //increase timer and continue on to any other particles that need to be created - this._spawnTimer += this._frequency; - } - } - //if the position changed before this update, then keep track of that - if (this._posChanged) { - this._prevEmitterPos.x = curX; - this._prevEmitterPos.y = curY; - this._prevPosIsValid = true; - this._posChanged = false; - } - //if we are all done and should destroy ourselves, take care of that - if (!this._emit && !this._activeParticlesFirst) { - if (this._completeCallback) { - var cb = this._completeCallback; - this._completeCallback = null; - cb(); - } - if (this._destroyWhenComplete) { - this.destroy(); - } - } - }; - /** - * Set additional properties to new particle. - * Using on classes that extend from Emitter - * @param p The particle - */ - Emitter.prototype.applyAdditionalProperties = function (p) { - }; - /** - * Positions a particle for a point type emitter. - * @param p The particle to position and rotate. - * @param emitPosX The emitter's x position - * @param emitPosY The emitter's y position - * @param i The particle number in the current wave. Not used for this function. - */ - Emitter.prototype._spawnPoint = function (p, emitPosX, emitPosY) { - //set the initial rotation/direction of the particle based on - //starting particle angle and rotation of emitter - if (this.minStartRotation == this.maxStartRotation) - p.rotation = this.minStartRotation + this.rotation; - else - p.rotation = Math.random() * (this.maxStartRotation - this.minStartRotation) + this.minStartRotation + this.rotation; - //drop the particle at the emitter's position - p.position.x = emitPosX; - p.position.y = emitPosY; - }; - /** - * Positions a particle for a rectangle type emitter. - * @param p The particle to position and rotate. - * @param emitPosX The emitter's x position - * @param emitPosY The emitter's y position - * @param i The particle number in the current wave. Not used for this function. - */ - Emitter.prototype._spawnRect = function (p, emitPosX, emitPosY) { - //set the initial rotation/direction of the particle based on starting - //particle angle and rotation of emitter - if (this.minStartRotation == this.maxStartRotation) - p.rotation = this.minStartRotation + this.rotation; - else - p.rotation = Math.random() * (this.maxStartRotation - this.minStartRotation) + this.minStartRotation + this.rotation; - //place the particle at a random point in the rectangle - helperPoint.x = Math.random() * this.spawnRect.width + this.spawnRect.x; - helperPoint.y = Math.random() * this.spawnRect.height + this.spawnRect.y; - if (this.rotation !== 0) - exports.ParticleUtils.rotatePoint(this.rotation, helperPoint); - p.position.x = emitPosX + helperPoint.x; - p.position.y = emitPosY + helperPoint.y; - }; - /** - * Positions a particle for a circle type emitter. - * @param p The particle to position and rotate. - * @param emitPosX The emitter's x position - * @param emitPosY The emitter's y position - * @param i The particle number in the current wave. Not used for this function. - */ - Emitter.prototype._spawnCircle = function (p, emitPosX, emitPosY) { - //set the initial rotation/direction of the particle based on starting - //particle angle and rotation of emitter - if (this.minStartRotation == this.maxStartRotation) - p.rotation = this.minStartRotation + this.rotation; - else - p.rotation = Math.random() * (this.maxStartRotation - this.minStartRotation) + - this.minStartRotation + this.rotation; - //place the particle at a random radius in the circle - helperPoint.x = Math.random() * this.spawnCircle.radius; - helperPoint.y = 0; - //rotate the point to a random angle in the circle - exports.ParticleUtils.rotatePoint(Math.random() * 360, helperPoint); - //offset by the circle's center - helperPoint.x += this.spawnCircle.x; - helperPoint.y += this.spawnCircle.y; - //rotate the point by the emitter's rotation - if (this.rotation !== 0) - exports.ParticleUtils.rotatePoint(this.rotation, helperPoint); - //set the position, offset by the emitter's position - p.position.x = emitPosX + helperPoint.x; - p.position.y = emitPosY + helperPoint.y; - }; - /** - * Positions a particle for a ring type emitter. - * @param p The particle to position and rotate. - * @param emitPosX The emitter's x position - * @param emitPosY The emitter's y position - * @param i The particle number in the current wave. Not used for this function. - */ - Emitter.prototype._spawnRing = function (p, emitPosX, emitPosY) { - var spawnCircle = this.spawnCircle; - //set the initial rotation/direction of the particle based on starting - //particle angle and rotation of emitter - if (this.minStartRotation == this.maxStartRotation) - p.rotation = this.minStartRotation + this.rotation; - else - p.rotation = Math.random() * (this.maxStartRotation - this.minStartRotation) + - this.minStartRotation + this.rotation; - //place the particle at a random radius in the ring - if (spawnCircle.minRadius !== spawnCircle.radius) { - helperPoint.x = Math.random() * (spawnCircle.radius - spawnCircle.minRadius) + - spawnCircle.minRadius; - } - else - helperPoint.x = spawnCircle.radius; - helperPoint.y = 0; - //rotate the point to a random angle in the circle - var angle = Math.random() * 360; - p.rotation += angle; - exports.ParticleUtils.rotatePoint(angle, helperPoint); - //offset by the circle's center - helperPoint.x += this.spawnCircle.x; - helperPoint.y += this.spawnCircle.y; - //rotate the point by the emitter's rotation - if (this.rotation !== 0) - exports.ParticleUtils.rotatePoint(this.rotation, helperPoint); - //set the position, offset by the emitter's position - p.position.x = emitPosX + helperPoint.x; - p.position.y = emitPosY + helperPoint.y; - }; - /** - * Positions a particle for polygonal chain. - * @param p The particle to position and rotate. - * @param emitPosX The emitter's x position - * @param emitPosY The emitter's y position - * @param i The particle number in the current wave. Not used for this function. - */ - Emitter.prototype._spawnPolygonalChain = function (p, emitPosX, emitPosY) { - //set the initial rotation/direction of the particle based on starting - //particle angle and rotation of emitter - if (this.minStartRotation == this.maxStartRotation) - p.rotation = this.minStartRotation + this.rotation; - else - p.rotation = Math.random() * (this.maxStartRotation - this.minStartRotation) + - this.minStartRotation + this.rotation; - // get random point on the polygon chain - this.spawnPolygonalChain.getRandomPoint(helperPoint); - //rotate the point by the emitter's rotation - if (this.rotation !== 0) - exports.ParticleUtils.rotatePoint(this.rotation, helperPoint); - //set the position, offset by the emitter's position - p.position.x = emitPosX + helperPoint.x; - p.position.y = emitPosY + helperPoint.y; - }; - /** - * Positions a particle for a burst type emitter. - * @param p The particle to position and rotate. - * @param emitPosX The emitter's x position - * @param emitPosY The emitter's y position - * @param i The particle number in the current wave. - */ - Emitter.prototype._spawnBurst = function (p, emitPosX, emitPosY, i) { - //set the initial rotation/direction of the particle based on spawn - //angle and rotation of emitter - if (this.particleSpacing === 0) - p.rotation = Math.random() * 360; - else - p.rotation = this.angleStart + (this.particleSpacing * i) + this.rotation; - //drop the particle at the emitter's position - p.position.x = emitPosX; - p.position.y = emitPosY; - }; - /** - * Kills all active particles immediately. - */ - Emitter.prototype.cleanup = function () { - var particle, next; - for (particle = this._activeParticlesFirst; particle; particle = next) { - next = particle.next; - this.recycle(particle); - if (particle.parent) - particle.parent.removeChild(particle); - } - this._activeParticlesFirst = this._activeParticlesLast = null; - this.particleCount = 0; - }; - /** - * Destroys the emitter and all of its particles. - */ - Emitter.prototype.destroy = function () { - //make sure we aren't still listening to any tickers - this.autoUpdate = false; - //puts all active particles in the pool, and removes them from the particle parent - this.cleanup(); - //wipe the pool clean - var next; - for (var particle = this._poolFirst; particle; particle = next) { - //store next value so we don't lose it in our destroy call - next = particle.next; - particle.destroy(); - } - this._poolFirst = this._parent = this.particleImages = this.spawnPos = this.ownerPos = - this.startColor = this.startScale = this.startAlpha = this.startSpeed = - this.customEase = this._completeCallback = null; - }; - return Emitter; + // get the shared ticker, in V4 and V5 friendly methods + /** + * @hidden + */ + var ticker; + // to avoid Rollup transforming our import, save pixi namespace in a variable + var pixiNS$1 = pixi; + if (parseInt(/^(\d+)\./.exec(pixi.VERSION)[1]) < 5) { + ticker = pixiNS$1.ticker.shared; + } + else { + ticker = pixiNS$1.Ticker.shared; + } + /** + * @hidden + */ + var helperPoint = new pixi.Point(); + /** + * A particle emitter. + */ + var Emitter = /** @class */ (function () { + /** + * @param particleParent The container to add the particles to. + * @param particleImages A texture or array of textures to use + * for the particles. Strings will be turned + * into textures via Texture.fromImage(). + * @param config A configuration object containing settings for the emitter. + * @param config.emit If config.emit is explicitly passed as false, the + * Emitter will start disabled. + * @param config.autoUpdate If config.autoUpdate is explicitly passed as + * true, the Emitter will automatically call + * update via the PIXI shared ticker. + */ + function Emitter(particleParent, particleImages, config) { + /** + * A number keeping index of currently applied image. Used to emit arts in order. + */ + this._currentImageIndex = -1; + this._particleConstructor = Particle; + //properties for individual particles + this.particleImages = null; + this.startAlpha = null; + this.startSpeed = null; + this.minimumSpeedMultiplier = 1; + this.acceleration = null; + this.maxSpeed = NaN; + this.startScale = null; + this.minimumScaleMultiplier = 1; + this.startColor = null; + this.minLifetime = 0; + this.maxLifetime = 0; + this.minStartRotation = 0; + this.maxStartRotation = 0; + this.noRotation = false; + this.minRotationSpeed = 0; + this.maxRotationSpeed = 0; + this.particleBlendMode = 0; + this.customEase = null; + this.extraData = null; + //properties for spawning particles + this._frequency = 1; + this.spawnChance = 1; + this.maxParticles = 1000; + this.emitterLifetime = -1; + this.spawnPos = null; + this.spawnType = null; + this._spawnFunc = null; + this.spawnRect = null; + this.spawnCircle = null; + this.spawnPolygonalChain = null; + this.particlesPerWave = 1; + this.particleSpacing = 0; + this.angleStart = 0; + //emitter properties + this.rotation = 0; + this.ownerPos = null; + this._prevEmitterPos = null; + this._prevPosIsValid = false; + this._posChanged = false; + this._parent = null; + this.addAtBack = false; + this.particleCount = 0; + this._emit = false; + this._spawnTimer = 0; + this._emitterLife = -1; + this._activeParticlesFirst = null; + this._activeParticlesLast = null; + this._poolFirst = null; + this._origConfig = null; + this._origArt = null; + this._autoUpdate = false; + this._currentImageIndex = -1; + this._destroyWhenComplete = false; + this._completeCallback = null; + //set the initial parent + this.parent = particleParent; + if (particleImages && config) + this.init(particleImages, config); + //save often used functions on the instance instead of the prototype for better speed + this.recycle = this.recycle; + this.update = this.update; + this.rotate = this.rotate; + this.updateSpawnPos = this.updateSpawnPos; + this.updateOwnerPos = this.updateOwnerPos; + } + Object.defineProperty(Emitter.prototype, "orderedArt", { + /** + * If the emitter is using particle art in order as provided in `particleImages`. + * Effective only when `particleImages` has multiple art options. + * This is particularly useful ensuring that each art shows up once, in case you need to emit a body in an order. + * For example: dragon - [Head, body1, body2, ..., tail] + */ + get: function () { return this._currentImageIndex !== -1; }, + set: function (value) { + this._currentImageIndex = value ? 0 : -1; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Emitter.prototype, "frequency", { + /** + * Time between particle spawns in seconds. If this value is not a number greater than 0, + * it will be set to 1 (particle per second) to prevent infinite loops. + */ + get: function () { return this._frequency; }, + set: function (value) { + //do some error checking to prevent infinite loops + if (typeof value == "number" && value > 0) + this._frequency = value; + else + this._frequency = 1; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Emitter.prototype, "particleConstructor", { + /** + * The constructor used to create new particles. The default is + * the built in Particle class. Setting this will dump any active or + * pooled particles, if the emitter has already been used. + */ + get: function () { return this._particleConstructor; }, + set: function (value) { + if (value != this._particleConstructor) { + this._particleConstructor = value; + //clean up existing particles + this.cleanup(); + //scrap all the particles + for (var particle = this._poolFirst; particle; particle = particle.next) { + particle.destroy(); + } + this._poolFirst = null; + //re-initialize the emitter so that the new constructor can do anything it needs to + if (this._origConfig && this._origArt) + this.init(this._origArt, this._origConfig); + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Emitter.prototype, "parent", { + /** + * The container to add particles to. Settings this will dump any active particles. + */ + get: function () { return this._parent; }, + set: function (value) { + this.cleanup(); + this._parent = value; + }, + enumerable: true, + configurable: true + }); + /** + * Sets up the emitter based on the config settings. + * @param art A texture or array of textures to use for the particles. + * @param config A configuration object containing settings for the emitter. + */ + Emitter.prototype.init = function (art, config) { + if (!art || !config) + return; + //clean up any existing particles + this.cleanup(); + //store the original config and particle images, in case we need to re-initialize + //when the particle constructor is changed + this._origConfig = config; + this._origArt = art; + //set up the array of data, also ensuring that it is an array + art = Array.isArray(art) ? art.slice() : [art]; + //run the art through the particle class's parsing function + var partClass = this._particleConstructor; + this.particleImages = partClass.parseArt ? partClass.parseArt(art) : art; + /////////////////////////// + // Particle Properties // + /////////////////////////// + //set up the alpha + if (config.alpha) { + this.startAlpha = PropertyNode.createList(config.alpha); + } + else + this.startAlpha = new PropertyNode(1, 0); + //set up the speed + if (config.speed) { + this.startSpeed = PropertyNode.createList(config.speed); + this.minimumSpeedMultiplier = ('minimumSpeedMultiplier' in config ? config.minimumSpeedMultiplier : config.speed.minimumSpeedMultiplier) || 1; + } + else { + this.minimumSpeedMultiplier = 1; + this.startSpeed = new PropertyNode(0, 0); + } + //set up acceleration + var acceleration = config.acceleration; + if (acceleration && (acceleration.x || acceleration.y)) { + //make sure we disable speed interpolation + this.startSpeed.next = null; + this.acceleration = new pixi.Point(acceleration.x, acceleration.y); + this.maxSpeed = config.maxSpeed || NaN; + } + else + this.acceleration = new pixi.Point(); + //set up the scale + if (config.scale) { + this.startScale = PropertyNode.createList(config.scale); + this.minimumScaleMultiplier = ('minimumScaleMultiplier' in config ? config.minimumScaleMultiplier : config.scale.minimumScaleMultiplier) || 1; + } + else { + this.startScale = new PropertyNode(1, 0); + this.minimumScaleMultiplier = 1; + } + //set up the color + if (config.color) { + this.startColor = PropertyNode.createList(config.color); + } + else { + this.startColor = new PropertyNode({ r: 0xFF, g: 0xFF, b: 0xFF }, 0); + } + //set up the start rotation + if (config.startRotation) { + this.minStartRotation = config.startRotation.min; + this.maxStartRotation = config.startRotation.max; + } + else + this.minStartRotation = this.maxStartRotation = 0; + if (config.noRotation && + (this.minStartRotation || this.maxStartRotation)) { + this.noRotation = !!config.noRotation; + } + else + this.noRotation = false; + //set up the rotation speed + if (config.rotationSpeed) { + this.minRotationSpeed = config.rotationSpeed.min; + this.maxRotationSpeed = config.rotationSpeed.max; + } + else + this.minRotationSpeed = this.maxRotationSpeed = 0; + this.rotationAcceleration = config.rotationAcceleration || 0; + //set up the lifetime + this.minLifetime = config.lifetime.min; + this.maxLifetime = config.lifetime.max; + //get the blend mode + this.particleBlendMode = exports.ParticleUtils.getBlendMode(config.blendMode); + //use the custom ease if provided + if (config.ease) { + this.customEase = typeof config.ease == "function" ? + config.ease : exports.ParticleUtils.generateEase(config.ease); + } + else + this.customEase = null; + //set up the extra data, running it through the particle class's parseData function. + if (partClass.parseData) + this.extraData = partClass.parseData(config.extraData); + else + this.extraData = config.extraData || null; + ////////////////////////// + // Emitter Properties // + ////////////////////////// + //reset spawn type specific settings + this.spawnRect = this.spawnCircle = null; + this.particlesPerWave = 1; + if (config.particlesPerWave && config.particlesPerWave > 1) + this.particlesPerWave = config.particlesPerWave; + this.particleSpacing = 0; + this.angleStart = 0; + //determine the spawn function to use + this.parseSpawnType(config); + //set the spawning frequency + this.frequency = config.frequency; + this.spawnChance = (typeof config.spawnChance === 'number' && config.spawnChance > 0) ? config.spawnChance : 1; + //set the emitter lifetime + this.emitterLifetime = config.emitterLifetime || -1; + //set the max particles + this.maxParticles = config.maxParticles > 0 ? config.maxParticles : 1000; + //determine if we should add the particle at the back of the list or not + this.addAtBack = !!config.addAtBack; + //reset the emitter position and rotation variables + this.rotation = 0; + this.ownerPos = new pixi.Point(); + this.spawnPos = new pixi.Point(config.pos.x, config.pos.y); + this.initAdditional(art, config); + this._prevEmitterPos = this.spawnPos.clone(); + //previous emitter position is invalid and should not be used for interpolation + this._prevPosIsValid = false; + //start emitting + this._spawnTimer = 0; + this.emit = config.emit === undefined ? true : !!config.emit; + this.autoUpdate = !!config.autoUpdate; + this.orderedArt = !!config.orderedArt; + }; + /** + * Sets up additional parameters to the emitter from config settings. + * Using for parsing additional parameters on classes that extend from Emitter + * @param art A texture or array of textures to use for the particles. + * @param config A configuration object containing settings for the emitter. + */ + Emitter.prototype.initAdditional = function (art, config) { + }; + /** + * Parsing emitter spawn type from config settings. + * Place for override and add new kind of spawn type + * @param config A configuration object containing settings for the emitter. + */ + Emitter.prototype.parseSpawnType = function (config) { + var spawnCircle; + switch (config.spawnType) { + case "rect": + this.spawnType = "rect"; + this._spawnFunc = this._spawnRect; + var spawnRect = config.spawnRect; + this.spawnRect = new pixi.Rectangle(spawnRect.x, spawnRect.y, spawnRect.w, spawnRect.h); + break; + case "circle": + this.spawnType = "circle"; + this._spawnFunc = this._spawnCircle; + spawnCircle = config.spawnCircle; + this.spawnCircle = new pixi.Circle(spawnCircle.x, spawnCircle.y, spawnCircle.r); + break; + case "ring": + this.spawnType = "ring"; + this._spawnFunc = this._spawnRing; + spawnCircle = config.spawnCircle; + this.spawnCircle = new pixi.Circle(spawnCircle.x, spawnCircle.y, spawnCircle.r); + this.spawnCircle.minRadius = spawnCircle.minR; + break; + case "burst": + this.spawnType = "burst"; + this._spawnFunc = this._spawnBurst; + this.particleSpacing = config.particleSpacing; + this.angleStart = config.angleStart ? config.angleStart : 0; + break; + case "point": + this.spawnType = "point"; + this._spawnFunc = this._spawnPoint; + break; + case "polygonalChain": + this.spawnType = "polygonalChain"; + this._spawnFunc = this._spawnPolygonalChain; + this.spawnPolygonalChain = new PolygonalChain(config.spawnPolygon); + break; + default: + this.spawnType = "point"; + this._spawnFunc = this._spawnPoint; + break; + } + }; + /** + * Recycles an individual particle. For internal use only. + * @param particle The particle to recycle. + * @internal + */ + Emitter.prototype.recycle = function (particle) { + if (particle.next) + particle.next.prev = particle.prev; + if (particle.prev) + particle.prev.next = particle.next; + if (particle == this._activeParticlesLast) + this._activeParticlesLast = particle.prev; + if (particle == this._activeParticlesFirst) + this._activeParticlesFirst = particle.next; + //add to pool + particle.prev = null; + particle.next = this._poolFirst; + this._poolFirst = particle; + //remove child from display, or make it invisible if it is in a ParticleContainer + if (particle.parent) + particle.parent.removeChild(particle); + //decrease count + --this.particleCount; + }; + /** + * Sets the rotation of the emitter to a new value. + * @param newRot The new rotation, in degrees. + */ + Emitter.prototype.rotate = function (newRot) { + if (this.rotation == newRot) + return; + //caclulate the difference in rotation for rotating spawnPos + var diff = newRot - this.rotation; + this.rotation = newRot; + //rotate spawnPos + exports.ParticleUtils.rotatePoint(diff, this.spawnPos); + //mark the position as having changed + this._posChanged = true; + }; + /** + * Changes the spawn position of the emitter. + * @param x The new x value of the spawn position for the emitter. + * @param y The new y value of the spawn position for the emitter. + */ + Emitter.prototype.updateSpawnPos = function (x, y) { + this._posChanged = true; + this.spawnPos.x = x; + this.spawnPos.y = y; + }; + /** + * Changes the position of the emitter's owner. You should call this if you are adding + * particles to the world container that your emitter's owner is moving around in. + * @param x The new x value of the emitter's owner. + * @param y The new y value of the emitter's owner. + */ + Emitter.prototype.updateOwnerPos = function (x, y) { + this._posChanged = true; + this.ownerPos.x = x; + this.ownerPos.y = y; + }; + /** + * Prevents emitter position interpolation in the next update. + * This should be used if you made a major position change of your emitter's owner + * that was not normal movement. + */ + Emitter.prototype.resetPositionTracking = function () { + this._prevPosIsValid = false; + }; + Object.defineProperty(Emitter.prototype, "emit", { + /** + * If particles should be emitted during update() calls. Setting this to false + * stops new particles from being created, but allows existing ones to die out. + */ + get: function () { return this._emit; }, + set: function (value) { + this._emit = !!value; + this._emitterLife = this.emitterLifetime; + }, + enumerable: true, + configurable: true + }); + ; + Object.defineProperty(Emitter.prototype, "autoUpdate", { + /** + * If the update function is called automatically from the shared ticker. + * Setting this to false requires calling the update function manually. + */ + get: function () { return this._autoUpdate; }, + set: function (value) { + if (this._autoUpdate && !value) { + ticker.remove(this.update, this); + } + else if (!this._autoUpdate && value) { + ticker.add(this.update, this); + } + this._autoUpdate = !!value; + }, + enumerable: true, + configurable: true + }); + /** + * Starts emitting particles, sets autoUpdate to true, and sets up the Emitter to destroy itself + * when particle emission is complete. + * @param callback Callback for when emission is complete (all particles have died off) + */ + Emitter.prototype.playOnceAndDestroy = function (callback) { + this.autoUpdate = true; + this.emit = true; + this._destroyWhenComplete = true; + this._completeCallback = callback; + }; + /** + * Starts emitting particles and optionally calls a callback when particle emission is complete. + * @param callback Callback for when emission is complete (all particles have died off) + */ + Emitter.prototype.playOnce = function (callback) { + this.emit = true; + this._completeCallback = callback; + }; + /** + * Updates all particles spawned by this emitter and emits new ones. + * @param delta Time elapsed since the previous frame, in __seconds__. + */ + Emitter.prototype.update = function (delta) { + if (this._autoUpdate) { + delta = delta / pixi.settings.TARGET_FPMS / 1000; + } + //if we don't have a parent to add particles to, then don't do anything. + //this also works as a isDestroyed check + if (!this._parent) + return; + //update existing particles + var i, particle, next; + for (particle = this._activeParticlesFirst; particle; particle = next) { + next = particle.next; + particle.update(delta); + } + var prevX, prevY; + //if the previous position is valid, store these for later interpolation + if (this._prevPosIsValid) { + prevX = this._prevEmitterPos.x; + prevY = this._prevEmitterPos.y; + } + //store current position of the emitter as local variables + var curX = this.ownerPos.x + this.spawnPos.x; + var curY = this.ownerPos.y + this.spawnPos.y; + //spawn new particles + if (this._emit) { + //decrease spawn timer + this._spawnTimer -= delta < 0 ? 0 : delta; + //while _spawnTimer < 0, we have particles to spawn + while (this._spawnTimer <= 0) { + //determine if the emitter should stop spawning + if (this._emitterLife > 0) { + this._emitterLife -= this._frequency; + if (this._emitterLife <= 0) { + this._spawnTimer = 0; + this._emitterLife = 0; + this.emit = false; + break; + } + } + //determine if we have hit the particle limit + if (this.particleCount >= this.maxParticles) { + this._spawnTimer += this._frequency; + continue; + } + //determine the particle lifetime + var lifetime = void 0; + if (this.minLifetime == this.maxLifetime) + lifetime = this.minLifetime; + else + lifetime = Math.random() * (this.maxLifetime - this.minLifetime) + this.minLifetime; + //only make the particle if it wouldn't immediately destroy itself + if (-this._spawnTimer < lifetime) { + //If the position has changed and this isn't the first spawn, + //interpolate the spawn position + var emitPosX = void 0, emitPosY = void 0; + if (this._prevPosIsValid && this._posChanged) { + //1 - _spawnTimer / delta, but _spawnTimer is negative + var lerp = 1 + this._spawnTimer / delta; + emitPosX = (curX - prevX) * lerp + prevX; + emitPosY = (curY - prevY) * lerp + prevY; + } + else //otherwise just set to the spawn position + { + emitPosX = curX; + emitPosY = curY; + } + //create enough particles to fill the wave (non-burst types have a wave of 1) + i = 0; + for (var len = Math.min(this.particlesPerWave, this.maxParticles - this.particleCount); i < len; ++i) { + //see if we actually spawn one + if (this.spawnChance < 1 && Math.random() >= this.spawnChance) + continue; + //create particle + var p = void 0; + if (this._poolFirst) { + p = this._poolFirst; + this._poolFirst = this._poolFirst.next; + p.next = null; + } + else { + p = new this.particleConstructor(this); + } + //set a random texture if we have more than one + if (this.particleImages.length > 1) { + // if using ordered art + if (this._currentImageIndex !== -1) { + // get current art index, then increment for the next particle + p.applyArt(this.particleImages[this._currentImageIndex++]); + // loop around if needed + if (this._currentImageIndex < 0 || this._currentImageIndex >= this.particleImages.length) { + this._currentImageIndex = 0; + } + } + // otherwise grab a random one + else { + p.applyArt(this.particleImages[Math.floor(Math.random() * this.particleImages.length)]); + } + } + else { + //if they are actually the same texture, a standard particle + //will quit early from the texture setting in setTexture(). + p.applyArt(this.particleImages[0]); + } + //set up the start and end values + p.alphaList.reset(this.startAlpha); + if (this.minimumSpeedMultiplier != 1) { + p.speedMultiplier = Math.random() * (1 - this.minimumSpeedMultiplier) + this.minimumSpeedMultiplier; + } + p.speedList.reset(this.startSpeed); + p.acceleration.x = this.acceleration.x; + p.acceleration.y = this.acceleration.y; + p.maxSpeed = this.maxSpeed; + if (this.minimumScaleMultiplier != 1) { + p.scaleMultiplier = Math.random() * (1 - this.minimumScaleMultiplier) + this.minimumScaleMultiplier; + } + p.scaleList.reset(this.startScale); + p.colorList.reset(this.startColor); + //randomize the rotation speed + if (this.minRotationSpeed == this.maxRotationSpeed) + p.rotationSpeed = this.minRotationSpeed; + else + p.rotationSpeed = Math.random() * (this.maxRotationSpeed - this.minRotationSpeed) + this.minRotationSpeed; + p.rotationAcceleration = this.rotationAcceleration; + p.noRotation = this.noRotation; + //set up the lifetime + p.maxLife = lifetime; + //set the blend mode + p.blendMode = this.particleBlendMode; + //set the custom ease, if any + p.ease = this.customEase; + //set the extra data, if any + p.extraData = this.extraData; + //set additional properties to particle + this.applyAdditionalProperties(p); + //call the proper function to handle rotation and position of particle + this._spawnFunc(p, emitPosX, emitPosY, i); + //initialize particle + p.init(); + //update the particle by the time passed, so the particles are spread out properly + p.update(-this._spawnTimer); //we want a positive delta, because a negative delta messes things up + //add the particle to the display list + if (!p.parent) { + if (this.addAtBack) + this._parent.addChildAt(p, 0); + else + this._parent.addChild(p); + } + else { + //kind of hacky, but performance friendly + //shuffle children to correct place + var children = this._parent.children; + //avoid using splice if possible + if (children[0] == p) + children.shift(); + else if (children[children.length - 1] == p) + children.pop(); + else { + var index = children.indexOf(p); + children.splice(index, 1); + } + if (this.addAtBack) + children.unshift(p); + else + children.push(p); + } + //add particle to list of active particles + if (this._activeParticlesLast) { + this._activeParticlesLast.next = p; + p.prev = this._activeParticlesLast; + this._activeParticlesLast = p; + } + else { + this._activeParticlesLast = this._activeParticlesFirst = p; + } + ++this.particleCount; + } + } + //increase timer and continue on to any other particles that need to be created + this._spawnTimer += this._frequency; + } + } + //if the position changed before this update, then keep track of that + if (this._posChanged) { + this._prevEmitterPos.x = curX; + this._prevEmitterPos.y = curY; + this._prevPosIsValid = true; + this._posChanged = false; + } + //if we are all done and should destroy ourselves, take care of that + if (!this._emit && !this._activeParticlesFirst) { + if (this._completeCallback) { + var cb = this._completeCallback; + this._completeCallback = null; + cb(); + } + if (this._destroyWhenComplete) { + this.destroy(); + } + } + }; + /** + * Set additional properties to new particle. + * Using on classes that extend from Emitter + * @param p The particle + */ + Emitter.prototype.applyAdditionalProperties = function (p) { + }; + /** + * Positions a particle for a point type emitter. + * @param p The particle to position and rotate. + * @param emitPosX The emitter's x position + * @param emitPosY The emitter's y position + * @param i The particle number in the current wave. Not used for this function. + */ + Emitter.prototype._spawnPoint = function (p, emitPosX, emitPosY) { + //set the initial rotation/direction of the particle based on + //starting particle angle and rotation of emitter + if (this.minStartRotation == this.maxStartRotation) + p.rotation = this.minStartRotation + this.rotation; + else + p.rotation = Math.random() * (this.maxStartRotation - this.minStartRotation) + this.minStartRotation + this.rotation; + //drop the particle at the emitter's position + p.position.x = emitPosX; + p.position.y = emitPosY; + }; + /** + * Positions a particle for a rectangle type emitter. + * @param p The particle to position and rotate. + * @param emitPosX The emitter's x position + * @param emitPosY The emitter's y position + * @param i The particle number in the current wave. Not used for this function. + */ + Emitter.prototype._spawnRect = function (p, emitPosX, emitPosY) { + //set the initial rotation/direction of the particle based on starting + //particle angle and rotation of emitter + if (this.minStartRotation == this.maxStartRotation) + p.rotation = this.minStartRotation + this.rotation; + else + p.rotation = Math.random() * (this.maxStartRotation - this.minStartRotation) + this.minStartRotation + this.rotation; + //place the particle at a random point in the rectangle + helperPoint.x = Math.random() * this.spawnRect.width + this.spawnRect.x; + helperPoint.y = Math.random() * this.spawnRect.height + this.spawnRect.y; + if (this.rotation !== 0) + exports.ParticleUtils.rotatePoint(this.rotation, helperPoint); + p.position.x = emitPosX + helperPoint.x; + p.position.y = emitPosY + helperPoint.y; + }; + /** + * Positions a particle for a circle type emitter. + * @param p The particle to position and rotate. + * @param emitPosX The emitter's x position + * @param emitPosY The emitter's y position + * @param i The particle number in the current wave. Not used for this function. + */ + Emitter.prototype._spawnCircle = function (p, emitPosX, emitPosY) { + //set the initial rotation/direction of the particle based on starting + //particle angle and rotation of emitter + if (this.minStartRotation == this.maxStartRotation) + p.rotation = this.minStartRotation + this.rotation; + else + p.rotation = Math.random() * (this.maxStartRotation - this.minStartRotation) + + this.minStartRotation + this.rotation; + //place the particle at a random radius in the circle + helperPoint.x = Math.random() * this.spawnCircle.radius; + helperPoint.y = 0; + //rotate the point to a random angle in the circle + exports.ParticleUtils.rotatePoint(Math.random() * 360, helperPoint); + //offset by the circle's center + helperPoint.x += this.spawnCircle.x; + helperPoint.y += this.spawnCircle.y; + //rotate the point by the emitter's rotation + if (this.rotation !== 0) + exports.ParticleUtils.rotatePoint(this.rotation, helperPoint); + //set the position, offset by the emitter's position + p.position.x = emitPosX + helperPoint.x; + p.position.y = emitPosY + helperPoint.y; + }; + /** + * Positions a particle for a ring type emitter. + * @param p The particle to position and rotate. + * @param emitPosX The emitter's x position + * @param emitPosY The emitter's y position + * @param i The particle number in the current wave. Not used for this function. + */ + Emitter.prototype._spawnRing = function (p, emitPosX, emitPosY) { + var spawnCircle = this.spawnCircle; + //set the initial rotation/direction of the particle based on starting + //particle angle and rotation of emitter + if (this.minStartRotation == this.maxStartRotation) + p.rotation = this.minStartRotation + this.rotation; + else + p.rotation = Math.random() * (this.maxStartRotation - this.minStartRotation) + + this.minStartRotation + this.rotation; + //place the particle at a random radius in the ring + if (spawnCircle.minRadius !== spawnCircle.radius) { + helperPoint.x = Math.random() * (spawnCircle.radius - spawnCircle.minRadius) + + spawnCircle.minRadius; + } + else + helperPoint.x = spawnCircle.radius; + helperPoint.y = 0; + //rotate the point to a random angle in the circle + var angle = Math.random() * 360; + p.rotation += angle; + exports.ParticleUtils.rotatePoint(angle, helperPoint); + //offset by the circle's center + helperPoint.x += this.spawnCircle.x; + helperPoint.y += this.spawnCircle.y; + //rotate the point by the emitter's rotation + if (this.rotation !== 0) + exports.ParticleUtils.rotatePoint(this.rotation, helperPoint); + //set the position, offset by the emitter's position + p.position.x = emitPosX + helperPoint.x; + p.position.y = emitPosY + helperPoint.y; + }; + /** + * Positions a particle for polygonal chain. + * @param p The particle to position and rotate. + * @param emitPosX The emitter's x position + * @param emitPosY The emitter's y position + * @param i The particle number in the current wave. Not used for this function. + */ + Emitter.prototype._spawnPolygonalChain = function (p, emitPosX, emitPosY) { + //set the initial rotation/direction of the particle based on starting + //particle angle and rotation of emitter + if (this.minStartRotation == this.maxStartRotation) + p.rotation = this.minStartRotation + this.rotation; + else + p.rotation = Math.random() * (this.maxStartRotation - this.minStartRotation) + + this.minStartRotation + this.rotation; + // get random point on the polygon chain + this.spawnPolygonalChain.getRandomPoint(helperPoint); + //rotate the point by the emitter's rotation + if (this.rotation !== 0) + exports.ParticleUtils.rotatePoint(this.rotation, helperPoint); + //set the position, offset by the emitter's position + p.position.x = emitPosX + helperPoint.x; + p.position.y = emitPosY + helperPoint.y; + }; + /** + * Positions a particle for a burst type emitter. + * @param p The particle to position and rotate. + * @param emitPosX The emitter's x position + * @param emitPosY The emitter's y position + * @param i The particle number in the current wave. + */ + Emitter.prototype._spawnBurst = function (p, emitPosX, emitPosY, i) { + //set the initial rotation/direction of the particle based on spawn + //angle and rotation of emitter + if (this.particleSpacing === 0) + p.rotation = Math.random() * 360; + else + p.rotation = this.angleStart + (this.particleSpacing * i) + this.rotation; + //drop the particle at the emitter's position + p.position.x = emitPosX; + p.position.y = emitPosY; + }; + /** + * Kills all active particles immediately. + */ + Emitter.prototype.cleanup = function () { + var particle, next; + for (particle = this._activeParticlesFirst; particle; particle = next) { + next = particle.next; + this.recycle(particle); + if (particle.parent) + particle.parent.removeChild(particle); + } + this._activeParticlesFirst = this._activeParticlesLast = null; + this.particleCount = 0; + }; + /** + * Destroys the emitter and all of its particles. + */ + Emitter.prototype.destroy = function () { + //make sure we aren't still listening to any tickers + this.autoUpdate = false; + //puts all active particles in the pool, and removes them from the particle parent + this.cleanup(); + //wipe the pool clean + var next; + for (var particle = this._poolFirst; particle; particle = next) { + //store next value so we don't lose it in our destroy call + next = particle.next; + particle.destroy(); + } + this._poolFirst = this._parent = this.particleImages = this.spawnPos = this.ownerPos = + this.startColor = this.startScale = this.startAlpha = this.startSpeed = + this.customEase = this._completeCallback = null; + }; + return Emitter; }()); - /** - * A helper point for math things. - * @hidden - */ - var helperPoint$1 = new pixi.Point(); - /** - * A hand picked list of Math functions (and a couple properties) that are - * allowable. They should be used without the preceding "Math." - * @hidden - */ - var MATH_FUNCS = [ - "pow", - "sqrt", - "abs", - "floor", - "round", - "ceil", - "E", - "PI", - "sin", - "cos", - "tan", - "asin", - "acos", - "atan", - "atan2", - "log" - ]; - /** - * create an actual regular expression object from the string - * @hidden - */ - var WHITELISTER = new RegExp([ - //Allow the 4 basic operations, parentheses and all numbers/decimals, as well - //as 'x', for the variable usage. - "[01234567890\\.\\*\\-\\+\\/\\(\\)x ,]", - ].concat(MATH_FUNCS).join("|"), "g"); - /** - * Parses a string into a function for path following. - * This involves whitelisting the string for safety, inserting "Math." to math function - * names, and using `new Function()` to generate a function. - * @hidden - * @param pathString The string to parse. - * @return The path function - takes x, outputs y. - */ - var parsePath = function (pathString) { - var matches = pathString.match(WHITELISTER); - for (var i = matches.length - 1; i >= 0; --i) { - if (MATH_FUNCS.indexOf(matches[i]) >= 0) - matches[i] = "Math." + matches[i]; - } - pathString = matches.join(""); - return new Function("x", "return " + pathString + ";"); - }; - /** - * An particle that follows a path defined by an algebraic expression, e.g. "sin(x)" or - * "5x + 3". - * To use this class, the particle config must have a "path" string in the - * "extraData" parameter. This string should have "x" in it to represent movement (from the - * speed settings of the particle). It may have numbers, parentheses, the four basic - * operations, and the following Math functions or properties (without the preceding "Math."): - * "pow", "sqrt", "abs", "floor", "round", "ceil", "E", "PI", "sin", "cos", "tan", "asin", - * "acos", "atan", "atan2", "log". - * The overall movement of the particle and the expression value become x and y positions for - * the particle, respectively. The final position is rotated by the spawn rotation/angle of - * the particle. - * - * Some example paths: - * - * "sin(x/10) * 20" // A sine wave path. - * "cos(x/100) * 30" // Particles curve counterclockwise (for medium speed/low lifetime particles) - * "pow(x/10, 2) / 2" // Particles curve clockwise (remember, +y is down). - */ - var PathParticle = /** @class */ (function (_super) { - __extends(PathParticle, _super); - /** - * @param {PIXI.particles.Emitter} emitter The emitter that controls this PathParticle. - */ - function PathParticle(emitter) { - var _this = _super.call(this, emitter) || this; - _this.path = null; - _this.initialRotation = 0; - _this.initialPosition = new pixi.Point(); - _this.movement = 0; - return _this; - } - /** - * Initializes the particle for use, based on the properties that have to - * have been set already on the particle. - */ - PathParticle.prototype.init = function () { - //get initial rotation before it is converted to radians - this.initialRotation = this.rotation; - //standard init - this.Particle_init(); - //set the path for the particle - this.path = this.extraData.path; - //cancel the normal movement behavior - this._doNormalMovement = !this.path; - //reset movement - this.movement = 0; - //grab position - this.initialPosition.x = this.position.x; - this.initialPosition.y = this.position.y; - }; - /** - * Updates the particle. - * @param delta Time elapsed since the previous frame, in __seconds__. - */ - PathParticle.prototype.update = function (delta) { - var lerp = this.Particle_update(delta); - //if the particle died during the update, then don't bother - if (lerp >= 0 && this.path) { - //increase linear movement based on speed - var speed = this.speedList.interpolate(lerp) * this.speedMultiplier; - this.movement += speed * delta; - //set up the helper point for rotation - helperPoint$1.x = this.movement; - helperPoint$1.y = this.path(this.movement); - exports.ParticleUtils.rotatePoint(this.initialRotation, helperPoint$1); - this.position.x = this.initialPosition.x + helperPoint$1.x; - this.position.y = this.initialPosition.y + helperPoint$1.y; - } - return lerp; - }; - /** - * Destroys the particle, removing references and preventing future use. - */ - PathParticle.prototype.destroy = function () { - this.Particle_destroy(); - this.path = this.initialPosition = null; - }; - /** - * Checks over the art that was passed to the Emitter's init() function, to do any special - * modifications to prepare it ahead of time. This just runs Particle.parseArt(). - * @param art The array of art data. For Particle, it should be an array of - * Textures. Any strings in the array will be converted to - * Textures via Texture.fromImage(). - * @return The art, after any needed modifications. - */ - PathParticle.parseArt = function (art) { - return Particle.parseArt(art); - }; - /** - * Parses extra emitter data to ensure it is set up for this particle class. - * PathParticle checks for the existence of path data, and parses the path data for use - * by particle instances. - * @param extraData The extra data from the particle config. - * @return The parsed extra data. - */ - PathParticle.parseData = function (extraData) { - var output = {}; - if (extraData && extraData.path) { - try { - output.path = parsePath(extraData.path); - } - catch (e) { - if (exports.ParticleUtils.verbose) - console.error("PathParticle: error in parsing path expression"); - output.path = null; - } - } - else { - if (exports.ParticleUtils.verbose) - console.error("PathParticle requires a path string in extraData!"); - output.path = null; - } - return output; - }; - return PathParticle; + /** + * A helper point for math things. + * @hidden + */ + var helperPoint$1 = new pixi.Point(); + /** + * A hand picked list of Math functions (and a couple properties) that are + * allowable. They should be used without the preceding "Math." + * @hidden + */ + var MATH_FUNCS = [ + "pow", + "sqrt", + "abs", + "floor", + "round", + "ceil", + "E", + "PI", + "sin", + "cos", + "tan", + "asin", + "acos", + "atan", + "atan2", + "log" + ]; + /** + * create an actual regular expression object from the string + * @hidden + */ + var WHITELISTER = new RegExp([ + //Allow the 4 basic operations, parentheses and all numbers/decimals, as well + //as 'x', for the variable usage. + "[01234567890\\.\\*\\-\\+\\/\\(\\)x ,]", + ].concat(MATH_FUNCS).join("|"), "g"); + /** + * Parses a string into a function for path following. + * This involves whitelisting the string for safety, inserting "Math." to math function + * names, and using `new Function()` to generate a function. + * @hidden + * @param pathString The string to parse. + * @return The path function - takes x, outputs y. + */ + var parsePath = function (pathString) { + var matches = pathString.match(WHITELISTER); + for (var i = matches.length - 1; i >= 0; --i) { + if (MATH_FUNCS.indexOf(matches[i]) >= 0) + matches[i] = "Math." + matches[i]; + } + pathString = matches.join(""); + return new Function("x", "return " + pathString + ";"); + }; + /** + * An particle that follows a path defined by an algebraic expression, e.g. "sin(x)" or + * "5x + 3". + * To use this class, the particle config must have a "path" string in the + * "extraData" parameter. This string should have "x" in it to represent movement (from the + * speed settings of the particle). It may have numbers, parentheses, the four basic + * operations, and the following Math functions or properties (without the preceding "Math."): + * "pow", "sqrt", "abs", "floor", "round", "ceil", "E", "PI", "sin", "cos", "tan", "asin", + * "acos", "atan", "atan2", "log". + * The overall movement of the particle and the expression value become x and y positions for + * the particle, respectively. The final position is rotated by the spawn rotation/angle of + * the particle. + * + * Some example paths: + * + * "sin(x/10) * 20" // A sine wave path. + * "cos(x/100) * 30" // Particles curve counterclockwise (for medium speed/low lifetime particles) + * "pow(x/10, 2) / 2" // Particles curve clockwise (remember, +y is down). + */ + var PathParticle = /** @class */ (function (_super) { + __extends(PathParticle, _super); + /** + * @param {PIXI.particles.Emitter} emitter The emitter that controls this PathParticle. + */ + function PathParticle(emitter) { + var _this = _super.call(this, emitter) || this; + _this.path = null; + _this.initialRotation = 0; + _this.initialPosition = new pixi.Point(); + _this.movement = 0; + return _this; + } + /** + * Initializes the particle for use, based on the properties that have to + * have been set already on the particle. + */ + PathParticle.prototype.init = function () { + //get initial rotation before it is converted to radians + this.initialRotation = this.rotation; + //standard init + this.Particle_init(); + //set the path for the particle + this.path = this.extraData.path; + //cancel the normal movement behavior + this._doNormalMovement = !this.path; + //reset movement + this.movement = 0; + //grab position + this.initialPosition.x = this.position.x; + this.initialPosition.y = this.position.y; + }; + /** + * Updates the particle. + * @param delta Time elapsed since the previous frame, in __seconds__. + */ + PathParticle.prototype.update = function (delta) { + var lerp = this.Particle_update(delta); + //if the particle died during the update, then don't bother + if (lerp >= 0 && this.path) { + //increase linear movement based on speed + var speed = this.speedList.interpolate(lerp) * this.speedMultiplier; + this.movement += speed * delta; + //set up the helper point for rotation + helperPoint$1.x = this.movement; + helperPoint$1.y = this.path(this.movement); + exports.ParticleUtils.rotatePoint(this.initialRotation, helperPoint$1); + this.position.x = this.initialPosition.x + helperPoint$1.x; + this.position.y = this.initialPosition.y + helperPoint$1.y; + } + return lerp; + }; + /** + * Destroys the particle, removing references and preventing future use. + */ + PathParticle.prototype.destroy = function () { + this.Particle_destroy(); + this.path = this.initialPosition = null; + }; + /** + * Checks over the art that was passed to the Emitter's init() function, to do any special + * modifications to prepare it ahead of time. This just runs Particle.parseArt(). + * @param art The array of art data. For Particle, it should be an array of + * Textures. Any strings in the array will be converted to + * Textures via Texture.fromImage(). + * @return The art, after any needed modifications. + */ + PathParticle.parseArt = function (art) { + return Particle.parseArt(art); + }; + /** + * Parses extra emitter data to ensure it is set up for this particle class. + * PathParticle checks for the existence of path data, and parses the path data for use + * by particle instances. + * @param extraData The extra data from the particle config. + * @return The parsed extra data. + */ + PathParticle.parseData = function (extraData) { + var output = {}; + if (extraData && extraData.path) { + try { + output.path = parsePath(extraData.path); + } + catch (e) { + if (exports.ParticleUtils.verbose) + console.error("PathParticle: error in parsing path expression"); + output.path = null; + } + } + else { + if (exports.ParticleUtils.verbose) + console.error("PathParticle requires a path string in extraData!"); + output.path = null; + } + return output; + }; + return PathParticle; }(Particle)); - /** - * An individual particle image with an animation. Art data passed to the emitter must be - * formatted in a particular way for AnimatedParticle to be able to handle it: - * - * ```typescript - * { - * //framerate is required. It is the animation speed of the particle in frames per - * //second. - * //A value of "matchLife" causes the animation to match the lifetime of an individual - * //particle, instead of at a constant framerate. This causes the animation to play - * //through one time, completing when the particle expires. - * framerate: 6, - * //loop is optional, and defaults to false. - * loop: true, - * //textures is required, and can be an array of any (non-zero) length. - * textures: [ - * //each entry represents a single texture that should be used for one or more - * //frames. Any strings will be converted to Textures with Texture.from(). - * //Instances of PIXI.Texture will be used directly. - * "animFrame1.png", - * //entries can be an object with a 'count' property, telling AnimatedParticle to - * //use that texture for 'count' frames sequentially. - * { - * texture: "animFrame2.png", - * count: 3 - * }, - * "animFrame3.png" - * ] - * } - * ``` - */ - var AnimatedParticle = /** @class */ (function (_super) { - __extends(AnimatedParticle, _super); - /** - * @param emitter The emitter that controls this AnimatedParticle. - */ - function AnimatedParticle(emitter) { - var _this = _super.call(this, emitter) || this; - _this.textures = null; - _this.duration = 0; - _this.framerate = 0; - _this.elapsed = 0; - _this.loop = false; - return _this; - } - /** - * Initializes the particle for use, based on the properties that have to - * have been set already on the particle. - */ - AnimatedParticle.prototype.init = function () { - this.Particle_init(); - this.elapsed = 0; - //if the animation needs to match the particle's life, then cacluate variables - if (this.framerate < 0) { - this.duration = this.maxLife; - this.framerate = this.textures.length / this.duration; - } - }; - /** - * Sets the textures for the particle. - * @param art An array of PIXI.Texture objects for this animated particle. - */ - AnimatedParticle.prototype.applyArt = function (art) { - this.textures = art.textures; - this.framerate = art.framerate; - this.duration = art.duration; - this.loop = art.loop; - }; - /** - * Updates the particle. - * @param delta Time elapsed since the previous frame, in __seconds__. - */ - AnimatedParticle.prototype.update = function (delta) { - var lerp = this.Particle_update(delta); - //only animate the particle if it is still alive - if (lerp >= 0) { - this.elapsed += delta; - if (this.elapsed > this.duration) { - //loop elapsed back around - if (this.loop) - this.elapsed = this.elapsed % this.duration; - //subtract a small amount to prevent attempting to go past the end of the animation - else - this.elapsed = this.duration - 0.000001; - } - // add a very small number to the frame and then floor it to avoid - // the frame being one short due to floating point errors. - var frame = (this.elapsed * this.framerate + 0.0000001) | 0; - this.texture = this.textures[frame] || pixi.Texture.EMPTY; - } - return lerp; - }; - /** - * Destroys the particle, removing references and preventing future use. - */ - AnimatedParticle.prototype.destroy = function () { - this.Particle_destroy(); - this.textures = null; - }; - /** - * Checks over the art that was passed to the Emitter's init() function, to do any special - * modifications to prepare it ahead of time. - * @param art The array of art data, properly formatted for AnimatedParticle. - * @return The art, after any needed modifications. - */ - AnimatedParticle.parseArt = function (art) { - var data, output, textures, tex, outTextures; - var outArr = []; - for (var i = 0; i < art.length; ++i) { - data = art[i]; - outArr[i] = output = {}; - output.textures = outTextures = []; - textures = data.textures; - for (var j = 0; j < textures.length; ++j) { - tex = textures[j]; - if (typeof tex == "string") - outTextures.push(GetTextureFromString(tex)); - else if (tex instanceof pixi.Texture) - outTextures.push(tex); - //assume an object with extra data determining duplicate frame data - else { - var dupe = tex.count || 1; - if (typeof tex.texture == "string") - tex = GetTextureFromString(tex.texture); - else // if(tex.texture instanceof Texture) - tex = tex.texture; - for (; dupe > 0; --dupe) { - outTextures.push(tex); - } - } - } - //use these values to signify that the animation should match the particle life time. - if (data.framerate == "matchLife") { - //-1 means that it should be calculated - output.framerate = -1; - output.duration = 0; - output.loop = false; - } - else { - //determine if the animation should loop - output.loop = !!data.loop; - //get the framerate, default to 60 - output.framerate = data.framerate > 0 ? data.framerate : 60; - //determine the duration - output.duration = outTextures.length / output.framerate; - } - } - return outArr; - }; - return AnimatedParticle; + /** + * An individual particle image with an animation. Art data passed to the emitter must be + * formatted in a particular way for AnimatedParticle to be able to handle it: + * + * ```typescript + * { + * //framerate is required. It is the animation speed of the particle in frames per + * //second. + * //A value of "matchLife" causes the animation to match the lifetime of an individual + * //particle, instead of at a constant framerate. This causes the animation to play + * //through one time, completing when the particle expires. + * framerate: 6, + * //loop is optional, and defaults to false. + * loop: true, + * //textures is required, and can be an array of any (non-zero) length. + * textures: [ + * //each entry represents a single texture that should be used for one or more + * //frames. Any strings will be converted to Textures with Texture.from(). + * //Instances of PIXI.Texture will be used directly. + * "animFrame1.png", + * //entries can be an object with a 'count' property, telling AnimatedParticle to + * //use that texture for 'count' frames sequentially. + * { + * texture: "animFrame2.png", + * count: 3 + * }, + * "animFrame3.png" + * ] + * } + * ``` + */ + var AnimatedParticle = /** @class */ (function (_super) { + __extends(AnimatedParticle, _super); + /** + * @param emitter The emitter that controls this AnimatedParticle. + */ + function AnimatedParticle(emitter) { + var _this = _super.call(this, emitter) || this; + _this.textures = null; + _this.duration = 0; + _this.framerate = 0; + _this.elapsed = 0; + _this.loop = false; + return _this; + } + /** + * Initializes the particle for use, based on the properties that have to + * have been set already on the particle. + */ + AnimatedParticle.prototype.init = function () { + this.Particle_init(); + this.elapsed = 0; + //if the animation needs to match the particle's life, then cacluate variables + if (this.framerate < 0) { + this.duration = this.maxLife; + this.framerate = this.textures.length / this.duration; + } + }; + /** + * Sets the textures for the particle. + * @param art An array of PIXI.Texture objects for this animated particle. + */ + AnimatedParticle.prototype.applyArt = function (art) { + this.textures = art.textures; + this.framerate = art.framerate; + this.duration = art.duration; + this.loop = art.loop; + }; + /** + * Updates the particle. + * @param delta Time elapsed since the previous frame, in __seconds__. + */ + AnimatedParticle.prototype.update = function (delta) { + var lerp = this.Particle_update(delta); + //only animate the particle if it is still alive + if (lerp >= 0) { + this.elapsed += delta; + if (this.elapsed > this.duration) { + //loop elapsed back around + if (this.loop) + this.elapsed = this.elapsed % this.duration; + //subtract a small amount to prevent attempting to go past the end of the animation + else + this.elapsed = this.duration - 0.000001; + } + // add a very small number to the frame and then floor it to avoid + // the frame being one short due to floating point errors. + var frame = (this.elapsed * this.framerate + 0.0000001) | 0; + this.texture = this.textures[frame] || pixi.Texture.EMPTY; + } + return lerp; + }; + /** + * Destroys the particle, removing references and preventing future use. + */ + AnimatedParticle.prototype.destroy = function () { + this.Particle_destroy(); + this.textures = null; + }; + /** + * Checks over the art that was passed to the Emitter's init() function, to do any special + * modifications to prepare it ahead of time. + * @param art The array of art data, properly formatted for AnimatedParticle. + * @return The art, after any needed modifications. + */ + AnimatedParticle.parseArt = function (art) { + var data, output, textures, tex, outTextures; + var outArr = []; + for (var i = 0; i < art.length; ++i) { + data = art[i]; + outArr[i] = output = {}; + output.textures = outTextures = []; + textures = data.textures; + for (var j = 0; j < textures.length; ++j) { + tex = textures[j]; + if (typeof tex == "string") + outTextures.push(GetTextureFromString(tex)); + else if (tex instanceof pixi.Texture) + outTextures.push(tex); + //assume an object with extra data determining duplicate frame data + else { + var dupe = tex.count || 1; + if (typeof tex.texture == "string") + tex = GetTextureFromString(tex.texture); + else // if(tex.texture instanceof Texture) + tex = tex.texture; + for (; dupe > 0; --dupe) { + outTextures.push(tex); + } + } + } + //use these values to signify that the animation should match the particle life time. + if (data.framerate == "matchLife") { + //-1 means that it should be calculated + output.framerate = -1; + output.duration = 0; + output.loop = false; + } + else { + //determine if the animation should loop + output.loop = !!data.loop; + //get the framerate, default to 60 + output.framerate = data.framerate > 0 ? data.framerate : 60; + //determine the duration + output.duration = outTextures.length / output.framerate; + } + } + return outArr; + }; + return AnimatedParticle; }(Particle)); exports.GetTextureFromString = GetTextureFromString; @@ -52193,3654 +52195,3756 @@ this.PIXI = this.PIXI || {}; }(this.PIXI.particles = this.PIXI.particles || {}, PIXI)); -var pixi_projection; -(function (pixi_projection) { - var utils; - (function (utils) { - function getIntersectionFactor(p1, p2, p3, p4, out) { - var A1 = p2.x - p1.x, B1 = p3.x - p4.x, C1 = p3.x - p1.x; - var A2 = p2.y - p1.y, B2 = p3.y - p4.y, C2 = p3.y - p1.y; - var D = A1 * B2 - A2 * B1; - if (Math.abs(D) < 1e-7) { - out.x = A1; - out.y = A2; - return 0; - } - var T = C1 * B2 - C2 * B1; - var U = A1 * C2 - A2 * C1; - var t = T / D, u = U / D; - if (u < (1e-6) || u - 1 > -1e-6) { - return -1; - } - out.x = p1.x + t * (p2.x - p1.x); - out.y = p1.y + t * (p2.y - p1.y); - return 1; - } - utils.getIntersectionFactor = getIntersectionFactor; - function getPositionFromQuad(p, anchor, out) { - out = out || new PIXI.Point(); - var a1 = 1.0 - anchor.x, a2 = 1.0 - a1; - var b1 = 1.0 - anchor.y, b2 = 1.0 - b1; - out.x = (p[0].x * a1 + p[1].x * a2) * b1 + (p[3].x * a1 + p[2].x * a2) * b2; - out.y = (p[0].y * a1 + p[1].y * a2) * b1 + (p[3].y * a1 + p[2].y * a2) * b2; - return out; - } - utils.getPositionFromQuad = getPositionFromQuad; - })(utils = pixi_projection.utils || (pixi_projection.utils = {})); -})(pixi_projection || (pixi_projection = {})); -PIXI.projection = pixi_projection; -var pixi_projection; -(function (pixi_projection) { - var AbstractProjection = (function () { - function AbstractProjection(legacy, enable) { - if (enable === void 0) { enable = true; } - this._enabled = false; - this.legacy = legacy; - if (enable) { - this.enabled = true; - } - this.legacy.proj = this; - } - Object.defineProperty(AbstractProjection.prototype, "enabled", { - get: function () { - return this._enabled; - }, - set: function (value) { - this._enabled = value; - }, - enumerable: true, - configurable: true - }); - AbstractProjection.prototype.clear = function () { - }; - return AbstractProjection; - }()); - pixi_projection.AbstractProjection = AbstractProjection; - var TRANSFORM_STEP; - (function (TRANSFORM_STEP) { - TRANSFORM_STEP[TRANSFORM_STEP["NONE"] = 0] = "NONE"; - TRANSFORM_STEP[TRANSFORM_STEP["BEFORE_PROJ"] = 4] = "BEFORE_PROJ"; - TRANSFORM_STEP[TRANSFORM_STEP["PROJ"] = 5] = "PROJ"; - TRANSFORM_STEP[TRANSFORM_STEP["ALL"] = 9] = "ALL"; - })(TRANSFORM_STEP = pixi_projection.TRANSFORM_STEP || (pixi_projection.TRANSFORM_STEP = {})); -})(pixi_projection || (pixi_projection = {})); -var __extends = (this && this.__extends) || (function () { - var 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 function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -var pixi_projection; -(function (pixi_projection) { - function transformHack(parentTransform) { - var proj = this.proj; - var ta = this; - var pwid = parentTransform._worldID; - var lt = ta.localTransform; - var scaleAfterAffine = proj.scaleAfterAffine && proj.affine >= 2; - if (ta._localID !== ta._currentLocalID) { - if (scaleAfterAffine) { - lt.a = ta._cx; - lt.b = ta._sx; - lt.c = ta._cy; - lt.d = ta._sy; - lt.tx = ta.position._x; - lt.ty = ta.position._y; - } - else { - lt.a = ta._cx * ta.scale._x; - lt.b = ta._sx * ta.scale._x; - lt.c = ta._cy * ta.scale._y; - lt.d = ta._sy * ta.scale._y; - lt.tx = ta.position._x - ((ta.pivot._x * lt.a) + (ta.pivot._y * lt.c)); - lt.ty = ta.position._y - ((ta.pivot._x * lt.b) + (ta.pivot._y * lt.d)); - } - ta._currentLocalID = ta._localID; - proj._currentProjID = -1; - } - var _matrixID = proj._projID; - if (proj._currentProjID !== _matrixID) { - proj._currentProjID = _matrixID; - proj.updateLocalTransform(lt); - ta._parentID = -1; - } - if (ta._parentID !== pwid) { - var pp = parentTransform.proj; - if (pp && !pp._affine) { - proj.world.setToMult(pp.world, proj.local); - } - else { - proj.world.setToMultLegacy(parentTransform.worldTransform, proj.local); - } - var wa = ta.worldTransform; - proj.world.copyTo(wa, proj._affine, proj.affinePreserveOrientation); - if (scaleAfterAffine) { - wa.a *= ta.scale._x; - wa.b *= ta.scale._x; - wa.c *= ta.scale._y; - wa.d *= ta.scale._y; - wa.tx -= ((ta.pivot._x * wa.a) + (ta.pivot._y * wa.c)); - wa.ty -= ((ta.pivot._x * wa.b) + (ta.pivot._y * wa.d)); - } - ta._parentID = pwid; - ta._worldID++; - } - } - var LinearProjection = (function (_super) { - __extends(LinearProjection, _super); - function LinearProjection() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this._projID = 0; - _this._currentProjID = -1; - _this._affine = pixi_projection.AFFINE.NONE; - _this.affinePreserveOrientation = false; - _this.scaleAfterAffine = true; - return _this; - } - LinearProjection.prototype.updateLocalTransform = function (lt) { - }; - Object.defineProperty(LinearProjection.prototype, "affine", { - get: function () { - return this._affine; - }, - set: function (value) { - if (this._affine == value) - return; - this._affine = value; - this._currentProjID = -1; - this.legacy._currentLocalID = -1; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(LinearProjection.prototype, "enabled", { - set: function (value) { - if (value === this._enabled) { - return; - } - this._enabled = value; - if (value) { - this.legacy.updateTransform = transformHack; - this.legacy._parentID = -1; - } - else { - this.legacy.updateTransform = PIXI.Transform.prototype.updateTransform; - this.legacy._parentID = -1; - } - }, - enumerable: true, - configurable: true - }); - LinearProjection.prototype.clear = function () { - this._currentProjID = -1; - this._projID = 0; - }; - return LinearProjection; - }(pixi_projection.AbstractProjection)); - pixi_projection.LinearProjection = LinearProjection; -})(pixi_projection || (pixi_projection = {})); -var pixi_projection; -(function (pixi_projection) { - var TYPES = PIXI.TYPES; - var premultiplyTint = PIXI.utils.premultiplyTint; - var shaderVert = "precision highp float;\nattribute vec3 aVertexPosition;\nattribute vec2 aTextureCoord;\nattribute vec4 aColor;\nattribute float aTextureId;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\nvarying vec4 vColor;\nvarying float vTextureId;\n\nvoid main(void){\n gl_Position.xyw = projectionMatrix * aVertexPosition;\n gl_Position.z = 0.0;\n \n vTextureCoord = aTextureCoord;\n vTextureId = aTextureId;\n vColor = aColor;\n}\n"; - var shaderFrag = "\nvarying vec2 vTextureCoord;\nvarying vec4 vColor;\nvarying float vTextureId;\nuniform sampler2D uSamplers[%count%];\n\nvoid main(void){\nvec4 color;\n%forloop%\ngl_FragColor = color * vColor;\n}"; - var Batch3dGeometry = (function (_super) { - __extends(Batch3dGeometry, _super); - function Batch3dGeometry(_static) { - if (_static === void 0) { _static = false; } - var _this = _super.call(this) || this; - _this._buffer = new PIXI.Buffer(null, _static, false); - _this._indexBuffer = new PIXI.Buffer(null, _static, true); - _this.addAttribute('aVertexPosition', _this._buffer, 3, false, TYPES.FLOAT) - .addAttribute('aTextureCoord', _this._buffer, 2, false, TYPES.FLOAT) - .addAttribute('aColor', _this._buffer, 4, true, TYPES.UNSIGNED_BYTE) - .addAttribute('aTextureId', _this._buffer, 1, true, TYPES.FLOAT) - .addIndex(_this._indexBuffer); - return _this; - } - return Batch3dGeometry; - }(PIXI.Geometry)); - pixi_projection.Batch3dGeometry = Batch3dGeometry; - var Batch2dPluginFactory = (function () { - function Batch2dPluginFactory() { - } - Batch2dPluginFactory.create = function (options) { - var _a = Object.assign({ - vertex: shaderVert, - fragment: shaderFrag, - geometryClass: Batch3dGeometry, - vertexSize: 7, - }, options), vertex = _a.vertex, fragment = _a.fragment, vertexSize = _a.vertexSize, geometryClass = _a.geometryClass; - return (function (_super) { - __extends(BatchPlugin, _super); - function BatchPlugin(renderer) { - var _this = _super.call(this, renderer) || this; - _this.shaderGenerator = new PIXI.BatchShaderGenerator(vertex, fragment); - _this.geometryClass = geometryClass; - _this.vertexSize = vertexSize; - return _this; - } - BatchPlugin.prototype.packInterleavedGeometry = function (element, attributeBuffer, indexBuffer, aIndex, iIndex) { - var uint32View = attributeBuffer.uint32View, float32View = attributeBuffer.float32View; - var p = aIndex / this.vertexSize; - var uvs = element.uvs; - var indicies = element.indices; - var vertexData = element.vertexData; - var vertexData2d = element.vertexData2d; - var textureId = element._texture.baseTexture._id; - var alpha = Math.min(element.worldAlpha, 1.0); - var argb = alpha < 1.0 && element._texture.baseTexture.premultiplyAlpha ? premultiplyTint(element._tintRGB, alpha) - : element._tintRGB + (alpha * 255 << 24); - if (vertexData2d) { - var j = 0; - for (var i = 0; i < vertexData2d.length; i += 3, j += 2) { - float32View[aIndex++] = vertexData2d[i]; - float32View[aIndex++] = vertexData2d[i + 1]; - float32View[aIndex++] = vertexData2d[i + 2]; - float32View[aIndex++] = uvs[j]; - float32View[aIndex++] = uvs[j + 1]; - uint32View[aIndex++] = argb; - float32View[aIndex++] = textureId; - } - } - else { - for (var i = 0; i < vertexData.length; i += 2) { - float32View[aIndex++] = vertexData[i]; - float32View[aIndex++] = vertexData[i + 1]; - float32View[aIndex++] = 1.0; - float32View[aIndex++] = uvs[i]; - float32View[aIndex++] = uvs[i + 1]; - uint32View[aIndex++] = argb; - float32View[aIndex++] = textureId; - } - } - for (var i = 0; i < indicies.length; i++) { - indexBuffer[iIndex++] = p + indicies[i]; - } - }; - return BatchPlugin; - }(PIXI.AbstractBatchRenderer)); - }; - return Batch2dPluginFactory; - }()); - pixi_projection.Batch2dPluginFactory = Batch2dPluginFactory; - PIXI.Renderer.registerPlugin('batch2d', Batch2dPluginFactory.create({})); -})(pixi_projection || (pixi_projection = {})); -var pixi_projection; -(function (pixi_projection) { - var UniformBatchRenderer = (function (_super) { - __extends(UniformBatchRenderer, _super); - function UniformBatchRenderer() { - return _super !== null && _super.apply(this, arguments) || this; - } - UniformBatchRenderer.prototype.addToBatch = function (sprite) { - }; - return UniformBatchRenderer; - }(PIXI.AbstractBatchRenderer)); - pixi_projection.UniformBatchRenderer = UniformBatchRenderer; -})(pixi_projection || (pixi_projection = {})); -var pixi_projection; -(function (pixi_projection) { - var p = [new PIXI.Point(), new PIXI.Point(), new PIXI.Point(), new PIXI.Point()]; - var a = [0, 0, 0, 0]; - var Surface = (function () { - function Surface() { - this.surfaceID = "default"; - this._updateID = 0; - this.vertexSrc = ""; - this.fragmentSrc = ""; - } - Surface.prototype.fillUniforms = function (uniforms) { - }; - Surface.prototype.clear = function () { - }; - Surface.prototype.boundsQuad = function (v, out, after) { - var minX = out[0], minY = out[1]; - var maxX = out[0], maxY = out[1]; - for (var i = 2; i < 8; i += 2) { - if (minX > out[i]) - minX = out[i]; - if (maxX < out[i]) - maxX = out[i]; - if (minY > out[i + 1]) - minY = out[i + 1]; - if (maxY < out[i + 1]) - maxY = out[i + 1]; - } - p[0].set(minX, minY); - this.apply(p[0], p[0]); - p[1].set(maxX, minY); - this.apply(p[1], p[1]); - p[2].set(maxX, maxY); - this.apply(p[2], p[2]); - p[3].set(minX, maxY); - this.apply(p[3], p[3]); - if (after) { - after.apply(p[0], p[0]); - after.apply(p[1], p[1]); - after.apply(p[2], p[2]); - after.apply(p[3], p[3]); - out[0] = p[0].x; - out[1] = p[0].y; - out[2] = p[1].x; - out[3] = p[1].y; - out[4] = p[2].x; - out[5] = p[2].y; - out[6] = p[3].x; - out[7] = p[3].y; - } - else { - for (var i = 1; i <= 3; i++) { - if (p[i].y < p[0].y || p[i].y == p[0].y && p[i].x < p[0].x) { - var t = p[0]; - p[0] = p[i]; - p[i] = t; - } - } - for (var i = 1; i <= 3; i++) { - a[i] = Math.atan2(p[i].y - p[0].y, p[i].x - p[0].x); - } - for (var i = 1; i <= 3; i++) { - for (var j = i + 1; j <= 3; j++) { - if (a[i] > a[j]) { - var t = p[i]; - p[i] = p[j]; - p[j] = t; - var t2 = a[i]; - a[i] = a[j]; - a[j] = t2; - } - } - } - out[0] = p[0].x; - out[1] = p[0].y; - out[2] = p[1].x; - out[3] = p[1].y; - out[4] = p[2].x; - out[5] = p[2].y; - out[6] = p[3].x; - out[7] = p[3].y; - if ((p[3].x - p[2].x) * (p[1].y - p[2].y) - (p[1].x - p[2].x) * (p[3].y - p[2].y) < 0) { - out[4] = p[3].x; - out[5] = p[3].y; - return; - } - } - }; - return Surface; - }()); - pixi_projection.Surface = Surface; -})(pixi_projection || (pixi_projection = {})); -var pixi_projection; -(function (pixi_projection) { - var tempMat = new PIXI.Matrix(); - var tempRect = new PIXI.Rectangle(); - var tempPoint = new PIXI.Point(); - var BilinearSurface = (function (_super) { - __extends(BilinearSurface, _super); - function BilinearSurface() { - var _this = _super.call(this) || this; - _this.distortion = new PIXI.Point(); - return _this; - } - BilinearSurface.prototype.clear = function () { - this.distortion.set(0, 0); - }; - BilinearSurface.prototype.apply = function (pos, newPos) { - newPos = newPos || new PIXI.Point(); - var d = this.distortion; - var m = pos.x * pos.y; - newPos.x = pos.x + d.x * m; - newPos.y = pos.y + d.y * m; - return newPos; - }; - BilinearSurface.prototype.applyInverse = function (pos, newPos) { - newPos = newPos || new PIXI.Point(); - var vx = pos.x, vy = pos.y; - var dx = this.distortion.x, dy = this.distortion.y; - if (dx == 0.0) { - newPos.x = vx; - newPos.y = vy / (1.0 + dy * vx); - } - else if (dy == 0.0) { - newPos.y = vy; - newPos.x = vx / (1.0 + dx * vy); - } - else { - var b = (vy * dx - vx * dy + 1.0) * 0.5 / dy; - var d = b * b + vx / dy; - if (d <= 0.00001) { - newPos.set(NaN, NaN); - return; - } - if (dy > 0.0) { - newPos.x = -b + Math.sqrt(d); - } - else { - newPos.x = -b - Math.sqrt(d); - } - newPos.y = (vx / newPos.x - 1.0) / dx; - } - return newPos; - }; - BilinearSurface.prototype.mapSprite = function (sprite, quad, outTransform) { - var tex = sprite.texture; - tempRect.x = -sprite.anchor.x * tex.orig.width; - tempRect.y = -sprite.anchor.y * tex.orig.height; - tempRect.width = tex.orig.width; - tempRect.height = tex.orig.height; - return this.mapQuad(tempRect, quad, outTransform || sprite.transform); - }; - BilinearSurface.prototype.mapQuad = function (rect, quad, outTransform) { - var ax = -rect.x / rect.width; - var ay = -rect.y / rect.height; - var ax2 = (1.0 - rect.x) / rect.width; - var ay2 = (1.0 - rect.y) / rect.height; - var up1x = (quad[0].x * (1.0 - ax) + quad[1].x * ax); - var up1y = (quad[0].y * (1.0 - ax) + quad[1].y * ax); - var up2x = (quad[0].x * (1.0 - ax2) + quad[1].x * ax2); - var up2y = (quad[0].y * (1.0 - ax2) + quad[1].y * ax2); - var down1x = (quad[3].x * (1.0 - ax) + quad[2].x * ax); - var down1y = (quad[3].y * (1.0 - ax) + quad[2].y * ax); - var down2x = (quad[3].x * (1.0 - ax2) + quad[2].x * ax2); - var down2y = (quad[3].y * (1.0 - ax2) + quad[2].y * ax2); - var x00 = up1x * (1.0 - ay) + down1x * ay; - var y00 = up1y * (1.0 - ay) + down1y * ay; - var x10 = up2x * (1.0 - ay) + down2x * ay; - var y10 = up2y * (1.0 - ay) + down2y * ay; - var x01 = up1x * (1.0 - ay2) + down1x * ay2; - var y01 = up1y * (1.0 - ay2) + down1y * ay2; - var x11 = up2x * (1.0 - ay2) + down2x * ay2; - var y11 = up2y * (1.0 - ay2) + down2y * ay2; - var mat = tempMat; - mat.tx = x00; - mat.ty = y00; - mat.a = x10 - x00; - mat.b = y10 - y00; - mat.c = x01 - x00; - mat.d = y01 - y00; - tempPoint.set(x11, y11); - mat.applyInverse(tempPoint, tempPoint); - this.distortion.set(tempPoint.x - 1, tempPoint.y - 1); - outTransform.setFromMatrix(mat); - return this; - }; - BilinearSurface.prototype.fillUniforms = function (uniforms) { - uniforms.distortion = uniforms.distortion || new Float32Array([0, 0, 0, 0]); - var ax = Math.abs(this.distortion.x); - var ay = Math.abs(this.distortion.y); - uniforms.distortion[0] = ax * 10000 <= ay ? 0 : this.distortion.x; - uniforms.distortion[1] = ay * 10000 <= ax ? 0 : this.distortion.y; - uniforms.distortion[2] = 1.0 / uniforms.distortion[0]; - uniforms.distortion[3] = 1.0 / uniforms.distortion[1]; - }; - return BilinearSurface; - }(pixi_projection.Surface)); - pixi_projection.BilinearSurface = BilinearSurface; -})(pixi_projection || (pixi_projection = {})); -var pixi_projection; -(function (pixi_projection) { - var Container2s = (function (_super) { - __extends(Container2s, _super); - function Container2s() { - var _this = _super.call(this) || this; - _this.proj = new pixi_projection.ProjectionSurface(_this.transform); - return _this; - } - Object.defineProperty(Container2s.prototype, "worldTransform", { - get: function () { - return this.proj; - }, - enumerable: true, - configurable: true - }); - return Container2s; - }(PIXI.Container)); - pixi_projection.Container2s = Container2s; -})(pixi_projection || (pixi_projection = {})); -var pixi_projection; -(function (pixi_projection) { - var fun = PIXI.Transform.prototype.updateTransform; - function transformHack(parentTransform) { - var proj = this.proj; - var pp = parentTransform.proj; - var ta = this; - if (!pp) { - fun.call(this, parentTransform); - proj._activeProjection = null; - return; - } - if (pp._surface) { - proj._activeProjection = pp; - this.updateLocalTransform(); - this.localTransform.copyFrom(this.worldTransform); - if (ta._parentID < 0) { - ++ta._worldID; - } - return; - } - fun.call(this, parentTransform); - proj._activeProjection = pp._activeProjection; - } - var ProjectionSurface = (function (_super) { - __extends(ProjectionSurface, _super); - function ProjectionSurface(legacy, enable) { - var _this = _super.call(this, legacy, enable) || this; - _this._surface = null; - _this._activeProjection = null; - _this._currentSurfaceID = -1; - _this._currentLegacyID = -1; - _this._lastUniforms = null; - return _this; - } - Object.defineProperty(ProjectionSurface.prototype, "enabled", { - set: function (value) { - if (value === this._enabled) { - return; - } - this._enabled = value; - if (value) { - this.legacy.updateTransform = transformHack; - this.legacy._parentID = -1; - } - else { - this.legacy.updateTransform = PIXI.Transform.prototype.updateTransform; - this.legacy._parentID = -1; - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ProjectionSurface.prototype, "surface", { - get: function () { - return this._surface; - }, - set: function (value) { - if (this._surface == value) { - return; - } - this._surface = value || null; - this.legacy._parentID = -1; - }, - enumerable: true, - configurable: true - }); - ProjectionSurface.prototype.applyPartial = function (pos, newPos) { - if (this._activeProjection !== null) { - newPos = this.legacy.worldTransform.apply(pos, newPos); - return this._activeProjection.surface.apply(newPos, newPos); - } - if (this._surface !== null) { - return this.surface.apply(pos, newPos); - } - return this.legacy.worldTransform.apply(pos, newPos); - }; - ProjectionSurface.prototype.apply = function (pos, newPos) { - if (this._activeProjection !== null) { - newPos = this.legacy.worldTransform.apply(pos, newPos); - this._activeProjection.surface.apply(newPos, newPos); - return this._activeProjection.legacy.worldTransform.apply(newPos, newPos); - } - if (this._surface !== null) { - newPos = this.surface.apply(pos, newPos); - return this.legacy.worldTransform.apply(newPos, newPos); - } - return this.legacy.worldTransform.apply(pos, newPos); - }; - ProjectionSurface.prototype.applyInverse = function (pos, newPos) { - if (this._activeProjection !== null) { - newPos = this._activeProjection.legacy.worldTransform.applyInverse(pos, newPos); - this._activeProjection._surface.applyInverse(newPos, newPos); - return this.legacy.worldTransform.applyInverse(newPos, newPos); - } - if (this._surface !== null) { - newPos = this.legacy.worldTransform.applyInverse(pos, newPos); - return this._surface.applyInverse(newPos, newPos); - } - return this.legacy.worldTransform.applyInverse(pos, newPos); - }; - ProjectionSurface.prototype.mapBilinearSprite = function (sprite, quad) { - if (!(this._surface instanceof pixi_projection.BilinearSurface)) { - this.surface = new pixi_projection.BilinearSurface(); - } - this.surface.mapSprite(sprite, quad, this.legacy); - }; - ProjectionSurface.prototype.clear = function () { - if (this.surface) { - this.surface.clear(); - } - }; - Object.defineProperty(ProjectionSurface.prototype, "uniforms", { - get: function () { - if (this._currentLegacyID === this.legacy._worldID && - this._currentSurfaceID === this.surface._updateID) { - return this._lastUniforms; - } - this._lastUniforms = this._lastUniforms || {}; - this._lastUniforms.worldTransform = this.legacy.worldTransform.toArray(true); - this._surface.fillUniforms(this._lastUniforms); - return this._lastUniforms; - }, - enumerable: true, - configurable: true - }); - return ProjectionSurface; - }(pixi_projection.AbstractProjection)); - pixi_projection.ProjectionSurface = ProjectionSurface; -})(pixi_projection || (pixi_projection = {})); -var pixi_projection; -(function (pixi_projection) { - var TYPES = PIXI.TYPES; - var premultiplyTint = PIXI.utils.premultiplyTint; - var shaderVert = "precision highp float;\nattribute vec2 aVertexPosition;\nattribute vec3 aTrans1;\nattribute vec3 aTrans2;\nattribute vec4 aFrame;\nattribute vec4 aColor;\nattribute float aTextureId;\n\nuniform mat3 projectionMatrix;\nuniform mat3 worldTransform;\n\nvarying vec2 vTextureCoord;\nvarying vec3 vTrans1;\nvarying vec3 vTrans2;\nvarying vec4 vFrame;\nvarying vec4 vColor;\nvarying float vTextureId;\n\nvoid main(void){\n gl_Position.xyw = projectionMatrix * worldTransform * vec3(aVertexPosition, 1.0);\n gl_Position.z = 0.0;\n \n vTextureCoord = aVertexPosition;\n vTrans1 = aTrans1;\n vTrans2 = aTrans2;\n vTextureId = aTextureId;\n vColor = aColor;\n vFrame = aFrame;\n}\n"; - var shaderFrag = "precision highp float;\nvarying vec2 vTextureCoord;\nvarying vec3 vTrans1;\nvarying vec3 vTrans2;\nvarying vec4 vFrame;\nvarying vec4 vColor;\nvarying float vTextureId;\n\nuniform sampler2D uSamplers[%count%];\nuniform vec2 samplerSize[%count%]; \nuniform vec4 distortion;\n\nvoid main(void){\nvec2 surface;\nvec2 surface2;\n\nfloat vx = vTextureCoord.x;\nfloat vy = vTextureCoord.y;\nfloat dx = distortion.x;\nfloat dy = distortion.y;\nfloat revx = distortion.z;\nfloat revy = distortion.w;\n\nif (distortion.x == 0.0) {\n surface.x = vx;\n surface.y = vy / (1.0 + dy * vx);\n surface2 = surface;\n} else\nif (distortion.y == 0.0) {\n surface.y = vy;\n surface.x = vx/ (1.0 + dx * vy);\n surface2 = surface;\n} else {\n float c = vy * dx - vx * dy;\n float b = (c + 1.0) * 0.5;\n float b2 = (-c + 1.0) * 0.5;\n float d = b * b + vx * dy;\n if (d < -0.00001) {\n discard;\n }\n d = sqrt(max(d, 0.0));\n surface.x = (- b + d) * revy;\n surface2.x = (- b - d) * revy;\n surface.y = (- b2 + d) * revx;\n surface2.y = (- b2 - d) * revx;\n}\n\nvec2 uv;\nuv.x = vTrans1.x * surface.x + vTrans1.y * surface.y + vTrans1.z;\nuv.y = vTrans2.x * surface.x + vTrans2.y * surface.y + vTrans2.z;\n\nvec2 pixels = uv * samplerSize[0];\n\nif (pixels.x < vFrame.x || pixels.x > vFrame.z ||\n pixels.y < vFrame.y || pixels.y > vFrame.w) {\n uv.x = vTrans1.x * surface2.x + vTrans1.y * surface2.y + vTrans1.z;\n uv.y = vTrans2.x * surface2.x + vTrans2.y * surface2.y + vTrans2.z;\n pixels = uv * samplerSize[0];\n \n if (pixels.x < vFrame.x || pixels.x > vFrame.z ||\n pixels.y < vFrame.y || pixels.y > vFrame.w) {\n discard;\n }\n}\n\nvec4 edge;\nedge.xy = clamp(pixels - vFrame.xy + 0.5, vec2(0.0, 0.0), vec2(1.0, 1.0));\nedge.zw = clamp(vFrame.zw - pixels + 0.5, vec2(0.0, 0.0), vec2(1.0, 1.0));\n\nfloat alpha = 1.0; //edge.x * edge.y * edge.z * edge.w;\nvec4 rColor = vColor * alpha;\n\nfloat textureId = floor(vTextureId+0.5);\n%forloop%\ngl_FragColor = color * rColor;\n}"; - var BatchBilineardGeometry = (function (_super) { - __extends(BatchBilineardGeometry, _super); - function BatchBilineardGeometry(_static) { - if (_static === void 0) { _static = false; } - var _this = _super.call(this) || this; - _this._buffer = new PIXI.Buffer(null, _static, false); - _this._indexBuffer = new PIXI.Buffer(null, _static, true); - _this.addAttribute('aVertexPosition', _this._buffer, 2, false, TYPES.FLOAT) - .addAttribute('aTrans1', _this._buffer, 3, false, TYPES.FLOAT) - .addAttribute('aTrans2', _this._buffer, 3, false, TYPES.FLOAT) - .addAttribute('aFrame', _this._buffer, 4, false, TYPES.FLOAT) - .addAttribute('aColor', _this._buffer, 4, true, TYPES.UNSIGNED_BYTE) - .addIndex(_this._indexBuffer); - return _this; - } - return BatchBilineardGeometry; - }(PIXI.Geometry)); - pixi_projection.BatchBilineardGeometry = BatchBilineardGeometry; - var BatchBilinearPluginFactory = (function () { - function BatchBilinearPluginFactory() { - } - BatchBilinearPluginFactory.create = function (options) { - var _a = Object.assign({ - vertex: shaderVert, - fragment: shaderFrag, - geometryClass: pixi_projection.Batch3dGeometry, - vertexSize: 7, - }, options), vertex = _a.vertex, fragment = _a.fragment, vertexSize = _a.vertexSize, geometryClass = _a.geometryClass; - return (function (_super) { - __extends(BatchPlugin, _super); - function BatchPlugin(renderer) { - var _this = _super.call(this, renderer) || this; - _this.defUniforms = { - worldTransform: new Float32Array([1, 0, 0, 0, 1, 0, 0, 0, 1]), - distortion: new Float32Array([0, 0]) - }; - _this.shaderGenerator = new PIXI.BatchShaderGenerator(vertex, fragment); - _this.geometryClass = geometryClass; - _this.vertexSize = vertexSize; - return _this; - } - BatchPlugin.prototype.getUniforms = function (sprite) { - var proj = sprite.proj; - var shader = this._shader; - if (proj.surface !== null) { - return proj.uniforms; - } - if (proj._activeProjection !== null) { - return proj._activeProjection.uniforms; - } - return this.defUniforms; - }; - BatchPlugin.prototype.packGeometry = function (element, float32View, uint32View, indexBuffer, index, indexCount) { - var p = index / this.vertexSize; - var uvs = element.uvs; - var indices = element.indices; - var vertexData = element.vertexData; - var tex = element._texture; - var frame = tex._frame; - var aTrans = element.aTrans; - var alpha = Math.min(element.worldAlpha, 1.0); - var argb = alpha < 1.0 && element._texture.baseTexture.premultiplyAlpha ? premultiplyTint(element._tintRGB, alpha) - : element._tintRGB + (alpha * 255 << 24); - for (var i = 0; i < vertexData.length; i += 2) { - float32View[index] = vertexData[i * 2]; - float32View[index + 1] = vertexData[i * 2 + 1]; - float32View[index + 2] = aTrans.a; - float32View[index + 3] = aTrans.c; - float32View[index + 4] = aTrans.tx; - float32View[index + 5] = aTrans.b; - float32View[index + 6] = aTrans.d; - float32View[index + 7] = aTrans.ty; - float32View[index + 8] = frame.x; - float32View[index + 9] = frame.y; - float32View[index + 10] = frame.x + frame.width; - float32View[index + 11] = frame.y + frame.height; - uint32View[index + 12] = argb; - index += 13; - } - for (var i = 0; i < indices.length; i++) { - indexBuffer[indexCount++] = p + indices[i]; - } - }; - return BatchPlugin; - }(PIXI.AbstractBatchRenderer)); - }; - return BatchBilinearPluginFactory; - }()); - pixi_projection.BatchBilinearPluginFactory = BatchBilinearPluginFactory; -})(pixi_projection || (pixi_projection = {})); -var pixi_projection; -(function (pixi_projection) { - var Sprite2s = (function (_super) { - __extends(Sprite2s, _super); - function Sprite2s(texture) { - var _this = _super.call(this, texture) || this; - _this.aTrans = new PIXI.Matrix(); - _this.proj = new pixi_projection.ProjectionSurface(_this.transform); - _this.pluginName = 'batch_bilinear'; - return _this; - } - Sprite2s.prototype._calculateBounds = function () { - this.calculateTrimmedVertices(); - this._bounds.addQuad(this.vertexTrimmedData); - }; - Sprite2s.prototype.calculateVertices = function () { - var wid = this.transform._worldID; - var tuid = this._texture._updateID; - if (this._transformID === wid && this._textureID === tuid) { - return; - } - this._transformID = wid; - this._textureID = tuid; - var texture = this._texture; - var vertexData = this.vertexData; - var trim = texture.trim; - var orig = texture.orig; - var anchor = this._anchor; - var w0 = 0; - var w1 = 0; - var h0 = 0; - var h1 = 0; - if (trim) { - w1 = trim.x - (anchor._x * orig.width); - w0 = w1 + trim.width; - h1 = trim.y - (anchor._y * orig.height); - h0 = h1 + trim.height; - } - else { - w1 = -anchor._x * orig.width; - w0 = w1 + orig.width; - h1 = -anchor._y * orig.height; - h0 = h1 + orig.height; - } - if (this.proj._surface) { - vertexData[0] = w1; - vertexData[1] = h1; - vertexData[2] = w0; - vertexData[3] = h1; - vertexData[4] = w0; - vertexData[5] = h0; - vertexData[6] = w1; - vertexData[7] = h0; - this.proj._surface.boundsQuad(vertexData, vertexData); - } - else { - var wt = this.transform.worldTransform; - var a = wt.a; - var b = wt.b; - var c = wt.c; - var d = wt.d; - var tx = wt.tx; - var ty = wt.ty; - vertexData[0] = (a * w1) + (c * h1) + tx; - vertexData[1] = (d * h1) + (b * w1) + ty; - vertexData[2] = (a * w0) + (c * h1) + tx; - vertexData[3] = (d * h1) + (b * w0) + ty; - vertexData[4] = (a * w0) + (c * h0) + tx; - vertexData[5] = (d * h0) + (b * w0) + ty; - vertexData[6] = (a * w1) + (c * h0) + tx; - vertexData[7] = (d * h0) + (b * w1) + ty; - if (this.proj._activeProjection) { - this.proj._activeProjection.surface.boundsQuad(vertexData, vertexData); - } - } - if (!texture.uvMatrix) { - texture.uvMatrix = new PIXI.TextureMatrix(texture); - } - texture.uvMatrix.update(); - var aTrans = this.aTrans; - aTrans.set(orig.width, 0, 0, orig.height, w1, h1); - if (this.proj._surface === null) { - aTrans.prepend(this.transform.worldTransform); - } - aTrans.invert(); - aTrans.prepend(texture.uvMatrix.mapCoord); - }; - Sprite2s.prototype.calculateTrimmedVertices = function () { - var wid = this.transform._worldID; - var tuid = this._texture._updateID; - if (!this.vertexTrimmedData) { - this.vertexTrimmedData = new Float32Array(8); - } - else if (this._transformTrimmedID === wid && this._textureTrimmedID === tuid) { - return; - } - this._transformTrimmedID = wid; - this._textureTrimmedID = tuid; - var texture = this._texture; - var vertexData = this.vertexTrimmedData; - var orig = texture.orig; - var anchor = this._anchor; - var w1 = -anchor._x * orig.width; - var w0 = w1 + orig.width; - var h1 = -anchor._y * orig.height; - var h0 = h1 + orig.height; - if (this.proj._surface) { - vertexData[0] = w1; - vertexData[1] = h1; - vertexData[2] = w0; - vertexData[3] = h1; - vertexData[4] = w0; - vertexData[5] = h0; - vertexData[6] = w1; - vertexData[7] = h0; - this.proj._surface.boundsQuad(vertexData, vertexData, this.transform.worldTransform); - } - else { - var wt = this.transform.worldTransform; - var a = wt.a; - var b = wt.b; - var c = wt.c; - var d = wt.d; - var tx = wt.tx; - var ty = wt.ty; - vertexData[0] = (a * w1) + (c * h1) + tx; - vertexData[1] = (d * h1) + (b * w1) + ty; - vertexData[2] = (a * w0) + (c * h1) + tx; - vertexData[3] = (d * h1) + (b * w0) + ty; - vertexData[4] = (a * w0) + (c * h0) + tx; - vertexData[5] = (d * h0) + (b * w0) + ty; - vertexData[6] = (a * w1) + (c * h0) + tx; - vertexData[7] = (d * h0) + (b * w1) + ty; - if (this.proj._activeProjection) { - this.proj._activeProjection.surface.boundsQuad(vertexData, vertexData, this.proj._activeProjection.legacy.worldTransform); - } - } - }; - Object.defineProperty(Sprite2s.prototype, "worldTransform", { - get: function () { - return this.proj; - }, - enumerable: true, - configurable: true - }); - return Sprite2s; - }(PIXI.Sprite)); - pixi_projection.Sprite2s = Sprite2s; -})(pixi_projection || (pixi_projection = {})); -var pixi_projection; -(function (pixi_projection) { - var Text2s = (function (_super) { - __extends(Text2s, _super); - function Text2s(text, style, canvas) { - var _this = _super.call(this, text, style, canvas) || this; - _this.aTrans = new PIXI.Matrix(); - _this.proj = new pixi_projection.ProjectionSurface(_this.transform); - _this.pluginName = 'batch_bilinear'; - return _this; - } - Object.defineProperty(Text2s.prototype, "worldTransform", { - get: function () { - return this.proj; - }, - enumerable: true, - configurable: true - }); - return Text2s; - }(PIXI.Text)); - pixi_projection.Text2s = Text2s; - Text2s.prototype.calculateVertices = pixi_projection.Sprite2s.prototype.calculateVertices; - Text2s.prototype.calculateTrimmedVertices = pixi_projection.Sprite2s.prototype.calculateTrimmedVertices; - Text2s.prototype._calculateBounds = pixi_projection.Sprite2s.prototype._calculateBounds; -})(pixi_projection || (pixi_projection = {})); -var pixi_projection; -(function (pixi_projection) { - PIXI.Sprite.prototype.convertTo2s = function () { - if (this.proj) - return; - this.pluginName = 'sprite_bilinear'; - this.aTrans = new PIXI.Matrix(); - this.calculateVertices = pixi_projection.Sprite2s.prototype.calculateVertices; - this.calculateTrimmedVertices = pixi_projection.Sprite2s.prototype.calculateTrimmedVertices; - this._calculateBounds = pixi_projection.Sprite2s.prototype._calculateBounds; - PIXI.Container.prototype.convertTo2s.call(this); - }; - PIXI.Container.prototype.convertTo2s = function () { - if (this.proj) - return; - this.proj = new pixi_projection.Projection2d(this.transform); - Object.defineProperty(this, "worldTransform", { - get: function () { - return this.proj; - }, - enumerable: true, - configurable: true - }); - }; - PIXI.Container.prototype.convertSubtreeTo2s = function () { - this.convertTo2s(); - for (var i = 0; i < this.children.length; i++) { - this.children[i].convertSubtreeTo2s(); - } - }; -})(pixi_projection || (pixi_projection = {})); -var pixi_projection; -(function (pixi_projection) { - function container2dWorldTransform() { - return this.proj.affine ? this.transform.worldTransform : this.proj.world; - } - pixi_projection.container2dWorldTransform = container2dWorldTransform; - var Container2d = (function (_super) { - __extends(Container2d, _super); - function Container2d() { - var _this = _super.call(this) || this; - _this.proj = new pixi_projection.Projection2d(_this.transform); - return _this; - } - Container2d.prototype.toLocal = function (position, from, point, skipUpdate, step) { - if (step === void 0) { step = pixi_projection.TRANSFORM_STEP.ALL; } - if (from) { - position = from.toGlobal(position, point, skipUpdate); - } - if (!skipUpdate) { - this._recursivePostUpdateTransform(); - } - if (step >= pixi_projection.TRANSFORM_STEP.PROJ) { - if (!skipUpdate) { - this.displayObjectUpdateTransform(); - } - if (this.proj.affine) { - return this.transform.worldTransform.applyInverse(position, point); - } - return this.proj.world.applyInverse(position, point); - } - if (this.parent) { - point = this.parent.worldTransform.applyInverse(position, point); - } - else { - point.copyFrom(position); - } - if (step === pixi_projection.TRANSFORM_STEP.NONE) { - return point; - } - return this.transform.localTransform.applyInverse(point, point); - }; - Object.defineProperty(Container2d.prototype, "worldTransform", { - get: function () { - return this.proj.affine ? this.transform.worldTransform : this.proj.world; - }, - enumerable: true, - configurable: true - }); - return Container2d; - }(PIXI.Container)); - pixi_projection.Container2d = Container2d; - pixi_projection.container2dToLocal = Container2d.prototype.toLocal; -})(pixi_projection || (pixi_projection = {})); -var pixi_projection; -(function (pixi_projection) { - var Point = PIXI.Point; - var mat3id = [1, 0, 0, 0, 1, 0, 0, 0, 1]; - var AFFINE; - (function (AFFINE) { - AFFINE[AFFINE["NONE"] = 0] = "NONE"; - AFFINE[AFFINE["FREE"] = 1] = "FREE"; - AFFINE[AFFINE["AXIS_X"] = 2] = "AXIS_X"; - AFFINE[AFFINE["AXIS_Y"] = 3] = "AXIS_Y"; - AFFINE[AFFINE["POINT"] = 4] = "POINT"; - AFFINE[AFFINE["AXIS_XR"] = 5] = "AXIS_XR"; - })(AFFINE = pixi_projection.AFFINE || (pixi_projection.AFFINE = {})); - var Matrix2d = (function () { - function Matrix2d(backingArray) { - this.floatArray = null; - this.mat3 = new Float64Array(backingArray || mat3id); - } - Object.defineProperty(Matrix2d.prototype, "a", { - get: function () { - return this.mat3[0] / this.mat3[8]; - }, - set: function (value) { - this.mat3[0] = value * this.mat3[8]; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Matrix2d.prototype, "b", { - get: function () { - return this.mat3[1] / this.mat3[8]; - }, - set: function (value) { - this.mat3[1] = value * this.mat3[8]; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Matrix2d.prototype, "c", { - get: function () { - return this.mat3[3] / this.mat3[8]; - }, - set: function (value) { - this.mat3[3] = value * this.mat3[8]; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Matrix2d.prototype, "d", { - get: function () { - return this.mat3[4] / this.mat3[8]; - }, - set: function (value) { - this.mat3[4] = value * this.mat3[8]; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Matrix2d.prototype, "tx", { - get: function () { - return this.mat3[6] / this.mat3[8]; - }, - set: function (value) { - this.mat3[6] = value * this.mat3[8]; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Matrix2d.prototype, "ty", { - get: function () { - return this.mat3[7] / this.mat3[8]; - }, - set: function (value) { - this.mat3[7] = value * this.mat3[8]; - }, - enumerable: true, - configurable: true - }); - Matrix2d.prototype.set = function (a, b, c, d, tx, ty) { - var mat3 = this.mat3; - mat3[0] = a; - mat3[1] = b; - mat3[2] = 0; - mat3[3] = c; - mat3[4] = d; - mat3[5] = 0; - mat3[6] = tx; - mat3[7] = ty; - mat3[8] = 1; - return this; - }; - Matrix2d.prototype.toArray = function (transpose, out) { - if (!this.floatArray) { - this.floatArray = new Float32Array(9); - } - var array = out || this.floatArray; - var mat3 = this.mat3; - if (transpose) { - array[0] = mat3[0]; - array[1] = mat3[1]; - array[2] = mat3[2]; - array[3] = mat3[3]; - array[4] = mat3[4]; - array[5] = mat3[5]; - array[6] = mat3[6]; - array[7] = mat3[7]; - array[8] = mat3[8]; - } - else { - array[0] = mat3[0]; - array[1] = mat3[3]; - array[2] = mat3[6]; - array[3] = mat3[1]; - array[4] = mat3[4]; - array[5] = mat3[7]; - array[6] = mat3[2]; - array[7] = mat3[5]; - array[8] = mat3[8]; - } - return array; - }; - Matrix2d.prototype.apply = function (pos, newPos) { - newPos = newPos || new PIXI.Point(); - var mat3 = this.mat3; - var x = pos.x; - var y = pos.y; - var z = 1.0 / (mat3[2] * x + mat3[5] * y + mat3[8]); - newPos.x = z * (mat3[0] * x + mat3[3] * y + mat3[6]); - newPos.y = z * (mat3[1] * x + mat3[4] * y + mat3[7]); - return newPos; - }; - Matrix2d.prototype.translate = function (tx, ty) { - var mat3 = this.mat3; - mat3[0] += tx * mat3[2]; - mat3[1] += ty * mat3[2]; - mat3[3] += tx * mat3[5]; - mat3[4] += ty * mat3[5]; - mat3[6] += tx * mat3[8]; - mat3[7] += ty * mat3[8]; - return this; - }; - Matrix2d.prototype.scale = function (x, y) { - var mat3 = this.mat3; - mat3[0] *= x; - mat3[1] *= y; - mat3[3] *= x; - mat3[4] *= y; - mat3[6] *= x; - mat3[7] *= y; - return this; - }; - Matrix2d.prototype.scaleAndTranslate = function (scaleX, scaleY, tx, ty) { - var mat3 = this.mat3; - mat3[0] = scaleX * mat3[0] + tx * mat3[2]; - mat3[1] = scaleY * mat3[1] + ty * mat3[2]; - mat3[3] = scaleX * mat3[3] + tx * mat3[5]; - mat3[4] = scaleY * mat3[4] + ty * mat3[5]; - mat3[6] = scaleX * mat3[6] + tx * mat3[8]; - mat3[7] = scaleY * mat3[7] + ty * mat3[8]; - }; - Matrix2d.prototype.applyInverse = function (pos, newPos) { - newPos = newPos || new Point(); - var a = this.mat3; - var x = pos.x; - var y = pos.y; - var a00 = a[0], a01 = a[3], a02 = a[6], a10 = a[1], a11 = a[4], a12 = a[7], a20 = a[2], a21 = a[5], a22 = a[8]; - var newX = (a22 * a11 - a12 * a21) * x + (-a22 * a01 + a02 * a21) * y + (a12 * a01 - a02 * a11); - var newY = (-a22 * a10 + a12 * a20) * x + (a22 * a00 - a02 * a20) * y + (-a12 * a00 + a02 * a10); - var newZ = (a21 * a10 - a11 * a20) * x + (-a21 * a00 + a01 * a20) * y + (a11 * a00 - a01 * a10); - newPos.x = newX / newZ; - newPos.y = newY / newZ; - return newPos; - }; - Matrix2d.prototype.invert = function () { - var a = this.mat3; - var a00 = a[0], a01 = a[1], a02 = a[2], a10 = a[3], a11 = a[4], a12 = a[5], a20 = a[6], a21 = a[7], a22 = a[8], b01 = a22 * a11 - a12 * a21, b11 = -a22 * a10 + a12 * a20, b21 = a21 * a10 - a11 * a20; - var det = a00 * b01 + a01 * b11 + a02 * b21; - if (!det) { - return this; - } - det = 1.0 / det; - a[0] = b01 * det; - a[1] = (-a22 * a01 + a02 * a21) * det; - a[2] = (a12 * a01 - a02 * a11) * det; - a[3] = b11 * det; - a[4] = (a22 * a00 - a02 * a20) * det; - a[5] = (-a12 * a00 + a02 * a10) * det; - a[6] = b21 * det; - a[7] = (-a21 * a00 + a01 * a20) * det; - a[8] = (a11 * a00 - a01 * a10) * det; - return this; - }; - Matrix2d.prototype.identity = function () { - var mat3 = this.mat3; - mat3[0] = 1; - mat3[1] = 0; - mat3[2] = 0; - mat3[3] = 0; - mat3[4] = 1; - mat3[5] = 0; - mat3[6] = 0; - mat3[7] = 0; - mat3[8] = 1; - return this; - }; - Matrix2d.prototype.clone = function () { - return new Matrix2d(this.mat3); - }; - Matrix2d.prototype.copyTo2dOr3d = function (matrix) { - var mat3 = this.mat3; - var ar2 = matrix.mat3; - ar2[0] = mat3[0]; - ar2[1] = mat3[1]; - ar2[2] = mat3[2]; - ar2[3] = mat3[3]; - ar2[4] = mat3[4]; - ar2[5] = mat3[5]; - ar2[6] = mat3[6]; - ar2[7] = mat3[7]; - ar2[8] = mat3[8]; - return matrix; - }; - Matrix2d.prototype.copyTo = function (matrix, affine, preserveOrientation) { - var mat3 = this.mat3; - var d = 1.0 / mat3[8]; - var tx = mat3[6] * d, ty = mat3[7] * d; - matrix.a = (mat3[0] - mat3[2] * tx) * d; - matrix.b = (mat3[1] - mat3[2] * ty) * d; - matrix.c = (mat3[3] - mat3[5] * tx) * d; - matrix.d = (mat3[4] - mat3[5] * ty) * d; - matrix.tx = tx; - matrix.ty = ty; - if (affine >= 2) { - var D = matrix.a * matrix.d - matrix.b * matrix.c; - if (!preserveOrientation) { - D = Math.abs(D); - } - if (affine === AFFINE.POINT) { - if (D > 0) { - D = 1; - } - else - D = -1; - matrix.a = D; - matrix.b = 0; - matrix.c = 0; - matrix.d = D; - } - else if (affine === AFFINE.AXIS_X) { - D /= Math.sqrt(matrix.b * matrix.b + matrix.d * matrix.d); - matrix.c = 0; - matrix.d = D; - } - else if (affine === AFFINE.AXIS_Y) { - D /= Math.sqrt(matrix.a * matrix.a + matrix.c * matrix.c); - matrix.a = D; - matrix.c = 0; - } - else if (affine === AFFINE.AXIS_XR) { - matrix.a = matrix.d * D; - matrix.c = -matrix.b * D; - } - } - return matrix; - }; - Matrix2d.prototype.copyFrom = function (matrix) { - var mat3 = this.mat3; - mat3[0] = matrix.a; - mat3[1] = matrix.b; - mat3[2] = 0; - mat3[3] = matrix.c; - mat3[4] = matrix.d; - mat3[5] = 0; - mat3[6] = matrix.tx; - mat3[7] = matrix.ty; - mat3[8] = 1.0; - return this; - }; - Matrix2d.prototype.setToMultLegacy = function (pt, lt) { - var out = this.mat3; - var b = lt.mat3; - var a00 = pt.a, a01 = pt.b, a10 = pt.c, a11 = pt.d, a20 = pt.tx, a21 = pt.ty, b00 = b[0], b01 = b[1], b02 = b[2], b10 = b[3], b11 = b[4], b12 = b[5], b20 = b[6], b21 = b[7], b22 = b[8]; - out[0] = b00 * a00 + b01 * a10 + b02 * a20; - out[1] = b00 * a01 + b01 * a11 + b02 * a21; - out[2] = b02; - out[3] = b10 * a00 + b11 * a10 + b12 * a20; - out[4] = b10 * a01 + b11 * a11 + b12 * a21; - out[5] = b12; - out[6] = b20 * a00 + b21 * a10 + b22 * a20; - out[7] = b20 * a01 + b21 * a11 + b22 * a21; - out[8] = b22; - return this; - }; - Matrix2d.prototype.setToMultLegacy2 = function (pt, lt) { - var out = this.mat3; - var a = pt.mat3; - var a00 = a[0], a01 = a[1], a02 = a[2], a10 = a[3], a11 = a[4], a12 = a[5], a20 = a[6], a21 = a[7], a22 = a[8], b00 = lt.a, b01 = lt.b, b10 = lt.c, b11 = lt.d, b20 = lt.tx, b21 = lt.ty; - out[0] = b00 * a00 + b01 * a10; - out[1] = b00 * a01 + b01 * a11; - out[2] = b00 * a02 + b01 * a12; - out[3] = b10 * a00 + b11 * a10; - out[4] = b10 * a01 + b11 * a11; - out[5] = b10 * a02 + b11 * a12; - out[6] = b20 * a00 + b21 * a10 + a20; - out[7] = b20 * a01 + b21 * a11 + a21; - out[8] = b20 * a02 + b21 * a12 + a22; - return this; - }; - Matrix2d.prototype.setToMult = function (pt, lt) { - var out = this.mat3; - var a = pt.mat3, b = lt.mat3; - var a00 = a[0], a01 = a[1], a02 = a[2], a10 = a[3], a11 = a[4], a12 = a[5], a20 = a[6], a21 = a[7], a22 = a[8], b00 = b[0], b01 = b[1], b02 = b[2], b10 = b[3], b11 = b[4], b12 = b[5], b20 = b[6], b21 = b[7], b22 = b[8]; - out[0] = b00 * a00 + b01 * a10 + b02 * a20; - out[1] = b00 * a01 + b01 * a11 + b02 * a21; - out[2] = b00 * a02 + b01 * a12 + b02 * a22; - out[3] = b10 * a00 + b11 * a10 + b12 * a20; - out[4] = b10 * a01 + b11 * a11 + b12 * a21; - out[5] = b10 * a02 + b11 * a12 + b12 * a22; - out[6] = b20 * a00 + b21 * a10 + b22 * a20; - out[7] = b20 * a01 + b21 * a11 + b22 * a21; - out[8] = b20 * a02 + b21 * a12 + b22 * a22; - return this; - }; - Matrix2d.prototype.prepend = function (lt) { - if (lt.mat3) { - return this.setToMult(lt, this); - } - else { - return this.setToMultLegacy(lt, this); - } - }; - Matrix2d.IDENTITY = new Matrix2d(); - Matrix2d.TEMP_MATRIX = new Matrix2d(); - return Matrix2d; - }()); - pixi_projection.Matrix2d = Matrix2d; -})(pixi_projection || (pixi_projection = {})); -var pixi_projection; -(function (pixi_projection) { - var t0 = new PIXI.Point(); - var tt = [new PIXI.Point(), new PIXI.Point(), new PIXI.Point(), new PIXI.Point()]; - var tempRect = new PIXI.Rectangle(); - var tempMat = new pixi_projection.Matrix2d(); - var Projection2d = (function (_super) { - __extends(Projection2d, _super); - function Projection2d(legacy, enable) { - var _this = _super.call(this, legacy, enable) || this; - _this.matrix = new pixi_projection.Matrix2d(); - _this.pivot = new PIXI.ObservablePoint(_this.onChange, _this, 0, 0); - _this.reverseLocalOrder = false; - _this.local = new pixi_projection.Matrix2d(); - _this.world = new pixi_projection.Matrix2d(); - return _this; - } - Projection2d.prototype.onChange = function () { - var pivot = this.pivot; - var mat3 = this.matrix.mat3; - mat3[6] = -(pivot._x * mat3[0] + pivot._y * mat3[3]); - mat3[7] = -(pivot._x * mat3[1] + pivot._y * mat3[4]); - this._projID++; - }; - Projection2d.prototype.setAxisX = function (p, factor) { - if (factor === void 0) { factor = 1; } - var x = p.x, y = p.y; - var d = Math.sqrt(x * x + y * y); - var mat3 = this.matrix.mat3; - mat3[0] = x / d; - mat3[1] = y / d; - mat3[2] = factor / d; - this.onChange(); - }; - Projection2d.prototype.setAxisY = function (p, factor) { - if (factor === void 0) { factor = 1; } - var x = p.x, y = p.y; - var d = Math.sqrt(x * x + y * y); - var mat3 = this.matrix.mat3; - mat3[3] = x / d; - mat3[4] = y / d; - mat3[5] = factor / d; - this.onChange(); - }; - Projection2d.prototype.mapSprite = function (sprite, quad) { - var tex = sprite.texture; - tempRect.x = -sprite.anchor.x * tex.orig.width; - tempRect.y = -sprite.anchor.y * tex.orig.height; - tempRect.width = tex.orig.width; - tempRect.height = tex.orig.height; - return this.mapQuad(tempRect, quad); - }; - Projection2d.prototype.mapQuad = function (rect, p) { - tt[0].set(rect.x, rect.y); - tt[1].set(rect.x + rect.width, rect.y); - tt[2].set(rect.x + rect.width, rect.y + rect.height); - tt[3].set(rect.x, rect.y + rect.height); - var k1 = 1, k2 = 2, k3 = 3; - var f = pixi_projection.utils.getIntersectionFactor(p[0], p[2], p[1], p[3], t0); - if (f !== 0) { - k1 = 1; - k2 = 3; - k3 = 2; - } - else { - return; - } - var d0 = Math.sqrt((p[0].x - t0.x) * (p[0].x - t0.x) + (p[0].y - t0.y) * (p[0].y - t0.y)); - var d1 = Math.sqrt((p[k1].x - t0.x) * (p[k1].x - t0.x) + (p[k1].y - t0.y) * (p[k1].y - t0.y)); - var d2 = Math.sqrt((p[k2].x - t0.x) * (p[k2].x - t0.x) + (p[k2].y - t0.y) * (p[k2].y - t0.y)); - var d3 = Math.sqrt((p[k3].x - t0.x) * (p[k3].x - t0.x) + (p[k3].y - t0.y) * (p[k3].y - t0.y)); - var q0 = (d0 + d3) / d3; - var q1 = (d1 + d2) / d2; - var q2 = (d1 + d2) / d1; - var mat3 = this.matrix.mat3; - mat3[0] = tt[0].x * q0; - mat3[1] = tt[0].y * q0; - mat3[2] = q0; - mat3[3] = tt[k1].x * q1; - mat3[4] = tt[k1].y * q1; - mat3[5] = q1; - mat3[6] = tt[k2].x * q2; - mat3[7] = tt[k2].y * q2; - mat3[8] = q2; - this.matrix.invert(); - mat3 = tempMat.mat3; - mat3[0] = p[0].x; - mat3[1] = p[0].y; - mat3[2] = 1; - mat3[3] = p[k1].x; - mat3[4] = p[k1].y; - mat3[5] = 1; - mat3[6] = p[k2].x; - mat3[7] = p[k2].y; - mat3[8] = 1; - this.matrix.setToMult(tempMat, this.matrix); - this._projID++; - }; - Projection2d.prototype.updateLocalTransform = function (lt) { - if (this._projID !== 0) { - if (this.reverseLocalOrder) { - this.local.setToMultLegacy2(this.matrix, lt); - } - else { - this.local.setToMultLegacy(lt, this.matrix); - } - } - else { - this.local.copyFrom(lt); - } - }; - Projection2d.prototype.clear = function () { - _super.prototype.clear.call(this); - this.matrix.identity(); - this.pivot.set(0, 0); - }; - return Projection2d; - }(pixi_projection.LinearProjection)); - pixi_projection.Projection2d = Projection2d; -})(pixi_projection || (pixi_projection = {})); -var pixi_projection; -(function (pixi_projection) { - var Mesh2d = (function (_super) { - __extends(Mesh2d, _super); - function Mesh2d(geometry, shader, state, drawMode) { - var _this = _super.call(this, geometry, shader, state, drawMode) || this; - _this.vertexData2d = null; - _this.proj = new pixi_projection.Projection2d(_this.transform); - return _this; - } - Mesh2d.prototype.calculateVertices = function () { - if (this.proj._affine) { - this.vertexData2d = null; - _super.prototype.calculateVertices.call(this); - return; - } - var geometry = this.geometry; - var vertices = geometry.buffers[0].data; - var thisAny = this; - if (geometry.vertexDirtyId === thisAny.vertexDirty && thisAny._transformID === thisAny.transform._worldID) { - return; - } - thisAny._transformID = thisAny.transform._worldID; - if (thisAny.vertexData.length !== vertices.length) { - thisAny.vertexData = new Float32Array(vertices.length); - } - if (this.vertexData2d.length !== vertices.length * 3 / 2) { - this.vertexData2d = new Float32Array(vertices.length * 3); - } - var wt = this.proj.world.mat3; - var vertexData2d = this.vertexData2d; - var vertexData = thisAny.vertexData; - for (var i = 0; i < vertexData.length / 2; i++) { - var x = vertices[(i * 2)]; - var y = vertices[(i * 2) + 1]; - var xx = (wt[0] * x) + (wt[3] * y) + wt[6]; - var yy = (wt[1] * x) + (wt[4] * y) + wt[7]; - var ww = (wt[2] * x) + (wt[5] * y) + wt[8]; - vertexData2d[i * 3] = xx; - vertexData2d[i * 3 + 1] = yy; - vertexData2d[i * 3 + 2] = ww; - vertexData[(i * 2)] = xx / ww; - vertexData[(i * 2) + 1] = yy / ww; - } - thisAny.vertexDirty = geometry.vertexDirtyId; - }; - Mesh2d.prototype._renderDefault = function (renderer) { - var shader = this.shader; - shader.alpha = this.worldAlpha; - if (shader.update) { - shader.update(); - } - renderer.batch.flush(); - if (shader.program.uniformData.translationMatrix) { - shader.uniforms.translationMatrix = this.worldTransform.toArray(true); - } - renderer.shader.bind(shader, false); - renderer.state.set(this.state); - renderer.geometry.bind(this.geometry, shader); - renderer.geometry.draw(this.drawMode, this.size, this.start, this.geometry.instanceCount); - }; - Mesh2d.prototype.toLocal = function (position, from, point, skipUpdate, step) { - if (step === void 0) { step = pixi_projection.TRANSFORM_STEP.ALL; } - return pixi_projection.container2dToLocal.call(this, position, from, point, skipUpdate, step); - }; - Object.defineProperty(Mesh2d.prototype, "worldTransform", { - get: function () { - return this.proj.affine ? this.transform.worldTransform : this.proj.world; - }, - enumerable: true, - configurable: true - }); - Mesh2d.defaultVertexShader = "precision highp float;\nattribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\nuniform mat3 translationMatrix;\nuniform mat3 uTransform;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position.xyw = projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0);\n gl_Position.z = 0.0;\n\n vTextureCoord = (uTransform * vec3(aTextureCoord, 1.0)).xy;\n}\n"; - Mesh2d.defaultFragmentShader = "\nvarying vec2 vTextureCoord;\nuniform vec4 uColor;\n\nuniform sampler2D uSampler;\n\nvoid main(void)\n{\n gl_FragColor = texture2D(uSampler, vTextureCoord) * uColor;\n}"; - return Mesh2d; - }(PIXI.Mesh)); - pixi_projection.Mesh2d = Mesh2d; - var SimpleMesh2d = (function (_super) { - __extends(SimpleMesh2d, _super); - function SimpleMesh2d(texture, vertices, uvs, indices, drawMode) { - var _this = _super.call(this, new PIXI.MeshGeometry(vertices, uvs, indices), new PIXI.MeshMaterial(texture, { - program: PIXI.Program.from(Mesh2d.defaultVertexShader, Mesh2d.defaultFragmentShader), - pluginName: 'batch2d' - }), null, drawMode) || this; - _this.autoUpdate = true; - _this.geometry.getBuffer('aVertexPosition').static = false; - return _this; - } - Object.defineProperty(SimpleMesh2d.prototype, "vertices", { - get: function () { - return this.geometry.getBuffer('aVertexPosition').data; - }, - set: function (value) { - this.geometry.getBuffer('aVertexPosition').data = value; - }, - enumerable: true, - configurable: true - }); - SimpleMesh2d.prototype._render = function (renderer) { - if (this.autoUpdate) { - this.geometry.getBuffer('aVertexPosition').update(); - } - _super.prototype._render.call(this, renderer); - }; - return SimpleMesh2d; - }(Mesh2d)); - pixi_projection.SimpleMesh2d = SimpleMesh2d; -})(pixi_projection || (pixi_projection = {})); -var pixi_projection; -(function (pixi_projection) { - var Sprite2d = (function (_super) { - __extends(Sprite2d, _super); - function Sprite2d(texture) { - var _this = _super.call(this, texture) || this; - _this.vertexData2d = null; - _this.proj = new pixi_projection.Projection2d(_this.transform); - _this.pluginName = 'batch2d'; - return _this; - } - Sprite2d.prototype._calculateBounds = function () { - this.calculateTrimmedVertices(); - this._bounds.addQuad(this.vertexTrimmedData); - }; - Sprite2d.prototype.calculateVertices = function () { - var texture = this._texture; - if (this.proj._affine) { - this.vertexData2d = null; - _super.prototype.calculateVertices.call(this); - return; - } - if (!this.vertexData2d) { - this.vertexData2d = new Float32Array(12); - } - var wid = this.transform._worldID; - var tuid = texture._updateID; - if (this._transformID === wid && this._textureID === tuid) { - return; - } - if (this._textureID !== tuid) { - this.uvs = texture._uvs.uvsFloat32; - } - this._transformID = wid; - this._textureID = tuid; - var wt = this.proj.world.mat3; - var vertexData2d = this.vertexData2d; - var vertexData = this.vertexData; - var trim = texture.trim; - var orig = texture.orig; - var anchor = this._anchor; - var w0 = 0; - var w1 = 0; - var h0 = 0; - var h1 = 0; - if (trim) { - w1 = trim.x - (anchor._x * orig.width); - w0 = w1 + trim.width; - h1 = trim.y - (anchor._y * orig.height); - h0 = h1 + trim.height; - } - else { - w1 = -anchor._x * orig.width; - w0 = w1 + orig.width; - h1 = -anchor._y * orig.height; - h0 = h1 + orig.height; - } - vertexData2d[0] = (wt[0] * w1) + (wt[3] * h1) + wt[6]; - vertexData2d[1] = (wt[1] * w1) + (wt[4] * h1) + wt[7]; - vertexData2d[2] = (wt[2] * w1) + (wt[5] * h1) + wt[8]; - vertexData2d[3] = (wt[0] * w0) + (wt[3] * h1) + wt[6]; - vertexData2d[4] = (wt[1] * w0) + (wt[4] * h1) + wt[7]; - vertexData2d[5] = (wt[2] * w0) + (wt[5] * h1) + wt[8]; - vertexData2d[6] = (wt[0] * w0) + (wt[3] * h0) + wt[6]; - vertexData2d[7] = (wt[1] * w0) + (wt[4] * h0) + wt[7]; - vertexData2d[8] = (wt[2] * w0) + (wt[5] * h0) + wt[8]; - vertexData2d[9] = (wt[0] * w1) + (wt[3] * h0) + wt[6]; - vertexData2d[10] = (wt[1] * w1) + (wt[4] * h0) + wt[7]; - vertexData2d[11] = (wt[2] * w1) + (wt[5] * h0) + wt[8]; - vertexData[0] = vertexData2d[0] / vertexData2d[2]; - vertexData[1] = vertexData2d[1] / vertexData2d[2]; - vertexData[2] = vertexData2d[3] / vertexData2d[5]; - vertexData[3] = vertexData2d[4] / vertexData2d[5]; - vertexData[4] = vertexData2d[6] / vertexData2d[8]; - vertexData[5] = vertexData2d[7] / vertexData2d[8]; - vertexData[6] = vertexData2d[9] / vertexData2d[11]; - vertexData[7] = vertexData2d[10] / vertexData2d[11]; - }; - Sprite2d.prototype.calculateTrimmedVertices = function () { - if (this.proj._affine) { - _super.prototype.calculateTrimmedVertices.call(this); - return; - } - var wid = this.transform._worldID; - var tuid = this._texture._updateID; - if (!this.vertexTrimmedData) { - this.vertexTrimmedData = new Float32Array(8); - } - else if (this._transformTrimmedID === wid && this._textureTrimmedID === tuid) { - return; - } - this._transformTrimmedID = wid; - this._textureTrimmedID = tuid; - var texture = this._texture; - var vertexData = this.vertexTrimmedData; - var orig = texture.orig; - var anchor = this._anchor; - var wt = this.proj.world.mat3; - var w1 = -anchor._x * orig.width; - var w0 = w1 + orig.width; - var h1 = -anchor._y * orig.height; - var h0 = h1 + orig.height; - var z = 1.0 / (wt[2] * w1 + wt[5] * h1 + wt[8]); - vertexData[0] = z * ((wt[0] * w1) + (wt[3] * h1) + wt[6]); - vertexData[1] = z * ((wt[1] * w1) + (wt[4] * h1) + wt[7]); - z = 1.0 / (wt[2] * w0 + wt[5] * h1 + wt[8]); - vertexData[2] = z * ((wt[0] * w0) + (wt[3] * h1) + wt[6]); - vertexData[3] = z * ((wt[1] * w0) + (wt[4] * h1) + wt[7]); - z = 1.0 / (wt[2] * w0 + wt[5] * h0 + wt[8]); - vertexData[4] = z * ((wt[0] * w0) + (wt[3] * h0) + wt[6]); - vertexData[5] = z * ((wt[1] * w0) + (wt[4] * h0) + wt[7]); - z = 1.0 / (wt[2] * w1 + wt[5] * h0 + wt[8]); - vertexData[6] = z * ((wt[0] * w1) + (wt[3] * h0) + wt[6]); - vertexData[7] = z * ((wt[1] * w1) + (wt[4] * h0) + wt[7]); - }; - Sprite2d.prototype.toLocal = function (position, from, point, skipUpdate, step) { - if (step === void 0) { step = pixi_projection.TRANSFORM_STEP.ALL; } - return pixi_projection.container2dToLocal.call(this, position, from, point, skipUpdate, step); - }; - Object.defineProperty(Sprite2d.prototype, "worldTransform", { - get: function () { - return this.proj.affine ? this.transform.worldTransform : this.proj.world; - }, - enumerable: true, - configurable: true - }); - return Sprite2d; - }(PIXI.Sprite)); - pixi_projection.Sprite2d = Sprite2d; -})(pixi_projection || (pixi_projection = {})); -var pixi_projection; -(function (pixi_projection) { - var Text2d = (function (_super) { - __extends(Text2d, _super); - function Text2d(text, style, canvas) { - var _this = _super.call(this, text, style, canvas) || this; - _this.vertexData2d = null; - _this.proj = new pixi_projection.Projection2d(_this.transform); - _this.pluginName = 'batch2d'; - return _this; - } - Object.defineProperty(Text2d.prototype, "worldTransform", { - get: function () { - return this.proj.affine ? this.transform.worldTransform : this.proj.world; - }, - enumerable: true, - configurable: true - }); - return Text2d; - }(PIXI.Text)); - pixi_projection.Text2d = Text2d; - Text2d.prototype.calculateVertices = pixi_projection.Sprite2d.prototype.calculateVertices; - Text2d.prototype.calculateTrimmedVertices = pixi_projection.Sprite2d.prototype.calculateTrimmedVertices; - Text2d.prototype._calculateBounds = pixi_projection.Sprite2d.prototype._calculateBounds; -})(pixi_projection || (pixi_projection = {})); -var pixi_projection; -(function (pixi_projection) { - function convertTo2d() { - if (this.proj) - return; - this.proj = new pixi_projection.Projection2d(this.transform); - this.toLocal = pixi_projection.Container2d.prototype.toLocal; - Object.defineProperty(this, "worldTransform", { - get: pixi_projection.container2dWorldTransform, - enumerable: true, - configurable: true - }); - } - PIXI.Container.prototype.convertTo2d = convertTo2d; - PIXI.Sprite.prototype.convertTo2d = function () { - if (this.proj) - return; - this.calculateVertices = pixi_projection.Sprite2d.prototype.calculateVertices; - this.calculateTrimmedVertices = pixi_projection.Sprite2d.prototype.calculateTrimmedVertices; - this._calculateBounds = pixi_projection.Sprite2d.prototype._calculateBounds; - this.pluginName = 'sprite2d'; - convertTo2d.call(this); - }; - PIXI.Container.prototype.convertSubtreeTo2d = function () { - this.convertTo2d(); - for (var i = 0; i < this.children.length; i++) { - this.children[i].convertSubtreeTo2d(); - } - }; - if (PIXI.SimpleMesh) { - PIXI.SimpleMesh.prototype.convertTo2d = - PIXI.SimpleRope.prototype.convertTo2d = - function () { - if (this.proj) - return; - this.calculateVertices = pixi_projection.Mesh2d.prototype.calculateVertices; - this._renderDefault = pixi_projection.Mesh2d.prototype._renderDefault; - if (this.material.pluginName !== 'batch2d') { - this.material = new PIXI.MeshMaterial(this.material.texture, { - program: PIXI.Program.from(pixi_projection.Mesh2d.defaultVertexShader, pixi_projection.Mesh2d.defaultFragmentShader), - pluginName: 'batch2d' - }); - } - convertTo2d.call(this); - }; - } -})(pixi_projection || (pixi_projection = {})); -var pixi_projection; -(function (pixi_projection) { - var tempTransform = new PIXI.Transform(); - var TilingSprite2d = (function (_super) { - __extends(TilingSprite2d, _super); - function TilingSprite2d(texture, width, height) { - var _this = _super.call(this, texture, width, height) || this; - _this.tileProj = new pixi_projection.Projection2d(_this.tileTransform); - _this.tileProj.reverseLocalOrder = true; - _this.proj = new pixi_projection.Projection2d(_this.transform); - _this.pluginName = 'tilingSprite2d'; - _this.uvRespectAnchor = true; - return _this; - } - Object.defineProperty(TilingSprite2d.prototype, "worldTransform", { - get: function () { - return this.proj.affine ? this.transform.worldTransform : this.proj.world; - }, - enumerable: true, - configurable: true - }); - TilingSprite2d.prototype.toLocal = function (position, from, point, skipUpdate, step) { - if (step === void 0) { step = pixi_projection.TRANSFORM_STEP.ALL; } - return pixi_projection.container2dToLocal.call(this, position, from, point, skipUpdate, step); - }; - TilingSprite2d.prototype._render = function (renderer) { - var texture = this._texture; - if (!texture || !texture.valid) { - return; - } - this.tileTransform.updateTransform(tempTransform); - this.uvMatrix.update(); - renderer.batch.setObjectRenderer(renderer.plugins[this.pluginName]); - renderer.plugins[this.pluginName].render(this); - }; - return TilingSprite2d; - }(PIXI.TilingSprite)); - pixi_projection.TilingSprite2d = TilingSprite2d; -})(pixi_projection || (pixi_projection = {})); -var pixi_projection; -(function (pixi_projection) { - var shaderVert = "attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\nuniform mat3 translationMatrix;\nuniform mat3 uTransform;\n\nvarying vec3 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position.xyw = projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0);\n\n vTextureCoord = uTransform * vec3(aTextureCoord, 1.0);\n}\n"; - var shaderFrag = "\nvarying vec3 vTextureCoord;\n\nuniform sampler2D uSampler;\nuniform vec4 uColor;\nuniform mat3 uMapCoord;\nuniform vec4 uClampFrame;\nuniform vec2 uClampOffset;\n\nvoid main(void)\n{\n vec2 coord = mod(vTextureCoord.xy / vTextureCoord.z - uClampOffset, vec2(1.0, 1.0)) + uClampOffset;\n coord = (uMapCoord * vec3(coord, 1.0)).xy;\n coord = clamp(coord, uClampFrame.xy, uClampFrame.zw);\n\n vec4 sample = texture2D(uSampler, coord);\n gl_FragColor = sample * uColor;\n}\n"; - var shaderSimpleFrag = "\n\tvarying vec3 vTextureCoord;\n\nuniform sampler2D uSampler;\nuniform vec4 uColor;\n\nvoid main(void)\n{\n vec4 sample = texture2D(uSampler, vTextureCoord.xy / vTextureCoord.z);\n gl_FragColor = sample * uColor;\n}\n"; - var tempMat = new pixi_projection.Matrix2d(); - var WRAP_MODES = PIXI.WRAP_MODES; - var utils = PIXI.utils; - var TilingSprite2dRenderer = (function (_super) { - __extends(TilingSprite2dRenderer, _super); - function TilingSprite2dRenderer(renderer) { - var _this = _super.call(this, renderer) || this; - _this.quad = new PIXI.QuadUv(); - var uniforms = { globals: _this.renderer.globalUniforms }; - _this.shader = PIXI.Shader.from(shaderVert, shaderFrag, uniforms); - _this.simpleShader = PIXI.Shader.from(shaderVert, shaderSimpleFrag, uniforms); - return _this; - } - TilingSprite2dRenderer.prototype.render = function (ts) { - var renderer = this.renderer; - var quad = this.quad; - var vertices = quad.vertices; - vertices[0] = vertices[6] = (ts._width) * -ts.anchor.x; - vertices[1] = vertices[3] = ts._height * -ts.anchor.y; - vertices[2] = vertices[4] = (ts._width) * (1.0 - ts.anchor.x); - vertices[5] = vertices[7] = ts._height * (1.0 - ts.anchor.y); - if (ts.uvRespectAnchor) { - vertices = quad.uvs; - vertices[0] = vertices[6] = -ts.anchor.x; - vertices[1] = vertices[3] = -ts.anchor.y; - vertices[2] = vertices[4] = 1.0 - ts.anchor.x; - vertices[5] = vertices[7] = 1.0 - ts.anchor.y; - } - quad.invalidate(); - var tex = ts._texture; - var baseTex = tex.baseTexture; - var lt = ts.tileProj.world; - var uv = ts.uvMatrix; - var isSimple = baseTex.isPowerOfTwo - && tex.frame.width === baseTex.width && tex.frame.height === baseTex.height; - if (isSimple) { - if (!baseTex._glTextures[renderer.CONTEXT_UID]) { - if (baseTex.wrapMode === WRAP_MODES.CLAMP) { - baseTex.wrapMode = WRAP_MODES.REPEAT; - } - } - else { - isSimple = baseTex.wrapMode !== WRAP_MODES.CLAMP; - } - } - var shader = isSimple ? this.simpleShader : this.shader; - tempMat.identity(); - tempMat.scale(tex.width, tex.height); - tempMat.prepend(lt); - tempMat.scale(1.0 / ts._width, 1.0 / ts._height); - tempMat.invert(); - if (isSimple) { - tempMat.prepend(uv.mapCoord); - } - else { - shader.uniforms.uMapCoord = uv.mapCoord.toArray(true); - shader.uniforms.uClampFrame = uv.uClampFrame; - shader.uniforms.uClampOffset = uv.uClampOffset; - } - shader.uniforms.uTransform = tempMat.toArray(true); - shader.uniforms.uColor = utils.premultiplyTintToRgba(ts.tint, ts.worldAlpha, shader.uniforms.uColor, baseTex.premultiplyAlpha); - shader.uniforms.translationMatrix = ts.transform.worldTransform.toArray(true); - shader.uniforms.uSampler = tex; - renderer.shader.bind(shader, false); - renderer.geometry.bind(quad, undefined); - renderer.state.setBlendMode(utils.correctBlendMode(ts.blendMode, baseTex.premultiplyAlpha)); - renderer.geometry.draw(PIXI.DRAW_MODES.TRIANGLES, 6, 0); - }; - return TilingSprite2dRenderer; - }(PIXI.ObjectRenderer)); - pixi_projection.TilingSprite2dRenderer = TilingSprite2dRenderer; - PIXI.Renderer.registerPlugin('tilingSprite2d', TilingSprite2dRenderer); -})(pixi_projection || (pixi_projection = {})); -var pixi_projection; -(function (pixi_projection) { - PIXI.systems.MaskSystem.prototype.pushSpriteMask = function (target, maskData) { - var alphaMaskFilter = this.alphaMaskPool[this.alphaMaskIndex]; - if (!alphaMaskFilter) { - alphaMaskFilter = this.alphaMaskPool[this.alphaMaskIndex] = [new pixi_projection.SpriteMaskFilter2d(maskData)]; - } - alphaMaskFilter[0].resolution = this.renderer.resolution; - alphaMaskFilter[0].maskSprite = maskData; - target.filterArea = maskData.getBounds(true); - this.renderer.filter.push(target, alphaMaskFilter); - this.alphaMaskIndex++; - }; -})(pixi_projection || (pixi_projection = {})); -var pixi_projection; -(function (pixi_projection) { - var spriteMaskVert = "\nattribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\nuniform mat3 otherMatrix;\n\nvarying vec3 vMaskCoord;\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n\tgl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n\n\tvTextureCoord = aTextureCoord;\n\tvMaskCoord = otherMatrix * vec3( aTextureCoord, 1.0);\n}\n"; - var spriteMaskFrag = "\nvarying vec3 vMaskCoord;\nvarying vec2 vTextureCoord;\n\nuniform sampler2D uSampler;\nuniform sampler2D mask;\nuniform float alpha;\nuniform vec4 maskClamp;\n\nvoid main(void)\n{\n vec2 uv = vMaskCoord.xy / vMaskCoord.z;\n \n float clip = step(3.5,\n step(maskClamp.x, uv.x) +\n step(maskClamp.y, uv.y) +\n step(uv.x, maskClamp.z) +\n step(uv.y, maskClamp.w));\n\n vec4 original = texture2D(uSampler, vTextureCoord);\n vec4 masky = texture2D(mask, uv);\n \n original *= (masky.r * masky.a * alpha * clip);\n\n gl_FragColor = original;\n}\n"; - var tempMat = new pixi_projection.Matrix2d(); - var SpriteMaskFilter2d = (function (_super) { - __extends(SpriteMaskFilter2d, _super); - function SpriteMaskFilter2d(sprite) { - var _this = _super.call(this, spriteMaskVert, spriteMaskFrag) || this; - _this.maskMatrix = new pixi_projection.Matrix2d(); - sprite.renderable = false; - _this.maskSprite = sprite; - return _this; - } - SpriteMaskFilter2d.prototype.apply = function (filterManager, input, output, clear) { - var maskSprite = this.maskSprite; - var tex = this.maskSprite.texture; - if (!tex.valid) { - return; - } - if (!tex.uvMatrix) { - tex.uvMatrix = new PIXI.TextureMatrix(tex, 0.0); - } - tex.uvMatrix.update(); - this.uniforms.mask = maskSprite.texture; - this.uniforms.otherMatrix = SpriteMaskFilter2d.calculateSpriteMatrix(input, this.maskMatrix, maskSprite) - .prepend(tex.uvMatrix.mapCoord); - this.uniforms.alpha = maskSprite.worldAlpha; - this.uniforms.maskClamp = tex.uvMatrix.uClampFrame; - filterManager.applyFilter(this, input, output, clear); - }; - SpriteMaskFilter2d.calculateSpriteMatrix = function (input, mappedMatrix, sprite) { - var proj = sprite.proj; - var filterArea = input.filterFrame; - var worldTransform = proj && !proj._affine ? proj.world.copyTo2dOr3d(tempMat) : tempMat.copyFrom(sprite.transform.worldTransform); - var texture = sprite.texture.orig; - mappedMatrix.set(input.width, 0, 0, input.height, filterArea.x, filterArea.y); - worldTransform.invert(); - mappedMatrix.setToMult(worldTransform, mappedMatrix); - mappedMatrix.scaleAndTranslate(1.0 / texture.width, 1.0 / texture.height, sprite.anchor.x, sprite.anchor.y); - return mappedMatrix; - }; - return SpriteMaskFilter2d; - }(PIXI.Filter)); - pixi_projection.SpriteMaskFilter2d = SpriteMaskFilter2d; -})(pixi_projection || (pixi_projection = {})); -var pixi_projection; -(function (pixi_projection) { - function container3dWorldTransform() { - return this.proj.affine ? this.transform.worldTransform : this.proj.world; - } - pixi_projection.container3dWorldTransform = container3dWorldTransform; - var Container3d = (function (_super) { - __extends(Container3d, _super); - function Container3d() { - var _this = _super.call(this) || this; - _this.proj = new pixi_projection.Projection3d(_this.transform); - return _this; - } - Container3d.prototype.isFrontFace = function (forceUpdate) { - if (forceUpdate === void 0) { forceUpdate = false; } - if (forceUpdate) { - this._recursivePostUpdateTransform(); - this.displayObjectUpdateTransform(); - } - var mat = this.proj.world.mat4; - var dx1 = mat[0] * mat[15] - mat[3] * mat[12]; - var dy1 = mat[1] * mat[15] - mat[3] * mat[13]; - var dx2 = mat[4] * mat[15] - mat[7] * mat[12]; - var dy2 = mat[5] * mat[15] - mat[7] * mat[13]; - return dx1 * dy2 - dx2 * dy1 > 0; - }; - Container3d.prototype.getDepth = function (forceUpdate) { - if (forceUpdate === void 0) { forceUpdate = false; } - if (forceUpdate) { - this._recursivePostUpdateTransform(); - this.displayObjectUpdateTransform(); - } - var mat4 = this.proj.world.mat4; - return mat4[14] / mat4[15]; - }; - Container3d.prototype.toLocal = function (position, from, point, skipUpdate, step) { - if (step === void 0) { step = pixi_projection.TRANSFORM_STEP.ALL; } - if (from) { - position = from.toGlobal(position, point, skipUpdate); - } - if (!skipUpdate) { - this._recursivePostUpdateTransform(); - } - if (step === pixi_projection.TRANSFORM_STEP.ALL) { - if (!skipUpdate) { - this.displayObjectUpdateTransform(); - } - if (this.proj.affine) { - return this.transform.worldTransform.applyInverse(position, point); - } - return this.proj.world.applyInverse(position, point); - } - if (this.parent) { - point = this.parent.worldTransform.applyInverse(position, point); - } - else { - point.copyFrom(position); - } - if (step === pixi_projection.TRANSFORM_STEP.NONE) { - return point; - } - point = this.transform.localTransform.applyInverse(point, point); - if (step === pixi_projection.TRANSFORM_STEP.PROJ && this.proj.cameraMode) { - point = this.proj.cameraMatrix.applyInverse(point, point); - } - return point; - }; - Object.defineProperty(Container3d.prototype, "worldTransform", { - get: function () { - return this.proj.affine ? this.transform.worldTransform : this.proj.world; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Container3d.prototype, "position3d", { - get: function () { - return this.proj.position; - }, - set: function (value) { - this.proj.position.copyFrom(value); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Container3d.prototype, "scale3d", { - get: function () { - return this.proj.scale; - }, - set: function (value) { - this.proj.scale.copyFrom(value); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Container3d.prototype, "euler", { - get: function () { - return this.proj.euler; - }, - set: function (value) { - this.proj.euler.copyFrom(value); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Container3d.prototype, "pivot3d", { - get: function () { - return this.proj.pivot; - }, - set: function (value) { - this.proj.pivot.copyFrom(value); - }, - enumerable: true, - configurable: true - }); - return Container3d; - }(PIXI.Container)); - pixi_projection.Container3d = Container3d; - pixi_projection.container3dToLocal = Container3d.prototype.toLocal; - pixi_projection.container3dGetDepth = Container3d.prototype.getDepth; - pixi_projection.container3dIsFrontFace = Container3d.prototype.isFrontFace; -})(pixi_projection || (pixi_projection = {})); -var pixi_projection; -(function (pixi_projection) { - var Camera3d = (function (_super) { - __extends(Camera3d, _super); - function Camera3d() { - var _this = _super.call(this) || this; - _this._far = 0; - _this._near = 0; - _this._focus = 0; - _this._orthographic = false; - _this.proj.cameraMode = true; - _this.setPlanes(400, 10, 10000, false); - return _this; - } - Object.defineProperty(Camera3d.prototype, "far", { - get: function () { - return this._far; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Camera3d.prototype, "near", { - get: function () { - return this._near; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Camera3d.prototype, "focus", { - get: function () { - return this._focus; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Camera3d.prototype, "ortographic", { - get: function () { - return this._orthographic; - }, - enumerable: true, - configurable: true - }); - Camera3d.prototype.setPlanes = function (focus, near, far, orthographic) { - if (near === void 0) { near = 10; } - if (far === void 0) { far = 10000; } - if (orthographic === void 0) { orthographic = false; } - this._focus = focus; - this._near = near; - this._far = far; - this._orthographic = orthographic; - var proj = this.proj; - var mat4 = proj.cameraMatrix.mat4; - proj._projID++; - mat4[10] = 1.0 / (far - near); - mat4[14] = (focus - near) / (far - near); - if (this._orthographic) { - mat4[11] = 0; - } - else { - mat4[11] = 1.0 / focus; - } - }; - return Camera3d; - }(pixi_projection.Container3d)); - pixi_projection.Camera3d = Camera3d; -})(pixi_projection || (pixi_projection = {})); -var pixi_projection; -(function (pixi_projection) { - var Euler = (function () { - function Euler(x, y, z) { - this._quatUpdateId = -1; - this._quatDirtyId = 0; - this._sign = 1; - this._x = x || 0; - this._y = y || 0; - this._z = z || 0; - this.quaternion = new Float64Array(4); - this.quaternion[3] = 1; - this.update(); - } - Object.defineProperty(Euler.prototype, "x", { - get: function () { - return this._x; - }, - set: function (value) { - if (this._x !== value) { - this._x = value; - this._quatDirtyId++; - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Euler.prototype, "y", { - get: function () { - return this._y; - }, - set: function (value) { - if (this._y !== value) { - this._y = value; - this._quatDirtyId++; - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Euler.prototype, "z", { - get: function () { - return this._z; - }, - set: function (value) { - if (this._z !== value) { - this._z = value; - this._quatDirtyId++; - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Euler.prototype, "pitch", { - get: function () { - return this._x; - }, - set: function (value) { - if (this._x !== value) { - this._x = value; - this._quatDirtyId++; - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Euler.prototype, "yaw", { - get: function () { - return this._y; - }, - set: function (value) { - if (this._y !== value) { - this._y = value; - this._quatDirtyId++; - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Euler.prototype, "roll", { - get: function () { - return this._z; - }, - set: function (value) { - if (this._z !== value) { - this._z = value; - this._quatDirtyId++; - } - }, - enumerable: true, - configurable: true - }); - Euler.prototype.set = function (x, y, z) { - var _x = x || 0; - var _y = y || 0; - var _z = z || 0; - if (this._x !== _x || this._y !== _y || this._z !== _z) { - this._x = _x; - this._y = _y; - this._z = _z; - this._quatDirtyId++; - } - }; - ; - Euler.prototype.copyFrom = function (euler) { - var _x = euler.x; - var _y = euler.y; - var _z = euler.z; - if (this._x !== _x || this._y !== _y || this._z !== _z) { - this._x = _x; - this._y = _y; - this._z = _z; - this._quatDirtyId++; - } - }; - Euler.prototype.copyTo = function (p) { - p.set(this._x, this._y, this._z); - return p; - }; - Euler.prototype.equals = function (euler) { - return this._x === euler.x - && this._y === euler.y - && this._z === euler.z; - }; - Euler.prototype.clone = function () { - return new Euler(this._x, this._y, this._z); - }; - Euler.prototype.update = function () { - if (this._quatUpdateId === this._quatDirtyId) { - return false; - } - this._quatUpdateId = this._quatDirtyId; - var c1 = Math.cos(this._x / 2); - var c2 = Math.cos(this._y / 2); - var c3 = Math.cos(this._z / 2); - var s = this._sign; - var s1 = s * Math.sin(this._x / 2); - var s2 = s * Math.sin(this._y / 2); - var s3 = s * Math.sin(this._z / 2); - var q = this.quaternion; - q[0] = s1 * c2 * c3 + c1 * s2 * s3; - q[1] = c1 * s2 * c3 - s1 * c2 * s3; - q[2] = c1 * c2 * s3 + s1 * s2 * c3; - q[3] = c1 * c2 * c3 - s1 * s2 * s3; - return true; - }; - return Euler; - }()); - pixi_projection.Euler = Euler; -})(pixi_projection || (pixi_projection = {})); -var pixi_projection; -(function (pixi_projection) { - var mat4id = [1, 0, 0, 0, - 0, 1, 0, 0, - 0, 0, 1, 0, - 0, 0, 0, 1]; - var Matrix3d = (function () { - function Matrix3d(backingArray) { - this.floatArray = null; - this._dirtyId = 0; - this._updateId = -1; - this._mat4inv = null; - this.cacheInverse = false; - this.mat4 = new Float64Array(backingArray || mat4id); - } - Object.defineProperty(Matrix3d.prototype, "a", { - get: function () { - return this.mat4[0] / this.mat4[15]; - }, - set: function (value) { - this.mat4[0] = value * this.mat4[15]; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Matrix3d.prototype, "b", { - get: function () { - return this.mat4[1] / this.mat4[15]; - }, - set: function (value) { - this.mat4[1] = value * this.mat4[15]; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Matrix3d.prototype, "c", { - get: function () { - return this.mat4[4] / this.mat4[15]; - }, - set: function (value) { - this.mat4[4] = value * this.mat4[15]; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Matrix3d.prototype, "d", { - get: function () { - return this.mat4[5] / this.mat4[15]; - }, - set: function (value) { - this.mat4[5] = value * this.mat4[15]; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Matrix3d.prototype, "tx", { - get: function () { - return this.mat4[12] / this.mat4[15]; - }, - set: function (value) { - this.mat4[12] = value * this.mat4[15]; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Matrix3d.prototype, "ty", { - get: function () { - return this.mat4[13] / this.mat4[15]; - }, - set: function (value) { - this.mat4[13] = value * this.mat4[15]; - }, - enumerable: true, - configurable: true - }); - Matrix3d.prototype.set = function (a, b, c, d, tx, ty) { - var mat4 = this.mat4; - mat4[0] = a; - mat4[1] = b; - mat4[2] = 0; - mat4[3] = 0; - mat4[4] = c; - mat4[5] = d; - mat4[6] = 0; - mat4[7] = 0; - mat4[8] = 0; - mat4[9] = 0; - mat4[10] = 1; - mat4[11] = 0; - mat4[12] = tx; - mat4[13] = ty; - mat4[14] = 0; - mat4[15] = 1; - return this; - }; - Matrix3d.prototype.toArray = function (transpose, out) { - if (!this.floatArray) { - this.floatArray = new Float32Array(9); - } - var array = out || this.floatArray; - var mat3 = this.mat4; - if (transpose) { - array[0] = mat3[0]; - array[1] = mat3[1]; - array[2] = mat3[3]; - array[3] = mat3[4]; - array[4] = mat3[5]; - array[5] = mat3[7]; - array[6] = mat3[12]; - array[7] = mat3[13]; - array[8] = mat3[15]; - } - else { - array[0] = mat3[0]; - array[1] = mat3[4]; - array[2] = mat3[12]; - array[3] = mat3[2]; - array[4] = mat3[6]; - array[5] = mat3[13]; - array[6] = mat3[3]; - array[7] = mat3[7]; - array[8] = mat3[15]; - } - return array; - }; - Matrix3d.prototype.setToTranslation = function (tx, ty, tz) { - var mat4 = this.mat4; - mat4[0] = 1; - mat4[1] = 0; - mat4[2] = 0; - mat4[3] = 0; - mat4[4] = 0; - mat4[5] = 1; - mat4[6] = 0; - mat4[7] = 0; - mat4[8] = 0; - mat4[9] = 0; - mat4[10] = 1; - mat4[11] = 0; - mat4[12] = tx; - mat4[13] = ty; - mat4[14] = tz; - mat4[15] = 1; - }; - Matrix3d.prototype.setToRotationTranslationScale = function (quat, tx, ty, tz, sx, sy, sz) { - var out = this.mat4; - var x = quat[0], y = quat[1], z = quat[2], w = quat[3]; - var x2 = x + x; - var y2 = y + y; - var z2 = z + z; - var xx = x * x2; - var xy = x * y2; - var xz = x * z2; - var yy = y * y2; - var yz = y * z2; - var zz = z * z2; - var wx = w * x2; - var wy = w * y2; - var wz = w * z2; - out[0] = (1 - (yy + zz)) * sx; - out[1] = (xy + wz) * sx; - out[2] = (xz - wy) * sx; - out[3] = 0; - out[4] = (xy - wz) * sy; - out[5] = (1 - (xx + zz)) * sy; - out[6] = (yz + wx) * sy; - out[7] = 0; - out[8] = (xz + wy) * sz; - out[9] = (yz - wx) * sz; - out[10] = (1 - (xx + yy)) * sz; - out[11] = 0; - out[12] = tx; - out[13] = ty; - out[14] = tz; - out[15] = 1; - return out; - }; - Matrix3d.prototype.apply = function (pos, newPos) { - newPos = newPos || new pixi_projection.Point3d(); - var mat4 = this.mat4; - var x = pos.x; - var y = pos.y; - var z = pos.z || 0; - var w = 1.0 / (mat4[3] * x + mat4[7] * y + mat4[11] * z + mat4[15]); - newPos.x = w * (mat4[0] * x + mat4[4] * y + mat4[8] * z + mat4[12]); - newPos.y = w * (mat4[1] * x + mat4[5] * y + mat4[9] * z + mat4[13]); - newPos.z = w * (mat4[2] * x + mat4[6] * y + mat4[10] * z + mat4[14]); - return newPos; - }; - Matrix3d.prototype.translate = function (tx, ty, tz) { - var a = this.mat4; - a[12] = a[0] * tx + a[4] * ty + a[8] * tz + a[12]; - a[13] = a[1] * tx + a[5] * ty + a[9] * tz + a[13]; - a[14] = a[2] * tx + a[6] * ty + a[10] * tz + a[14]; - a[15] = a[3] * tx + a[7] * ty + a[11] * tz + a[15]; - return this; - }; - Matrix3d.prototype.scale = function (x, y, z) { - var mat4 = this.mat4; - mat4[0] *= x; - mat4[1] *= x; - mat4[2] *= x; - mat4[3] *= x; - mat4[4] *= y; - mat4[5] *= y; - mat4[6] *= y; - mat4[7] *= y; - if (z !== undefined) { - mat4[8] *= z; - mat4[9] *= z; - mat4[10] *= z; - mat4[11] *= z; - } - return this; - }; - Matrix3d.prototype.scaleAndTranslate = function (scaleX, scaleY, scaleZ, tx, ty, tz) { - var mat4 = this.mat4; - mat4[0] = scaleX * mat4[0] + tx * mat4[3]; - mat4[1] = scaleY * mat4[1] + ty * mat4[3]; - mat4[2] = scaleZ * mat4[2] + tz * mat4[3]; - mat4[4] = scaleX * mat4[4] + tx * mat4[7]; - mat4[5] = scaleY * mat4[5] + ty * mat4[7]; - mat4[6] = scaleZ * mat4[6] + tz * mat4[7]; - mat4[8] = scaleX * mat4[8] + tx * mat4[11]; - mat4[9] = scaleY * mat4[9] + ty * mat4[11]; - mat4[10] = scaleZ * mat4[10] + tz * mat4[11]; - mat4[12] = scaleX * mat4[12] + tx * mat4[15]; - mat4[13] = scaleY * mat4[13] + ty * mat4[15]; - mat4[14] = scaleZ * mat4[14] + tz * mat4[15]; - }; - Matrix3d.prototype.applyInverse = function (pos, newPos) { - newPos = newPos || new pixi_projection.Point3d(); - if (!this._mat4inv) { - this._mat4inv = new Float64Array(16); - } - var mat4 = this._mat4inv; - var a = this.mat4; - var x = pos.x; - var y = pos.y; - var z = pos.z || 0; - if (!this.cacheInverse || this._updateId !== this._dirtyId) { - this._updateId = this._dirtyId; - Matrix3d.glMatrixMat4Invert(mat4, a); - } - var w1 = 1.0 / (mat4[3] * x + mat4[7] * y + mat4[11] * z + mat4[15]); - var x1 = w1 * (mat4[0] * x + mat4[4] * y + mat4[8] * z + mat4[12]); - var y1 = w1 * (mat4[1] * x + mat4[5] * y + mat4[9] * z + mat4[13]); - var z1 = w1 * (mat4[2] * x + mat4[6] * y + mat4[10] * z + mat4[14]); - z += 1.0; - var w2 = 1.0 / (mat4[3] * x + mat4[7] * y + mat4[11] * z + mat4[15]); - var x2 = w2 * (mat4[0] * x + mat4[4] * y + mat4[8] * z + mat4[12]); - var y2 = w2 * (mat4[1] * x + mat4[5] * y + mat4[9] * z + mat4[13]); - var z2 = w2 * (mat4[2] * x + mat4[6] * y + mat4[10] * z + mat4[14]); - if (Math.abs(z1 - z2) < 1e-10) { - newPos.set(NaN, NaN, 0); - } - var alpha = (0 - z1) / (z2 - z1); - newPos.set((x2 - x1) * alpha + x1, (y2 - y1) * alpha + y1, 0.0); - return newPos; - }; - Matrix3d.prototype.invert = function () { - Matrix3d.glMatrixMat4Invert(this.mat4, this.mat4); - return this; - }; - Matrix3d.prototype.invertCopyTo = function (matrix) { - if (!this._mat4inv) { - this._mat4inv = new Float64Array(16); - } - var mat4 = this._mat4inv; - var a = this.mat4; - if (!this.cacheInverse || this._updateId !== this._dirtyId) { - this._updateId = this._dirtyId; - Matrix3d.glMatrixMat4Invert(mat4, a); - } - matrix.mat4.set(mat4); - }; - Matrix3d.prototype.identity = function () { - var mat3 = this.mat4; - mat3[0] = 1; - mat3[1] = 0; - mat3[2] = 0; - mat3[3] = 0; - mat3[4] = 0; - mat3[5] = 1; - mat3[6] = 0; - mat3[7] = 0; - mat3[8] = 0; - mat3[9] = 0; - mat3[10] = 1; - mat3[11] = 0; - mat3[12] = 0; - mat3[13] = 0; - mat3[14] = 0; - mat3[15] = 1; - return this; - }; - Matrix3d.prototype.clone = function () { - return new Matrix3d(this.mat4); - }; - Matrix3d.prototype.copyTo3d = function (matrix) { - var mat3 = this.mat4; - var ar2 = matrix.mat4; - ar2[0] = mat3[0]; - ar2[1] = mat3[1]; - ar2[2] = mat3[2]; - ar2[3] = mat3[3]; - ar2[4] = mat3[4]; - ar2[5] = mat3[5]; - ar2[6] = mat3[6]; - ar2[7] = mat3[7]; - ar2[8] = mat3[8]; - return matrix; - }; - Matrix3d.prototype.copyTo2d = function (matrix) { - var mat3 = this.mat4; - var ar2 = matrix.mat3; - ar2[0] = mat3[0]; - ar2[1] = mat3[1]; - ar2[2] = mat3[3]; - ar2[3] = mat3[4]; - ar2[4] = mat3[5]; - ar2[5] = mat3[7]; - ar2[6] = mat3[12]; - ar2[7] = mat3[13]; - ar2[8] = mat3[15]; - return matrix; - }; - Matrix3d.prototype.copyTo2dOr3d = function (matrix) { - if (matrix instanceof pixi_projection.Matrix2d) { - return this.copyTo2d(matrix); - } - else { - return this.copyTo3d(matrix); - } - }; - Matrix3d.prototype.copyTo = function (matrix, affine, preserveOrientation) { - var mat3 = this.mat4; - var d = 1.0 / mat3[15]; - var tx = mat3[12] * d, ty = mat3[13] * d; - matrix.a = (mat3[0] - mat3[3] * tx) * d; - matrix.b = (mat3[1] - mat3[3] * ty) * d; - matrix.c = (mat3[4] - mat3[7] * tx) * d; - matrix.d = (mat3[5] - mat3[7] * ty) * d; - matrix.tx = tx; - matrix.ty = ty; - if (affine >= 2) { - var D = matrix.a * matrix.d - matrix.b * matrix.c; - if (!preserveOrientation) { - D = Math.abs(D); - } - if (affine === pixi_projection.AFFINE.POINT) { - if (D > 0) { - D = 1; - } - else - D = -1; - matrix.a = D; - matrix.b = 0; - matrix.c = 0; - matrix.d = D; - } - else if (affine === pixi_projection.AFFINE.AXIS_X) { - D /= Math.sqrt(matrix.b * matrix.b + matrix.d * matrix.d); - matrix.c = 0; - matrix.d = D; - } - else if (affine === pixi_projection.AFFINE.AXIS_Y) { - D /= Math.sqrt(matrix.a * matrix.a + matrix.c * matrix.c); - matrix.a = D; - matrix.c = 0; - } - } - return matrix; - }; - Matrix3d.prototype.copyFrom = function (matrix) { - var mat3 = this.mat4; - mat3[0] = matrix.a; - mat3[1] = matrix.b; - mat3[2] = 0; - mat3[3] = 0; - mat3[4] = matrix.c; - mat3[5] = matrix.d; - mat3[6] = 0; - mat3[7] = 0; - mat3[8] = 0; - mat3[9] = 0; - mat3[10] = 1; - mat3[11] = 0; - mat3[12] = matrix.tx; - mat3[13] = matrix.ty; - mat3[14] = 0; - mat3[15] = 1; - this._dirtyId++; - return this; - }; - Matrix3d.prototype.setToMultLegacy = function (pt, lt) { - var out = this.mat4; - var b = lt.mat4; - var a00 = pt.a, a01 = pt.b, a10 = pt.c, a11 = pt.d, a30 = pt.tx, a31 = pt.ty; - var b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3]; - out[0] = b0 * a00 + b1 * a10 + b3 * a30; - out[1] = b0 * a01 + b1 * a11 + b3 * a31; - out[2] = b2; - out[3] = b3; - b0 = b[4]; - b1 = b[5]; - b2 = b[6]; - b3 = b[7]; - out[4] = b0 * a00 + b1 * a10 + b3 * a30; - out[5] = b0 * a01 + b1 * a11 + b3 * a31; - out[6] = b2; - out[7] = b3; - b0 = b[8]; - b1 = b[9]; - b2 = b[10]; - b3 = b[11]; - out[8] = b0 * a00 + b1 * a10 + b3 * a30; - out[9] = b0 * a01 + b1 * a11 + b3 * a31; - out[10] = b2; - out[11] = b3; - b0 = b[12]; - b1 = b[13]; - b2 = b[14]; - b3 = b[15]; - out[12] = b0 * a00 + b1 * a10 + b3 * a30; - out[13] = b0 * a01 + b1 * a11 + b3 * a31; - out[14] = b2; - out[15] = b3; - this._dirtyId++; - return this; - }; - Matrix3d.prototype.setToMultLegacy2 = function (pt, lt) { - var out = this.mat4; - var a = pt.mat4; - var a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3]; - var a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7]; - var b00 = lt.a, b01 = lt.b, b10 = lt.c, b11 = lt.d, b30 = lt.tx, b31 = lt.ty; - out[0] = b00 * a00 + b01 * a10; - out[1] = b00 * a01 + b01 * a11; - out[2] = b00 * a02 + b01 * a12; - out[3] = b00 * a03 + b01 * a13; - out[4] = b10 * a00 + b11 * a10; - out[5] = b10 * a01 + b11 * a11; - out[6] = b10 * a02 + b11 * a12; - out[7] = b10 * a03 + b11 * a13; - out[8] = a[8]; - out[9] = a[9]; - out[10] = a[10]; - out[11] = a[11]; - out[12] = b30 * a00 + b31 * a10 + a[12]; - out[13] = b30 * a01 + b31 * a11 + a[13]; - out[14] = b30 * a02 + b31 * a12 + a[14]; - out[15] = b30 * a03 + b31 * a13 + a[15]; - this._dirtyId++; - return this; - }; - Matrix3d.prototype.setToMult = function (pt, lt) { - Matrix3d.glMatrixMat4Multiply(this.mat4, pt.mat4, lt.mat4); - this._dirtyId++; - return this; - }; - Matrix3d.prototype.prepend = function (lt) { - if (lt.mat4) { - this.setToMult(lt, this); - } - else { - this.setToMultLegacy(lt, this); - } - }; - Matrix3d.glMatrixMat4Invert = function (out, a) { - var a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3]; - var a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7]; - var a20 = a[8], a21 = a[9], a22 = a[10], a23 = a[11]; - var a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15]; - var b00 = a00 * a11 - a01 * a10; - var b01 = a00 * a12 - a02 * a10; - var b02 = a00 * a13 - a03 * a10; - var b03 = a01 * a12 - a02 * a11; - var b04 = a01 * a13 - a03 * a11; - var b05 = a02 * a13 - a03 * a12; - var b06 = a20 * a31 - a21 * a30; - var b07 = a20 * a32 - a22 * a30; - var b08 = a20 * a33 - a23 * a30; - var b09 = a21 * a32 - a22 * a31; - var b10 = a21 * a33 - a23 * a31; - var b11 = a22 * a33 - a23 * a32; - var det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06; - if (!det) { - return null; - } - det = 1.0 / det; - out[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det; - out[1] = (a02 * b10 - a01 * b11 - a03 * b09) * det; - out[2] = (a31 * b05 - a32 * b04 + a33 * b03) * det; - out[3] = (a22 * b04 - a21 * b05 - a23 * b03) * det; - out[4] = (a12 * b08 - a10 * b11 - a13 * b07) * det; - out[5] = (a00 * b11 - a02 * b08 + a03 * b07) * det; - out[6] = (a32 * b02 - a30 * b05 - a33 * b01) * det; - out[7] = (a20 * b05 - a22 * b02 + a23 * b01) * det; - out[8] = (a10 * b10 - a11 * b08 + a13 * b06) * det; - out[9] = (a01 * b08 - a00 * b10 - a03 * b06) * det; - out[10] = (a30 * b04 - a31 * b02 + a33 * b00) * det; - out[11] = (a21 * b02 - a20 * b04 - a23 * b00) * det; - out[12] = (a11 * b07 - a10 * b09 - a12 * b06) * det; - out[13] = (a00 * b09 - a01 * b07 + a02 * b06) * det; - out[14] = (a31 * b01 - a30 * b03 - a32 * b00) * det; - out[15] = (a20 * b03 - a21 * b01 + a22 * b00) * det; - return out; - }; - Matrix3d.glMatrixMat4Multiply = function (out, a, b) { - var a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3]; - var a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7]; - var a20 = a[8], a21 = a[9], a22 = a[10], a23 = a[11]; - var a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15]; - var b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3]; - out[0] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30; - out[1] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31; - out[2] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32; - out[3] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33; - b0 = b[4]; - b1 = b[5]; - b2 = b[6]; - b3 = b[7]; - out[4] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30; - out[5] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31; - out[6] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32; - out[7] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33; - b0 = b[8]; - b1 = b[9]; - b2 = b[10]; - b3 = b[11]; - out[8] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30; - out[9] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31; - out[10] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32; - out[11] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33; - b0 = b[12]; - b1 = b[13]; - b2 = b[14]; - b3 = b[15]; - out[12] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30; - out[13] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31; - out[14] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32; - out[15] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33; - return out; - }; - Matrix3d.IDENTITY = new Matrix3d(); - Matrix3d.TEMP_MATRIX = new Matrix3d(); - return Matrix3d; - }()); - pixi_projection.Matrix3d = Matrix3d; -})(pixi_projection || (pixi_projection = {})); -var pixi_projection; -(function (pixi_projection) { - var ObservableEuler = (function () { - function ObservableEuler(cb, scope, x, y, z) { - this.cb = cb; - this.scope = scope; - this._quatUpdateId = -1; - this._quatDirtyId = 0; - this._sign = 1; - this._x = x || 0; - this._y = y || 0; - this._z = z || 0; - this.quaternion = new Float64Array(4); - this.quaternion[3] = 1; - this.update(); - } - Object.defineProperty(ObservableEuler.prototype, "x", { - get: function () { - return this._x; - }, - set: function (value) { - if (this._x !== value) { - this._x = value; - this._quatDirtyId++; - this.cb.call(this.scope); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ObservableEuler.prototype, "y", { - get: function () { - return this._y; - }, - set: function (value) { - if (this._y !== value) { - this._y = value; - this._quatDirtyId++; - this.cb.call(this.scope); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ObservableEuler.prototype, "z", { - get: function () { - return this._z; - }, - set: function (value) { - if (this._z !== value) { - this._z = value; - this._quatDirtyId++; - this.cb.call(this.scope); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ObservableEuler.prototype, "pitch", { - get: function () { - return this._x; - }, - set: function (value) { - if (this._x !== value) { - this._x = value; - this._quatDirtyId++; - this.cb.call(this.scope); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ObservableEuler.prototype, "yaw", { - get: function () { - return this._y; - }, - set: function (value) { - if (this._y !== value) { - this._y = value; - this._quatDirtyId++; - this.cb.call(this.scope); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ObservableEuler.prototype, "roll", { - get: function () { - return this._z; - }, - set: function (value) { - if (this._z !== value) { - this._z = value; - this._quatDirtyId++; - this.cb.call(this.scope); - } - }, - enumerable: true, - configurable: true - }); - ObservableEuler.prototype.set = function (x, y, z) { - var _x = x || 0; - var _y = y || 0; - var _z = z || 0; - if (this._x !== _x || this._y !== _y || this._z !== _z) { - this._x = _x; - this._y = _y; - this._z = _z; - this._quatDirtyId++; - this.cb.call(this.scope); - } - }; - ; - ObservableEuler.prototype.copyFrom = function (euler) { - var _x = euler.x; - var _y = euler.y; - var _z = euler.z; - if (this._x !== _x || this._y !== _y || this._z !== _z) { - this._x = _x; - this._y = _y; - this._z = _z; - this._quatDirtyId++; - this.cb.call(this.scope); - } - }; - ObservableEuler.prototype.copyTo = function (p) { - p.set(this._x, this._y, this._z); - return p; - }; - ObservableEuler.prototype.equals = function (euler) { - return this._x === euler.x - && this._y === euler.y - && this._z === euler.z; - }; - ObservableEuler.prototype.clone = function () { - return new pixi_projection.Euler(this._x, this._y, this._z); - }; - ObservableEuler.prototype.update = function () { - if (this._quatUpdateId === this._quatDirtyId) { - return false; - } - this._quatUpdateId = this._quatDirtyId; - var c1 = Math.cos(this._x / 2); - var c2 = Math.cos(this._y / 2); - var c3 = Math.cos(this._z / 2); - var s = this._sign; - var s1 = s * Math.sin(this._x / 2); - var s2 = s * Math.sin(this._y / 2); - var s3 = s * Math.sin(this._z / 2); - var q = this.quaternion; - q[0] = s1 * c2 * c3 + c1 * s2 * s3; - q[1] = c1 * s2 * c3 - s1 * c2 * s3; - q[2] = c1 * c2 * s3 + s1 * s2 * c3; - q[3] = c1 * c2 * c3 - s1 * s2 * s3; - return true; - }; - return ObservableEuler; - }()); - pixi_projection.ObservableEuler = ObservableEuler; -})(pixi_projection || (pixi_projection = {})); -var pixi_projection; -(function (pixi_projection) { - PIXI.ObservablePoint.prototype.copy = function (point) { - }; - var Point3d = (function (_super) { - __extends(Point3d, _super); - function Point3d(x, y, z) { - var _this = _super.call(this, x, y) || this; - _this.z = z; - return _this; - } - Point3d.prototype.set = function (x, y, z) { - this.x = x || 0; - this.y = (y === undefined) ? this.x : (y || 0); - this.z = (y === undefined) ? this.x : (z || 0); - }; - Point3d.prototype.copyFrom = function (p) { - this.set(p.x, p.y, p.z || 0); - return this; - }; - Point3d.prototype.copyTo = function (p) { - p.set(this.x, this.y, this.z); - return p; - }; - return Point3d; - }(PIXI.Point)); - pixi_projection.Point3d = Point3d; - var ObservablePoint3d = (function (_super) { - __extends(ObservablePoint3d, _super); - function ObservablePoint3d() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this._z = 0; - return _this; - } - Object.defineProperty(ObservablePoint3d.prototype, "z", { - get: function () { - return this._z; - }, - set: function (value) { - if (this._z !== value) { - this._z = value; - this.cb.call(this.scope); - } - }, - enumerable: true, - configurable: true - }); - ObservablePoint3d.prototype.set = function (x, y, z) { - var _x = x || 0; - var _y = (y === undefined) ? _x : (y || 0); - var _z = (y === undefined) ? _x : (z || 0); - if (this._x !== _x || this._y !== _y || this._z !== _z) { - this._x = _x; - this._y = _y; - this._z = _z; - this.cb.call(this.scope); - } - }; - ObservablePoint3d.prototype.copyFrom = function (p) { - this.set(p.x, p.y, p.z || 0); - return this; - }; - ObservablePoint3d.prototype.copyTo = function (p) { - p.set(this._x, this._y, this._z); - return p; - }; - return ObservablePoint3d; - }(PIXI.ObservablePoint)); - pixi_projection.ObservablePoint3d = ObservablePoint3d; -})(pixi_projection || (pixi_projection = {})); -var pixi_projection; -(function (pixi_projection) { - var tempMat = new pixi_projection.Matrix3d(); - var Projection3d = (function (_super) { - __extends(Projection3d, _super); - function Projection3d(legacy, enable) { - var _this = _super.call(this, legacy, enable) || this; - _this.cameraMatrix = null; - _this._cameraMode = false; - _this.position = new pixi_projection.ObservablePoint3d(_this.onChange, _this, 0, 0); - _this.scale = new pixi_projection.ObservablePoint3d(_this.onChange, _this, 1, 1); - _this.euler = new pixi_projection.ObservableEuler(_this.onChange, _this, 0, 0, 0); - _this.pivot = new pixi_projection.ObservablePoint3d(_this.onChange, _this, 0, 0); - _this.local = new pixi_projection.Matrix3d(); - _this.world = new pixi_projection.Matrix3d(); - _this.local.cacheInverse = true; - _this.world.cacheInverse = true; - _this.position._z = 0; - _this.scale._z = 1; - _this.pivot._z = 0; - return _this; - } - Object.defineProperty(Projection3d.prototype, "cameraMode", { - get: function () { - return this._cameraMode; - }, - set: function (value) { - if (this._cameraMode === value) { - return; - } - this._cameraMode = value; - this.euler._sign = this._cameraMode ? -1 : 1; - this.euler._quatDirtyId++; - if (value) { - this.cameraMatrix = new pixi_projection.Matrix3d(); - } - }, - enumerable: true, - configurable: true - }); - Projection3d.prototype.onChange = function () { - this._projID++; - }; - Projection3d.prototype.clear = function () { - if (this.cameraMatrix) { - this.cameraMatrix.identity(); - } - this.position.set(0, 0, 0); - this.scale.set(1, 1, 1); - this.euler.set(0, 0, 0); - this.pivot.set(0, 0, 0); - _super.prototype.clear.call(this); - }; - Projection3d.prototype.updateLocalTransform = function (lt) { - if (this._projID === 0) { - this.local.copyFrom(lt); - return; - } - var matrix = this.local; - var euler = this.euler; - var pos = this.position; - var scale = this.scale; - var pivot = this.pivot; - euler.update(); - if (!this.cameraMode) { - matrix.setToRotationTranslationScale(euler.quaternion, pos._x, pos._y, pos._z, scale._x, scale._y, scale._z); - matrix.translate(-pivot._x, -pivot._y, -pivot._z); - matrix.setToMultLegacy(lt, matrix); - return; - } - matrix.setToMultLegacy(lt, this.cameraMatrix); - matrix.translate(pivot._x, pivot._y, pivot._z); - matrix.scale(1.0 / scale._x, 1.0 / scale._y, 1.0 / scale._z); - tempMat.setToRotationTranslationScale(euler.quaternion, 0, 0, 0, 1, 1, 1); - matrix.setToMult(matrix, tempMat); - matrix.translate(-pos._x, -pos._y, -pos._z); - this.local._dirtyId++; - }; - return Projection3d; - }(pixi_projection.LinearProjection)); - pixi_projection.Projection3d = Projection3d; -})(pixi_projection || (pixi_projection = {})); -var pixi_projection; -(function (pixi_projection) { - var Mesh3d2d = (function (_super) { - __extends(Mesh3d2d, _super); - function Mesh3d2d(geometry, shader, state, drawMode) { - var _this = _super.call(this, geometry, shader, state, drawMode) || this; - _this.vertexData2d = null; - _this.proj = new pixi_projection.Projection3d(_this.transform); - return _this; - } - Mesh3d2d.prototype.calculateVertices = function () { - if (this.proj._affine) { - this.vertexData2d = null; - _super.prototype.calculateVertices.call(this); - return; - } - var geometry = this.geometry; - var vertices = geometry.buffers[0].data; - var thisAny = this; - if (geometry.vertexDirtyId === thisAny.vertexDirty && thisAny._transformID === thisAny.transform._worldID) { - return; - } - thisAny._transformID = thisAny.transform._worldID; - if (thisAny.vertexData.length !== vertices.length) { - thisAny.vertexData = new Float32Array(vertices.length); - } - if (this.vertexData2d.length !== vertices.length * 3 / 2) { - this.vertexData2d = new Float32Array(vertices.length * 3); - } - var wt = this.proj.world.mat4; - var vertexData2d = this.vertexData2d; - var vertexData = thisAny.vertexData; - for (var i = 0; i < vertexData.length / 2; i++) { - var x = vertices[(i * 2)]; - var y = vertices[(i * 2) + 1]; - var xx = (wt[0] * x) + (wt[4] * y) + wt[12]; - var yy = (wt[1] * x) + (wt[5] * y) + wt[13]; - var ww = (wt[3] * x) + (wt[7] * y) + wt[15]; - vertexData2d[i * 3] = xx; - vertexData2d[i * 3 + 1] = yy; - vertexData2d[i * 3 + 2] = ww; - vertexData[(i * 2)] = xx / ww; - vertexData[(i * 2) + 1] = yy / ww; - } - thisAny.vertexDirty = geometry.vertexDirtyId; - }; - Object.defineProperty(Mesh3d2d.prototype, "worldTransform", { - get: function () { - return this.proj.affine ? this.transform.worldTransform : this.proj.world; - }, - enumerable: true, - configurable: true - }); - Mesh3d2d.prototype.toLocal = function (position, from, point, skipUpdate, step) { - if (step === void 0) { step = pixi_projection.TRANSFORM_STEP.ALL; } - return pixi_projection.container3dToLocal.call(this, position, from, point, skipUpdate, step); - }; - Mesh3d2d.prototype.isFrontFace = function (forceUpdate) { - return pixi_projection.container3dIsFrontFace.call(this, forceUpdate); - }; - Mesh3d2d.prototype.getDepth = function (forceUpdate) { - return pixi_projection.container3dGetDepth.call(this, forceUpdate); - }; - Object.defineProperty(Mesh3d2d.prototype, "position3d", { - get: function () { - return this.proj.position; - }, - set: function (value) { - this.proj.position.copyFrom(value); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Mesh3d2d.prototype, "scale3d", { - get: function () { - return this.proj.scale; - }, - set: function (value) { - this.proj.scale.copyFrom(value); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Mesh3d2d.prototype, "euler", { - get: function () { - return this.proj.euler; - }, - set: function (value) { - this.proj.euler.copyFrom(value); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Mesh3d2d.prototype, "pivot3d", { - get: function () { - return this.proj.pivot; - }, - set: function (value) { - this.proj.pivot.copyFrom(value); - }, - enumerable: true, - configurable: true - }); - return Mesh3d2d; - }(PIXI.Mesh)); - pixi_projection.Mesh3d2d = Mesh3d2d; - Mesh3d2d.prototype._renderDefault = pixi_projection.Mesh2d.prototype._renderDefault; - var SimpleMesh3d2d = (function (_super) { - __extends(SimpleMesh3d2d, _super); - function SimpleMesh3d2d(texture, vertices, uvs, indices, drawMode) { - var _this = _super.call(this, new PIXI.MeshGeometry(vertices, uvs, indices), new PIXI.MeshMaterial(texture, { - program: PIXI.Program.from(pixi_projection.Mesh2d.defaultVertexShader, pixi_projection.Mesh2d.defaultFragmentShader), - pluginName: 'batch2d' - }), null, drawMode) || this; - _this.autoUpdate = true; - _this.geometry.getBuffer('aVertexPosition').static = false; - return _this; - } - Object.defineProperty(SimpleMesh3d2d.prototype, "vertices", { - get: function () { - return this.geometry.getBuffer('aVertexPosition').data; - }, - set: function (value) { - this.geometry.getBuffer('aVertexPosition').data = value; - }, - enumerable: true, - configurable: true - }); - SimpleMesh3d2d.prototype._render = function (renderer) { - if (this.autoUpdate) { - this.geometry.getBuffer('aVertexPosition').update(); - } - _super.prototype._render.call(this, renderer); - }; - return SimpleMesh3d2d; - }(Mesh3d2d)); - pixi_projection.SimpleMesh3d2d = SimpleMesh3d2d; -})(pixi_projection || (pixi_projection = {})); -var pixi_projection; -(function (pixi_projection) { - var Sprite3d = (function (_super) { - __extends(Sprite3d, _super); - function Sprite3d(texture) { - var _this = _super.call(this, texture) || this; - _this.vertexData2d = null; - _this.culledByFrustrum = false; - _this.trimmedCulledByFrustrum = false; - _this.proj = new pixi_projection.Projection3d(_this.transform); - _this.pluginName = 'batch2d'; - return _this; - } - Sprite3d.prototype.calculateVertices = function () { - var texture = this._texture; - if (this.proj._affine) { - this.vertexData2d = null; - _super.prototype.calculateVertices.call(this); - return; - } - if (!this.vertexData2d) { - this.vertexData2d = new Float32Array(12); - } - var wid = this.transform._worldID; - var tuid = texture._updateID; - if (this._transformID === wid && this._textureID === tuid) { - return; - } - if (this._textureID !== tuid) { - this.uvs = texture._uvs.uvsFloat32; - } - this._transformID = wid; - this._textureID = tuid; - var wt = this.proj.world.mat4; - var vertexData2d = this.vertexData2d; - var vertexData = this.vertexData; - var trim = texture.trim; - var orig = texture.orig; - var anchor = this._anchor; - var w0 = 0; - var w1 = 0; - var h0 = 0; - var h1 = 0; - if (trim) { - w1 = trim.x - (anchor._x * orig.width); - w0 = w1 + trim.width; - h1 = trim.y - (anchor._y * orig.height); - h0 = h1 + trim.height; - } - else { - w1 = -anchor._x * orig.width; - w0 = w1 + orig.width; - h1 = -anchor._y * orig.height; - h0 = h1 + orig.height; - } - var culled = false; - var z; - vertexData2d[0] = (wt[0] * w1) + (wt[4] * h1) + wt[12]; - vertexData2d[1] = (wt[1] * w1) + (wt[5] * h1) + wt[13]; - z = (wt[2] * w1) + (wt[6] * h1) + wt[14]; - vertexData2d[2] = (wt[3] * w1) + (wt[7] * h1) + wt[15]; - culled = culled || z < 0; - vertexData2d[3] = (wt[0] * w0) + (wt[4] * h1) + wt[12]; - vertexData2d[4] = (wt[1] * w0) + (wt[5] * h1) + wt[13]; - z = (wt[2] * w0) + (wt[6] * h1) + wt[14]; - vertexData2d[5] = (wt[3] * w0) + (wt[7] * h1) + wt[15]; - culled = culled || z < 0; - vertexData2d[6] = (wt[0] * w0) + (wt[4] * h0) + wt[12]; - vertexData2d[7] = (wt[1] * w0) + (wt[5] * h0) + wt[13]; - z = (wt[2] * w0) + (wt[6] * h0) + wt[14]; - vertexData2d[8] = (wt[3] * w0) + (wt[7] * h0) + wt[15]; - culled = culled || z < 0; - vertexData2d[9] = (wt[0] * w1) + (wt[4] * h0) + wt[12]; - vertexData2d[10] = (wt[1] * w1) + (wt[5] * h0) + wt[13]; - z = (wt[2] * w1) + (wt[6] * h0) + wt[14]; - vertexData2d[11] = (wt[3] * w1) + (wt[7] * h0) + wt[15]; - culled = culled || z < 0; - this.culledByFrustrum = culled; - vertexData[0] = vertexData2d[0] / vertexData2d[2]; - vertexData[1] = vertexData2d[1] / vertexData2d[2]; - vertexData[2] = vertexData2d[3] / vertexData2d[5]; - vertexData[3] = vertexData2d[4] / vertexData2d[5]; - vertexData[4] = vertexData2d[6] / vertexData2d[8]; - vertexData[5] = vertexData2d[7] / vertexData2d[8]; - vertexData[6] = vertexData2d[9] / vertexData2d[11]; - vertexData[7] = vertexData2d[10] / vertexData2d[11]; - }; - Sprite3d.prototype.calculateTrimmedVertices = function () { - if (this.proj._affine) { - _super.prototype.calculateTrimmedVertices.call(this); - return; - } - var wid = this.transform._worldID; - var tuid = this._texture._updateID; - if (!this.vertexTrimmedData) { - this.vertexTrimmedData = new Float32Array(8); - } - else if (this._transformTrimmedID === wid && this._textureTrimmedID === tuid) { - return; - } - this._transformTrimmedID = wid; - this._textureTrimmedID = tuid; - var texture = this._texture; - var vertexData = this.vertexTrimmedData; - var orig = texture.orig; - var anchor = this._anchor; - var wt = this.proj.world.mat4; - var w1 = -anchor._x * orig.width; - var w0 = w1 + orig.width; - var h1 = -anchor._y * orig.height; - var h0 = h1 + orig.height; - var culled = false; - var z; - var w = 1.0 / ((wt[3] * w1) + (wt[7] * h1) + wt[15]); - vertexData[0] = w * ((wt[0] * w1) + (wt[4] * h1) + wt[12]); - vertexData[1] = w * ((wt[1] * w1) + (wt[5] * h1) + wt[13]); - z = (wt[2] * w1) + (wt[6] * h1) + wt[14]; - culled = culled || z < 0; - w = 1.0 / ((wt[3] * w0) + (wt[7] * h1) + wt[15]); - vertexData[2] = w * ((wt[0] * w0) + (wt[4] * h1) + wt[12]); - vertexData[3] = w * ((wt[1] * w0) + (wt[5] * h1) + wt[13]); - z = (wt[2] * w0) + (wt[6] * h1) + wt[14]; - culled = culled || z < 0; - w = 1.0 / ((wt[3] * w0) + (wt[7] * h0) + wt[15]); - vertexData[4] = w * ((wt[0] * w0) + (wt[4] * h0) + wt[12]); - vertexData[5] = w * ((wt[1] * w0) + (wt[5] * h0) + wt[13]); - z = (wt[2] * w0) + (wt[6] * h0) + wt[14]; - culled = culled || z < 0; - w = 1.0 / ((wt[3] * w1) + (wt[7] * h0) + wt[15]); - vertexData[6] = w * ((wt[0] * w1) + (wt[4] * h0) + wt[12]); - vertexData[7] = w * ((wt[1] * w1) + (wt[5] * h0) + wt[13]); - z = (wt[2] * w1) + (wt[6] * h0) + wt[14]; - culled = culled || z < 0; - this.culledByFrustrum = culled; - }; - Sprite3d.prototype._calculateBounds = function () { - this.calculateVertices(); - if (this.culledByFrustrum) { - return; - } - var trim = this._texture.trim; - var orig = this._texture.orig; - if (!trim || (trim.width === orig.width && trim.height === orig.height)) { - this._bounds.addQuad(this.vertexData); - return; - } - this.calculateTrimmedVertices(); - if (!this.trimmedCulledByFrustrum) { - this._bounds.addQuad(this.vertexTrimmedData); - } - }; - Sprite3d.prototype._render = function (renderer) { - this.calculateVertices(); - if (this.culledByFrustrum) { - return; - } - renderer.batch.setObjectRenderer(renderer.plugins[this.pluginName]); - renderer.plugins[this.pluginName].render(this); - }; - Sprite3d.prototype.containsPoint = function (point) { - if (this.culledByFrustrum) { - return false; - } - return _super.prototype.containsPoint.call(this, point); - }; - Object.defineProperty(Sprite3d.prototype, "worldTransform", { - get: function () { - return this.proj.affine ? this.transform.worldTransform : this.proj.world; - }, - enumerable: true, - configurable: true - }); - Sprite3d.prototype.toLocal = function (position, from, point, skipUpdate, step) { - if (step === void 0) { step = pixi_projection.TRANSFORM_STEP.ALL; } - return pixi_projection.container3dToLocal.call(this, position, from, point, skipUpdate, step); - }; - Sprite3d.prototype.isFrontFace = function (forceUpdate) { - return pixi_projection.container3dIsFrontFace.call(this, forceUpdate); - }; - Sprite3d.prototype.getDepth = function (forceUpdate) { - return pixi_projection.container3dGetDepth.call(this, forceUpdate); - }; - Object.defineProperty(Sprite3d.prototype, "position3d", { - get: function () { - return this.proj.position; - }, - set: function (value) { - this.proj.position.copyFrom(value); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Sprite3d.prototype, "scale3d", { - get: function () { - return this.proj.scale; - }, - set: function (value) { - this.proj.scale.copyFrom(value); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Sprite3d.prototype, "euler", { - get: function () { - return this.proj.euler; - }, - set: function (value) { - this.proj.euler.copyFrom(value); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Sprite3d.prototype, "pivot3d", { - get: function () { - return this.proj.pivot; - }, - set: function (value) { - this.proj.pivot.copyFrom(value); - }, - enumerable: true, - configurable: true - }); - return Sprite3d; - }(PIXI.Sprite)); - pixi_projection.Sprite3d = Sprite3d; -})(pixi_projection || (pixi_projection = {})); -var pixi_projection; -(function (pixi_projection) { - var Text3d = (function (_super) { - __extends(Text3d, _super); - function Text3d(text, style, canvas) { - var _this = _super.call(this, text, style, canvas) || this; - _this.vertexData2d = null; - _this.proj = new pixi_projection.Projection3d(_this.transform); - _this.pluginName = 'batch2d'; - return _this; - } - Object.defineProperty(Text3d.prototype, "worldTransform", { - get: function () { - return this.proj.affine ? this.transform.worldTransform : this.proj.world; - }, - enumerable: true, - configurable: true - }); - Text3d.prototype.toLocal = function (position, from, point, skipUpdate, step) { - if (step === void 0) { step = pixi_projection.TRANSFORM_STEP.ALL; } - return pixi_projection.container3dToLocal.call(this, position, from, point, skipUpdate, step); - }; - Text3d.prototype.isFrontFace = function (forceUpdate) { - return pixi_projection.container3dIsFrontFace.call(this, forceUpdate); - }; - Text3d.prototype.getDepth = function (forceUpdate) { - return pixi_projection.container3dGetDepth.call(this, forceUpdate); - }; - Object.defineProperty(Text3d.prototype, "position3d", { - get: function () { - return this.proj.position; - }, - set: function (value) { - this.proj.position.copyFrom(value); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Text3d.prototype, "scale3d", { - get: function () { - return this.proj.scale; - }, - set: function (value) { - this.proj.scale.copyFrom(value); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Text3d.prototype, "euler", { - get: function () { - return this.proj.euler; - }, - set: function (value) { - this.proj.euler.copyFrom(value); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Text3d.prototype, "pivot3d", { - get: function () { - return this.proj.pivot; - }, - set: function (value) { - this.proj.pivot.copyFrom(value); - }, - enumerable: true, - configurable: true - }); - return Text3d; - }(PIXI.Text)); - pixi_projection.Text3d = Text3d; - Text3d.prototype.calculateVertices = pixi_projection.Sprite3d.prototype.calculateVertices; - Text3d.prototype.calculateTrimmedVertices = pixi_projection.Sprite3d.prototype.calculateTrimmedVertices; - Text3d.prototype._calculateBounds = pixi_projection.Sprite3d.prototype._calculateBounds; - Text3d.prototype.containsPoint = pixi_projection.Sprite3d.prototype.containsPoint; - Text3d.prototype._render = pixi_projection.Sprite3d.prototype._render; -})(pixi_projection || (pixi_projection = {})); -var pixi_projection; -(function (pixi_projection) { - var containerProps = { - worldTransform: { - get: pixi_projection.container3dWorldTransform, - enumerable: true, - configurable: true - }, - position3d: { - get: function () { return this.proj.position; }, - set: function (value) { this.proj.position.copy(value); } - }, - scale3d: { - get: function () { return this.proj.scale; }, - set: function (value) { this.proj.scale.copy(value); } - }, - pivot3d: { - get: function () { return this.proj.pivot; }, - set: function (value) { this.proj.pivot.copy(value); } - }, - euler: { - get: function () { return this.proj.euler; }, - set: function (value) { this.proj.euler.copy(value); } - } - }; - function convertTo3d() { - if (this.proj) - return; - this.proj = new pixi_projection.Projection3d(this.transform); - this.toLocal = pixi_projection.Container3d.prototype.toLocal; - this.isFrontFace = pixi_projection.Container3d.prototype.isFrontFace; - this.getDepth = pixi_projection.Container3d.prototype.getDepth; - Object.defineProperties(this, containerProps); - } - PIXI.Container.prototype.convertTo3d = convertTo3d; - PIXI.Sprite.prototype.convertTo3d = function () { - if (this.proj) - return; - this.calculateVertices = pixi_projection.Sprite3d.prototype.calculateVertices; - this.calculateTrimmedVertices = pixi_projection.Sprite3d.prototype.calculateTrimmedVertices; - this._calculateBounds = pixi_projection.Sprite3d.prototype._calculateBounds; - this.containsPoint = pixi_projection.Sprite3d.prototype.containsPoint; - this.pluginName = 'batch2d'; - convertTo3d.call(this); - }; - PIXI.Container.prototype.convertSubtreeTo3d = function () { - this.convertTo3d(); - for (var i = 0; i < this.children.length; i++) { - this.children[i].convertSubtreeTo3d(); - } - }; - if (PIXI.SimpleMesh) { - PIXI.SimpleMesh.prototype.convertTo3d = - PIXI.SimpleRope.prototype.convertTo3d = - function () { - if (this.proj) - return; - this.calculateVertices = pixi_projection.Mesh3d2d.prototype.calculateVertices; - this._renderDefault = pixi_projection.Mesh3d2d.prototype._renderDefault; - if (this.material.pluginName !== 'batch2d') { - this.material = new PIXI.MeshMaterial(this.material.texture, { - program: PIXI.Program.from(pixi_projection.Mesh2d.defaultVertexShader, pixi_projection.Mesh2d.defaultFragmentShader), - pluginName: 'batch2d' - }); - } - convertTo3d.call(this); - }; - } -})(pixi_projection || (pixi_projection = {})); +var pixi_projection; +(function (pixi_projection) { + var utils; + (function (utils) { + function getIntersectionFactor(p1, p2, p3, p4, out) { + var A1 = p2.x - p1.x, B1 = p3.x - p4.x, C1 = p3.x - p1.x; + var A2 = p2.y - p1.y, B2 = p3.y - p4.y, C2 = p3.y - p1.y; + var D = A1 * B2 - A2 * B1; + if (Math.abs(D) < 1e-7) { + out.x = A1; + out.y = A2; + return 0; + } + var T = C1 * B2 - C2 * B1; + var U = A1 * C2 - A2 * C1; + var t = T / D, u = U / D; + if (u < (1e-6) || u - 1 > -1e-6) { + return -1; + } + out.x = p1.x + t * (p2.x - p1.x); + out.y = p1.y + t * (p2.y - p1.y); + return 1; + } + utils.getIntersectionFactor = getIntersectionFactor; + function getPositionFromQuad(p, anchor, out) { + out = out || new PIXI.Point(); + var a1 = 1.0 - anchor.x, a2 = 1.0 - a1; + var b1 = 1.0 - anchor.y, b2 = 1.0 - b1; + out.x = (p[0].x * a1 + p[1].x * a2) * b1 + (p[3].x * a1 + p[2].x * a2) * b2; + out.y = (p[0].y * a1 + p[1].y * a2) * b1 + (p[3].y * a1 + p[2].y * a2) * b2; + return out; + } + utils.getPositionFromQuad = getPositionFromQuad; + })(utils = pixi_projection.utils || (pixi_projection.utils = {})); +})(pixi_projection || (pixi_projection = {})); +PIXI.projection = pixi_projection; +var pixi_projection; +(function (pixi_projection) { + var AbstractProjection = (function () { + function AbstractProjection(legacy, enable) { + if (enable === void 0) { enable = true; } + this._enabled = false; + this.legacy = legacy; + if (enable) { + this.enabled = true; + } + this.legacy.proj = this; + } + Object.defineProperty(AbstractProjection.prototype, "enabled", { + get: function () { + return this._enabled; + }, + set: function (value) { + this._enabled = value; + }, + enumerable: true, + configurable: true + }); + AbstractProjection.prototype.clear = function () { + }; + return AbstractProjection; + }()); + pixi_projection.AbstractProjection = AbstractProjection; + var TRANSFORM_STEP; + (function (TRANSFORM_STEP) { + TRANSFORM_STEP[TRANSFORM_STEP["NONE"] = 0] = "NONE"; + TRANSFORM_STEP[TRANSFORM_STEP["BEFORE_PROJ"] = 4] = "BEFORE_PROJ"; + TRANSFORM_STEP[TRANSFORM_STEP["PROJ"] = 5] = "PROJ"; + TRANSFORM_STEP[TRANSFORM_STEP["ALL"] = 9] = "ALL"; + })(TRANSFORM_STEP = pixi_projection.TRANSFORM_STEP || (pixi_projection.TRANSFORM_STEP = {})); +})(pixi_projection || (pixi_projection = {})); +var __extends = (this && this.__extends) || (function () { + 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); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var pixi_projection; +(function (pixi_projection) { + function transformHack(parentTransform) { + var proj = this.proj; + var ta = this; + var pwid = parentTransform._worldID; + var lt = ta.localTransform; + var scaleAfterAffine = proj.scaleAfterAffine && proj.affine >= 2; + if (ta._localID !== ta._currentLocalID) { + if (scaleAfterAffine) { + lt.a = ta._cx; + lt.b = ta._sx; + lt.c = ta._cy; + lt.d = ta._sy; + lt.tx = ta.position._x; + lt.ty = ta.position._y; + } + else { + lt.a = ta._cx * ta.scale._x; + lt.b = ta._sx * ta.scale._x; + lt.c = ta._cy * ta.scale._y; + lt.d = ta._sy * ta.scale._y; + lt.tx = ta.position._x - ((ta.pivot._x * lt.a) + (ta.pivot._y * lt.c)); + lt.ty = ta.position._y - ((ta.pivot._x * lt.b) + (ta.pivot._y * lt.d)); + } + ta._currentLocalID = ta._localID; + proj._currentProjID = -1; + } + var _matrixID = proj._projID; + if (proj._currentProjID !== _matrixID) { + proj._currentProjID = _matrixID; + proj.updateLocalTransform(lt); + ta._parentID = -1; + } + if (ta._parentID !== pwid) { + var pp = parentTransform.proj; + if (pp && !pp._affine) { + proj.world.setToMult(pp.world, proj.local); + } + else { + proj.world.setToMultLegacy(parentTransform.worldTransform, proj.local); + } + var wa = ta.worldTransform; + proj.world.copyTo(wa, proj._affine, proj.affinePreserveOrientation); + if (scaleAfterAffine) { + wa.a *= ta.scale._x; + wa.b *= ta.scale._x; + wa.c *= ta.scale._y; + wa.d *= ta.scale._y; + wa.tx -= ((ta.pivot._x * wa.a) + (ta.pivot._y * wa.c)); + wa.ty -= ((ta.pivot._x * wa.b) + (ta.pivot._y * wa.d)); + } + ta._parentID = pwid; + ta._worldID++; + } + } + var LinearProjection = (function (_super) { + __extends(LinearProjection, _super); + function LinearProjection() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this._projID = 0; + _this._currentProjID = -1; + _this._affine = pixi_projection.AFFINE.NONE; + _this.affinePreserveOrientation = false; + _this.scaleAfterAffine = true; + return _this; + } + LinearProjection.prototype.updateLocalTransform = function (lt) { + }; + Object.defineProperty(LinearProjection.prototype, "affine", { + get: function () { + return this._affine; + }, + set: function (value) { + if (this._affine == value) + return; + this._affine = value; + this._currentProjID = -1; + this.legacy._currentLocalID = -1; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(LinearProjection.prototype, "enabled", { + set: function (value) { + if (value === this._enabled) { + return; + } + this._enabled = value; + if (value) { + this.legacy.updateTransform = transformHack; + this.legacy._parentID = -1; + } + else { + this.legacy.updateTransform = PIXI.Transform.prototype.updateTransform; + this.legacy._parentID = -1; + } + }, + enumerable: true, + configurable: true + }); + LinearProjection.prototype.clear = function () { + this._currentProjID = -1; + this._projID = 0; + }; + return LinearProjection; + }(pixi_projection.AbstractProjection)); + pixi_projection.LinearProjection = LinearProjection; +})(pixi_projection || (pixi_projection = {})); +var pixi_projection; +(function (pixi_projection) { + var TYPES = PIXI.TYPES; + var premultiplyTint = PIXI.utils.premultiplyTint; + var shaderVert = "precision highp float;\nattribute vec3 aVertexPosition;\nattribute vec2 aTextureCoord;\nattribute vec4 aColor;\nattribute float aTextureId;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\nvarying vec4 vColor;\nvarying float vTextureId;\n\nvoid main(void){\n gl_Position.xyw = projectionMatrix * aVertexPosition;\n gl_Position.z = 0.0;\n \n vTextureCoord = aTextureCoord;\n vTextureId = aTextureId;\n vColor = aColor;\n}\n"; + var shaderFrag = "\nvarying vec2 vTextureCoord;\nvarying vec4 vColor;\nvarying float vTextureId;\nuniform sampler2D uSamplers[%count%];\n\nvoid main(void){\nvec4 color;\n%forloop%\ngl_FragColor = color * vColor;\n}"; + var Batch3dGeometry = (function (_super) { + __extends(Batch3dGeometry, _super); + function Batch3dGeometry(_static) { + if (_static === void 0) { _static = false; } + var _this = _super.call(this) || this; + _this._buffer = new PIXI.Buffer(null, _static, false); + _this._indexBuffer = new PIXI.Buffer(null, _static, true); + _this.addAttribute('aVertexPosition', _this._buffer, 3, false, TYPES.FLOAT) + .addAttribute('aTextureCoord', _this._buffer, 2, false, TYPES.FLOAT) + .addAttribute('aColor', _this._buffer, 4, true, TYPES.UNSIGNED_BYTE) + .addAttribute('aTextureId', _this._buffer, 1, true, TYPES.FLOAT) + .addIndex(_this._indexBuffer); + return _this; + } + return Batch3dGeometry; + }(PIXI.Geometry)); + pixi_projection.Batch3dGeometry = Batch3dGeometry; + var Batch2dPluginFactory = (function () { + function Batch2dPluginFactory() { + } + Batch2dPluginFactory.create = function (options) { + var _a = Object.assign({ + vertex: shaderVert, + fragment: shaderFrag, + geometryClass: Batch3dGeometry, + vertexSize: 7, + }, options), vertex = _a.vertex, fragment = _a.fragment, vertexSize = _a.vertexSize, geometryClass = _a.geometryClass; + return (function (_super) { + __extends(BatchPlugin, _super); + function BatchPlugin(renderer) { + var _this = _super.call(this, renderer) || this; + _this.shaderGenerator = new PIXI.BatchShaderGenerator(vertex, fragment); + _this.geometryClass = geometryClass; + _this.vertexSize = vertexSize; + return _this; + } + BatchPlugin.prototype.packInterleavedGeometry = function (element, attributeBuffer, indexBuffer, aIndex, iIndex) { + var uint32View = attributeBuffer.uint32View, float32View = attributeBuffer.float32View; + var p = aIndex / this.vertexSize; + var uvs = element.uvs; + var indices = element.indices; + var vertexData = element.vertexData; + var vertexData2d = element.vertexData2d; + var textureId = element._texture.baseTexture._batchLocation; + var alpha = Math.min(element.worldAlpha, 1.0); + var argb = alpha < 1.0 && element._texture.baseTexture.alphaMode ? premultiplyTint(element._tintRGB, alpha) + : element._tintRGB + (alpha * 255 << 24); + if (vertexData2d) { + var j = 0; + for (var i = 0; i < vertexData2d.length; i += 3, j += 2) { + float32View[aIndex++] = vertexData2d[i]; + float32View[aIndex++] = vertexData2d[i + 1]; + float32View[aIndex++] = vertexData2d[i + 2]; + float32View[aIndex++] = uvs[j]; + float32View[aIndex++] = uvs[j + 1]; + uint32View[aIndex++] = argb; + float32View[aIndex++] = textureId; + } + } + else { + for (var i = 0; i < vertexData.length; i += 2) { + float32View[aIndex++] = vertexData[i]; + float32View[aIndex++] = vertexData[i + 1]; + float32View[aIndex++] = 1.0; + float32View[aIndex++] = uvs[i]; + float32View[aIndex++] = uvs[i + 1]; + uint32View[aIndex++] = argb; + float32View[aIndex++] = textureId; + } + } + for (var i = 0; i < indices.length; i++) { + indexBuffer[iIndex++] = p + indices[i]; + } + }; + return BatchPlugin; + }(PIXI.AbstractBatchRenderer)); + }; + return Batch2dPluginFactory; + }()); + pixi_projection.Batch2dPluginFactory = Batch2dPluginFactory; + PIXI.Renderer.registerPlugin('batch2d', Batch2dPluginFactory.create({})); +})(pixi_projection || (pixi_projection = {})); +var pixi_projection; +(function (pixi_projection) { + var AbstractBatchRenderer = PIXI.AbstractBatchRenderer; + var premultiplyBlendMode = PIXI.utils.premultiplyBlendMode; + var UniformBatchRenderer = (function (_super) { + __extends(UniformBatchRenderer, _super); + function UniformBatchRenderer() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.forceMaxTextures = 0; + _this.defUniforms = {}; + return _this; + } + UniformBatchRenderer.prototype.getUniforms = function (sprite) { + return this.defUniforms; + }; + UniformBatchRenderer.prototype.syncUniforms = function (obj) { + if (!obj) + return; + var sh = this._shader; + for (var key in obj) { + sh.uniforms[key] = obj[key]; + } + }; + UniformBatchRenderer.prototype.buildDrawCalls = function (texArray, start, finish) { + var thisAny = this; + var _a = this, elements = _a._bufferedElements, _attributeBuffer = _a._attributeBuffer, _indexBuffer = _a._indexBuffer, vertexSize = _a.vertexSize; + var drawCalls = AbstractBatchRenderer._drawCallPool; + var dcIndex = this._dcIndex; + var aIndex = this._aIndex; + var iIndex = this._iIndex; + var drawCall = drawCalls[dcIndex]; + drawCall.start = this._iIndex; + drawCall.texArray = texArray; + for (var i = start; i < finish; ++i) { + var sprite = elements[i]; + var tex = sprite._texture.baseTexture; + var spriteBlendMode = premultiplyBlendMode[tex.alphaMode ? 1 : 0][sprite.blendMode]; + var uniforms = this.getUniforms(sprite); + elements[i] = null; + if (start < i && (drawCall.blend !== spriteBlendMode || drawCall.uniforms !== uniforms)) { + drawCall.size = iIndex - drawCall.start; + start = i; + drawCall = drawCalls[++dcIndex]; + drawCall.texArray = texArray; + drawCall.start = iIndex; + } + this.packInterleavedGeometry(sprite, _attributeBuffer, _indexBuffer, aIndex, iIndex); + aIndex += sprite.vertexData.length / 2 * vertexSize; + iIndex += sprite.indices.length; + drawCall.blend = spriteBlendMode; + drawCall.uniforms = uniforms; + } + if (start < finish) { + drawCall.size = iIndex - drawCall.start; + ++dcIndex; + } + thisAny._dcIndex = dcIndex; + thisAny._aIndex = aIndex; + thisAny._iIndex = iIndex; + }; + UniformBatchRenderer.prototype.drawBatches = function () { + var dcCount = this._dcIndex; + var _a = this.renderer, gl = _a.gl, stateSystem = _a.state, shaderSystem = _a.shader; + var drawCalls = AbstractBatchRenderer._drawCallPool; + var curUniforms = null; + var curTexArray = null; + for (var i = 0; i < dcCount; i++) { + var _b = drawCalls[i], texArray = _b.texArray, type = _b.type, size = _b.size, start = _b.start, blend = _b.blend, uniforms = _b.uniforms; + if (curTexArray !== texArray) { + curTexArray = texArray; + this.bindAndClearTexArray(texArray); + } + if (curUniforms !== uniforms) { + curUniforms = uniforms; + this.syncUniforms(uniforms); + shaderSystem.syncUniformGroup(this._shader.uniformGroup); + } + stateSystem.setBlendMode(blend); + gl.drawElements(type, size, gl.UNSIGNED_SHORT, start * 2); + } + }; + UniformBatchRenderer.prototype.contextChange = function () { + if (!this.forceMaxTextures) { + _super.prototype.contextChange.call(this); + this.syncUniforms(this.defUniforms); + return; + } + var gl = this.renderer.gl; + var thisAny = this; + thisAny.MAX_TEXTURES = this.forceMaxTextures; + this._shader = thisAny.shaderGenerator.generateShader(this.MAX_TEXTURES); + this.syncUniforms(this.defUniforms); + for (var i = 0; i < thisAny._packedGeometryPoolSize; i++) { + thisAny._packedGeometries[i] = new (this.geometryClass)(); + } + this.initFlushBuffers(); + }; + return UniformBatchRenderer; + }(AbstractBatchRenderer)); + pixi_projection.UniformBatchRenderer = UniformBatchRenderer; +})(pixi_projection || (pixi_projection = {})); +var pixi_projection; +(function (pixi_projection) { + var p = [new PIXI.Point(), new PIXI.Point(), new PIXI.Point(), new PIXI.Point()]; + var a = [0, 0, 0, 0]; + var Surface = (function () { + function Surface() { + this.surfaceID = "default"; + this._updateID = 0; + this.vertexSrc = ""; + this.fragmentSrc = ""; + } + Surface.prototype.fillUniforms = function (uniforms) { + }; + Surface.prototype.clear = function () { + }; + Surface.prototype.boundsQuad = function (v, out, after) { + var minX = out[0], minY = out[1]; + var maxX = out[0], maxY = out[1]; + for (var i = 2; i < 8; i += 2) { + if (minX > out[i]) + minX = out[i]; + if (maxX < out[i]) + maxX = out[i]; + if (minY > out[i + 1]) + minY = out[i + 1]; + if (maxY < out[i + 1]) + maxY = out[i + 1]; + } + p[0].set(minX, minY); + this.apply(p[0], p[0]); + p[1].set(maxX, minY); + this.apply(p[1], p[1]); + p[2].set(maxX, maxY); + this.apply(p[2], p[2]); + p[3].set(minX, maxY); + this.apply(p[3], p[3]); + if (after) { + after.apply(p[0], p[0]); + after.apply(p[1], p[1]); + after.apply(p[2], p[2]); + after.apply(p[3], p[3]); + out[0] = p[0].x; + out[1] = p[0].y; + out[2] = p[1].x; + out[3] = p[1].y; + out[4] = p[2].x; + out[5] = p[2].y; + out[6] = p[3].x; + out[7] = p[3].y; + } + else { + for (var i = 1; i <= 3; i++) { + if (p[i].y < p[0].y || p[i].y == p[0].y && p[i].x < p[0].x) { + var t = p[0]; + p[0] = p[i]; + p[i] = t; + } + } + for (var i = 1; i <= 3; i++) { + a[i] = Math.atan2(p[i].y - p[0].y, p[i].x - p[0].x); + } + for (var i = 1; i <= 3; i++) { + for (var j = i + 1; j <= 3; j++) { + if (a[i] > a[j]) { + var t = p[i]; + p[i] = p[j]; + p[j] = t; + var t2 = a[i]; + a[i] = a[j]; + a[j] = t2; + } + } + } + out[0] = p[0].x; + out[1] = p[0].y; + out[2] = p[1].x; + out[3] = p[1].y; + out[4] = p[2].x; + out[5] = p[2].y; + out[6] = p[3].x; + out[7] = p[3].y; + if ((p[3].x - p[2].x) * (p[1].y - p[2].y) - (p[1].x - p[2].x) * (p[3].y - p[2].y) < 0) { + out[4] = p[3].x; + out[5] = p[3].y; + return; + } + } + }; + return Surface; + }()); + pixi_projection.Surface = Surface; +})(pixi_projection || (pixi_projection = {})); +var pixi_projection; +(function (pixi_projection) { + var tempMat = new PIXI.Matrix(); + var tempRect = new PIXI.Rectangle(); + var tempPoint = new PIXI.Point(); + var BilinearSurface = (function (_super) { + __extends(BilinearSurface, _super); + function BilinearSurface() { + var _this = _super.call(this) || this; + _this.distortion = new PIXI.Point(); + return _this; + } + BilinearSurface.prototype.clear = function () { + this.distortion.set(0, 0); + }; + BilinearSurface.prototype.apply = function (pos, newPos) { + newPos = newPos || new PIXI.Point(); + var d = this.distortion; + var m = pos.x * pos.y; + newPos.x = pos.x + d.x * m; + newPos.y = pos.y + d.y * m; + return newPos; + }; + BilinearSurface.prototype.applyInverse = function (pos, newPos) { + newPos = newPos || new PIXI.Point(); + var vx = pos.x, vy = pos.y; + var dx = this.distortion.x, dy = this.distortion.y; + if (dx == 0.0) { + newPos.x = vx; + newPos.y = vy / (1.0 + dy * vx); + } + else if (dy == 0.0) { + newPos.y = vy; + newPos.x = vx / (1.0 + dx * vy); + } + else { + var b = (vy * dx - vx * dy + 1.0) * 0.5 / dy; + var d = b * b + vx / dy; + if (d <= 0.00001) { + newPos.set(NaN, NaN); + return; + } + if (dy > 0.0) { + newPos.x = -b + Math.sqrt(d); + } + else { + newPos.x = -b - Math.sqrt(d); + } + newPos.y = (vx / newPos.x - 1.0) / dx; + } + return newPos; + }; + BilinearSurface.prototype.mapSprite = function (sprite, quad, outTransform) { + var tex = sprite.texture; + tempRect.x = -sprite.anchor.x * tex.orig.width; + tempRect.y = -sprite.anchor.y * tex.orig.height; + tempRect.width = tex.orig.width; + tempRect.height = tex.orig.height; + return this.mapQuad(tempRect, quad, outTransform || sprite.transform); + }; + BilinearSurface.prototype.mapQuad = function (rect, quad, outTransform) { + var ax = -rect.x / rect.width; + var ay = -rect.y / rect.height; + var ax2 = (1.0 - rect.x) / rect.width; + var ay2 = (1.0 - rect.y) / rect.height; + var up1x = (quad[0].x * (1.0 - ax) + quad[1].x * ax); + var up1y = (quad[0].y * (1.0 - ax) + quad[1].y * ax); + var up2x = (quad[0].x * (1.0 - ax2) + quad[1].x * ax2); + var up2y = (quad[0].y * (1.0 - ax2) + quad[1].y * ax2); + var down1x = (quad[3].x * (1.0 - ax) + quad[2].x * ax); + var down1y = (quad[3].y * (1.0 - ax) + quad[2].y * ax); + var down2x = (quad[3].x * (1.0 - ax2) + quad[2].x * ax2); + var down2y = (quad[3].y * (1.0 - ax2) + quad[2].y * ax2); + var x00 = up1x * (1.0 - ay) + down1x * ay; + var y00 = up1y * (1.0 - ay) + down1y * ay; + var x10 = up2x * (1.0 - ay) + down2x * ay; + var y10 = up2y * (1.0 - ay) + down2y * ay; + var x01 = up1x * (1.0 - ay2) + down1x * ay2; + var y01 = up1y * (1.0 - ay2) + down1y * ay2; + var x11 = up2x * (1.0 - ay2) + down2x * ay2; + var y11 = up2y * (1.0 - ay2) + down2y * ay2; + var mat = tempMat; + mat.tx = x00; + mat.ty = y00; + mat.a = x10 - x00; + mat.b = y10 - y00; + mat.c = x01 - x00; + mat.d = y01 - y00; + tempPoint.set(x11, y11); + mat.applyInverse(tempPoint, tempPoint); + this.distortion.set(tempPoint.x - 1, tempPoint.y - 1); + outTransform.setFromMatrix(mat); + return this; + }; + BilinearSurface.prototype.fillUniforms = function (uniforms) { + uniforms.distortion = uniforms.distortion || new Float32Array([0, 0, 0, 0]); + var ax = Math.abs(this.distortion.x); + var ay = Math.abs(this.distortion.y); + uniforms.distortion[0] = ax * 10000 <= ay ? 0 : this.distortion.x; + uniforms.distortion[1] = ay * 10000 <= ax ? 0 : this.distortion.y; + uniforms.distortion[2] = 1.0 / uniforms.distortion[0]; + uniforms.distortion[3] = 1.0 / uniforms.distortion[1]; + }; + return BilinearSurface; + }(pixi_projection.Surface)); + pixi_projection.BilinearSurface = BilinearSurface; +})(pixi_projection || (pixi_projection = {})); +var pixi_projection; +(function (pixi_projection) { + var Container2s = (function (_super) { + __extends(Container2s, _super); + function Container2s() { + var _this = _super.call(this) || this; + _this.proj = new pixi_projection.ProjectionSurface(_this.transform); + return _this; + } + Object.defineProperty(Container2s.prototype, "worldTransform", { + get: function () { + return this.proj; + }, + enumerable: true, + configurable: true + }); + return Container2s; + }(PIXI.Container)); + pixi_projection.Container2s = Container2s; +})(pixi_projection || (pixi_projection = {})); +var pixi_projection; +(function (pixi_projection) { + var fun = PIXI.Transform.prototype.updateTransform; + function transformHack(parentTransform) { + var proj = this.proj; + var pp = parentTransform.proj; + var ta = this; + if (!pp) { + fun.call(this, parentTransform); + proj._activeProjection = null; + return; + } + if (pp._surface) { + proj._activeProjection = pp; + this.updateLocalTransform(); + this.localTransform.copyFrom(this.worldTransform); + if (ta._parentID < 0) { + ++ta._worldID; + } + return; + } + fun.call(this, parentTransform); + proj._activeProjection = pp._activeProjection; + } + var ProjectionSurface = (function (_super) { + __extends(ProjectionSurface, _super); + function ProjectionSurface(legacy, enable) { + var _this = _super.call(this, legacy, enable) || this; + _this._surface = null; + _this._activeProjection = null; + _this._currentSurfaceID = -1; + _this._currentLegacyID = -1; + _this._lastUniforms = null; + return _this; + } + Object.defineProperty(ProjectionSurface.prototype, "enabled", { + set: function (value) { + if (value === this._enabled) { + return; + } + this._enabled = value; + if (value) { + this.legacy.updateTransform = transformHack; + this.legacy._parentID = -1; + } + else { + this.legacy.updateTransform = PIXI.Transform.prototype.updateTransform; + this.legacy._parentID = -1; + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ProjectionSurface.prototype, "surface", { + get: function () { + return this._surface; + }, + set: function (value) { + if (this._surface == value) { + return; + } + this._surface = value || null; + this.legacy._parentID = -1; + }, + enumerable: true, + configurable: true + }); + ProjectionSurface.prototype.applyPartial = function (pos, newPos) { + if (this._activeProjection !== null) { + newPos = this.legacy.worldTransform.apply(pos, newPos); + return this._activeProjection.surface.apply(newPos, newPos); + } + if (this._surface !== null) { + return this.surface.apply(pos, newPos); + } + return this.legacy.worldTransform.apply(pos, newPos); + }; + ProjectionSurface.prototype.apply = function (pos, newPos) { + if (this._activeProjection !== null) { + newPos = this.legacy.worldTransform.apply(pos, newPos); + this._activeProjection.surface.apply(newPos, newPos); + return this._activeProjection.legacy.worldTransform.apply(newPos, newPos); + } + if (this._surface !== null) { + newPos = this.surface.apply(pos, newPos); + return this.legacy.worldTransform.apply(newPos, newPos); + } + return this.legacy.worldTransform.apply(pos, newPos); + }; + ProjectionSurface.prototype.applyInverse = function (pos, newPos) { + if (this._activeProjection !== null) { + newPos = this._activeProjection.legacy.worldTransform.applyInverse(pos, newPos); + this._activeProjection._surface.applyInverse(newPos, newPos); + return this.legacy.worldTransform.applyInverse(newPos, newPos); + } + if (this._surface !== null) { + newPos = this.legacy.worldTransform.applyInverse(pos, newPos); + return this._surface.applyInverse(newPos, newPos); + } + return this.legacy.worldTransform.applyInverse(pos, newPos); + }; + ProjectionSurface.prototype.mapBilinearSprite = function (sprite, quad) { + if (!(this._surface instanceof pixi_projection.BilinearSurface)) { + this.surface = new pixi_projection.BilinearSurface(); + } + this.surface.mapSprite(sprite, quad, this.legacy); + }; + ProjectionSurface.prototype.clear = function () { + if (this.surface) { + this.surface.clear(); + } + }; + Object.defineProperty(ProjectionSurface.prototype, "uniforms", { + get: function () { + if (this._currentLegacyID === this.legacy._worldID && + this._currentSurfaceID === this.surface._updateID) { + return this._lastUniforms; + } + this._lastUniforms = this._lastUniforms || {}; + this._lastUniforms.translationMatrix = this.legacy.worldTransform; + this._surface.fillUniforms(this._lastUniforms); + return this._lastUniforms; + }, + enumerable: true, + configurable: true + }); + return ProjectionSurface; + }(pixi_projection.AbstractProjection)); + pixi_projection.ProjectionSurface = ProjectionSurface; +})(pixi_projection || (pixi_projection = {})); +var pixi_projection; +(function (pixi_projection) { + var TYPES = PIXI.TYPES; + var premultiplyTint = PIXI.utils.premultiplyTint; + var shaderVert = "precision highp float;\nattribute vec2 aVertexPosition;\nattribute vec3 aTrans1;\nattribute vec3 aTrans2;\nattribute vec2 aSamplerSize;\nattribute vec4 aFrame;\nattribute vec4 aColor;\nattribute float aTextureId;\n\nuniform mat3 projectionMatrix;\nuniform mat3 translationMatrix;\n\nvarying vec2 vertexPosition;\nvarying vec3 vTrans1;\nvarying vec3 vTrans2;\nvarying vec2 vSamplerSize;\nvarying vec4 vFrame;\nvarying vec4 vColor;\nvarying float vTextureId;\n\nvoid main(void){\n gl_Position.xyw = projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0);\n gl_Position.z = 0.0;\n \n vertexPosition = aVertexPosition;\n vTrans1 = aTrans1;\n vTrans2 = aTrans2;\n vTextureId = aTextureId;\n vColor = aColor;\n vSamplerSize = aSamplerSize;\n vFrame = aFrame;\n}\n"; + var shaderFrag = "precision highp float;\nvarying vec2 vertexPosition;\nvarying vec3 vTrans1;\nvarying vec3 vTrans2;\nvarying vec2 vSamplerSize;\nvarying vec4 vFrame;\nvarying vec4 vColor;\nvarying float vTextureId;\n\nuniform sampler2D uSamplers[%count%];\nuniform vec4 distortion;\n\nvoid main(void){\nvec2 surface;\nvec2 surface2;\n\nfloat vx = vertexPosition.x;\nfloat vy = vertexPosition.y;\nfloat dx = distortion.x;\nfloat dy = distortion.y;\nfloat revx = distortion.z;\nfloat revy = distortion.w;\n\nif (distortion.x == 0.0) {\n surface.x = vx;\n surface.y = vy / (1.0 + dy * vx);\n surface2 = surface;\n} else\nif (distortion.y == 0.0) {\n surface.y = vy;\n surface.x = vx / (1.0 + dx * vy);\n surface2 = surface;\n} else {\n float c = vy * dx - vx * dy;\n float b = (c + 1.0) * 0.5;\n float b2 = (-c + 1.0) * 0.5;\n float d = b * b + vx * dy;\n //if (d < -0.00001) {\n // discard;\n //}\n d = sqrt(max(d, 0.0));\n surface.x = (- b + d) * revy;\n surface2.x = (- b - d) * revy;\n surface.y = (- b2 + d) * revx;\n surface2.y = (- b2 - d) * revx;\n}\n\nvec2 uv;\nuv.x = vTrans1.x * surface.x + vTrans1.y * surface.y + vTrans1.z;\nuv.y = vTrans2.x * surface.x + vTrans2.y * surface.y + vTrans2.z;\n\nvec2 pixels = uv * vSamplerSize;\n\nif (pixels.x < vFrame.x || pixels.x > vFrame.z ||\n pixels.y < vFrame.y || pixels.y > vFrame.w) {\n uv.x = vTrans1.x * surface2.x + vTrans1.y * surface2.y + vTrans1.z;\n uv.y = vTrans2.x * surface2.x + vTrans2.y * surface2.y + vTrans2.z;\n pixels = uv * vSamplerSize;\n \n// if (pixels.x < vFrame.x || pixels.x > vFrame.z ||\n// pixels.y < vFrame.y || pixels.y > vFrame.w) {\n// discard;\n// }\n}\n\nvec4 edge;\nedge.xy = clamp(pixels - vFrame.xy + 0.5, vec2(0.0, 0.0), vec2(1.0, 1.0));\nedge.zw = clamp(vFrame.zw - pixels + 0.5, vec2(0.0, 0.0), vec2(1.0, 1.0));\n\nfloat alpha = 1.0; //edge.x * edge.y * edge.z * edge.w;\nvec4 rColor = vColor * alpha;\n\nfloat textureId = floor(vTextureId+0.5);\nvec2 vTextureCoord = uv;\nvec4 color;\n%forloop%\ngl_FragColor = vec4(0.0, 1.0, 0.0, 1.0);\n//gl_FragColor = color * rColor;\n}"; + var BatchBilineardGeometry = (function (_super) { + __extends(BatchBilineardGeometry, _super); + function BatchBilineardGeometry(_static) { + if (_static === void 0) { _static = false; } + var _this = _super.call(this) || this; + _this._buffer = new PIXI.Buffer(null, _static, false); + _this._indexBuffer = new PIXI.Buffer(null, _static, true); + _this.addAttribute('aVertexPosition', _this._buffer, 2, false, TYPES.FLOAT) + .addAttribute('aTrans1', _this._buffer, 3, false, TYPES.FLOAT) + .addAttribute('aTrans2', _this._buffer, 3, false, TYPES.FLOAT) + .addAttribute('aSamplerSize', _this._buffer, 2, false, TYPES.FLOAT) + .addAttribute('aFrame', _this._buffer, 4, false, TYPES.FLOAT) + .addAttribute('aColor', _this._buffer, 4, true, TYPES.UNSIGNED_BYTE) + .addAttribute('aTextureId', _this._buffer, 1, true, TYPES.FLOAT) + .addIndex(_this._indexBuffer); + return _this; + } + return BatchBilineardGeometry; + }(PIXI.Geometry)); + pixi_projection.BatchBilineardGeometry = BatchBilineardGeometry; + var BatchBilinearPluginFactory = (function () { + function BatchBilinearPluginFactory() { + } + BatchBilinearPluginFactory.create = function (options) { + var _a = Object.assign({ + vertex: shaderVert, + fragment: shaderFrag, + geometryClass: BatchBilineardGeometry, + vertexSize: 16, + }, options), vertex = _a.vertex, fragment = _a.fragment, vertexSize = _a.vertexSize, geometryClass = _a.geometryClass; + return (function (_super) { + __extends(BatchPlugin, _super); + function BatchPlugin(renderer) { + var _this = _super.call(this, renderer) || this; + _this.defUniforms = { + translationMatrix: new PIXI.Matrix(), + distortion: new Float32Array([0, 0]) + }; + _this.size = 1000; + _this.forceMaxTextures = 1; + _this.shaderGenerator = new PIXI.BatchShaderGenerator(vertex, fragment); + _this.geometryClass = geometryClass; + _this.vertexSize = vertexSize; + return _this; + } + BatchPlugin.prototype.getUniforms = function (sprite) { + var proj = sprite.proj; + if (proj.surface !== null) { + return proj.uniforms; + } + if (proj._activeProjection !== null) { + return proj._activeProjection.uniforms; + } + return this.defUniforms; + }; + BatchPlugin.prototype.packInterleavedGeometry = function (element, attributeBuffer, indexBuffer, aIndex, iIndex) { + var uint32View = attributeBuffer.uint32View, float32View = attributeBuffer.float32View; + var p = aIndex / this.vertexSize; + var indices = element.indices; + var vertexData = element.vertexData; + var tex = element._texture; + var frame = tex._frame; + var aTrans = element.aTrans; + var _a = element._texture.baseTexture, _batchLocation = _a._batchLocation, realWidth = _a.realWidth, realHeight = _a.realHeight, resolution = _a.resolution; + var alpha = Math.min(element.worldAlpha, 1.0); + var argb = alpha < 1.0 && element._texture.baseTexture.alphaMode ? premultiplyTint(element._tintRGB, alpha) + : element._tintRGB + (alpha * 255 << 24); + for (var i = 0; i < vertexData.length; i += 2) { + float32View[aIndex] = vertexData[i * 2]; + float32View[aIndex + 1] = vertexData[i * 2 + 1]; + float32View[aIndex + 2] = aTrans.a; + float32View[aIndex + 3] = aTrans.c; + float32View[aIndex + 4] = aTrans.tx; + float32View[aIndex + 5] = aTrans.b; + float32View[aIndex + 6] = aTrans.d; + float32View[aIndex + 7] = aTrans.ty; + float32View[aIndex + 8] = realWidth; + float32View[aIndex + 9] = realHeight; + float32View[aIndex + 10] = frame.x * resolution; + float32View[aIndex + 11] = frame.y * resolution; + float32View[aIndex + 12] = (frame.x + frame.width) * resolution; + float32View[aIndex + 13] = (frame.y + frame.height) * resolution; + uint32View[aIndex + 14] = argb; + float32View[aIndex + 15] = _batchLocation; + aIndex += 16; + } + for (var i = 0; i < indices.length; i++) { + indexBuffer[iIndex++] = p + indices[i]; + } + }; + return BatchPlugin; + }(pixi_projection.UniformBatchRenderer)); + }; + return BatchBilinearPluginFactory; + }()); + pixi_projection.BatchBilinearPluginFactory = BatchBilinearPluginFactory; + PIXI.Renderer.registerPlugin('batch_bilinear', BatchBilinearPluginFactory.create({})); +})(pixi_projection || (pixi_projection = {})); +var pixi_projection; +(function (pixi_projection) { + var Sprite2s = (function (_super) { + __extends(Sprite2s, _super); + function Sprite2s(texture) { + var _this = _super.call(this, texture) || this; + _this.aTrans = new PIXI.Matrix(); + _this.proj = new pixi_projection.ProjectionSurface(_this.transform); + _this.pluginName = 'batch_bilinear'; + return _this; + } + Sprite2s.prototype._calculateBounds = function () { + this.calculateTrimmedVertices(); + this._bounds.addQuad(this.vertexTrimmedData); + }; + Sprite2s.prototype.calculateVertices = function () { + var wid = this.transform._worldID; + var tuid = this._texture._updateID; + if (this._transformID === wid && this._textureID === tuid) { + return; + } + this._transformID = wid; + this._textureID = tuid; + var texture = this._texture; + var vertexData = this.vertexData; + var trim = texture.trim; + var orig = texture.orig; + var anchor = this._anchor; + var w0 = 0; + var w1 = 0; + var h0 = 0; + var h1 = 0; + if (trim) { + w1 = trim.x - (anchor._x * orig.width); + w0 = w1 + trim.width; + h1 = trim.y - (anchor._y * orig.height); + h0 = h1 + trim.height; + } + else { + w1 = -anchor._x * orig.width; + w0 = w1 + orig.width; + h1 = -anchor._y * orig.height; + h0 = h1 + orig.height; + } + if (this.proj._surface) { + vertexData[0] = w1; + vertexData[1] = h1; + vertexData[2] = w0; + vertexData[3] = h1; + vertexData[4] = w0; + vertexData[5] = h0; + vertexData[6] = w1; + vertexData[7] = h0; + this.proj._surface.boundsQuad(vertexData, vertexData); + } + else { + var wt = this.transform.worldTransform; + var a = wt.a; + var b = wt.b; + var c = wt.c; + var d = wt.d; + var tx = wt.tx; + var ty = wt.ty; + vertexData[0] = (a * w1) + (c * h1) + tx; + vertexData[1] = (d * h1) + (b * w1) + ty; + vertexData[2] = (a * w0) + (c * h1) + tx; + vertexData[3] = (d * h1) + (b * w0) + ty; + vertexData[4] = (a * w0) + (c * h0) + tx; + vertexData[5] = (d * h0) + (b * w0) + ty; + vertexData[6] = (a * w1) + (c * h0) + tx; + vertexData[7] = (d * h0) + (b * w1) + ty; + if (this.proj._activeProjection) { + this.proj._activeProjection.surface.boundsQuad(vertexData, vertexData); + } + } + if (!texture.uvMatrix) { + texture.uvMatrix = new PIXI.TextureMatrix(texture); + } + texture.uvMatrix.update(); + var aTrans = this.aTrans; + aTrans.set(orig.width, 0, 0, orig.height, w1, h1); + if (this.proj._surface === null) { + aTrans.prepend(this.transform.worldTransform); + } + aTrans.invert(); + aTrans.prepend(texture.uvMatrix.mapCoord); + }; + Sprite2s.prototype.calculateTrimmedVertices = function () { + var wid = this.transform._worldID; + var tuid = this._texture._updateID; + if (!this.vertexTrimmedData) { + this.vertexTrimmedData = new Float32Array(8); + } + else if (this._transformTrimmedID === wid && this._textureTrimmedID === tuid) { + return; + } + this._transformTrimmedID = wid; + this._textureTrimmedID = tuid; + var texture = this._texture; + var vertexData = this.vertexTrimmedData; + var orig = texture.orig; + var anchor = this._anchor; + var w1 = -anchor._x * orig.width; + var w0 = w1 + orig.width; + var h1 = -anchor._y * orig.height; + var h0 = h1 + orig.height; + if (this.proj._surface) { + vertexData[0] = w1; + vertexData[1] = h1; + vertexData[2] = w0; + vertexData[3] = h1; + vertexData[4] = w0; + vertexData[5] = h0; + vertexData[6] = w1; + vertexData[7] = h0; + this.proj._surface.boundsQuad(vertexData, vertexData, this.transform.worldTransform); + } + else { + var wt = this.transform.worldTransform; + var a = wt.a; + var b = wt.b; + var c = wt.c; + var d = wt.d; + var tx = wt.tx; + var ty = wt.ty; + vertexData[0] = (a * w1) + (c * h1) + tx; + vertexData[1] = (d * h1) + (b * w1) + ty; + vertexData[2] = (a * w0) + (c * h1) + tx; + vertexData[3] = (d * h1) + (b * w0) + ty; + vertexData[4] = (a * w0) + (c * h0) + tx; + vertexData[5] = (d * h0) + (b * w0) + ty; + vertexData[6] = (a * w1) + (c * h0) + tx; + vertexData[7] = (d * h0) + (b * w1) + ty; + if (this.proj._activeProjection) { + this.proj._activeProjection.surface.boundsQuad(vertexData, vertexData, this.proj._activeProjection.legacy.worldTransform); + } + } + }; + Object.defineProperty(Sprite2s.prototype, "worldTransform", { + get: function () { + return this.proj; + }, + enumerable: true, + configurable: true + }); + return Sprite2s; + }(PIXI.Sprite)); + pixi_projection.Sprite2s = Sprite2s; +})(pixi_projection || (pixi_projection = {})); +var pixi_projection; +(function (pixi_projection) { + var Text2s = (function (_super) { + __extends(Text2s, _super); + function Text2s(text, style, canvas) { + var _this = _super.call(this, text, style, canvas) || this; + _this.aTrans = new PIXI.Matrix(); + _this.proj = new pixi_projection.ProjectionSurface(_this.transform); + _this.pluginName = 'batch_bilinear'; + return _this; + } + Object.defineProperty(Text2s.prototype, "worldTransform", { + get: function () { + return this.proj; + }, + enumerable: true, + configurable: true + }); + return Text2s; + }(PIXI.Text)); + pixi_projection.Text2s = Text2s; + Text2s.prototype.calculateVertices = pixi_projection.Sprite2s.prototype.calculateVertices; + Text2s.prototype.calculateTrimmedVertices = pixi_projection.Sprite2s.prototype.calculateTrimmedVertices; + Text2s.prototype._calculateBounds = pixi_projection.Sprite2s.prototype._calculateBounds; +})(pixi_projection || (pixi_projection = {})); +var pixi_projection; +(function (pixi_projection) { + PIXI.Sprite.prototype.convertTo2s = function () { + if (this.proj) + return; + this.pluginName = 'sprite_bilinear'; + this.aTrans = new PIXI.Matrix(); + this.calculateVertices = pixi_projection.Sprite2s.prototype.calculateVertices; + this.calculateTrimmedVertices = pixi_projection.Sprite2s.prototype.calculateTrimmedVertices; + this._calculateBounds = pixi_projection.Sprite2s.prototype._calculateBounds; + PIXI.Container.prototype.convertTo2s.call(this); + }; + PIXI.Container.prototype.convertTo2s = function () { + if (this.proj) + return; + this.proj = new pixi_projection.Projection2d(this.transform); + Object.defineProperty(this, "worldTransform", { + get: function () { + return this.proj; + }, + enumerable: true, + configurable: true + }); + }; + PIXI.Container.prototype.convertSubtreeTo2s = function () { + this.convertTo2s(); + for (var i = 0; i < this.children.length; i++) { + this.children[i].convertSubtreeTo2s(); + } + }; +})(pixi_projection || (pixi_projection = {})); +var pixi_projection; +(function (pixi_projection) { + function container2dWorldTransform() { + return this.proj.affine ? this.transform.worldTransform : this.proj.world; + } + pixi_projection.container2dWorldTransform = container2dWorldTransform; + var Container2d = (function (_super) { + __extends(Container2d, _super); + function Container2d() { + var _this = _super.call(this) || this; + _this.proj = new pixi_projection.Projection2d(_this.transform); + return _this; + } + Container2d.prototype.toLocal = function (position, from, point, skipUpdate, step) { + if (step === void 0) { step = pixi_projection.TRANSFORM_STEP.ALL; } + if (from) { + position = from.toGlobal(position, point, skipUpdate); + } + if (!skipUpdate) { + this._recursivePostUpdateTransform(); + } + if (step >= pixi_projection.TRANSFORM_STEP.PROJ) { + if (!skipUpdate) { + this.displayObjectUpdateTransform(); + } + if (this.proj.affine) { + return this.transform.worldTransform.applyInverse(position, point); + } + return this.proj.world.applyInverse(position, point); + } + if (this.parent) { + point = this.parent.worldTransform.applyInverse(position, point); + } + else { + point.copyFrom(position); + } + if (step === pixi_projection.TRANSFORM_STEP.NONE) { + return point; + } + return this.transform.localTransform.applyInverse(point, point); + }; + Object.defineProperty(Container2d.prototype, "worldTransform", { + get: function () { + return this.proj.affine ? this.transform.worldTransform : this.proj.world; + }, + enumerable: true, + configurable: true + }); + return Container2d; + }(PIXI.Container)); + pixi_projection.Container2d = Container2d; + pixi_projection.container2dToLocal = Container2d.prototype.toLocal; +})(pixi_projection || (pixi_projection = {})); +var pixi_projection; +(function (pixi_projection) { + var Point = PIXI.Point; + var mat3id = [1, 0, 0, 0, 1, 0, 0, 0, 1]; + var AFFINE; + (function (AFFINE) { + AFFINE[AFFINE["NONE"] = 0] = "NONE"; + AFFINE[AFFINE["FREE"] = 1] = "FREE"; + AFFINE[AFFINE["AXIS_X"] = 2] = "AXIS_X"; + AFFINE[AFFINE["AXIS_Y"] = 3] = "AXIS_Y"; + AFFINE[AFFINE["POINT"] = 4] = "POINT"; + AFFINE[AFFINE["AXIS_XR"] = 5] = "AXIS_XR"; + })(AFFINE = pixi_projection.AFFINE || (pixi_projection.AFFINE = {})); + var Matrix2d = (function () { + function Matrix2d(backingArray) { + this.floatArray = null; + this.mat3 = new Float64Array(backingArray || mat3id); + } + Object.defineProperty(Matrix2d.prototype, "a", { + get: function () { + return this.mat3[0] / this.mat3[8]; + }, + set: function (value) { + this.mat3[0] = value * this.mat3[8]; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Matrix2d.prototype, "b", { + get: function () { + return this.mat3[1] / this.mat3[8]; + }, + set: function (value) { + this.mat3[1] = value * this.mat3[8]; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Matrix2d.prototype, "c", { + get: function () { + return this.mat3[3] / this.mat3[8]; + }, + set: function (value) { + this.mat3[3] = value * this.mat3[8]; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Matrix2d.prototype, "d", { + get: function () { + return this.mat3[4] / this.mat3[8]; + }, + set: function (value) { + this.mat3[4] = value * this.mat3[8]; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Matrix2d.prototype, "tx", { + get: function () { + return this.mat3[6] / this.mat3[8]; + }, + set: function (value) { + this.mat3[6] = value * this.mat3[8]; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Matrix2d.prototype, "ty", { + get: function () { + return this.mat3[7] / this.mat3[8]; + }, + set: function (value) { + this.mat3[7] = value * this.mat3[8]; + }, + enumerable: true, + configurable: true + }); + Matrix2d.prototype.set = function (a, b, c, d, tx, ty) { + var mat3 = this.mat3; + mat3[0] = a; + mat3[1] = b; + mat3[2] = 0; + mat3[3] = c; + mat3[4] = d; + mat3[5] = 0; + mat3[6] = tx; + mat3[7] = ty; + mat3[8] = 1; + return this; + }; + Matrix2d.prototype.toArray = function (transpose, out) { + if (!this.floatArray) { + this.floatArray = new Float32Array(9); + } + var array = out || this.floatArray; + var mat3 = this.mat3; + if (transpose) { + array[0] = mat3[0]; + array[1] = mat3[1]; + array[2] = mat3[2]; + array[3] = mat3[3]; + array[4] = mat3[4]; + array[5] = mat3[5]; + array[6] = mat3[6]; + array[7] = mat3[7]; + array[8] = mat3[8]; + } + else { + array[0] = mat3[0]; + array[1] = mat3[3]; + array[2] = mat3[6]; + array[3] = mat3[1]; + array[4] = mat3[4]; + array[5] = mat3[7]; + array[6] = mat3[2]; + array[7] = mat3[5]; + array[8] = mat3[8]; + } + return array; + }; + Matrix2d.prototype.apply = function (pos, newPos) { + newPos = newPos || new PIXI.Point(); + var mat3 = this.mat3; + var x = pos.x; + var y = pos.y; + var z = 1.0 / (mat3[2] * x + mat3[5] * y + mat3[8]); + newPos.x = z * (mat3[0] * x + mat3[3] * y + mat3[6]); + newPos.y = z * (mat3[1] * x + mat3[4] * y + mat3[7]); + return newPos; + }; + Matrix2d.prototype.translate = function (tx, ty) { + var mat3 = this.mat3; + mat3[0] += tx * mat3[2]; + mat3[1] += ty * mat3[2]; + mat3[3] += tx * mat3[5]; + mat3[4] += ty * mat3[5]; + mat3[6] += tx * mat3[8]; + mat3[7] += ty * mat3[8]; + return this; + }; + Matrix2d.prototype.scale = function (x, y) { + var mat3 = this.mat3; + mat3[0] *= x; + mat3[1] *= y; + mat3[3] *= x; + mat3[4] *= y; + mat3[6] *= x; + mat3[7] *= y; + return this; + }; + Matrix2d.prototype.scaleAndTranslate = function (scaleX, scaleY, tx, ty) { + var mat3 = this.mat3; + mat3[0] = scaleX * mat3[0] + tx * mat3[2]; + mat3[1] = scaleY * mat3[1] + ty * mat3[2]; + mat3[3] = scaleX * mat3[3] + tx * mat3[5]; + mat3[4] = scaleY * mat3[4] + ty * mat3[5]; + mat3[6] = scaleX * mat3[6] + tx * mat3[8]; + mat3[7] = scaleY * mat3[7] + ty * mat3[8]; + }; + Matrix2d.prototype.applyInverse = function (pos, newPos) { + newPos = newPos || new Point(); + var a = this.mat3; + var x = pos.x; + var y = pos.y; + var a00 = a[0], a01 = a[3], a02 = a[6], a10 = a[1], a11 = a[4], a12 = a[7], a20 = a[2], a21 = a[5], a22 = a[8]; + var newX = (a22 * a11 - a12 * a21) * x + (-a22 * a01 + a02 * a21) * y + (a12 * a01 - a02 * a11); + var newY = (-a22 * a10 + a12 * a20) * x + (a22 * a00 - a02 * a20) * y + (-a12 * a00 + a02 * a10); + var newZ = (a21 * a10 - a11 * a20) * x + (-a21 * a00 + a01 * a20) * y + (a11 * a00 - a01 * a10); + newPos.x = newX / newZ; + newPos.y = newY / newZ; + return newPos; + }; + Matrix2d.prototype.invert = function () { + var a = this.mat3; + var a00 = a[0], a01 = a[1], a02 = a[2], a10 = a[3], a11 = a[4], a12 = a[5], a20 = a[6], a21 = a[7], a22 = a[8], b01 = a22 * a11 - a12 * a21, b11 = -a22 * a10 + a12 * a20, b21 = a21 * a10 - a11 * a20; + var det = a00 * b01 + a01 * b11 + a02 * b21; + if (!det) { + return this; + } + det = 1.0 / det; + a[0] = b01 * det; + a[1] = (-a22 * a01 + a02 * a21) * det; + a[2] = (a12 * a01 - a02 * a11) * det; + a[3] = b11 * det; + a[4] = (a22 * a00 - a02 * a20) * det; + a[5] = (-a12 * a00 + a02 * a10) * det; + a[6] = b21 * det; + a[7] = (-a21 * a00 + a01 * a20) * det; + a[8] = (a11 * a00 - a01 * a10) * det; + return this; + }; + Matrix2d.prototype.identity = function () { + var mat3 = this.mat3; + mat3[0] = 1; + mat3[1] = 0; + mat3[2] = 0; + mat3[3] = 0; + mat3[4] = 1; + mat3[5] = 0; + mat3[6] = 0; + mat3[7] = 0; + mat3[8] = 1; + return this; + }; + Matrix2d.prototype.clone = function () { + return new Matrix2d(this.mat3); + }; + Matrix2d.prototype.copyTo2dOr3d = function (matrix) { + var mat3 = this.mat3; + var ar2 = matrix.mat3; + ar2[0] = mat3[0]; + ar2[1] = mat3[1]; + ar2[2] = mat3[2]; + ar2[3] = mat3[3]; + ar2[4] = mat3[4]; + ar2[5] = mat3[5]; + ar2[6] = mat3[6]; + ar2[7] = mat3[7]; + ar2[8] = mat3[8]; + return matrix; + }; + Matrix2d.prototype.copyTo = function (matrix, affine, preserveOrientation) { + var mat3 = this.mat3; + var d = 1.0 / mat3[8]; + var tx = mat3[6] * d, ty = mat3[7] * d; + matrix.a = (mat3[0] - mat3[2] * tx) * d; + matrix.b = (mat3[1] - mat3[2] * ty) * d; + matrix.c = (mat3[3] - mat3[5] * tx) * d; + matrix.d = (mat3[4] - mat3[5] * ty) * d; + matrix.tx = tx; + matrix.ty = ty; + if (affine >= 2) { + var D = matrix.a * matrix.d - matrix.b * matrix.c; + if (!preserveOrientation) { + D = Math.abs(D); + } + if (affine === AFFINE.POINT) { + if (D > 0) { + D = 1; + } + else + D = -1; + matrix.a = D; + matrix.b = 0; + matrix.c = 0; + matrix.d = D; + } + else if (affine === AFFINE.AXIS_X) { + D /= Math.sqrt(matrix.b * matrix.b + matrix.d * matrix.d); + matrix.c = 0; + matrix.d = D; + } + else if (affine === AFFINE.AXIS_Y) { + D /= Math.sqrt(matrix.a * matrix.a + matrix.c * matrix.c); + matrix.a = D; + matrix.c = 0; + } + else if (affine === AFFINE.AXIS_XR) { + matrix.a = matrix.d * D; + matrix.c = -matrix.b * D; + } + } + return matrix; + }; + Matrix2d.prototype.copyFrom = function (matrix) { + var mat3 = this.mat3; + mat3[0] = matrix.a; + mat3[1] = matrix.b; + mat3[2] = 0; + mat3[3] = matrix.c; + mat3[4] = matrix.d; + mat3[5] = 0; + mat3[6] = matrix.tx; + mat3[7] = matrix.ty; + mat3[8] = 1.0; + return this; + }; + Matrix2d.prototype.setToMultLegacy = function (pt, lt) { + var out = this.mat3; + var b = lt.mat3; + var a00 = pt.a, a01 = pt.b, a10 = pt.c, a11 = pt.d, a20 = pt.tx, a21 = pt.ty, b00 = b[0], b01 = b[1], b02 = b[2], b10 = b[3], b11 = b[4], b12 = b[5], b20 = b[6], b21 = b[7], b22 = b[8]; + out[0] = b00 * a00 + b01 * a10 + b02 * a20; + out[1] = b00 * a01 + b01 * a11 + b02 * a21; + out[2] = b02; + out[3] = b10 * a00 + b11 * a10 + b12 * a20; + out[4] = b10 * a01 + b11 * a11 + b12 * a21; + out[5] = b12; + out[6] = b20 * a00 + b21 * a10 + b22 * a20; + out[7] = b20 * a01 + b21 * a11 + b22 * a21; + out[8] = b22; + return this; + }; + Matrix2d.prototype.setToMultLegacy2 = function (pt, lt) { + var out = this.mat3; + var a = pt.mat3; + var a00 = a[0], a01 = a[1], a02 = a[2], a10 = a[3], a11 = a[4], a12 = a[5], a20 = a[6], a21 = a[7], a22 = a[8], b00 = lt.a, b01 = lt.b, b10 = lt.c, b11 = lt.d, b20 = lt.tx, b21 = lt.ty; + out[0] = b00 * a00 + b01 * a10; + out[1] = b00 * a01 + b01 * a11; + out[2] = b00 * a02 + b01 * a12; + out[3] = b10 * a00 + b11 * a10; + out[4] = b10 * a01 + b11 * a11; + out[5] = b10 * a02 + b11 * a12; + out[6] = b20 * a00 + b21 * a10 + a20; + out[7] = b20 * a01 + b21 * a11 + a21; + out[8] = b20 * a02 + b21 * a12 + a22; + return this; + }; + Matrix2d.prototype.setToMult = function (pt, lt) { + var out = this.mat3; + var a = pt.mat3, b = lt.mat3; + var a00 = a[0], a01 = a[1], a02 = a[2], a10 = a[3], a11 = a[4], a12 = a[5], a20 = a[6], a21 = a[7], a22 = a[8], b00 = b[0], b01 = b[1], b02 = b[2], b10 = b[3], b11 = b[4], b12 = b[5], b20 = b[6], b21 = b[7], b22 = b[8]; + out[0] = b00 * a00 + b01 * a10 + b02 * a20; + out[1] = b00 * a01 + b01 * a11 + b02 * a21; + out[2] = b00 * a02 + b01 * a12 + b02 * a22; + out[3] = b10 * a00 + b11 * a10 + b12 * a20; + out[4] = b10 * a01 + b11 * a11 + b12 * a21; + out[5] = b10 * a02 + b11 * a12 + b12 * a22; + out[6] = b20 * a00 + b21 * a10 + b22 * a20; + out[7] = b20 * a01 + b21 * a11 + b22 * a21; + out[8] = b20 * a02 + b21 * a12 + b22 * a22; + return this; + }; + Matrix2d.prototype.prepend = function (lt) { + if (lt.mat3) { + return this.setToMult(lt, this); + } + else { + return this.setToMultLegacy(lt, this); + } + }; + Matrix2d.IDENTITY = new Matrix2d(); + Matrix2d.TEMP_MATRIX = new Matrix2d(); + return Matrix2d; + }()); + pixi_projection.Matrix2d = Matrix2d; +})(pixi_projection || (pixi_projection = {})); +var pixi_projection; +(function (pixi_projection) { + var t0 = new PIXI.Point(); + var tt = [new PIXI.Point(), new PIXI.Point(), new PIXI.Point(), new PIXI.Point()]; + var tempRect = new PIXI.Rectangle(); + var tempMat = new pixi_projection.Matrix2d(); + var Projection2d = (function (_super) { + __extends(Projection2d, _super); + function Projection2d(legacy, enable) { + var _this = _super.call(this, legacy, enable) || this; + _this.matrix = new pixi_projection.Matrix2d(); + _this.pivot = new PIXI.ObservablePoint(_this.onChange, _this, 0, 0); + _this.reverseLocalOrder = false; + _this.local = new pixi_projection.Matrix2d(); + _this.world = new pixi_projection.Matrix2d(); + return _this; + } + Projection2d.prototype.onChange = function () { + var pivot = this.pivot; + var mat3 = this.matrix.mat3; + mat3[6] = -(pivot._x * mat3[0] + pivot._y * mat3[3]); + mat3[7] = -(pivot._x * mat3[1] + pivot._y * mat3[4]); + this._projID++; + }; + Projection2d.prototype.setAxisX = function (p, factor) { + if (factor === void 0) { factor = 1; } + var x = p.x, y = p.y; + var d = Math.sqrt(x * x + y * y); + var mat3 = this.matrix.mat3; + mat3[0] = x / d; + mat3[1] = y / d; + mat3[2] = factor / d; + this.onChange(); + }; + Projection2d.prototype.setAxisY = function (p, factor) { + if (factor === void 0) { factor = 1; } + var x = p.x, y = p.y; + var d = Math.sqrt(x * x + y * y); + var mat3 = this.matrix.mat3; + mat3[3] = x / d; + mat3[4] = y / d; + mat3[5] = factor / d; + this.onChange(); + }; + Projection2d.prototype.mapSprite = function (sprite, quad) { + var tex = sprite.texture; + tempRect.x = -sprite.anchor.x * tex.orig.width; + tempRect.y = -sprite.anchor.y * tex.orig.height; + tempRect.width = tex.orig.width; + tempRect.height = tex.orig.height; + return this.mapQuad(tempRect, quad); + }; + Projection2d.prototype.mapQuad = function (rect, p) { + tt[0].set(rect.x, rect.y); + tt[1].set(rect.x + rect.width, rect.y); + tt[2].set(rect.x + rect.width, rect.y + rect.height); + tt[3].set(rect.x, rect.y + rect.height); + var k1 = 1, k2 = 2, k3 = 3; + var f = pixi_projection.utils.getIntersectionFactor(p[0], p[2], p[1], p[3], t0); + if (f !== 0) { + k1 = 1; + k2 = 3; + k3 = 2; + } + else { + return; + } + var d0 = Math.sqrt((p[0].x - t0.x) * (p[0].x - t0.x) + (p[0].y - t0.y) * (p[0].y - t0.y)); + var d1 = Math.sqrt((p[k1].x - t0.x) * (p[k1].x - t0.x) + (p[k1].y - t0.y) * (p[k1].y - t0.y)); + var d2 = Math.sqrt((p[k2].x - t0.x) * (p[k2].x - t0.x) + (p[k2].y - t0.y) * (p[k2].y - t0.y)); + var d3 = Math.sqrt((p[k3].x - t0.x) * (p[k3].x - t0.x) + (p[k3].y - t0.y) * (p[k3].y - t0.y)); + var q0 = (d0 + d3) / d3; + var q1 = (d1 + d2) / d2; + var q2 = (d1 + d2) / d1; + var mat3 = this.matrix.mat3; + mat3[0] = tt[0].x * q0; + mat3[1] = tt[0].y * q0; + mat3[2] = q0; + mat3[3] = tt[k1].x * q1; + mat3[4] = tt[k1].y * q1; + mat3[5] = q1; + mat3[6] = tt[k2].x * q2; + mat3[7] = tt[k2].y * q2; + mat3[8] = q2; + this.matrix.invert(); + mat3 = tempMat.mat3; + mat3[0] = p[0].x; + mat3[1] = p[0].y; + mat3[2] = 1; + mat3[3] = p[k1].x; + mat3[4] = p[k1].y; + mat3[5] = 1; + mat3[6] = p[k2].x; + mat3[7] = p[k2].y; + mat3[8] = 1; + this.matrix.setToMult(tempMat, this.matrix); + this._projID++; + }; + Projection2d.prototype.updateLocalTransform = function (lt) { + if (this._projID !== 0) { + if (this.reverseLocalOrder) { + this.local.setToMultLegacy2(this.matrix, lt); + } + else { + this.local.setToMultLegacy(lt, this.matrix); + } + } + else { + this.local.copyFrom(lt); + } + }; + Projection2d.prototype.clear = function () { + _super.prototype.clear.call(this); + this.matrix.identity(); + this.pivot.set(0, 0); + }; + return Projection2d; + }(pixi_projection.LinearProjection)); + pixi_projection.Projection2d = Projection2d; +})(pixi_projection || (pixi_projection = {})); +var pixi_projection; +(function (pixi_projection) { + var Mesh2d = (function (_super) { + __extends(Mesh2d, _super); + function Mesh2d(geometry, shader, state, drawMode) { + var _this = _super.call(this, geometry, shader, state, drawMode) || this; + _this.vertexData2d = null; + _this.proj = new pixi_projection.Projection2d(_this.transform); + return _this; + } + Mesh2d.prototype.calculateVertices = function () { + if (this.proj._affine) { + this.vertexData2d = null; + _super.prototype.calculateVertices.call(this); + return; + } + var geometry = this.geometry; + var vertices = geometry.buffers[0].data; + var thisAny = this; + if (geometry.vertexDirtyId === thisAny.vertexDirty && thisAny._transformID === thisAny.transform._worldID) { + return; + } + thisAny._transformID = thisAny.transform._worldID; + if (thisAny.vertexData.length !== vertices.length) { + thisAny.vertexData = new Float32Array(vertices.length); + } + if (this.vertexData2d.length !== vertices.length * 3 / 2) { + this.vertexData2d = new Float32Array(vertices.length * 3); + } + var wt = this.proj.world.mat3; + var vertexData2d = this.vertexData2d; + var vertexData = thisAny.vertexData; + for (var i = 0; i < vertexData.length / 2; i++) { + var x = vertices[(i * 2)]; + var y = vertices[(i * 2) + 1]; + var xx = (wt[0] * x) + (wt[3] * y) + wt[6]; + var yy = (wt[1] * x) + (wt[4] * y) + wt[7]; + var ww = (wt[2] * x) + (wt[5] * y) + wt[8]; + vertexData2d[i * 3] = xx; + vertexData2d[i * 3 + 1] = yy; + vertexData2d[i * 3 + 2] = ww; + vertexData[(i * 2)] = xx / ww; + vertexData[(i * 2) + 1] = yy / ww; + } + thisAny.vertexDirty = geometry.vertexDirtyId; + }; + Mesh2d.prototype._renderDefault = function (renderer) { + var shader = this.shader; + shader.alpha = this.worldAlpha; + if (shader.update) { + shader.update(); + } + renderer.batch.flush(); + if (shader.program.uniformData.translationMatrix) { + shader.uniforms.translationMatrix = this.worldTransform.toArray(true); + } + renderer.shader.bind(shader, false); + renderer.state.set(this.state); + renderer.geometry.bind(this.geometry, shader); + renderer.geometry.draw(this.drawMode, this.size, this.start, this.geometry.instanceCount); + }; + Mesh2d.prototype.toLocal = function (position, from, point, skipUpdate, step) { + if (step === void 0) { step = pixi_projection.TRANSFORM_STEP.ALL; } + return pixi_projection.container2dToLocal.call(this, position, from, point, skipUpdate, step); + }; + Object.defineProperty(Mesh2d.prototype, "worldTransform", { + get: function () { + return this.proj.affine ? this.transform.worldTransform : this.proj.world; + }, + enumerable: true, + configurable: true + }); + Mesh2d.defaultVertexShader = "precision highp float;\nattribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\nuniform mat3 translationMatrix;\nuniform mat3 uTransform;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position.xyw = projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0);\n gl_Position.z = 0.0;\n\n vTextureCoord = (uTransform * vec3(aTextureCoord, 1.0)).xy;\n}\n"; + Mesh2d.defaultFragmentShader = "\nvarying vec2 vTextureCoord;\nuniform vec4 uColor;\n\nuniform sampler2D uSampler;\n\nvoid main(void)\n{\n gl_FragColor = texture2D(uSampler, vTextureCoord) * uColor;\n}"; + return Mesh2d; + }(PIXI.Mesh)); + pixi_projection.Mesh2d = Mesh2d; + var SimpleMesh2d = (function (_super) { + __extends(SimpleMesh2d, _super); + function SimpleMesh2d(texture, vertices, uvs, indices, drawMode) { + var _this = _super.call(this, new PIXI.MeshGeometry(vertices, uvs, indices), new PIXI.MeshMaterial(texture, { + program: PIXI.Program.from(Mesh2d.defaultVertexShader, Mesh2d.defaultFragmentShader), + pluginName: 'batch2d' + }), null, drawMode) || this; + _this.autoUpdate = true; + _this.geometry.getBuffer('aVertexPosition').static = false; + return _this; + } + Object.defineProperty(SimpleMesh2d.prototype, "vertices", { + get: function () { + return this.geometry.getBuffer('aVertexPosition').data; + }, + set: function (value) { + this.geometry.getBuffer('aVertexPosition').data = value; + }, + enumerable: true, + configurable: true + }); + SimpleMesh2d.prototype._render = function (renderer) { + if (this.autoUpdate) { + this.geometry.getBuffer('aVertexPosition').update(); + } + _super.prototype._render.call(this, renderer); + }; + return SimpleMesh2d; + }(Mesh2d)); + pixi_projection.SimpleMesh2d = SimpleMesh2d; +})(pixi_projection || (pixi_projection = {})); +var pixi_projection; +(function (pixi_projection) { + var Sprite2d = (function (_super) { + __extends(Sprite2d, _super); + function Sprite2d(texture) { + var _this = _super.call(this, texture) || this; + _this.vertexData2d = null; + _this.proj = new pixi_projection.Projection2d(_this.transform); + _this.pluginName = 'batch2d'; + return _this; + } + Sprite2d.prototype._calculateBounds = function () { + this.calculateTrimmedVertices(); + this._bounds.addQuad(this.vertexTrimmedData); + }; + Sprite2d.prototype.calculateVertices = function () { + var texture = this._texture; + if (this.proj._affine) { + this.vertexData2d = null; + _super.prototype.calculateVertices.call(this); + return; + } + if (!this.vertexData2d) { + this.vertexData2d = new Float32Array(12); + } + var wid = this.transform._worldID; + var tuid = texture._updateID; + if (this._transformID === wid && this._textureID === tuid) { + return; + } + if (this._textureID !== tuid) { + this.uvs = texture._uvs.uvsFloat32; + } + this._transformID = wid; + this._textureID = tuid; + var wt = this.proj.world.mat3; + var vertexData2d = this.vertexData2d; + var vertexData = this.vertexData; + var trim = texture.trim; + var orig = texture.orig; + var anchor = this._anchor; + var w0 = 0; + var w1 = 0; + var h0 = 0; + var h1 = 0; + if (trim) { + w1 = trim.x - (anchor._x * orig.width); + w0 = w1 + trim.width; + h1 = trim.y - (anchor._y * orig.height); + h0 = h1 + trim.height; + } + else { + w1 = -anchor._x * orig.width; + w0 = w1 + orig.width; + h1 = -anchor._y * orig.height; + h0 = h1 + orig.height; + } + vertexData2d[0] = (wt[0] * w1) + (wt[3] * h1) + wt[6]; + vertexData2d[1] = (wt[1] * w1) + (wt[4] * h1) + wt[7]; + vertexData2d[2] = (wt[2] * w1) + (wt[5] * h1) + wt[8]; + vertexData2d[3] = (wt[0] * w0) + (wt[3] * h1) + wt[6]; + vertexData2d[4] = (wt[1] * w0) + (wt[4] * h1) + wt[7]; + vertexData2d[5] = (wt[2] * w0) + (wt[5] * h1) + wt[8]; + vertexData2d[6] = (wt[0] * w0) + (wt[3] * h0) + wt[6]; + vertexData2d[7] = (wt[1] * w0) + (wt[4] * h0) + wt[7]; + vertexData2d[8] = (wt[2] * w0) + (wt[5] * h0) + wt[8]; + vertexData2d[9] = (wt[0] * w1) + (wt[3] * h0) + wt[6]; + vertexData2d[10] = (wt[1] * w1) + (wt[4] * h0) + wt[7]; + vertexData2d[11] = (wt[2] * w1) + (wt[5] * h0) + wt[8]; + vertexData[0] = vertexData2d[0] / vertexData2d[2]; + vertexData[1] = vertexData2d[1] / vertexData2d[2]; + vertexData[2] = vertexData2d[3] / vertexData2d[5]; + vertexData[3] = vertexData2d[4] / vertexData2d[5]; + vertexData[4] = vertexData2d[6] / vertexData2d[8]; + vertexData[5] = vertexData2d[7] / vertexData2d[8]; + vertexData[6] = vertexData2d[9] / vertexData2d[11]; + vertexData[7] = vertexData2d[10] / vertexData2d[11]; + }; + Sprite2d.prototype.calculateTrimmedVertices = function () { + if (this.proj._affine) { + _super.prototype.calculateTrimmedVertices.call(this); + return; + } + var wid = this.transform._worldID; + var tuid = this._texture._updateID; + if (!this.vertexTrimmedData) { + this.vertexTrimmedData = new Float32Array(8); + } + else if (this._transformTrimmedID === wid && this._textureTrimmedID === tuid) { + return; + } + this._transformTrimmedID = wid; + this._textureTrimmedID = tuid; + var texture = this._texture; + var vertexData = this.vertexTrimmedData; + var orig = texture.orig; + var anchor = this._anchor; + var wt = this.proj.world.mat3; + var w1 = -anchor._x * orig.width; + var w0 = w1 + orig.width; + var h1 = -anchor._y * orig.height; + var h0 = h1 + orig.height; + var z = 1.0 / (wt[2] * w1 + wt[5] * h1 + wt[8]); + vertexData[0] = z * ((wt[0] * w1) + (wt[3] * h1) + wt[6]); + vertexData[1] = z * ((wt[1] * w1) + (wt[4] * h1) + wt[7]); + z = 1.0 / (wt[2] * w0 + wt[5] * h1 + wt[8]); + vertexData[2] = z * ((wt[0] * w0) + (wt[3] * h1) + wt[6]); + vertexData[3] = z * ((wt[1] * w0) + (wt[4] * h1) + wt[7]); + z = 1.0 / (wt[2] * w0 + wt[5] * h0 + wt[8]); + vertexData[4] = z * ((wt[0] * w0) + (wt[3] * h0) + wt[6]); + vertexData[5] = z * ((wt[1] * w0) + (wt[4] * h0) + wt[7]); + z = 1.0 / (wt[2] * w1 + wt[5] * h0 + wt[8]); + vertexData[6] = z * ((wt[0] * w1) + (wt[3] * h0) + wt[6]); + vertexData[7] = z * ((wt[1] * w1) + (wt[4] * h0) + wt[7]); + }; + Sprite2d.prototype.toLocal = function (position, from, point, skipUpdate, step) { + if (step === void 0) { step = pixi_projection.TRANSFORM_STEP.ALL; } + return pixi_projection.container2dToLocal.call(this, position, from, point, skipUpdate, step); + }; + Object.defineProperty(Sprite2d.prototype, "worldTransform", { + get: function () { + return this.proj.affine ? this.transform.worldTransform : this.proj.world; + }, + enumerable: true, + configurable: true + }); + return Sprite2d; + }(PIXI.Sprite)); + pixi_projection.Sprite2d = Sprite2d; +})(pixi_projection || (pixi_projection = {})); +var pixi_projection; +(function (pixi_projection) { + var Text2d = (function (_super) { + __extends(Text2d, _super); + function Text2d(text, style, canvas) { + var _this = _super.call(this, text, style, canvas) || this; + _this.vertexData2d = null; + _this.proj = new pixi_projection.Projection2d(_this.transform); + _this.pluginName = 'batch2d'; + return _this; + } + Object.defineProperty(Text2d.prototype, "worldTransform", { + get: function () { + return this.proj.affine ? this.transform.worldTransform : this.proj.world; + }, + enumerable: true, + configurable: true + }); + return Text2d; + }(PIXI.Text)); + pixi_projection.Text2d = Text2d; + Text2d.prototype.calculateVertices = pixi_projection.Sprite2d.prototype.calculateVertices; + Text2d.prototype.calculateTrimmedVertices = pixi_projection.Sprite2d.prototype.calculateTrimmedVertices; + Text2d.prototype._calculateBounds = pixi_projection.Sprite2d.prototype._calculateBounds; +})(pixi_projection || (pixi_projection = {})); +var pixi_projection; +(function (pixi_projection) { + function convertTo2d() { + if (this.proj) + return; + this.proj = new pixi_projection.Projection2d(this.transform); + this.toLocal = pixi_projection.Container2d.prototype.toLocal; + Object.defineProperty(this, "worldTransform", { + get: pixi_projection.container2dWorldTransform, + enumerable: true, + configurable: true + }); + } + PIXI.Container.prototype.convertTo2d = convertTo2d; + PIXI.Sprite.prototype.convertTo2d = function () { + if (this.proj) + return; + this.calculateVertices = pixi_projection.Sprite2d.prototype.calculateVertices; + this.calculateTrimmedVertices = pixi_projection.Sprite2d.prototype.calculateTrimmedVertices; + this._calculateBounds = pixi_projection.Sprite2d.prototype._calculateBounds; + this.pluginName = 'sprite2d'; + convertTo2d.call(this); + }; + PIXI.Container.prototype.convertSubtreeTo2d = function () { + this.convertTo2d(); + for (var i = 0; i < this.children.length; i++) { + this.children[i].convertSubtreeTo2d(); + } + }; + if (PIXI.SimpleMesh) { + PIXI.SimpleMesh.prototype.convertTo2d = + PIXI.SimpleRope.prototype.convertTo2d = + function () { + if (this.proj) + return; + this.calculateVertices = pixi_projection.Mesh2d.prototype.calculateVertices; + this._renderDefault = pixi_projection.Mesh2d.prototype._renderDefault; + if (this.material.pluginName !== 'batch2d') { + this.material = new PIXI.MeshMaterial(this.material.texture, { + program: PIXI.Program.from(pixi_projection.Mesh2d.defaultVertexShader, pixi_projection.Mesh2d.defaultFragmentShader), + pluginName: 'batch2d' + }); + } + convertTo2d.call(this); + }; + } +})(pixi_projection || (pixi_projection = {})); +var pixi_projection; +(function (pixi_projection) { + var tempTransform = new PIXI.Transform(); + var TilingSprite2d = (function (_super) { + __extends(TilingSprite2d, _super); + function TilingSprite2d(texture, width, height) { + var _this = _super.call(this, texture, width, height) || this; + _this.tileProj = new pixi_projection.Projection2d(_this.tileTransform); + _this.tileProj.reverseLocalOrder = true; + _this.proj = new pixi_projection.Projection2d(_this.transform); + _this.pluginName = 'tilingSprite2d'; + _this.uvRespectAnchor = true; + return _this; + } + Object.defineProperty(TilingSprite2d.prototype, "worldTransform", { + get: function () { + return this.proj.affine ? this.transform.worldTransform : this.proj.world; + }, + enumerable: true, + configurable: true + }); + TilingSprite2d.prototype.toLocal = function (position, from, point, skipUpdate, step) { + if (step === void 0) { step = pixi_projection.TRANSFORM_STEP.ALL; } + return pixi_projection.container2dToLocal.call(this, position, from, point, skipUpdate, step); + }; + TilingSprite2d.prototype._render = function (renderer) { + var texture = this._texture; + if (!texture || !texture.valid) { + return; + } + this.tileTransform.updateTransform(tempTransform); + this.uvMatrix.update(); + renderer.batch.setObjectRenderer(renderer.plugins[this.pluginName]); + renderer.plugins[this.pluginName].render(this); + }; + return TilingSprite2d; + }(PIXI.TilingSprite)); + pixi_projection.TilingSprite2d = TilingSprite2d; +})(pixi_projection || (pixi_projection = {})); +var pixi_projection; +(function (pixi_projection) { + var shaderVert = "attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\nuniform mat3 translationMatrix;\nuniform mat3 uTransform;\n\nvarying vec3 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position.xyw = projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0);\n\n vTextureCoord = uTransform * vec3(aTextureCoord, 1.0);\n}\n"; + var shaderFrag = "\nvarying vec3 vTextureCoord;\n\nuniform sampler2D uSampler;\nuniform vec4 uColor;\nuniform mat3 uMapCoord;\nuniform vec4 uClampFrame;\nuniform vec2 uClampOffset;\n\nvoid main(void)\n{\n vec2 coord = mod(vTextureCoord.xy / vTextureCoord.z - uClampOffset, vec2(1.0, 1.0)) + uClampOffset;\n coord = (uMapCoord * vec3(coord, 1.0)).xy;\n coord = clamp(coord, uClampFrame.xy, uClampFrame.zw);\n\n vec4 sample = texture2D(uSampler, coord);\n gl_FragColor = sample * uColor;\n}\n"; + var shaderSimpleFrag = "\n\tvarying vec3 vTextureCoord;\n\nuniform sampler2D uSampler;\nuniform vec4 uColor;\n\nvoid main(void)\n{\n vec4 sample = texture2D(uSampler, vTextureCoord.xy / vTextureCoord.z);\n gl_FragColor = sample * uColor;\n}\n"; + var tempMat = new pixi_projection.Matrix2d(); + var WRAP_MODES = PIXI.WRAP_MODES; + var utils = PIXI.utils; + var TilingSprite2dRenderer = (function (_super) { + __extends(TilingSprite2dRenderer, _super); + function TilingSprite2dRenderer(renderer) { + var _this = _super.call(this, renderer) || this; + _this.quad = new PIXI.QuadUv(); + var uniforms = { globals: _this.renderer.globalUniforms }; + _this.shader = PIXI.Shader.from(shaderVert, shaderFrag, uniforms); + _this.simpleShader = PIXI.Shader.from(shaderVert, shaderSimpleFrag, uniforms); + return _this; + } + TilingSprite2dRenderer.prototype.render = function (ts) { + var renderer = this.renderer; + var quad = this.quad; + var vertices = quad.vertices; + vertices[0] = vertices[6] = (ts._width) * -ts.anchor.x; + vertices[1] = vertices[3] = ts._height * -ts.anchor.y; + vertices[2] = vertices[4] = (ts._width) * (1.0 - ts.anchor.x); + vertices[5] = vertices[7] = ts._height * (1.0 - ts.anchor.y); + if (ts.uvRespectAnchor) { + vertices = quad.uvs; + vertices[0] = vertices[6] = -ts.anchor.x; + vertices[1] = vertices[3] = -ts.anchor.y; + vertices[2] = vertices[4] = 1.0 - ts.anchor.x; + vertices[5] = vertices[7] = 1.0 - ts.anchor.y; + } + quad.invalidate(); + var tex = ts._texture; + var baseTex = tex.baseTexture; + var lt = ts.tileProj.world; + var uv = ts.uvMatrix; + var isSimple = baseTex.isPowerOfTwo + && tex.frame.width === baseTex.width && tex.frame.height === baseTex.height; + if (isSimple) { + if (!baseTex._glTextures[renderer.CONTEXT_UID]) { + if (baseTex.wrapMode === WRAP_MODES.CLAMP) { + baseTex.wrapMode = WRAP_MODES.REPEAT; + } + } + else { + isSimple = baseTex.wrapMode !== WRAP_MODES.CLAMP; + } + } + var shader = isSimple ? this.simpleShader : this.shader; + tempMat.identity(); + tempMat.scale(tex.width, tex.height); + tempMat.prepend(lt); + tempMat.scale(1.0 / ts._width, 1.0 / ts._height); + tempMat.invert(); + if (isSimple) { + tempMat.prepend(uv.mapCoord); + } + else { + shader.uniforms.uMapCoord = uv.mapCoord.toArray(true); + shader.uniforms.uClampFrame = uv.uClampFrame; + shader.uniforms.uClampOffset = uv.uClampOffset; + } + shader.uniforms.uTransform = tempMat.toArray(true); + shader.uniforms.uColor = utils.premultiplyTintToRgba(ts.tint, ts.worldAlpha, shader.uniforms.uColor, baseTex.premultiplyAlpha); + shader.uniforms.translationMatrix = ts.transform.worldTransform.toArray(true); + shader.uniforms.uSampler = tex; + renderer.shader.bind(shader, false); + renderer.geometry.bind(quad, undefined); + renderer.state.setBlendMode(utils.correctBlendMode(ts.blendMode, baseTex.premultiplyAlpha)); + renderer.geometry.draw(PIXI.DRAW_MODES.TRIANGLES, 6, 0); + }; + return TilingSprite2dRenderer; + }(PIXI.ObjectRenderer)); + pixi_projection.TilingSprite2dRenderer = TilingSprite2dRenderer; + PIXI.Renderer.registerPlugin('tilingSprite2d', TilingSprite2dRenderer); +})(pixi_projection || (pixi_projection = {})); +var pixi_projection; +(function (pixi_projection) { + PIXI.systems.MaskSystem.prototype.pushSpriteMask = function (maskData) { + var maskObject = maskData.maskObject; + var target = maskData._target; + var alphaMaskFilter = this.alphaMaskPool[this.alphaMaskIndex]; + if (!alphaMaskFilter) { + alphaMaskFilter = this.alphaMaskPool[this.alphaMaskIndex] = [new pixi_projection.SpriteMaskFilter2d(maskObject)]; + } + alphaMaskFilter[0].resolution = this.renderer.resolution; + alphaMaskFilter[0].maskSprite = maskData; + var stashFilterArea = target.filterArea; + target.filterArea = maskObject.getBounds(true); + this.renderer.filter.push(target, alphaMaskFilter); + target.filterArea = stashFilterArea; + this.renderer.filter.push(target, alphaMaskFilter); + this.alphaMaskIndex++; + }; +})(pixi_projection || (pixi_projection = {})); +var pixi_projection; +(function (pixi_projection) { + var spriteMaskVert = "\nattribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\nuniform mat3 otherMatrix;\n\nvarying vec3 vMaskCoord;\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n\tgl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n\n\tvTextureCoord = aTextureCoord;\n\tvMaskCoord = otherMatrix * vec3( aTextureCoord, 1.0);\n}\n"; + var spriteMaskFrag = "\nvarying vec3 vMaskCoord;\nvarying vec2 vTextureCoord;\n\nuniform sampler2D uSampler;\nuniform sampler2D mask;\nuniform float alpha;\nuniform vec4 maskClamp;\n\nvoid main(void)\n{\n vec2 uv = vMaskCoord.xy / vMaskCoord.z;\n \n float clip = step(3.5,\n step(maskClamp.x, uv.x) +\n step(maskClamp.y, uv.y) +\n step(uv.x, maskClamp.z) +\n step(uv.y, maskClamp.w));\n\n vec4 original = texture2D(uSampler, vTextureCoord);\n vec4 masky = texture2D(mask, uv);\n \n original *= (masky.r * masky.a * alpha * clip);\n\n gl_FragColor = original;\n}\n"; + var tempMat = new pixi_projection.Matrix2d(); + var SpriteMaskFilter2d = (function (_super) { + __extends(SpriteMaskFilter2d, _super); + function SpriteMaskFilter2d(sprite) { + var _this = _super.call(this, spriteMaskVert, spriteMaskFrag) || this; + _this.maskMatrix = new pixi_projection.Matrix2d(); + sprite.renderable = false; + _this.maskSprite = sprite; + return _this; + } + SpriteMaskFilter2d.prototype.apply = function (filterManager, input, output, clear) { + var maskSprite = this.maskSprite; + var tex = this.maskSprite.texture; + if (!tex.valid) { + return; + } + if (!tex.uvMatrix) { + tex.uvMatrix = new PIXI.TextureMatrix(tex, 0.0); + } + tex.uvMatrix.update(); + this.uniforms.mask = maskSprite.texture; + this.uniforms.otherMatrix = SpriteMaskFilter2d.calculateSpriteMatrix(input, this.maskMatrix, maskSprite) + .prepend(tex.uvMatrix.mapCoord); + this.uniforms.alpha = maskSprite.worldAlpha; + this.uniforms.maskClamp = tex.uvMatrix.uClampFrame; + filterManager.applyFilter(this, input, output, clear); + }; + SpriteMaskFilter2d.calculateSpriteMatrix = function (input, mappedMatrix, sprite) { + var proj = sprite.proj; + var filterArea = input.filterFrame; + var worldTransform = proj && !proj._affine ? proj.world.copyTo2dOr3d(tempMat) : tempMat.copyFrom(sprite.transform.worldTransform); + var texture = sprite.texture.orig; + mappedMatrix.set(input.width, 0, 0, input.height, filterArea.x, filterArea.y); + worldTransform.invert(); + mappedMatrix.setToMult(worldTransform, mappedMatrix); + mappedMatrix.scaleAndTranslate(1.0 / texture.width, 1.0 / texture.height, sprite.anchor.x, sprite.anchor.y); + return mappedMatrix; + }; + return SpriteMaskFilter2d; + }(PIXI.Filter)); + pixi_projection.SpriteMaskFilter2d = SpriteMaskFilter2d; +})(pixi_projection || (pixi_projection = {})); +var pixi_projection; +(function (pixi_projection) { + function container3dWorldTransform() { + return this.proj.affine ? this.transform.worldTransform : this.proj.world; + } + pixi_projection.container3dWorldTransform = container3dWorldTransform; + var Container3d = (function (_super) { + __extends(Container3d, _super); + function Container3d() { + var _this = _super.call(this) || this; + _this.proj = new pixi_projection.Projection3d(_this.transform); + return _this; + } + Container3d.prototype.isFrontFace = function (forceUpdate) { + if (forceUpdate === void 0) { forceUpdate = false; } + if (forceUpdate) { + this._recursivePostUpdateTransform(); + this.displayObjectUpdateTransform(); + } + var mat = this.proj.world.mat4; + var dx1 = mat[0] * mat[15] - mat[3] * mat[12]; + var dy1 = mat[1] * mat[15] - mat[3] * mat[13]; + var dx2 = mat[4] * mat[15] - mat[7] * mat[12]; + var dy2 = mat[5] * mat[15] - mat[7] * mat[13]; + return dx1 * dy2 - dx2 * dy1 > 0; + }; + Container3d.prototype.getDepth = function (forceUpdate) { + if (forceUpdate === void 0) { forceUpdate = false; } + if (forceUpdate) { + this._recursivePostUpdateTransform(); + this.displayObjectUpdateTransform(); + } + var mat4 = this.proj.world.mat4; + return mat4[14] / mat4[15]; + }; + Container3d.prototype.toLocal = function (position, from, point, skipUpdate, step) { + if (step === void 0) { step = pixi_projection.TRANSFORM_STEP.ALL; } + if (from) { + position = from.toGlobal(position, point, skipUpdate); + } + if (!skipUpdate) { + this._recursivePostUpdateTransform(); + } + if (step === pixi_projection.TRANSFORM_STEP.ALL) { + if (!skipUpdate) { + this.displayObjectUpdateTransform(); + } + if (this.proj.affine) { + return this.transform.worldTransform.applyInverse(position, point); + } + return this.proj.world.applyInverse(position, point); + } + if (this.parent) { + point = this.parent.worldTransform.applyInverse(position, point); + } + else { + point.copyFrom(position); + } + if (step === pixi_projection.TRANSFORM_STEP.NONE) { + return point; + } + point = this.transform.localTransform.applyInverse(point, point); + if (step === pixi_projection.TRANSFORM_STEP.PROJ && this.proj.cameraMode) { + point = this.proj.cameraMatrix.applyInverse(point, point); + } + return point; + }; + Object.defineProperty(Container3d.prototype, "worldTransform", { + get: function () { + return this.proj.affine ? this.transform.worldTransform : this.proj.world; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Container3d.prototype, "position3d", { + get: function () { + return this.proj.position; + }, + set: function (value) { + this.proj.position.copyFrom(value); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Container3d.prototype, "scale3d", { + get: function () { + return this.proj.scale; + }, + set: function (value) { + this.proj.scale.copyFrom(value); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Container3d.prototype, "euler", { + get: function () { + return this.proj.euler; + }, + set: function (value) { + this.proj.euler.copyFrom(value); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Container3d.prototype, "pivot3d", { + get: function () { + return this.proj.pivot; + }, + set: function (value) { + this.proj.pivot.copyFrom(value); + }, + enumerable: true, + configurable: true + }); + return Container3d; + }(PIXI.Container)); + pixi_projection.Container3d = Container3d; + pixi_projection.container3dToLocal = Container3d.prototype.toLocal; + pixi_projection.container3dGetDepth = Container3d.prototype.getDepth; + pixi_projection.container3dIsFrontFace = Container3d.prototype.isFrontFace; +})(pixi_projection || (pixi_projection = {})); +var pixi_projection; +(function (pixi_projection) { + var Camera3d = (function (_super) { + __extends(Camera3d, _super); + function Camera3d() { + var _this = _super.call(this) || this; + _this._far = 0; + _this._near = 0; + _this._focus = 0; + _this._orthographic = false; + _this.proj.cameraMode = true; + _this.setPlanes(400, 10, 10000, false); + return _this; + } + Object.defineProperty(Camera3d.prototype, "far", { + get: function () { + return this._far; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Camera3d.prototype, "near", { + get: function () { + return this._near; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Camera3d.prototype, "focus", { + get: function () { + return this._focus; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Camera3d.prototype, "ortographic", { + get: function () { + return this._orthographic; + }, + enumerable: true, + configurable: true + }); + Camera3d.prototype.setPlanes = function (focus, near, far, orthographic) { + if (near === void 0) { near = 10; } + if (far === void 0) { far = 10000; } + if (orthographic === void 0) { orthographic = false; } + this._focus = focus; + this._near = near; + this._far = far; + this._orthographic = orthographic; + var proj = this.proj; + var mat4 = proj.cameraMatrix.mat4; + proj._projID++; + mat4[10] = 1.0 / (far - near); + mat4[14] = (focus - near) / (far - near); + if (this._orthographic) { + mat4[11] = 0; + } + else { + mat4[11] = 1.0 / focus; + } + }; + return Camera3d; + }(pixi_projection.Container3d)); + pixi_projection.Camera3d = Camera3d; +})(pixi_projection || (pixi_projection = {})); +var pixi_projection; +(function (pixi_projection) { + var Euler = (function () { + function Euler(x, y, z) { + this._quatUpdateId = -1; + this._quatDirtyId = 0; + this._sign = 1; + this._x = x || 0; + this._y = y || 0; + this._z = z || 0; + this.quaternion = new Float64Array(4); + this.quaternion[3] = 1; + this.update(); + } + Object.defineProperty(Euler.prototype, "x", { + get: function () { + return this._x; + }, + set: function (value) { + if (this._x !== value) { + this._x = value; + this._quatDirtyId++; + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Euler.prototype, "y", { + get: function () { + return this._y; + }, + set: function (value) { + if (this._y !== value) { + this._y = value; + this._quatDirtyId++; + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Euler.prototype, "z", { + get: function () { + return this._z; + }, + set: function (value) { + if (this._z !== value) { + this._z = value; + this._quatDirtyId++; + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Euler.prototype, "pitch", { + get: function () { + return this._x; + }, + set: function (value) { + if (this._x !== value) { + this._x = value; + this._quatDirtyId++; + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Euler.prototype, "yaw", { + get: function () { + return this._y; + }, + set: function (value) { + if (this._y !== value) { + this._y = value; + this._quatDirtyId++; + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Euler.prototype, "roll", { + get: function () { + return this._z; + }, + set: function (value) { + if (this._z !== value) { + this._z = value; + this._quatDirtyId++; + } + }, + enumerable: true, + configurable: true + }); + Euler.prototype.set = function (x, y, z) { + var _x = x || 0; + var _y = y || 0; + var _z = z || 0; + if (this._x !== _x || this._y !== _y || this._z !== _z) { + this._x = _x; + this._y = _y; + this._z = _z; + this._quatDirtyId++; + } + }; + ; + Euler.prototype.copyFrom = function (euler) { + var _x = euler.x; + var _y = euler.y; + var _z = euler.z; + if (this._x !== _x || this._y !== _y || this._z !== _z) { + this._x = _x; + this._y = _y; + this._z = _z; + this._quatDirtyId++; + } + }; + Euler.prototype.copyTo = function (p) { + p.set(this._x, this._y, this._z); + return p; + }; + Euler.prototype.equals = function (euler) { + return this._x === euler.x + && this._y === euler.y + && this._z === euler.z; + }; + Euler.prototype.clone = function () { + return new Euler(this._x, this._y, this._z); + }; + Euler.prototype.update = function () { + if (this._quatUpdateId === this._quatDirtyId) { + return false; + } + this._quatUpdateId = this._quatDirtyId; + var c1 = Math.cos(this._x / 2); + var c2 = Math.cos(this._y / 2); + var c3 = Math.cos(this._z / 2); + var s = this._sign; + var s1 = s * Math.sin(this._x / 2); + var s2 = s * Math.sin(this._y / 2); + var s3 = s * Math.sin(this._z / 2); + var q = this.quaternion; + q[0] = s1 * c2 * c3 + c1 * s2 * s3; + q[1] = c1 * s2 * c3 - s1 * c2 * s3; + q[2] = c1 * c2 * s3 + s1 * s2 * c3; + q[3] = c1 * c2 * c3 - s1 * s2 * s3; + return true; + }; + return Euler; + }()); + pixi_projection.Euler = Euler; +})(pixi_projection || (pixi_projection = {})); +var pixi_projection; +(function (pixi_projection) { + var mat4id = [1, 0, 0, 0, + 0, 1, 0, 0, + 0, 0, 1, 0, + 0, 0, 0, 1]; + var Matrix3d = (function () { + function Matrix3d(backingArray) { + this.floatArray = null; + this._dirtyId = 0; + this._updateId = -1; + this._mat4inv = null; + this.cacheInverse = false; + this.mat4 = new Float64Array(backingArray || mat4id); + } + Object.defineProperty(Matrix3d.prototype, "a", { + get: function () { + return this.mat4[0] / this.mat4[15]; + }, + set: function (value) { + this.mat4[0] = value * this.mat4[15]; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Matrix3d.prototype, "b", { + get: function () { + return this.mat4[1] / this.mat4[15]; + }, + set: function (value) { + this.mat4[1] = value * this.mat4[15]; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Matrix3d.prototype, "c", { + get: function () { + return this.mat4[4] / this.mat4[15]; + }, + set: function (value) { + this.mat4[4] = value * this.mat4[15]; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Matrix3d.prototype, "d", { + get: function () { + return this.mat4[5] / this.mat4[15]; + }, + set: function (value) { + this.mat4[5] = value * this.mat4[15]; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Matrix3d.prototype, "tx", { + get: function () { + return this.mat4[12] / this.mat4[15]; + }, + set: function (value) { + this.mat4[12] = value * this.mat4[15]; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Matrix3d.prototype, "ty", { + get: function () { + return this.mat4[13] / this.mat4[15]; + }, + set: function (value) { + this.mat4[13] = value * this.mat4[15]; + }, + enumerable: true, + configurable: true + }); + Matrix3d.prototype.set = function (a, b, c, d, tx, ty) { + var mat4 = this.mat4; + mat4[0] = a; + mat4[1] = b; + mat4[2] = 0; + mat4[3] = 0; + mat4[4] = c; + mat4[5] = d; + mat4[6] = 0; + mat4[7] = 0; + mat4[8] = 0; + mat4[9] = 0; + mat4[10] = 1; + mat4[11] = 0; + mat4[12] = tx; + mat4[13] = ty; + mat4[14] = 0; + mat4[15] = 1; + return this; + }; + Matrix3d.prototype.toArray = function (transpose, out) { + if (!this.floatArray) { + this.floatArray = new Float32Array(9); + } + var array = out || this.floatArray; + var mat3 = this.mat4; + if (transpose) { + array[0] = mat3[0]; + array[1] = mat3[1]; + array[2] = mat3[3]; + array[3] = mat3[4]; + array[4] = mat3[5]; + array[5] = mat3[7]; + array[6] = mat3[12]; + array[7] = mat3[13]; + array[8] = mat3[15]; + } + else { + array[0] = mat3[0]; + array[1] = mat3[4]; + array[2] = mat3[12]; + array[3] = mat3[2]; + array[4] = mat3[6]; + array[5] = mat3[13]; + array[6] = mat3[3]; + array[7] = mat3[7]; + array[8] = mat3[15]; + } + return array; + }; + Matrix3d.prototype.setToTranslation = function (tx, ty, tz) { + var mat4 = this.mat4; + mat4[0] = 1; + mat4[1] = 0; + mat4[2] = 0; + mat4[3] = 0; + mat4[4] = 0; + mat4[5] = 1; + mat4[6] = 0; + mat4[7] = 0; + mat4[8] = 0; + mat4[9] = 0; + mat4[10] = 1; + mat4[11] = 0; + mat4[12] = tx; + mat4[13] = ty; + mat4[14] = tz; + mat4[15] = 1; + }; + Matrix3d.prototype.setToRotationTranslationScale = function (quat, tx, ty, tz, sx, sy, sz) { + var out = this.mat4; + var x = quat[0], y = quat[1], z = quat[2], w = quat[3]; + var x2 = x + x; + var y2 = y + y; + var z2 = z + z; + var xx = x * x2; + var xy = x * y2; + var xz = x * z2; + var yy = y * y2; + var yz = y * z2; + var zz = z * z2; + var wx = w * x2; + var wy = w * y2; + var wz = w * z2; + out[0] = (1 - (yy + zz)) * sx; + out[1] = (xy + wz) * sx; + out[2] = (xz - wy) * sx; + out[3] = 0; + out[4] = (xy - wz) * sy; + out[5] = (1 - (xx + zz)) * sy; + out[6] = (yz + wx) * sy; + out[7] = 0; + out[8] = (xz + wy) * sz; + out[9] = (yz - wx) * sz; + out[10] = (1 - (xx + yy)) * sz; + out[11] = 0; + out[12] = tx; + out[13] = ty; + out[14] = tz; + out[15] = 1; + return out; + }; + Matrix3d.prototype.apply = function (pos, newPos) { + newPos = newPos || new pixi_projection.Point3d(); + var mat4 = this.mat4; + var x = pos.x; + var y = pos.y; + var z = pos.z || 0; + var w = 1.0 / (mat4[3] * x + mat4[7] * y + mat4[11] * z + mat4[15]); + newPos.x = w * (mat4[0] * x + mat4[4] * y + mat4[8] * z + mat4[12]); + newPos.y = w * (mat4[1] * x + mat4[5] * y + mat4[9] * z + mat4[13]); + newPos.z = w * (mat4[2] * x + mat4[6] * y + mat4[10] * z + mat4[14]); + return newPos; + }; + Matrix3d.prototype.translate = function (tx, ty, tz) { + var a = this.mat4; + a[12] = a[0] * tx + a[4] * ty + a[8] * tz + a[12]; + a[13] = a[1] * tx + a[5] * ty + a[9] * tz + a[13]; + a[14] = a[2] * tx + a[6] * ty + a[10] * tz + a[14]; + a[15] = a[3] * tx + a[7] * ty + a[11] * tz + a[15]; + return this; + }; + Matrix3d.prototype.scale = function (x, y, z) { + var mat4 = this.mat4; + mat4[0] *= x; + mat4[1] *= x; + mat4[2] *= x; + mat4[3] *= x; + mat4[4] *= y; + mat4[5] *= y; + mat4[6] *= y; + mat4[7] *= y; + if (z !== undefined) { + mat4[8] *= z; + mat4[9] *= z; + mat4[10] *= z; + mat4[11] *= z; + } + return this; + }; + Matrix3d.prototype.scaleAndTranslate = function (scaleX, scaleY, scaleZ, tx, ty, tz) { + var mat4 = this.mat4; + mat4[0] = scaleX * mat4[0] + tx * mat4[3]; + mat4[1] = scaleY * mat4[1] + ty * mat4[3]; + mat4[2] = scaleZ * mat4[2] + tz * mat4[3]; + mat4[4] = scaleX * mat4[4] + tx * mat4[7]; + mat4[5] = scaleY * mat4[5] + ty * mat4[7]; + mat4[6] = scaleZ * mat4[6] + tz * mat4[7]; + mat4[8] = scaleX * mat4[8] + tx * mat4[11]; + mat4[9] = scaleY * mat4[9] + ty * mat4[11]; + mat4[10] = scaleZ * mat4[10] + tz * mat4[11]; + mat4[12] = scaleX * mat4[12] + tx * mat4[15]; + mat4[13] = scaleY * mat4[13] + ty * mat4[15]; + mat4[14] = scaleZ * mat4[14] + tz * mat4[15]; + }; + Matrix3d.prototype.applyInverse = function (pos, newPos) { + newPos = newPos || new pixi_projection.Point3d(); + if (!this._mat4inv) { + this._mat4inv = new Float64Array(16); + } + var mat4 = this._mat4inv; + var a = this.mat4; + var x = pos.x; + var y = pos.y; + var z = pos.z || 0; + if (!this.cacheInverse || this._updateId !== this._dirtyId) { + this._updateId = this._dirtyId; + Matrix3d.glMatrixMat4Invert(mat4, a); + } + var w1 = 1.0 / (mat4[3] * x + mat4[7] * y + mat4[11] * z + mat4[15]); + var x1 = w1 * (mat4[0] * x + mat4[4] * y + mat4[8] * z + mat4[12]); + var y1 = w1 * (mat4[1] * x + mat4[5] * y + mat4[9] * z + mat4[13]); + var z1 = w1 * (mat4[2] * x + mat4[6] * y + mat4[10] * z + mat4[14]); + z += 1.0; + var w2 = 1.0 / (mat4[3] * x + mat4[7] * y + mat4[11] * z + mat4[15]); + var x2 = w2 * (mat4[0] * x + mat4[4] * y + mat4[8] * z + mat4[12]); + var y2 = w2 * (mat4[1] * x + mat4[5] * y + mat4[9] * z + mat4[13]); + var z2 = w2 * (mat4[2] * x + mat4[6] * y + mat4[10] * z + mat4[14]); + if (Math.abs(z1 - z2) < 1e-10) { + newPos.set(NaN, NaN, 0); + } + var alpha = (0 - z1) / (z2 - z1); + newPos.set((x2 - x1) * alpha + x1, (y2 - y1) * alpha + y1, 0.0); + return newPos; + }; + Matrix3d.prototype.invert = function () { + Matrix3d.glMatrixMat4Invert(this.mat4, this.mat4); + return this; + }; + Matrix3d.prototype.invertCopyTo = function (matrix) { + if (!this._mat4inv) { + this._mat4inv = new Float64Array(16); + } + var mat4 = this._mat4inv; + var a = this.mat4; + if (!this.cacheInverse || this._updateId !== this._dirtyId) { + this._updateId = this._dirtyId; + Matrix3d.glMatrixMat4Invert(mat4, a); + } + matrix.mat4.set(mat4); + }; + Matrix3d.prototype.identity = function () { + var mat3 = this.mat4; + mat3[0] = 1; + mat3[1] = 0; + mat3[2] = 0; + mat3[3] = 0; + mat3[4] = 0; + mat3[5] = 1; + mat3[6] = 0; + mat3[7] = 0; + mat3[8] = 0; + mat3[9] = 0; + mat3[10] = 1; + mat3[11] = 0; + mat3[12] = 0; + mat3[13] = 0; + mat3[14] = 0; + mat3[15] = 1; + return this; + }; + Matrix3d.prototype.clone = function () { + return new Matrix3d(this.mat4); + }; + Matrix3d.prototype.copyTo3d = function (matrix) { + var mat3 = this.mat4; + var ar2 = matrix.mat4; + ar2[0] = mat3[0]; + ar2[1] = mat3[1]; + ar2[2] = mat3[2]; + ar2[3] = mat3[3]; + ar2[4] = mat3[4]; + ar2[5] = mat3[5]; + ar2[6] = mat3[6]; + ar2[7] = mat3[7]; + ar2[8] = mat3[8]; + return matrix; + }; + Matrix3d.prototype.copyTo2d = function (matrix) { + var mat3 = this.mat4; + var ar2 = matrix.mat3; + ar2[0] = mat3[0]; + ar2[1] = mat3[1]; + ar2[2] = mat3[3]; + ar2[3] = mat3[4]; + ar2[4] = mat3[5]; + ar2[5] = mat3[7]; + ar2[6] = mat3[12]; + ar2[7] = mat3[13]; + ar2[8] = mat3[15]; + return matrix; + }; + Matrix3d.prototype.copyTo2dOr3d = function (matrix) { + if (matrix instanceof pixi_projection.Matrix2d) { + return this.copyTo2d(matrix); + } + else { + return this.copyTo3d(matrix); + } + }; + Matrix3d.prototype.copyTo = function (matrix, affine, preserveOrientation) { + var mat3 = this.mat4; + var d = 1.0 / mat3[15]; + var tx = mat3[12] * d, ty = mat3[13] * d; + matrix.a = (mat3[0] - mat3[3] * tx) * d; + matrix.b = (mat3[1] - mat3[3] * ty) * d; + matrix.c = (mat3[4] - mat3[7] * tx) * d; + matrix.d = (mat3[5] - mat3[7] * ty) * d; + matrix.tx = tx; + matrix.ty = ty; + if (affine >= 2) { + var D = matrix.a * matrix.d - matrix.b * matrix.c; + if (!preserveOrientation) { + D = Math.abs(D); + } + if (affine === pixi_projection.AFFINE.POINT) { + if (D > 0) { + D = 1; + } + else + D = -1; + matrix.a = D; + matrix.b = 0; + matrix.c = 0; + matrix.d = D; + } + else if (affine === pixi_projection.AFFINE.AXIS_X) { + D /= Math.sqrt(matrix.b * matrix.b + matrix.d * matrix.d); + matrix.c = 0; + matrix.d = D; + } + else if (affine === pixi_projection.AFFINE.AXIS_Y) { + D /= Math.sqrt(matrix.a * matrix.a + matrix.c * matrix.c); + matrix.a = D; + matrix.c = 0; + } + } + return matrix; + }; + Matrix3d.prototype.copyFrom = function (matrix) { + var mat3 = this.mat4; + mat3[0] = matrix.a; + mat3[1] = matrix.b; + mat3[2] = 0; + mat3[3] = 0; + mat3[4] = matrix.c; + mat3[5] = matrix.d; + mat3[6] = 0; + mat3[7] = 0; + mat3[8] = 0; + mat3[9] = 0; + mat3[10] = 1; + mat3[11] = 0; + mat3[12] = matrix.tx; + mat3[13] = matrix.ty; + mat3[14] = 0; + mat3[15] = 1; + this._dirtyId++; + return this; + }; + Matrix3d.prototype.setToMultLegacy = function (pt, lt) { + var out = this.mat4; + var b = lt.mat4; + var a00 = pt.a, a01 = pt.b, a10 = pt.c, a11 = pt.d, a30 = pt.tx, a31 = pt.ty; + var b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3]; + out[0] = b0 * a00 + b1 * a10 + b3 * a30; + out[1] = b0 * a01 + b1 * a11 + b3 * a31; + out[2] = b2; + out[3] = b3; + b0 = b[4]; + b1 = b[5]; + b2 = b[6]; + b3 = b[7]; + out[4] = b0 * a00 + b1 * a10 + b3 * a30; + out[5] = b0 * a01 + b1 * a11 + b3 * a31; + out[6] = b2; + out[7] = b3; + b0 = b[8]; + b1 = b[9]; + b2 = b[10]; + b3 = b[11]; + out[8] = b0 * a00 + b1 * a10 + b3 * a30; + out[9] = b0 * a01 + b1 * a11 + b3 * a31; + out[10] = b2; + out[11] = b3; + b0 = b[12]; + b1 = b[13]; + b2 = b[14]; + b3 = b[15]; + out[12] = b0 * a00 + b1 * a10 + b3 * a30; + out[13] = b0 * a01 + b1 * a11 + b3 * a31; + out[14] = b2; + out[15] = b3; + this._dirtyId++; + return this; + }; + Matrix3d.prototype.setToMultLegacy2 = function (pt, lt) { + var out = this.mat4; + var a = pt.mat4; + var a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3]; + var a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7]; + var b00 = lt.a, b01 = lt.b, b10 = lt.c, b11 = lt.d, b30 = lt.tx, b31 = lt.ty; + out[0] = b00 * a00 + b01 * a10; + out[1] = b00 * a01 + b01 * a11; + out[2] = b00 * a02 + b01 * a12; + out[3] = b00 * a03 + b01 * a13; + out[4] = b10 * a00 + b11 * a10; + out[5] = b10 * a01 + b11 * a11; + out[6] = b10 * a02 + b11 * a12; + out[7] = b10 * a03 + b11 * a13; + out[8] = a[8]; + out[9] = a[9]; + out[10] = a[10]; + out[11] = a[11]; + out[12] = b30 * a00 + b31 * a10 + a[12]; + out[13] = b30 * a01 + b31 * a11 + a[13]; + out[14] = b30 * a02 + b31 * a12 + a[14]; + out[15] = b30 * a03 + b31 * a13 + a[15]; + this._dirtyId++; + return this; + }; + Matrix3d.prototype.setToMult = function (pt, lt) { + Matrix3d.glMatrixMat4Multiply(this.mat4, pt.mat4, lt.mat4); + this._dirtyId++; + return this; + }; + Matrix3d.prototype.prepend = function (lt) { + if (lt.mat4) { + this.setToMult(lt, this); + } + else { + this.setToMultLegacy(lt, this); + } + }; + Matrix3d.glMatrixMat4Invert = function (out, a) { + var a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3]; + var a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7]; + var a20 = a[8], a21 = a[9], a22 = a[10], a23 = a[11]; + var a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15]; + var b00 = a00 * a11 - a01 * a10; + var b01 = a00 * a12 - a02 * a10; + var b02 = a00 * a13 - a03 * a10; + var b03 = a01 * a12 - a02 * a11; + var b04 = a01 * a13 - a03 * a11; + var b05 = a02 * a13 - a03 * a12; + var b06 = a20 * a31 - a21 * a30; + var b07 = a20 * a32 - a22 * a30; + var b08 = a20 * a33 - a23 * a30; + var b09 = a21 * a32 - a22 * a31; + var b10 = a21 * a33 - a23 * a31; + var b11 = a22 * a33 - a23 * a32; + var det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06; + if (!det) { + return null; + } + det = 1.0 / det; + out[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det; + out[1] = (a02 * b10 - a01 * b11 - a03 * b09) * det; + out[2] = (a31 * b05 - a32 * b04 + a33 * b03) * det; + out[3] = (a22 * b04 - a21 * b05 - a23 * b03) * det; + out[4] = (a12 * b08 - a10 * b11 - a13 * b07) * det; + out[5] = (a00 * b11 - a02 * b08 + a03 * b07) * det; + out[6] = (a32 * b02 - a30 * b05 - a33 * b01) * det; + out[7] = (a20 * b05 - a22 * b02 + a23 * b01) * det; + out[8] = (a10 * b10 - a11 * b08 + a13 * b06) * det; + out[9] = (a01 * b08 - a00 * b10 - a03 * b06) * det; + out[10] = (a30 * b04 - a31 * b02 + a33 * b00) * det; + out[11] = (a21 * b02 - a20 * b04 - a23 * b00) * det; + out[12] = (a11 * b07 - a10 * b09 - a12 * b06) * det; + out[13] = (a00 * b09 - a01 * b07 + a02 * b06) * det; + out[14] = (a31 * b01 - a30 * b03 - a32 * b00) * det; + out[15] = (a20 * b03 - a21 * b01 + a22 * b00) * det; + return out; + }; + Matrix3d.glMatrixMat4Multiply = function (out, a, b) { + var a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3]; + var a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7]; + var a20 = a[8], a21 = a[9], a22 = a[10], a23 = a[11]; + var a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15]; + var b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3]; + out[0] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30; + out[1] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31; + out[2] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32; + out[3] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33; + b0 = b[4]; + b1 = b[5]; + b2 = b[6]; + b3 = b[7]; + out[4] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30; + out[5] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31; + out[6] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32; + out[7] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33; + b0 = b[8]; + b1 = b[9]; + b2 = b[10]; + b3 = b[11]; + out[8] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30; + out[9] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31; + out[10] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32; + out[11] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33; + b0 = b[12]; + b1 = b[13]; + b2 = b[14]; + b3 = b[15]; + out[12] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30; + out[13] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31; + out[14] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32; + out[15] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33; + return out; + }; + Matrix3d.IDENTITY = new Matrix3d(); + Matrix3d.TEMP_MATRIX = new Matrix3d(); + return Matrix3d; + }()); + pixi_projection.Matrix3d = Matrix3d; +})(pixi_projection || (pixi_projection = {})); +var pixi_projection; +(function (pixi_projection) { + var ObservableEuler = (function () { + function ObservableEuler(cb, scope, x, y, z) { + this.cb = cb; + this.scope = scope; + this._quatUpdateId = -1; + this._quatDirtyId = 0; + this._sign = 1; + this._x = x || 0; + this._y = y || 0; + this._z = z || 0; + this.quaternion = new Float64Array(4); + this.quaternion[3] = 1; + this.update(); + } + Object.defineProperty(ObservableEuler.prototype, "x", { + get: function () { + return this._x; + }, + set: function (value) { + if (this._x !== value) { + this._x = value; + this._quatDirtyId++; + this.cb.call(this.scope); + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ObservableEuler.prototype, "y", { + get: function () { + return this._y; + }, + set: function (value) { + if (this._y !== value) { + this._y = value; + this._quatDirtyId++; + this.cb.call(this.scope); + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ObservableEuler.prototype, "z", { + get: function () { + return this._z; + }, + set: function (value) { + if (this._z !== value) { + this._z = value; + this._quatDirtyId++; + this.cb.call(this.scope); + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ObservableEuler.prototype, "pitch", { + get: function () { + return this._x; + }, + set: function (value) { + if (this._x !== value) { + this._x = value; + this._quatDirtyId++; + this.cb.call(this.scope); + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ObservableEuler.prototype, "yaw", { + get: function () { + return this._y; + }, + set: function (value) { + if (this._y !== value) { + this._y = value; + this._quatDirtyId++; + this.cb.call(this.scope); + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ObservableEuler.prototype, "roll", { + get: function () { + return this._z; + }, + set: function (value) { + if (this._z !== value) { + this._z = value; + this._quatDirtyId++; + this.cb.call(this.scope); + } + }, + enumerable: true, + configurable: true + }); + ObservableEuler.prototype.set = function (x, y, z) { + var _x = x || 0; + var _y = y || 0; + var _z = z || 0; + if (this._x !== _x || this._y !== _y || this._z !== _z) { + this._x = _x; + this._y = _y; + this._z = _z; + this._quatDirtyId++; + this.cb.call(this.scope); + } + }; + ; + ObservableEuler.prototype.copyFrom = function (euler) { + var _x = euler.x; + var _y = euler.y; + var _z = euler.z; + if (this._x !== _x || this._y !== _y || this._z !== _z) { + this._x = _x; + this._y = _y; + this._z = _z; + this._quatDirtyId++; + this.cb.call(this.scope); + } + }; + ObservableEuler.prototype.copyTo = function (p) { + p.set(this._x, this._y, this._z); + return p; + }; + ObservableEuler.prototype.equals = function (euler) { + return this._x === euler.x + && this._y === euler.y + && this._z === euler.z; + }; + ObservableEuler.prototype.clone = function () { + return new pixi_projection.Euler(this._x, this._y, this._z); + }; + ObservableEuler.prototype.update = function () { + if (this._quatUpdateId === this._quatDirtyId) { + return false; + } + this._quatUpdateId = this._quatDirtyId; + var c1 = Math.cos(this._x / 2); + var c2 = Math.cos(this._y / 2); + var c3 = Math.cos(this._z / 2); + var s = this._sign; + var s1 = s * Math.sin(this._x / 2); + var s2 = s * Math.sin(this._y / 2); + var s3 = s * Math.sin(this._z / 2); + var q = this.quaternion; + q[0] = s1 * c2 * c3 + c1 * s2 * s3; + q[1] = c1 * s2 * c3 - s1 * c2 * s3; + q[2] = c1 * c2 * s3 + s1 * s2 * c3; + q[3] = c1 * c2 * c3 - s1 * s2 * s3; + return true; + }; + return ObservableEuler; + }()); + pixi_projection.ObservableEuler = ObservableEuler; +})(pixi_projection || (pixi_projection = {})); +var pixi_projection; +(function (pixi_projection) { + var Point3d = (function (_super) { + __extends(Point3d, _super); + function Point3d(x, y, z) { + var _this = _super.call(this, x, y) || this; + _this.z = z; + return _this; + } + Point3d.prototype.set = function (x, y, z) { + this.x = x || 0; + this.y = (y === undefined) ? this.x : (y || 0); + this.z = (y === undefined) ? this.x : (z || 0); + }; + Point3d.prototype.copyFrom = function (p) { + this.set(p.x, p.y, p.z || 0); + return this; + }; + Point3d.prototype.copyTo = function (p) { + p.set(this.x, this.y, this.z); + return p; + }; + return Point3d; + }(PIXI.Point)); + pixi_projection.Point3d = Point3d; + var ObservablePoint3d = (function (_super) { + __extends(ObservablePoint3d, _super); + function ObservablePoint3d() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this._z = 0; + return _this; + } + Object.defineProperty(ObservablePoint3d.prototype, "z", { + get: function () { + return this._z; + }, + set: function (value) { + if (this._z !== value) { + this._z = value; + this.cb.call(this.scope); + } + }, + enumerable: true, + configurable: true + }); + ObservablePoint3d.prototype.set = function (x, y, z) { + var _x = x || 0; + var _y = (y === undefined) ? _x : (y || 0); + var _z = (y === undefined) ? _x : (z || 0); + if (this._x !== _x || this._y !== _y || this._z !== _z) { + this._x = _x; + this._y = _y; + this._z = _z; + this.cb.call(this.scope); + } + }; + ObservablePoint3d.prototype.copyFrom = function (p) { + this.set(p.x, p.y, p.z || 0); + return this; + }; + ObservablePoint3d.prototype.copyTo = function (p) { + p.set(this._x, this._y, this._z); + return p; + }; + return ObservablePoint3d; + }(PIXI.ObservablePoint)); + pixi_projection.ObservablePoint3d = ObservablePoint3d; +})(pixi_projection || (pixi_projection = {})); +var pixi_projection; +(function (pixi_projection) { + var tempMat = new pixi_projection.Matrix3d(); + var Projection3d = (function (_super) { + __extends(Projection3d, _super); + function Projection3d(legacy, enable) { + var _this = _super.call(this, legacy, enable) || this; + _this.cameraMatrix = null; + _this._cameraMode = false; + _this.position = new pixi_projection.ObservablePoint3d(_this.onChange, _this, 0, 0); + _this.scale = new pixi_projection.ObservablePoint3d(_this.onChange, _this, 1, 1); + _this.euler = new pixi_projection.ObservableEuler(_this.onChange, _this, 0, 0, 0); + _this.pivot = new pixi_projection.ObservablePoint3d(_this.onChange, _this, 0, 0); + _this.local = new pixi_projection.Matrix3d(); + _this.world = new pixi_projection.Matrix3d(); + _this.local.cacheInverse = true; + _this.world.cacheInverse = true; + _this.position._z = 0; + _this.scale._z = 1; + _this.pivot._z = 0; + return _this; + } + Object.defineProperty(Projection3d.prototype, "cameraMode", { + get: function () { + return this._cameraMode; + }, + set: function (value) { + if (this._cameraMode === value) { + return; + } + this._cameraMode = value; + this.euler._sign = this._cameraMode ? -1 : 1; + this.euler._quatDirtyId++; + if (value) { + this.cameraMatrix = new pixi_projection.Matrix3d(); + } + }, + enumerable: true, + configurable: true + }); + Projection3d.prototype.onChange = function () { + this._projID++; + }; + Projection3d.prototype.clear = function () { + if (this.cameraMatrix) { + this.cameraMatrix.identity(); + } + this.position.set(0, 0, 0); + this.scale.set(1, 1, 1); + this.euler.set(0, 0, 0); + this.pivot.set(0, 0, 0); + _super.prototype.clear.call(this); + }; + Projection3d.prototype.updateLocalTransform = function (lt) { + if (this._projID === 0) { + this.local.copyFrom(lt); + return; + } + var matrix = this.local; + var euler = this.euler; + var pos = this.position; + var scale = this.scale; + var pivot = this.pivot; + euler.update(); + if (!this.cameraMode) { + matrix.setToRotationTranslationScale(euler.quaternion, pos._x, pos._y, pos._z, scale._x, scale._y, scale._z); + matrix.translate(-pivot._x, -pivot._y, -pivot._z); + matrix.setToMultLegacy(lt, matrix); + return; + } + matrix.setToMultLegacy(lt, this.cameraMatrix); + matrix.translate(pivot._x, pivot._y, pivot._z); + matrix.scale(1.0 / scale._x, 1.0 / scale._y, 1.0 / scale._z); + tempMat.setToRotationTranslationScale(euler.quaternion, 0, 0, 0, 1, 1, 1); + matrix.setToMult(matrix, tempMat); + matrix.translate(-pos._x, -pos._y, -pos._z); + this.local._dirtyId++; + }; + return Projection3d; + }(pixi_projection.LinearProjection)); + pixi_projection.Projection3d = Projection3d; +})(pixi_projection || (pixi_projection = {})); +var pixi_projection; +(function (pixi_projection) { + var Mesh3d2d = (function (_super) { + __extends(Mesh3d2d, _super); + function Mesh3d2d(geometry, shader, state, drawMode) { + var _this = _super.call(this, geometry, shader, state, drawMode) || this; + _this.vertexData2d = null; + _this.proj = new pixi_projection.Projection3d(_this.transform); + return _this; + } + Mesh3d2d.prototype.calculateVertices = function () { + if (this.proj._affine) { + this.vertexData2d = null; + _super.prototype.calculateVertices.call(this); + return; + } + var geometry = this.geometry; + var vertices = geometry.buffers[0].data; + var thisAny = this; + if (geometry.vertexDirtyId === thisAny.vertexDirty && thisAny._transformID === thisAny.transform._worldID) { + return; + } + thisAny._transformID = thisAny.transform._worldID; + if (thisAny.vertexData.length !== vertices.length) { + thisAny.vertexData = new Float32Array(vertices.length); + } + if (this.vertexData2d.length !== vertices.length * 3 / 2) { + this.vertexData2d = new Float32Array(vertices.length * 3); + } + var wt = this.proj.world.mat4; + var vertexData2d = this.vertexData2d; + var vertexData = thisAny.vertexData; + for (var i = 0; i < vertexData.length / 2; i++) { + var x = vertices[(i * 2)]; + var y = vertices[(i * 2) + 1]; + var xx = (wt[0] * x) + (wt[4] * y) + wt[12]; + var yy = (wt[1] * x) + (wt[5] * y) + wt[13]; + var ww = (wt[3] * x) + (wt[7] * y) + wt[15]; + vertexData2d[i * 3] = xx; + vertexData2d[i * 3 + 1] = yy; + vertexData2d[i * 3 + 2] = ww; + vertexData[(i * 2)] = xx / ww; + vertexData[(i * 2) + 1] = yy / ww; + } + thisAny.vertexDirty = geometry.vertexDirtyId; + }; + Object.defineProperty(Mesh3d2d.prototype, "worldTransform", { + get: function () { + return this.proj.affine ? this.transform.worldTransform : this.proj.world; + }, + enumerable: true, + configurable: true + }); + Mesh3d2d.prototype.toLocal = function (position, from, point, skipUpdate, step) { + if (step === void 0) { step = pixi_projection.TRANSFORM_STEP.ALL; } + return pixi_projection.container3dToLocal.call(this, position, from, point, skipUpdate, step); + }; + Mesh3d2d.prototype.isFrontFace = function (forceUpdate) { + return pixi_projection.container3dIsFrontFace.call(this, forceUpdate); + }; + Mesh3d2d.prototype.getDepth = function (forceUpdate) { + return pixi_projection.container3dGetDepth.call(this, forceUpdate); + }; + Object.defineProperty(Mesh3d2d.prototype, "position3d", { + get: function () { + return this.proj.position; + }, + set: function (value) { + this.proj.position.copyFrom(value); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Mesh3d2d.prototype, "scale3d", { + get: function () { + return this.proj.scale; + }, + set: function (value) { + this.proj.scale.copyFrom(value); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Mesh3d2d.prototype, "euler", { + get: function () { + return this.proj.euler; + }, + set: function (value) { + this.proj.euler.copyFrom(value); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Mesh3d2d.prototype, "pivot3d", { + get: function () { + return this.proj.pivot; + }, + set: function (value) { + this.proj.pivot.copyFrom(value); + }, + enumerable: true, + configurable: true + }); + return Mesh3d2d; + }(PIXI.Mesh)); + pixi_projection.Mesh3d2d = Mesh3d2d; + Mesh3d2d.prototype._renderDefault = pixi_projection.Mesh2d.prototype._renderDefault; + var SimpleMesh3d2d = (function (_super) { + __extends(SimpleMesh3d2d, _super); + function SimpleMesh3d2d(texture, vertices, uvs, indices, drawMode) { + var _this = _super.call(this, new PIXI.MeshGeometry(vertices, uvs, indices), new PIXI.MeshMaterial(texture, { + program: PIXI.Program.from(pixi_projection.Mesh2d.defaultVertexShader, pixi_projection.Mesh2d.defaultFragmentShader), + pluginName: 'batch2d' + }), null, drawMode) || this; + _this.autoUpdate = true; + _this.geometry.getBuffer('aVertexPosition').static = false; + return _this; + } + Object.defineProperty(SimpleMesh3d2d.prototype, "vertices", { + get: function () { + return this.geometry.getBuffer('aVertexPosition').data; + }, + set: function (value) { + this.geometry.getBuffer('aVertexPosition').data = value; + }, + enumerable: true, + configurable: true + }); + SimpleMesh3d2d.prototype._render = function (renderer) { + if (this.autoUpdate) { + this.geometry.getBuffer('aVertexPosition').update(); + } + _super.prototype._render.call(this, renderer); + }; + return SimpleMesh3d2d; + }(Mesh3d2d)); + pixi_projection.SimpleMesh3d2d = SimpleMesh3d2d; +})(pixi_projection || (pixi_projection = {})); +var pixi_projection; +(function (pixi_projection) { + var Sprite3d = (function (_super) { + __extends(Sprite3d, _super); + function Sprite3d(texture) { + var _this = _super.call(this, texture) || this; + _this.vertexData2d = null; + _this.culledByFrustrum = false; + _this.trimmedCulledByFrustrum = false; + _this.proj = new pixi_projection.Projection3d(_this.transform); + _this.pluginName = 'batch2d'; + return _this; + } + Sprite3d.prototype.calculateVertices = function () { + var texture = this._texture; + if (this.proj._affine) { + this.vertexData2d = null; + _super.prototype.calculateVertices.call(this); + return; + } + if (!this.vertexData2d) { + this.vertexData2d = new Float32Array(12); + } + var wid = this.transform._worldID; + var tuid = texture._updateID; + if (this._transformID === wid && this._textureID === tuid) { + return; + } + if (this._textureID !== tuid) { + this.uvs = texture._uvs.uvsFloat32; + } + this._transformID = wid; + this._textureID = tuid; + var wt = this.proj.world.mat4; + var vertexData2d = this.vertexData2d; + var vertexData = this.vertexData; + var trim = texture.trim; + var orig = texture.orig; + var anchor = this._anchor; + var w0 = 0; + var w1 = 0; + var h0 = 0; + var h1 = 0; + if (trim) { + w1 = trim.x - (anchor._x * orig.width); + w0 = w1 + trim.width; + h1 = trim.y - (anchor._y * orig.height); + h0 = h1 + trim.height; + } + else { + w1 = -anchor._x * orig.width; + w0 = w1 + orig.width; + h1 = -anchor._y * orig.height; + h0 = h1 + orig.height; + } + var culled = false; + var z; + vertexData2d[0] = (wt[0] * w1) + (wt[4] * h1) + wt[12]; + vertexData2d[1] = (wt[1] * w1) + (wt[5] * h1) + wt[13]; + z = (wt[2] * w1) + (wt[6] * h1) + wt[14]; + vertexData2d[2] = (wt[3] * w1) + (wt[7] * h1) + wt[15]; + culled = culled || z < 0; + vertexData2d[3] = (wt[0] * w0) + (wt[4] * h1) + wt[12]; + vertexData2d[4] = (wt[1] * w0) + (wt[5] * h1) + wt[13]; + z = (wt[2] * w0) + (wt[6] * h1) + wt[14]; + vertexData2d[5] = (wt[3] * w0) + (wt[7] * h1) + wt[15]; + culled = culled || z < 0; + vertexData2d[6] = (wt[0] * w0) + (wt[4] * h0) + wt[12]; + vertexData2d[7] = (wt[1] * w0) + (wt[5] * h0) + wt[13]; + z = (wt[2] * w0) + (wt[6] * h0) + wt[14]; + vertexData2d[8] = (wt[3] * w0) + (wt[7] * h0) + wt[15]; + culled = culled || z < 0; + vertexData2d[9] = (wt[0] * w1) + (wt[4] * h0) + wt[12]; + vertexData2d[10] = (wt[1] * w1) + (wt[5] * h0) + wt[13]; + z = (wt[2] * w1) + (wt[6] * h0) + wt[14]; + vertexData2d[11] = (wt[3] * w1) + (wt[7] * h0) + wt[15]; + culled = culled || z < 0; + this.culledByFrustrum = culled; + vertexData[0] = vertexData2d[0] / vertexData2d[2]; + vertexData[1] = vertexData2d[1] / vertexData2d[2]; + vertexData[2] = vertexData2d[3] / vertexData2d[5]; + vertexData[3] = vertexData2d[4] / vertexData2d[5]; + vertexData[4] = vertexData2d[6] / vertexData2d[8]; + vertexData[5] = vertexData2d[7] / vertexData2d[8]; + vertexData[6] = vertexData2d[9] / vertexData2d[11]; + vertexData[7] = vertexData2d[10] / vertexData2d[11]; + }; + Sprite3d.prototype.calculateTrimmedVertices = function () { + if (this.proj._affine) { + _super.prototype.calculateTrimmedVertices.call(this); + return; + } + var wid = this.transform._worldID; + var tuid = this._texture._updateID; + if (!this.vertexTrimmedData) { + this.vertexTrimmedData = new Float32Array(8); + } + else if (this._transformTrimmedID === wid && this._textureTrimmedID === tuid) { + return; + } + this._transformTrimmedID = wid; + this._textureTrimmedID = tuid; + var texture = this._texture; + var vertexData = this.vertexTrimmedData; + var orig = texture.orig; + var anchor = this._anchor; + var wt = this.proj.world.mat4; + var w1 = -anchor._x * orig.width; + var w0 = w1 + orig.width; + var h1 = -anchor._y * orig.height; + var h0 = h1 + orig.height; + var culled = false; + var z; + var w = 1.0 / ((wt[3] * w1) + (wt[7] * h1) + wt[15]); + vertexData[0] = w * ((wt[0] * w1) + (wt[4] * h1) + wt[12]); + vertexData[1] = w * ((wt[1] * w1) + (wt[5] * h1) + wt[13]); + z = (wt[2] * w1) + (wt[6] * h1) + wt[14]; + culled = culled || z < 0; + w = 1.0 / ((wt[3] * w0) + (wt[7] * h1) + wt[15]); + vertexData[2] = w * ((wt[0] * w0) + (wt[4] * h1) + wt[12]); + vertexData[3] = w * ((wt[1] * w0) + (wt[5] * h1) + wt[13]); + z = (wt[2] * w0) + (wt[6] * h1) + wt[14]; + culled = culled || z < 0; + w = 1.0 / ((wt[3] * w0) + (wt[7] * h0) + wt[15]); + vertexData[4] = w * ((wt[0] * w0) + (wt[4] * h0) + wt[12]); + vertexData[5] = w * ((wt[1] * w0) + (wt[5] * h0) + wt[13]); + z = (wt[2] * w0) + (wt[6] * h0) + wt[14]; + culled = culled || z < 0; + w = 1.0 / ((wt[3] * w1) + (wt[7] * h0) + wt[15]); + vertexData[6] = w * ((wt[0] * w1) + (wt[4] * h0) + wt[12]); + vertexData[7] = w * ((wt[1] * w1) + (wt[5] * h0) + wt[13]); + z = (wt[2] * w1) + (wt[6] * h0) + wt[14]; + culled = culled || z < 0; + this.culledByFrustrum = culled; + }; + Sprite3d.prototype._calculateBounds = function () { + this.calculateVertices(); + if (this.culledByFrustrum) { + return; + } + var trim = this._texture.trim; + var orig = this._texture.orig; + if (!trim || (trim.width === orig.width && trim.height === orig.height)) { + this._bounds.addQuad(this.vertexData); + return; + } + this.calculateTrimmedVertices(); + if (!this.trimmedCulledByFrustrum) { + this._bounds.addQuad(this.vertexTrimmedData); + } + }; + Sprite3d.prototype._render = function (renderer) { + this.calculateVertices(); + if (this.culledByFrustrum) { + return; + } + renderer.batch.setObjectRenderer(renderer.plugins[this.pluginName]); + renderer.plugins[this.pluginName].render(this); + }; + Sprite3d.prototype.containsPoint = function (point) { + if (this.culledByFrustrum) { + return false; + } + return _super.prototype.containsPoint.call(this, point); + }; + Object.defineProperty(Sprite3d.prototype, "worldTransform", { + get: function () { + return this.proj.affine ? this.transform.worldTransform : this.proj.world; + }, + enumerable: true, + configurable: true + }); + Sprite3d.prototype.toLocal = function (position, from, point, skipUpdate, step) { + if (step === void 0) { step = pixi_projection.TRANSFORM_STEP.ALL; } + return pixi_projection.container3dToLocal.call(this, position, from, point, skipUpdate, step); + }; + Sprite3d.prototype.isFrontFace = function (forceUpdate) { + return pixi_projection.container3dIsFrontFace.call(this, forceUpdate); + }; + Sprite3d.prototype.getDepth = function (forceUpdate) { + return pixi_projection.container3dGetDepth.call(this, forceUpdate); + }; + Object.defineProperty(Sprite3d.prototype, "position3d", { + get: function () { + return this.proj.position; + }, + set: function (value) { + this.proj.position.copyFrom(value); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Sprite3d.prototype, "scale3d", { + get: function () { + return this.proj.scale; + }, + set: function (value) { + this.proj.scale.copyFrom(value); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Sprite3d.prototype, "euler", { + get: function () { + return this.proj.euler; + }, + set: function (value) { + this.proj.euler.copyFrom(value); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Sprite3d.prototype, "pivot3d", { + get: function () { + return this.proj.pivot; + }, + set: function (value) { + this.proj.pivot.copyFrom(value); + }, + enumerable: true, + configurable: true + }); + return Sprite3d; + }(PIXI.Sprite)); + pixi_projection.Sprite3d = Sprite3d; +})(pixi_projection || (pixi_projection = {})); +var pixi_projection; +(function (pixi_projection) { + var Text3d = (function (_super) { + __extends(Text3d, _super); + function Text3d(text, style, canvas) { + var _this = _super.call(this, text, style, canvas) || this; + _this.vertexData2d = null; + _this.proj = new pixi_projection.Projection3d(_this.transform); + _this.pluginName = 'batch2d'; + return _this; + } + Object.defineProperty(Text3d.prototype, "worldTransform", { + get: function () { + return this.proj.affine ? this.transform.worldTransform : this.proj.world; + }, + enumerable: true, + configurable: true + }); + Text3d.prototype.toLocal = function (position, from, point, skipUpdate, step) { + if (step === void 0) { step = pixi_projection.TRANSFORM_STEP.ALL; } + return pixi_projection.container3dToLocal.call(this, position, from, point, skipUpdate, step); + }; + Text3d.prototype.isFrontFace = function (forceUpdate) { + return pixi_projection.container3dIsFrontFace.call(this, forceUpdate); + }; + Text3d.prototype.getDepth = function (forceUpdate) { + return pixi_projection.container3dGetDepth.call(this, forceUpdate); + }; + Object.defineProperty(Text3d.prototype, "position3d", { + get: function () { + return this.proj.position; + }, + set: function (value) { + this.proj.position.copyFrom(value); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Text3d.prototype, "scale3d", { + get: function () { + return this.proj.scale; + }, + set: function (value) { + this.proj.scale.copyFrom(value); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Text3d.prototype, "euler", { + get: function () { + return this.proj.euler; + }, + set: function (value) { + this.proj.euler.copyFrom(value); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Text3d.prototype, "pivot3d", { + get: function () { + return this.proj.pivot; + }, + set: function (value) { + this.proj.pivot.copyFrom(value); + }, + enumerable: true, + configurable: true + }); + return Text3d; + }(PIXI.Text)); + pixi_projection.Text3d = Text3d; + Text3d.prototype.calculateVertices = pixi_projection.Sprite3d.prototype.calculateVertices; + Text3d.prototype.calculateTrimmedVertices = pixi_projection.Sprite3d.prototype.calculateTrimmedVertices; + Text3d.prototype._calculateBounds = pixi_projection.Sprite3d.prototype._calculateBounds; + Text3d.prototype.containsPoint = pixi_projection.Sprite3d.prototype.containsPoint; + Text3d.prototype._render = pixi_projection.Sprite3d.prototype._render; +})(pixi_projection || (pixi_projection = {})); +var pixi_projection; +(function (pixi_projection) { + var containerProps = { + worldTransform: { + get: pixi_projection.container3dWorldTransform, + enumerable: true, + configurable: true + }, + position3d: { + get: function () { return this.proj.position; }, + set: function (value) { this.proj.position.copy(value); } + }, + scale3d: { + get: function () { return this.proj.scale; }, + set: function (value) { this.proj.scale.copy(value); } + }, + pivot3d: { + get: function () { return this.proj.pivot; }, + set: function (value) { this.proj.pivot.copy(value); } + }, + euler: { + get: function () { return this.proj.euler; }, + set: function (value) { this.proj.euler.copy(value); } + } + }; + function convertTo3d() { + if (this.proj) + return; + this.proj = new pixi_projection.Projection3d(this.transform); + this.toLocal = pixi_projection.Container3d.prototype.toLocal; + this.isFrontFace = pixi_projection.Container3d.prototype.isFrontFace; + this.getDepth = pixi_projection.Container3d.prototype.getDepth; + Object.defineProperties(this, containerProps); + } + PIXI.Container.prototype.convertTo3d = convertTo3d; + PIXI.Sprite.prototype.convertTo3d = function () { + if (this.proj) + return; + this.calculateVertices = pixi_projection.Sprite3d.prototype.calculateVertices; + this.calculateTrimmedVertices = pixi_projection.Sprite3d.prototype.calculateTrimmedVertices; + this._calculateBounds = pixi_projection.Sprite3d.prototype._calculateBounds; + this.containsPoint = pixi_projection.Sprite3d.prototype.containsPoint; + this.pluginName = 'batch2d'; + convertTo3d.call(this); + }; + PIXI.Container.prototype.convertSubtreeTo3d = function () { + this.convertTo3d(); + for (var i = 0; i < this.children.length; i++) { + this.children[i].convertSubtreeTo3d(); + } + }; + if (PIXI.SimpleMesh) { + PIXI.SimpleMesh.prototype.convertTo3d = + PIXI.SimpleRope.prototype.convertTo3d = + function () { + if (this.proj) + return; + this.calculateVertices = pixi_projection.Mesh3d2d.prototype.calculateVertices; + this._renderDefault = pixi_projection.Mesh3d2d.prototype._renderDefault; + if (this.material.pluginName !== 'batch2d') { + this.material = new PIXI.MeshMaterial(this.material.texture, { + program: PIXI.Program.from(pixi_projection.Mesh2d.defaultVertexShader, pixi_projection.Mesh2d.defaultFragmentShader), + pluginName: 'batch2d' + }); + } + convertTo3d.call(this); + }; + } +})(pixi_projection || (pixi_projection = {})); /*! * VERSION: 2.1.3 @@ -75911,14 +76015,14 @@ var Wait = require('./wait'); var Ease = function (_Events) { _inherits(Ease, _Events); - /** - * Main class for creating eases - * @param {object} [options] - * @param {boolean} [options.noTicker] don't add the update function to PIXI.ticker - * @param {PIXI.ticker} [options.ticker=PIXI.ticker.shared] use this PIXI.ticker for the list - * @extends eventemitter - * @fire done - * @fire each + /** + * Main class for creating eases + * @param {object} [options] + * @param {boolean} [options.noTicker] don't add the update function to PIXI.ticker + * @param {PIXI.ticker} [options.ticker=PIXI.ticker.shared] use this PIXI.ticker for the list + * @extends eventemitter + * @fire done + * @fire each */ function Ease(options) { _classCallCheck(this, Ease); @@ -75940,10 +76044,10 @@ var Ease = function (_Events) { return _this; } - /** - * Add animation(s) to animation list - * @param {(object|object[])} any animation class - * @return {object} first animation + /** + * Add animation(s) to animation list + * @param {(object|object[])} any animation class + * @return {object} first animation */ @@ -76011,9 +76115,9 @@ var Ease = function (_Events) { return first; } - /** - * remove animation(s) - * @param {object|array} animate - the animation (or array of animations) to remove; can be null + /** + * remove animation(s) + * @param {object|array} animate - the animation (or array of animations) to remove; can be null */ }, { @@ -76029,9 +76133,9 @@ var Ease = function (_Events) { } } - /** - * remove all animations from list - * @inherited from yy-loop + /** + * remove all animations from list + * @inherited from yy-loop */ }, { @@ -76044,11 +76148,11 @@ var Ease = function (_Events) { } } - /** - * update frame - * this is automatically added to PIXI.ticker unless options.noTicker is set - * if using options.noTicker, this should be called manually - * @param {number} elasped time in MS since last update + /** + * update frame + * this is automatically added to PIXI.ticker unless options.noTicker is set + * if using options.noTicker, this should be called manually + * @param {number} elasped time in MS since last update */ }, { @@ -76077,50 +76181,50 @@ var Ease = function (_Events) { } } - /** - * number of animations - * @type {number} + /** + * number of animations + * @type {number} */ }, { key: 'to', - /** - * default options for all eases - * @typedef {object} EaseOptions - * @param {object} [EaseOptions.options] - * @param {number} [EaseOptions.options.wait=0] n milliseconds before starting animation (can also be used to pause animation for a length of time) - * @param {boolean} [EaseOptions.options.pause] start the animation paused - * @param {boolean|number} [EaseOptions.options.repeat] true: repeat animation forever n: repeat animation n times - * @param {boolean|number} [EaseOptions.options.reverse] true: reverse animation (if combined with repeat, then pulse) n: reverse animation n times - * @param {Function} [EaseOptions.options.load] loads an animation using an .save() object note the * parameters below cannot be loaded and must be re-set - * @param {string|Function} [EaseOptions.options.ease] name or function from easing.js (see http://easings.net for examples) + /** + * default options for all eases + * @typedef {object} EaseOptions + * @param {object} [EaseOptions.options] + * @param {number} [EaseOptions.options.wait=0] n milliseconds before starting animation (can also be used to pause animation for a length of time) + * @param {boolean} [EaseOptions.options.pause] start the animation paused + * @param {boolean|number} [EaseOptions.options.repeat] true: repeat animation forever n: repeat animation n times + * @param {boolean|number} [EaseOptions.options.reverse] true: reverse animation (if combined with repeat, then pulse) n: reverse animation n times + * @param {Function} [EaseOptions.options.load] loads an animation using an .save() object note the * parameters below cannot be loaded and must be re-set + * @param {string|Function} [EaseOptions.options.ease] name or function from easing.js (see http://easings.net for examples) */ - /** - * ease parameters of object - * @param {PIXI.DisplayObject} object to animate - * @param {object} goto - parameters to animate, e.g.: {alpha: 5, scale: {3, 5}, scale: 5, rotation: Math.PI} - * @param {number} duration - time to run - * @fires done - * @fires wait - * @fires first - * @fires each - * @fires loop - * @fires reverse + /** + * ease parameters of object + * @param {PIXI.DisplayObject} object to animate + * @param {object} goto - parameters to animate, e.g.: {alpha: 5, scale: {3, 5}, scale: 5, rotation: Math.PI} + * @param {number} duration - time to run + * @fires done + * @fires wait + * @fires first + * @fires each + * @fires loop + * @fires reverse */ value: function to() { return this.add(new (Function.prototype.bind.apply(To, [null].concat(Array.prototype.slice.call(arguments))))()); } - /** - * animate object's {x, y} using an angle - * @param {object} object to animate - * @param {number} angle in radians - * @param {number} speed in pixels/millisecond - * @param {number} [duration=0] in milliseconds; if 0, then continues forever - * @param {object} [options] @see {@link Wait} + /** + * animate object's {x, y} using an angle + * @param {object} object to animate + * @param {number} angle in radians + * @param {number} speed in pixels/millisecond + * @param {number} [duration=0] in milliseconds; if 0, then continues forever + * @param {object} [options] @see {@link Wait} */ }, { @@ -76190,9 +76294,9 @@ var Ease = function (_Events) { return this.list.length; } - /** - * number of active animations - * @type {number} + /** + * number of active animations + * @type {number} */ }, { @@ -76784,24 +76888,24 @@ var wait = require('./wait'); var to = function (_wait) { _inherits(to, _wait); - /** - * @private - * @param {object} object to animate - * @param {object} goto - parameters to animate, e.g.: {alpha: 5, scale: {3, 5}, scale: 5, rotation: Math.PI} - * @param {number} duration - time to run - * @param {object} [options] - * @param {number} [options.wait=0] n milliseconds before starting animation (can also be used to pause animation for a length of time) - * @param {boolean} [options.pause] start the animation paused - * @param {boolean|number} [options.repeat] true: repeat animation forever n: repeat animation n times - * @param {boolean|number} [options.reverse] true: reverse animation (if combined with repeat, then pulse) n: reverse animation n times - * @param {Function} [options.load] loads an animation using an .save() object note the * parameters below cannot be loaded and must be re-set - * @param {string|Function} [options.ease] name or function from easing.js (see http://easings.net for examples) - * @emits to:done animation expires - * @emits to:wait each update during a wait - * @emits to:first first update when animation starts - * @emits to:each each update while animation is running - * @emits to:loop when animation is repeated - * @emits to:reverse when animation is reversed + /** + * @private + * @param {object} object to animate + * @param {object} goto - parameters to animate, e.g.: {alpha: 5, scale: {3, 5}, scale: 5, rotation: Math.PI} + * @param {number} duration - time to run + * @param {object} [options] + * @param {number} [options.wait=0] n milliseconds before starting animation (can also be used to pause animation for a length of time) + * @param {boolean} [options.pause] start the animation paused + * @param {boolean|number} [options.repeat] true: repeat animation forever n: repeat animation n times + * @param {boolean|number} [options.reverse] true: reverse animation (if combined with repeat, then pulse) n: reverse animation n times + * @param {Function} [options.load] loads an animation using an .save() object note the * parameters below cannot be loaded and must be re-set + * @param {string|Function} [options.ease] name or function from easing.js (see http://easings.net for examples) + * @emits to:done animation expires + * @emits to:wait each update during a wait + * @emits to:first first update when animation starts + * @emits to:each each update while animation is running + * @emits to:loop when animation is repeated + * @emits to:reverse when animation is reversed */ function to(object, goto, duration, options) { _classCallCheck(this, to); @@ -76826,9 +76930,9 @@ var to = function (_wait) { return _this; } - /** - * converts scale from { scale: n } to { scale: { x: n, y: n }} - * @private + /** + * converts scale from { scale: n } to { scale: { x: n, y: n }} + * @private */ @@ -76980,24 +77084,24 @@ var EventEmitter = require('eventemitter3'); var wait = function (_EventEmitter) { _inherits(wait, _EventEmitter); - /** - * @param {object|object[]} object or list of objects to animate - * @param {object} [options] - * @param {number} [options.wait=0] n milliseconds before starting animation (can also be used to pause animation for a length of time) - * @param {boolean} [options.pause] start the animation paused - * @param {(boolean|number)} [options.repeat] true: repeat animation forever n: repeat animation n times - * @param {(boolean|number)} [options.reverse] true: reverse animation (if combined with repeat, then pulse) n: reverse animation n times - * - * @param {number} [options.id] user-generated id (e.g., I use it to properly load animations when an object has multiple animations running) - * @param {Function} [options.load] loads an animation using an .save() object note the * parameters below cannot be loaded and must be re-set - * @param {Function|string} [options.ease] function (or penner function name) from easing.js (see http://easings.net for examples)* - * - * @emits {done} animation expires - * @emits {wait} each update during a wait - * @emits {first} first update when animation starts - * @emits {each} each update while animation is running - * @emits {loop} when animation is repeated - * @emits {reverse} when animation is reversed + /** + * @param {object|object[]} object or list of objects to animate + * @param {object} [options] + * @param {number} [options.wait=0] n milliseconds before starting animation (can also be used to pause animation for a length of time) + * @param {boolean} [options.pause] start the animation paused + * @param {(boolean|number)} [options.repeat] true: repeat animation forever n: repeat animation n times + * @param {(boolean|number)} [options.reverse] true: reverse animation (if combined with repeat, then pulse) n: reverse animation n times + * + * @param {number} [options.id] user-generated id (e.g., I use it to properly load animations when an object has multiple animations running) + * @param {Function} [options.load] loads an animation using an .save() object note the * parameters below cannot be loaded and must be re-set + * @param {Function|string} [options.ease] function (or penner function name) from easing.js (see http://easings.net for examples)* + * + * @emits {done} animation expires + * @emits {wait} each update during a wait + * @emits {first} first update when animation starts + * @emits {each} each update while animation is running + * @emits {loop} when animation is repeated + * @emits {reverse} when animation is reversed */ function wait(object, options) { _classCallCheck(this, wait); @@ -77064,9 +77168,9 @@ var wait = function (_EventEmitter) { this.duration = _load.duration; } - /** - * pause this entry - * @type {boolean} + /** + * pause this entry + * @type {boolean} */ }, { @@ -79798,19 +79902,19 @@ var Plugin = require('./plugin'); module.exports = function (_Plugin) { _inherits(Bounce, _Plugin); - /** - * @private - * @param {Viewport} parent - * @param {object} [options] - * @param {string} [options.sides=all] all, horizontal, vertical, or combination of top, bottom, right, left (e.g., 'top-bottom-right') - * @param {number} [options.friction=0.5] friction to apply to decelerate if active - * @param {number} [options.time=150] time in ms to finish bounce - * @param {string|function} [ease=easeInOutSine] ease function or name (see http://easings.net/ for supported names) - * @param {string} [options.underflow=center] (top/bottom/center and left/right/center, or center) where to place world if too small for screen - * @fires bounce-start-x - * @fires bounce.end-x - * @fires bounce-start-y - * @fires bounce-end-y + /** + * @private + * @param {Viewport} parent + * @param {object} [options] + * @param {string} [options.sides=all] all, horizontal, vertical, or combination of top, bottom, right, left (e.g., 'top-bottom-right') + * @param {number} [options.friction=0.5] friction to apply to decelerate if active + * @param {number} [options.time=150] time in ms to finish bounce + * @param {string|function} [ease=easeInOutSine] ease function or name (see http://easings.net/ for supported names) + * @param {string} [options.underflow=center] (top/bottom/center and left/right/center, or center) where to place world if too small for screen + * @fires bounce-start-x + * @fires bounce.end-x + * @fires bounce-start-y + * @fires bounce-end-y */ function Bounce(parent, options) { _classCallCheck(this, Bounce); @@ -80008,13 +80112,13 @@ var Plugin = require('./plugin'); module.exports = function (_Plugin) { _inherits(ClampZoom, _Plugin); - /** - * @private - * @param {object} [options] - * @param {number} [options.minWidth] minimum width - * @param {number} [options.minHeight] minimum height - * @param {number} [options.maxWidth] maximum width - * @param {number} [options.maxHeight] maximum height + /** + * @private + * @param {object} [options] + * @param {number} [options.minWidth] minimum width + * @param {number} [options.minHeight] minimum height + * @param {number} [options.maxWidth] maximum width + * @param {number} [options.maxHeight] maximum height */ function ClampZoom(parent, options) { _classCallCheck(this, ClampZoom); @@ -80087,15 +80191,15 @@ var utils = require('./utils'); module.exports = function (_Plugin) { _inherits(clamp, _Plugin); - /** - * @private - * @param {object} options - * @param {(number|boolean)} [options.left] clamp left; true=0 - * @param {(number|boolean)} [options.right] clamp right; true=viewport.worldWidth - * @param {(number|boolean)} [options.top] clamp top; true=0 - * @param {(number|boolean)} [options.bottom] clamp bottom; true=viewport.worldHeight - * @param {string} [options.direction] (all, x, or y) using clamps of [0, viewport.worldWidth/viewport.worldHeight]; replaces left/right/top/bottom if set - * @param {string} [options.underflow=center] (top/bottom/center and left/right/center, or center) where to place world if too small for screen + /** + * @private + * @param {object} options + * @param {(number|boolean)} [options.left] clamp left; true=0 + * @param {(number|boolean)} [options.right] clamp right; true=viewport.worldWidth + * @param {(number|boolean)} [options.top] clamp top; true=0 + * @param {(number|boolean)} [options.bottom] clamp bottom; true=viewport.worldHeight + * @param {string} [options.direction] (all, x, or y) using clamps of [0, viewport.worldWidth/viewport.worldHeight]; replaces left/right/top/bottom if set + * @param {string} [options.underflow=center] (top/bottom/center and left/right/center, or center) where to place world if too small for screen */ function clamp(parent, options) { _classCallCheck(this, clamp); @@ -80252,13 +80356,13 @@ var Plugin = require('./plugin'); module.exports = function (_Plugin) { _inherits(Decelerate, _Plugin); - /** - * @private - * @param {Viewport} parent - * @param {object} [options] - * @param {number} [options.friction=0.95] percent to decelerate after movement - * @param {number} [options.bounce=0.8] percent to decelerate when past boundaries (only applicable when viewport.bounce() is active) - * @param {number} [options.minSpeed=0.01] minimum velocity before stopping/reversing acceleration + /** + * @private + * @param {Viewport} parent + * @param {object} [options] + * @param {number} [options.friction=0.95] percent to decelerate after movement + * @param {number} [options.bounce=0.8] percent to decelerate when past boundaries (only applicable when viewport.bounce() is active) + * @param {number} [options.minSpeed=0.01] minimum velocity before stopping/reversing acceleration */ function Decelerate(parent, options) { _classCallCheck(this, Decelerate); @@ -80332,11 +80436,11 @@ module.exports = function (_Plugin) { } } - /** - * manually activate plugin - * @param {object} options - * @param {number} [options.x] - * @param {number} [options.y] + /** + * manually activate plugin + * @param {object} options + * @param {number} [options.x] + * @param {number} [options.y] */ }, { @@ -80408,17 +80512,17 @@ var Plugin = require('./plugin'); module.exports = function (_Plugin) { _inherits(Drag, _Plugin); - /** - * enable one-finger touch to drag - * @private - * @param {Viewport} parent - * @param {object} [options] - * @param {string} [options.direction=all] direction to drag (all, x, or y) - * @param {boolean} [options.wheel=true] use wheel to scroll in y direction (unless wheel plugin is active) - * @param {number} [options.wheelScroll=1] number of pixels to scroll with each wheel spin - * @param {boolean} [options.reverse] reverse the direction of the wheel scroll - * @param {boolean|string} [options.clampWheel] (true, x, or y) clamp wheel (to avoid weird bounce with mouse wheel) - * @param {string} [options.underflow=center] (top/bottom/center and left/right/center, or center) where to place world if too small for screen + /** + * enable one-finger touch to drag + * @private + * @param {Viewport} parent + * @param {object} [options] + * @param {string} [options.direction=all] direction to drag (all, x, or y) + * @param {boolean} [options.wheel=true] use wheel to scroll in y direction (unless wheel plugin is active) + * @param {number} [options.wheelScroll=1] number of pixels to scroll with each wheel spin + * @param {boolean} [options.reverse] reverse the direction of the wheel scroll + * @param {boolean|string} [options.clampWheel] (true, x, or y) clamp wheel (to avoid weird bounce with mouse wheel) + * @param {string} [options.underflow=center] (top/bottom/center and left/right/center, or center) where to place world if too small for screen */ function Drag(parent, options) { _classCallCheck(this, Drag); @@ -80623,13 +80727,13 @@ var Plugin = require('./plugin'); module.exports = function (_Plugin) { _inherits(Follow, _Plugin); - /** - * @private - * @param {Viewport} parent - * @param {PIXI.DisplayObject} target to follow (object must include {x: x-coordinate, y: y-coordinate}) - * @param {object} [options] - * @param {number} [options.speed=0] to follow in pixels/frame (0=teleport to location) - * @param {number} [options.radius] radius (in world coordinates) of center circle where movement is allowed without moving the viewport + /** + * @private + * @param {Viewport} parent + * @param {PIXI.DisplayObject} target to follow (object must include {x: x-coordinate, y: y-coordinate}) + * @param {object} [options] + * @param {number} [options.speed=0] to follow in pixels/frame (0=teleport to location) + * @param {number} [options.radius] radius (in world coordinates) of center circle where movement is allowed without moving the viewport */ function Follow(parent, target, options) { _classCallCheck(this, Follow); @@ -80702,24 +80806,24 @@ var Plugin = require('./plugin'); module.exports = function (_Plugin) { _inherits(MouseEdges, _Plugin); - /** - * Scroll viewport when mouse hovers near one of the edges. - * @private - * @param {Viewport} parent - * @param {object} [options] - * @param {number} [options.radius] distance from center of screen in screen pixels - * @param {number} [options.distance] distance from all sides in screen pixels - * @param {number} [options.top] alternatively, set top distance (leave unset for no top scroll) - * @param {number} [options.bottom] alternatively, set bottom distance (leave unset for no top scroll) - * @param {number} [options.left] alternatively, set left distance (leave unset for no top scroll) - * @param {number} [options.right] alternatively, set right distance (leave unset for no top scroll) - * @param {number} [options.speed=8] speed in pixels/frame to scroll viewport - * @param {boolean} [options.reverse] reverse direction of scroll - * @param {boolean} [options.noDecelerate] don't use decelerate plugin even if it's installed - * @param {boolean} [options.linear] if using radius, use linear movement (+/- 1, +/- 1) instead of angled movement (Math.cos(angle from center), Math.sin(angle from center)) - * - * @event mouse-edge-start(Viewport) emitted when mouse-edge starts - * @event mouse-edge-end(Viewport) emitted when mouse-edge ends + /** + * Scroll viewport when mouse hovers near one of the edges. + * @private + * @param {Viewport} parent + * @param {object} [options] + * @param {number} [options.radius] distance from center of screen in screen pixels + * @param {number} [options.distance] distance from all sides in screen pixels + * @param {number} [options.top] alternatively, set top distance (leave unset for no top scroll) + * @param {number} [options.bottom] alternatively, set bottom distance (leave unset for no top scroll) + * @param {number} [options.left] alternatively, set left distance (leave unset for no top scroll) + * @param {number} [options.right] alternatively, set right distance (leave unset for no top scroll) + * @param {number} [options.speed=8] speed in pixels/frame to scroll viewport + * @param {boolean} [options.reverse] reverse direction of scroll + * @param {boolean} [options.noDecelerate] don't use decelerate plugin even if it's installed + * @param {boolean} [options.linear] if using radius, use linear movement (+/- 1, +/- 1) instead of angled movement (Math.cos(angle from center), Math.sin(angle from center)) + * + * @event mouse-edge-start(Viewport) emitted when mouse-edge starts + * @event mouse-edge-end(Viewport) emitted when mouse-edge ends */ function MouseEdges(parent, options) { _classCallCheck(this, MouseEdges); @@ -80875,13 +80979,13 @@ var Plugin = require('./plugin'); module.exports = function (_Plugin) { _inherits(Pinch, _Plugin); - /** - * @private - * @param {Viewport} parent - * @param {object} [options] - * @param {boolean} [options.noDrag] disable two-finger dragging - * @param {number} [options.percent=1.0] percent to modify pinch speed - * @param {PIXI.Point} [options.center] place this point at center during zoom instead of center of two fingers + /** + * @private + * @param {Viewport} parent + * @param {object} [options] + * @param {boolean} [options.noDrag] disable two-finger dragging + * @param {number} [options.percent=1.0] percent to modify pinch speed + * @param {PIXI.Point} [options.center] place this point at center during zoom instead of center of two fingers */ function Pinch(parent, options) { _classCallCheck(this, Pinch); @@ -81049,24 +81153,24 @@ var utils = require('./utils'); module.exports = function (_Plugin) { _inherits(SnapZoom, _Plugin); - /** - * @private - * @param {Viewport} parent - * @param {object} [options] - * @param {number} [options.width] the desired width to snap (to maintain aspect ratio, choose only width or height) - * @param {number} [options.height] the desired height to snap (to maintain aspect ratio, choose only width or height) - * @param {number} [options.time=1000] - * @param {string|function} [options.ease=easeInOutSine] ease function or name (see http://easings.net/ for supported names) - * @param {PIXI.Point} [options.center] place this point at center during zoom instead of center of the viewport - * @param {boolean} [options.interrupt=true] pause snapping with any user input on the viewport - * @param {boolean} [options.removeOnComplete] removes this plugin after snapping is complete - * @param {boolean} [options.removeOnInterrupt] removes this plugin if interrupted by any user input - * @param {boolean} [options.forceStart] starts the snap immediately regardless of whether the viewport is at the desired zoom - * @param {boolean} [options.noMove] zoom but do not move - * - * @event snap-zoom-start(Viewport) emitted each time a fit animation starts - * @event snap-zoom-end(Viewport) emitted each time fit reaches its target - * @event snap-zoom-end(Viewport) emitted each time fit reaches its target + /** + * @private + * @param {Viewport} parent + * @param {object} [options] + * @param {number} [options.width] the desired width to snap (to maintain aspect ratio, choose only width or height) + * @param {number} [options.height] the desired height to snap (to maintain aspect ratio, choose only width or height) + * @param {number} [options.time=1000] + * @param {string|function} [options.ease=easeInOutSine] ease function or name (see http://easings.net/ for supported names) + * @param {PIXI.Point} [options.center] place this point at center during zoom instead of center of the viewport + * @param {boolean} [options.interrupt=true] pause snapping with any user input on the viewport + * @param {boolean} [options.removeOnComplete] removes this plugin after snapping is complete + * @param {boolean} [options.removeOnInterrupt] removes this plugin if interrupted by any user input + * @param {boolean} [options.forceStart] starts the snap immediately regardless of whether the viewport is at the desired zoom + * @param {boolean} [options.noMove] zoom but do not move + * + * @event snap-zoom-start(Viewport) emitted each time a fit animation starts + * @event snap-zoom-end(Viewport) emitted each time fit reaches its target + * @event snap-zoom-end(Viewport) emitted each time fit reaches its target */ function SnapZoom(parent, options) { _classCallCheck(this, SnapZoom); @@ -81223,25 +81327,25 @@ var utils = require('./utils'); module.exports = function (_Plugin) { _inherits(Snap, _Plugin); - /** - * @private - * @param {Viewport} parent - * @param {number} x - * @param {number} y - * @param {object} [options] - * @param {boolean} [options.topLeft] snap to the top-left of viewport instead of center - * @param {number} [options.friction=0.8] friction/frame to apply if decelerate is active - * @param {number} [options.time=1000] - * @param {string|function} [options.ease=easeInOutSine] ease function or name (see http://easings.net/ for supported names) - * @param {boolean} [options.interrupt=true] pause snapping with any user input on the viewport - * @param {boolean} [options.removeOnComplete] removes this plugin after snapping is complete - * @param {boolean} [options.removeOnInterrupt] removes this plugin if interrupted by any user input - * @param {boolean} [options.forceStart] starts the snap immediately regardless of whether the viewport is at the desired location - * - * @event snap-start(Viewport) emitted each time a snap animation starts - * @event snap-restart(Viewport) emitted each time a snap resets because of a change in viewport size - * @event snap-end(Viewport) emitted each time snap reaches its target - * @event snap-remove(Viewport) emitted if snap plugin is removed + /** + * @private + * @param {Viewport} parent + * @param {number} x + * @param {number} y + * @param {object} [options] + * @param {boolean} [options.topLeft] snap to the top-left of viewport instead of center + * @param {number} [options.friction=0.8] friction/frame to apply if decelerate is active + * @param {number} [options.time=1000] + * @param {string|function} [options.ease=easeInOutSine] ease function or name (see http://easings.net/ for supported names) + * @param {boolean} [options.interrupt=true] pause snapping with any user input on the viewport + * @param {boolean} [options.removeOnComplete] removes this plugin after snapping is complete + * @param {boolean} [options.removeOnInterrupt] removes this plugin if interrupted by any user input + * @param {boolean} [options.forceStart] starts the snap immediately regardless of whether the viewport is at the desired location + * + * @event snap-start(Viewport) emitted each time a snap animation starts + * @event snap-restart(Viewport) emitted each time a snap resets because of a change in viewport size + * @event snap-end(Viewport) emitted each time snap reaches its target + * @event snap-remove(Viewport) emitted if snap plugin is removed */ function Snap(parent, x, y, options) { _classCallCheck(this, Snap); @@ -81417,45 +81521,45 @@ var PLUGIN_ORDER = ['drag', 'pinch', 'wheel', 'follow', 'mouse-edges', 'decelera var Viewport = function (_PIXI$Container) { _inherits(Viewport, _PIXI$Container); - /** - * @extends PIXI.Container - * @extends EventEmitter - * @param {object} [options] - * @param {number} [options.screenWidth=window.innerWidth] - * @param {number} [options.screenHeight=window.innerHeight] - * @param {number} [options.worldWidth=this.width] - * @param {number} [options.worldHeight=this.height] - * @param {number} [options.threshold = 5] number of pixels to move to trigger an input event (e.g., drag, pinch) - * @param {(PIXI.Rectangle|PIXI.Circle|PIXI.Ellipse|PIXI.Polygon|PIXI.RoundedRectangle)} [options.forceHitArea] change the default hitArea from world size to a new value - * @param {PIXI.ticker.Ticker} [options.ticker=PIXI.ticker.shared] use this PIXI.ticker for updates - * @param {PIXI.InteractionManager} [options.interaction=null] InteractionManager, available from instantiated WebGLRenderer/CanvasRenderer.plugins.interaction - used to calculate pointer postion relative to canvas location on screen - * @param {HTMLElement} [options.divWheel=document.body] div to attach the wheel event - * @fires clicked - * @fires drag-start - * @fires drag-end - * @fires drag-remove - * @fires pinch-start - * @fires pinch-end - * @fires pinch-remove - * @fires snap-start - * @fires snap-end - * @fires snap-remove - * @fires snap-zoom-start - * @fires snap-zoom-end - * @fires snap-zoom-remove - * @fires bounce-x-start - * @fires bounce-x-end - * @fires bounce-y-start - * @fires bounce-y-end - * @fires bounce-remove - * @fires wheel - * @fires wheel-remove - * @fires wheel-scroll - * @fires wheel-scroll-remove - * @fires mouse-edge-start - * @fires mouse-edge-end - * @fires mouse-edge-remove - * @fires moved + /** + * @extends PIXI.Container + * @extends EventEmitter + * @param {object} [options] + * @param {number} [options.screenWidth=window.innerWidth] + * @param {number} [options.screenHeight=window.innerHeight] + * @param {number} [options.worldWidth=this.width] + * @param {number} [options.worldHeight=this.height] + * @param {number} [options.threshold = 5] number of pixels to move to trigger an input event (e.g., drag, pinch) + * @param {(PIXI.Rectangle|PIXI.Circle|PIXI.Ellipse|PIXI.Polygon|PIXI.RoundedRectangle)} [options.forceHitArea] change the default hitArea from world size to a new value + * @param {PIXI.ticker.Ticker} [options.ticker=PIXI.ticker.shared] use this PIXI.ticker for updates + * @param {PIXI.InteractionManager} [options.interaction=null] InteractionManager, available from instantiated WebGLRenderer/CanvasRenderer.plugins.interaction - used to calculate pointer postion relative to canvas location on screen + * @param {HTMLElement} [options.divWheel=document.body] div to attach the wheel event + * @fires clicked + * @fires drag-start + * @fires drag-end + * @fires drag-remove + * @fires pinch-start + * @fires pinch-end + * @fires pinch-remove + * @fires snap-start + * @fires snap-end + * @fires snap-remove + * @fires snap-zoom-start + * @fires snap-zoom-end + * @fires snap-zoom-remove + * @fires bounce-x-start + * @fires bounce-x-end + * @fires bounce-y-start + * @fires bounce-y-end + * @fires bounce-remove + * @fires wheel + * @fires wheel-remove + * @fires wheel-scroll + * @fires wheel-scroll-remove + * @fires mouse-edge-start + * @fires mouse-edge-end + * @fires mouse-edge-remove + * @fires moved */ function Viewport(options) { _classCallCheck(this, Viewport); @@ -81477,10 +81581,10 @@ var Viewport = function (_PIXI$Container) { _this.div = options.divWheel || document.body; _this.listeners(_this.div); - /** - * active touch point ids on the viewport - * @type {number[]} - * @readonly + /** + * active touch point ids on the viewport + * @type {number[]} + * @readonly */ _this.touches = []; @@ -81492,9 +81596,9 @@ var Viewport = function (_PIXI$Container) { return _this; } - /** - * removes all event listeners from viewport - * (useful for cleanup of wheel and ticker events when removing viewport) + /** + * removes all event listeners from viewport + * (useful for cleanup of wheel and ticker events when removing viewport) */ @@ -81505,8 +81609,8 @@ var Viewport = function (_PIXI$Container) { this.div.removeEventListener('wheel', this.wheelFunction); } - /** - * overrides PIXI.Container's destroy to also remove the 'wheel' and PIXI.Ticker listeners + /** + * overrides PIXI.Container's destroy to also remove the 'wheel' and PIXI.Ticker listeners */ }, { @@ -81516,9 +81620,9 @@ var Viewport = function (_PIXI$Container) { this.removeListeners(); } - /** - * update animations - * @private + /** + * update animations + * @private */ }, { @@ -81558,12 +81662,12 @@ var Viewport = function (_PIXI$Container) { } } - /** - * use this to set screen and world sizes--needed for pinch/wheel/clamp/bounce - * @param {number} screenWidth - * @param {number} screenHeight - * @param {number} [worldWidth] - * @param {number} [worldHeight] + /** + * use this to set screen and world sizes--needed for pinch/wheel/clamp/bounce + * @param {number} screenWidth + * @param {number} screenHeight + * @param {number} [worldWidth] + * @param {number} [worldHeight] */ }, { @@ -81576,9 +81680,9 @@ var Viewport = function (_PIXI$Container) { this.resizePlugins(); } - /** - * called after a worldWidth/Height change - * @private + /** + * called after a worldWidth/Height change + * @private */ }, { @@ -81610,18 +81714,18 @@ var Viewport = function (_PIXI$Container) { } } - /** - * screen width in screen pixels - * @type {number} + /** + * screen width in screen pixels + * @type {number} */ }, { key: 'listeners', - /** - * add input listeners - * @private + /** + * add input listeners + * @private */ value: function listeners(div) { var _this2 = this; @@ -81643,9 +81747,9 @@ var Viewport = function (_PIXI$Container) { this.leftDown = false; } - /** - * handle down events - * @private + /** + * handle down events + * @private */ }, { @@ -81701,10 +81805,10 @@ var Viewport = function (_PIXI$Container) { } } - /** - * whether change exceeds threshold - * @private - * @param {number} change + /** + * whether change exceeds threshold + * @private + * @param {number} change */ }, { @@ -81716,9 +81820,9 @@ var Viewport = function (_PIXI$Container) { return false; } - /** - * handle move events - * @private + /** + * handle move events + * @private */ }, { @@ -81762,9 +81866,9 @@ var Viewport = function (_PIXI$Container) { } } - /** - * handle up events - * @private + /** + * handle up events + * @private */ }, { @@ -81818,10 +81922,10 @@ var Viewport = function (_PIXI$Container) { } } - /** - * gets pointer position if this.interaction is set - * @param {UIEvent} evt - * @private + /** + * gets pointer position if this.interaction is set + * @param {UIEvent} evt + * @private */ }, { @@ -81837,9 +81941,9 @@ var Viewport = function (_PIXI$Container) { return point; } - /** - * handle wheel events - * @private + /** + * handle wheel events + * @private */ }, { @@ -81884,11 +81988,11 @@ var Viewport = function (_PIXI$Container) { } } - /** - * change coordinates from screen to world - * @param {number|PIXI.Point} x - * @param {number} [y] - * @returns {PIXI.Point} + /** + * change coordinates from screen to world + * @param {number|PIXI.Point} x + * @param {number} [y] + * @returns {PIXI.Point} */ }, { @@ -81903,11 +82007,11 @@ var Viewport = function (_PIXI$Container) { } } - /** - * change coordinates from world to screen - * @param {number|PIXI.Point} x - * @param {number} [y] - * @returns {PIXI.Point} + /** + * change coordinates from world to screen + * @param {number|PIXI.Point} x + * @param {number} [y] + * @returns {PIXI.Point} */ }, { @@ -81923,21 +82027,21 @@ var Viewport = function (_PIXI$Container) { } } - /** - * screen width in world coordinates - * @type {number} - * @readonly + /** + * screen width in world coordinates + * @type {number} + * @readonly */ }, { key: 'moveCenter', - /** - * move center of viewport to point - * @param {(number|PIXI.PointLike)} x or point - * @param {number} [y] - * @return {Viewport} this + /** + * move center of viewport to point + * @param {(number|PIXI.PointLike)} x or point + * @param {number} [y] + * @return {Viewport} this */ value: function moveCenter() /*x, y | PIXI.Point*/{ var x = void 0, @@ -81954,20 +82058,20 @@ var Viewport = function (_PIXI$Container) { return this; } - /** - * top-left corner - * @type {PIXI.PointLike} + /** + * top-left corner + * @type {PIXI.PointLike} */ }, { key: 'moveCorner', - /** - * move viewport's top-left corner; also clamps and resets decelerate and bounce (as needed) - * @param {number|PIXI.Point} x|point - * @param {number} y - * @return {Viewport} this + /** + * move viewport's top-left corner; also clamps and resets decelerate and bounce (as needed) + * @param {number|PIXI.Point} x|point + * @param {number} y + * @return {Viewport} this */ value: function moveCorner() /*x, y | point*/{ if (arguments.length === 1) { @@ -81979,11 +82083,11 @@ var Viewport = function (_PIXI$Container) { return this; } - /** - * change zoom so the width fits in the viewport - * @param {number} [width=this._worldWidth] in world coordinates - * @param {boolean} [center] maintain the same center - * @return {Viewport} this + /** + * change zoom so the width fits in the viewport + * @param {number} [width=this._worldWidth] in world coordinates + * @param {boolean} [center] maintain the same center + * @return {Viewport} this */ }, { @@ -82002,11 +82106,11 @@ var Viewport = function (_PIXI$Container) { return this; } - /** - * change zoom so the height fits in the viewport - * @param {number} [height=this._worldHeight] in world coordinates - * @param {boolean} [center] maintain the same center of the screen after zoom - * @return {Viewport} this + /** + * change zoom so the height fits in the viewport + * @param {number} [height=this._worldHeight] in world coordinates + * @param {boolean} [center] maintain the same center of the screen after zoom + * @return {Viewport} this */ }, { @@ -82025,10 +82129,10 @@ var Viewport = function (_PIXI$Container) { return this; } - /** - * change zoom so it fits the entire world in the viewport - * @param {boolean} [center] maintain the same center of the screen after zoom - * @return {Viewport} this + /** + * change zoom so it fits the entire world in the viewport + * @param {boolean} [center] maintain the same center of the screen after zoom + * @return {Viewport} this */ }, { @@ -82051,12 +82155,12 @@ var Viewport = function (_PIXI$Container) { return this; } - /** - * change zoom so it fits the size or the entire world in the viewport - * @param {boolean} [center] maintain the same center of the screen after zoom - * @param {number} [width] desired width - * @param {number} [height] desired height - * @return {Viewport} this + /** + * change zoom so it fits the size or the entire world in the viewport + * @param {boolean} [center] maintain the same center of the screen after zoom + * @param {number} [width] desired width + * @param {number} [height] desired height + * @return {Viewport} this */ }, { @@ -82081,11 +82185,11 @@ var Viewport = function (_PIXI$Container) { return this; } - /** - * zoom viewport by a certain percent (in both x and y direction) - * @param {number} percent change (e.g., 0.25 would increase a starting scale of 1.0 to 1.25) - * @param {boolean} [center] maintain the same center of the screen after zoom - * @return {Viewport} the viewport + /** + * zoom viewport by a certain percent (in both x and y direction) + * @param {number} percent change (e.g., 0.25 would increase a starting scale of 1.0 to 1.25) + * @param {boolean} [center] maintain the same center of the screen after zoom + * @return {Viewport} the viewport */ }, { @@ -82103,11 +82207,11 @@ var Viewport = function (_PIXI$Container) { return this; } - /** - * zoom viewport by increasing/decreasing width by a certain number of pixels - * @param {number} change in pixels - * @param {boolean} [center] maintain the same center of the screen after zoom - * @return {Viewport} the viewport + /** + * zoom viewport by increasing/decreasing width by a certain number of pixels + * @param {number} change in pixels + * @param {boolean} [center] maintain the same center of the screen after zoom + * @return {Viewport} the viewport */ }, { @@ -82117,17 +82221,17 @@ var Viewport = function (_PIXI$Container) { return this; } - /** - * @param {object} [options] - * @param {number} [options.width] the desired width to snap (to maintain aspect ratio, choose only width or height) - * @param {number} [options.height] the desired height to snap (to maintain aspect ratio, choose only width or height) - * @param {number} [options.time=1000] - * @param {string|function} [options.ease=easeInOutSine] ease function or name (see http://easings.net/ for supported names) - * @param {PIXI.Point} [options.center] place this point at center during zoom instead of center of the viewport - * @param {boolean} [options.interrupt=true] pause snapping with any user input on the viewport - * @param {boolean} [options.removeOnComplete] removes this plugin after snapping is complete - * @param {boolean} [options.removeOnInterrupt] removes this plugin if interrupted by any user input - * @param {boolean} [options.forceStart] starts the snap immediately regardless of whether the viewport is at the desired zoom + /** + * @param {object} [options] + * @param {number} [options.width] the desired width to snap (to maintain aspect ratio, choose only width or height) + * @param {number} [options.height] the desired height to snap (to maintain aspect ratio, choose only width or height) + * @param {number} [options.time=1000] + * @param {string|function} [options.ease=easeInOutSine] ease function or name (see http://easings.net/ for supported names) + * @param {PIXI.Point} [options.center] place this point at center during zoom instead of center of the viewport + * @param {boolean} [options.interrupt=true] pause snapping with any user input on the viewport + * @param {boolean} [options.removeOnComplete] removes this plugin after snapping is complete + * @param {boolean} [options.removeOnInterrupt] removes this plugin if interrupted by any user input + * @param {boolean} [options.forceStart] starts the snap immediately regardless of whether the viewport is at the desired zoom */ }, { @@ -82138,20 +82242,20 @@ var Viewport = function (_PIXI$Container) { return this; } - /** - * @private - * @typedef OutOfBounds - * @type {object} - * @property {boolean} left - * @property {boolean} right - * @property {boolean} top - * @property {boolean} bottom + /** + * @private + * @typedef OutOfBounds + * @type {object} + * @property {boolean} left + * @property {boolean} right + * @property {boolean} top + * @property {boolean} bottom */ - /** - * is container out of world bounds - * @return {OutOfBounds} - * @private + /** + * is container out of world bounds + * @return {OutOfBounds} + * @private */ }, { @@ -82169,28 +82273,28 @@ var Viewport = function (_PIXI$Container) { return result; } - /** - * world coordinates of the right edge of the screen - * @type {number} + /** + * world coordinates of the right edge of the screen + * @type {number} */ }, { key: 'countDownPointers', - /** - * count of mouse/touch pointers that are down on the viewport - * @private - * @return {number} + /** + * count of mouse/touch pointers that are down on the viewport + * @private + * @return {number} */ value: function countDownPointers() { return (this.leftDown ? 1 : 0) + this.touches.length; } - /** - * array of touch pointers that are down on the viewport - * @private - * @return {PIXI.InteractionTrackingData[]} + /** + * array of touch pointers that are down on the viewport + * @private + * @return {PIXI.InteractionTrackingData[]} */ }, { @@ -82207,10 +82311,10 @@ var Viewport = function (_PIXI$Container) { return results; } - /** - * array of pointers that are down on the viewport - * @private - * @return {PIXI.InteractionTrackingData[]} + /** + * array of pointers that are down on the viewport + * @private + * @return {PIXI.InteractionTrackingData[]} */ }, { @@ -82224,9 +82328,9 @@ var Viewport = function (_PIXI$Container) { return results; } - /** - * clamps and resets bounce and decelerate (as needed) after manually moving viewport - * @private + /** + * clamps and resets bounce and decelerate (as needed) after manually moving viewport + * @private */ }, { @@ -82253,9 +82357,9 @@ var Viewport = function (_PIXI$Container) { // PLUGINS - /** - * removes installed plugin - * @param {string} type of plugin (e.g., 'drag', 'pinch') + /** + * removes installed plugin + * @param {string} type of plugin (e.g., 'drag', 'pinch') */ }, { @@ -82268,9 +82372,9 @@ var Viewport = function (_PIXI$Container) { } } - /** - * pause plugin - * @param {string} type of plugin (e.g., 'drag', 'pinch') + /** + * pause plugin + * @param {string} type of plugin (e.g., 'drag', 'pinch') */ }, { @@ -82281,9 +82385,9 @@ var Viewport = function (_PIXI$Container) { } } - /** - * resume plugin - * @param {string} type of plugin (e.g., 'drag', 'pinch') + /** + * resume plugin + * @param {string} type of plugin (e.g., 'drag', 'pinch') */ }, { @@ -82294,9 +82398,9 @@ var Viewport = function (_PIXI$Container) { } } - /** - * sort plugins for updates - * @private + /** + * sort plugins for updates + * @private */ }, { @@ -82331,14 +82435,14 @@ var Viewport = function (_PIXI$Container) { } } - /** - * enable one-finger touch to drag - * @param {object} [options] - * @param {string} [options.direction=all] direction to drag (all, x, or y) - * @param {boolean} [options.wheel=true] use wheel to scroll in y direction (unless wheel plugin is active) - * @param {number} [options.wheelScroll=10] number of pixels to scroll with each wheel spin - * @param {boolean} [options.reverse] reverse the direction of the wheel scroll - * @param {string} [options.underflow=center] (top/bottom/center and left/right/center, or center) where to place world if too small for screen + /** + * enable one-finger touch to drag + * @param {object} [options] + * @param {string} [options.direction=all] direction to drag (all, x, or y) + * @param {boolean} [options.wheel=true] use wheel to scroll in y direction (unless wheel plugin is active) + * @param {number} [options.wheelScroll=10] number of pixels to scroll with each wheel spin + * @param {boolean} [options.reverse] reverse the direction of the wheel scroll + * @param {string} [options.underflow=center] (top/bottom/center and left/right/center, or center) where to place world if too small for screen */ }, { @@ -82349,19 +82453,19 @@ var Viewport = function (_PIXI$Container) { return this; } - /** - * clamp to world boundaries or other provided boundaries - * NOTES: - * clamp is disabled if called with no options; use { direction: 'all' } for all edge clamping - * screenWidth, screenHeight, worldWidth, and worldHeight needs to be set for this to work properly - * @param {object} [options] - * @param {(number|boolean)} [options.left] clamp left; true=0 - * @param {(number|boolean)} [options.right] clamp right; true=viewport.worldWidth - * @param {(number|boolean)} [options.top] clamp top; true=0 - * @param {(number|boolean)} [options.bottom] clamp bottom; true=viewport.worldHeight - * @param {string} [options.direction] (all, x, or y) using clamps of [0, viewport.worldWidth/viewport.worldHeight]; replaces left/right/top/bottom if set - * @param {string} [options.underflow=center] (top/bottom/center and left/right/center, or center) where to place world if too small for screen - * @return {Viewport} this + /** + * clamp to world boundaries or other provided boundaries + * NOTES: + * clamp is disabled if called with no options; use { direction: 'all' } for all edge clamping + * screenWidth, screenHeight, worldWidth, and worldHeight needs to be set for this to work properly + * @param {object} [options] + * @param {(number|boolean)} [options.left] clamp left; true=0 + * @param {(number|boolean)} [options.right] clamp right; true=viewport.worldWidth + * @param {(number|boolean)} [options.top] clamp top; true=0 + * @param {(number|boolean)} [options.bottom] clamp bottom; true=viewport.worldHeight + * @param {string} [options.direction] (all, x, or y) using clamps of [0, viewport.worldWidth/viewport.worldHeight]; replaces left/right/top/bottom if set + * @param {string} [options.underflow=center] (top/bottom/center and left/right/center, or center) where to place world if too small for screen + * @return {Viewport} this */ }, { @@ -82372,13 +82476,13 @@ var Viewport = function (_PIXI$Container) { return this; } - /** - * decelerate after a move - * @param {object} [options] - * @param {number} [options.friction=0.95] percent to decelerate after movement - * @param {number} [options.bounce=0.8] percent to decelerate when past boundaries (only applicable when viewport.bounce() is active) - * @param {number} [options.minSpeed=0.01] minimum velocity before stopping/reversing acceleration - * @return {Viewport} this + /** + * decelerate after a move + * @param {object} [options] + * @param {number} [options.friction=0.95] percent to decelerate after movement + * @param {number} [options.bounce=0.8] percent to decelerate when past boundaries (only applicable when viewport.bounce() is active) + * @param {number} [options.minSpeed=0.01] minimum velocity before stopping/reversing acceleration + * @return {Viewport} this */ }, { @@ -82389,16 +82493,16 @@ var Viewport = function (_PIXI$Container) { return this; } - /** - * bounce on borders - * NOTE: screenWidth, screenHeight, worldWidth, and worldHeight needs to be set for this to work properly - * @param {object} [options] - * @param {string} [options.sides=all] all, horizontal, vertical, or combination of top, bottom, right, left (e.g., 'top-bottom-right') - * @param {number} [options.friction=0.5] friction to apply to decelerate if active - * @param {number} [options.time=150] time in ms to finish bounce - * @param {string|function} [options.ease=easeInOutSine] ease function or name (see http://easings.net/ for supported names) - * @param {string} [options.underflow=center] (top/bottom/center and left/right/center, or center) where to place world if too small for screen - * @return {Viewport} this + /** + * bounce on borders + * NOTE: screenWidth, screenHeight, worldWidth, and worldHeight needs to be set for this to work properly + * @param {object} [options] + * @param {string} [options.sides=all] all, horizontal, vertical, or combination of top, bottom, right, left (e.g., 'top-bottom-right') + * @param {number} [options.friction=0.5] friction to apply to decelerate if active + * @param {number} [options.time=150] time in ms to finish bounce + * @param {string|function} [options.ease=easeInOutSine] ease function or name (see http://easings.net/ for supported names) + * @param {string} [options.underflow=center] (top/bottom/center and left/right/center, or center) where to place world if too small for screen + * @return {Viewport} this */ }, { @@ -82409,13 +82513,13 @@ var Viewport = function (_PIXI$Container) { return this; } - /** - * enable pinch to zoom and two-finger touch to drag - * NOTE: screenWidth, screenHeight, worldWidth, and worldHeight needs to be set for this to work properly - * @param {number} [options.percent=1.0] percent to modify pinch speed - * @param {boolean} [options.noDrag] disable two-finger dragging - * @param {PIXI.Point} [options.center] place this point at center during zoom instead of center of two fingers - * @return {Viewport} this + /** + * enable pinch to zoom and two-finger touch to drag + * NOTE: screenWidth, screenHeight, worldWidth, and worldHeight needs to be set for this to work properly + * @param {number} [options.percent=1.0] percent to modify pinch speed + * @param {boolean} [options.noDrag] disable two-finger dragging + * @param {PIXI.Point} [options.center] place this point at center during zoom instead of center of two fingers + * @return {Viewport} this */ }, { @@ -82426,20 +82530,20 @@ var Viewport = function (_PIXI$Container) { return this; } - /** - * snap to a point - * @param {number} x - * @param {number} y - * @param {object} [options] - * @param {boolean} [options.topLeft] snap to the top-left of viewport instead of center - * @param {number} [options.friction=0.8] friction/frame to apply if decelerate is active - * @param {number} [options.time=1000] - * @param {string|function} [options.ease=easeInOutSine] ease function or name (see http://easings.net/ for supported names) - * @param {boolean} [options.interrupt=true] pause snapping with any user input on the viewport - * @param {boolean} [options.removeOnComplete] removes this plugin after snapping is complete - * @param {boolean} [options.removeOnInterrupt] removes this plugin if interrupted by any user input - * @param {boolean} [options.forceStart] starts the snap immediately regardless of whether the viewport is at the desired location - * @return {Viewport} this + /** + * snap to a point + * @param {number} x + * @param {number} y + * @param {object} [options] + * @param {boolean} [options.topLeft] snap to the top-left of viewport instead of center + * @param {number} [options.friction=0.8] friction/frame to apply if decelerate is active + * @param {number} [options.time=1000] + * @param {string|function} [options.ease=easeInOutSine] ease function or name (see http://easings.net/ for supported names) + * @param {boolean} [options.interrupt=true] pause snapping with any user input on the viewport + * @param {boolean} [options.removeOnComplete] removes this plugin after snapping is complete + * @param {boolean} [options.removeOnInterrupt] removes this plugin if interrupted by any user input + * @param {boolean} [options.forceStart] starts the snap immediately regardless of whether the viewport is at the desired location + * @return {Viewport} this */ }, { @@ -82450,13 +82554,13 @@ var Viewport = function (_PIXI$Container) { return this; } - /** - * follow a target - * @param {PIXI.DisplayObject} target to follow (object must include {x: x-coordinate, y: y-coordinate}) - * @param {object} [options] - * @param {number} [options.speed=0] to follow in pixels/frame (0=teleport to location) - * @param {number} [options.radius] radius (in world coordinates) of center circle where movement is allowed without moving the viewport - * @return {Viewport} this + /** + * follow a target + * @param {PIXI.DisplayObject} target to follow (object must include {x: x-coordinate, y: y-coordinate}) + * @param {object} [options] + * @param {number} [options.speed=0] to follow in pixels/frame (0=teleport to location) + * @param {number} [options.radius] radius (in world coordinates) of center circle where movement is allowed without moving the viewport + * @return {Viewport} this */ }, { @@ -82467,13 +82571,13 @@ var Viewport = function (_PIXI$Container) { return this; } - /** - * zoom using mouse wheel - * @param {object} [options] - * @param {number} [options.percent=0.1] percent to scroll with each spin - * @param {boolean} [options.reverse] reverse the direction of the scroll - * @param {PIXI.Point} [options.center] place this point at center during zoom instead of current mouse position - * @return {Viewport} this + /** + * zoom using mouse wheel + * @param {object} [options] + * @param {number} [options.percent=0.1] percent to scroll with each spin + * @param {boolean} [options.reverse] reverse the direction of the scroll + * @param {PIXI.Point} [options.center] place this point at center during zoom instead of current mouse position + * @return {Viewport} this */ }, { @@ -82484,15 +82588,15 @@ var Viewport = function (_PIXI$Container) { return this; } - /** - * enable clamping of zoom to constraints - * NOTE: screenWidth, screenHeight, worldWidth, and worldHeight needs to be set for this to work properly - * @param {object} [options] - * @param {number} [options.minWidth] minimum width - * @param {number} [options.minHeight] minimum height - * @param {number} [options.maxWidth] maximum width - * @param {number} [options.maxHeight] maximum height - * @return {Viewport} this + /** + * enable clamping of zoom to constraints + * NOTE: screenWidth, screenHeight, worldWidth, and worldHeight needs to be set for this to work properly + * @param {object} [options] + * @param {number} [options.minWidth] minimum width + * @param {number} [options.minHeight] minimum height + * @param {number} [options.maxWidth] maximum width + * @param {number} [options.maxHeight] maximum height + * @return {Viewport} this */ }, { @@ -82503,19 +82607,19 @@ var Viewport = function (_PIXI$Container) { return this; } - /** - * Scroll viewport when mouse hovers near one of the edges or radius-distance from center of screen. - * @param {object} [options] - * @param {number} [options.radius] distance from center of screen in screen pixels - * @param {number} [options.distance] distance from all sides in screen pixels - * @param {number} [options.top] alternatively, set top distance (leave unset for no top scroll) - * @param {number} [options.bottom] alternatively, set bottom distance (leave unset for no top scroll) - * @param {number} [options.left] alternatively, set left distance (leave unset for no top scroll) - * @param {number} [options.right] alternatively, set right distance (leave unset for no top scroll) - * @param {number} [options.speed=8] speed in pixels/frame to scroll viewport - * @param {boolean} [options.reverse] reverse direction of scroll - * @param {boolean} [options.noDecelerate] don't use decelerate plugin even if it's installed - * @param {boolean} [options.linear] if using radius, use linear movement (+/- 1, +/- 1) instead of angled movement (Math.cos(angle from center), Math.sin(angle from center)) + /** + * Scroll viewport when mouse hovers near one of the edges or radius-distance from center of screen. + * @param {object} [options] + * @param {number} [options.radius] distance from center of screen in screen pixels + * @param {number} [options.distance] distance from all sides in screen pixels + * @param {number} [options.top] alternatively, set top distance (leave unset for no top scroll) + * @param {number} [options.bottom] alternatively, set bottom distance (leave unset for no top scroll) + * @param {number} [options.left] alternatively, set left distance (leave unset for no top scroll) + * @param {number} [options.right] alternatively, set right distance (leave unset for no top scroll) + * @param {number} [options.speed=8] speed in pixels/frame to scroll viewport + * @param {boolean} [options.reverse] reverse direction of scroll + * @param {boolean} [options.noDecelerate] don't use decelerate plugin even if it's installed + * @param {boolean} [options.linear] if using radius, use linear movement (+/- 1, +/- 1) instead of angled movement (Math.cos(angle from center), Math.sin(angle from center)) */ }, { @@ -82526,10 +82630,10 @@ var Viewport = function (_PIXI$Container) { return this; } - /** - * pause viewport (including animation updates such as decelerate) - * NOTE: when setting pause=true, all touches and mouse actions are cleared (i.e., if mousedown was active, it becomes inactive for purposes of the viewport) - * @type {boolean} + /** + * pause viewport (including animation updates such as decelerate) + * NOTE: when setting pause=true, all touches and mouse actions are cleared (i.e., if mousedown was active, it becomes inactive for purposes of the viewport) + * @type {boolean} */ }, { @@ -82541,9 +82645,9 @@ var Viewport = function (_PIXI$Container) { this._screenWidth = value; } - /** - * screen height in screen pixels - * @type {number} + /** + * screen height in screen pixels + * @type {number} */ }, { @@ -82555,9 +82659,9 @@ var Viewport = function (_PIXI$Container) { this._screenHeight = value; } - /** - * world width in pixels - * @type {number} + /** + * world width in pixels + * @type {number} */ }, { @@ -82574,9 +82678,9 @@ var Viewport = function (_PIXI$Container) { this.resizePlugins(); } - /** - * world height in pixels - * @type {number} + /** + * world height in pixels + * @type {number} */ }, { @@ -82598,10 +82702,10 @@ var Viewport = function (_PIXI$Container) { return this._screenWidth / this.scale.x; } - /** - * screen height in world coordinates - * @type {number} - * @readonly + /** + * screen height in world coordinates + * @type {number} + * @readonly */ }, { @@ -82610,10 +82714,10 @@ var Viewport = function (_PIXI$Container) { return this._screenHeight / this.scale.y; } - /** - * world width in screen coordinates - * @type {number} - * @readonly + /** + * world width in screen coordinates + * @type {number} + * @readonly */ }, { @@ -82622,10 +82726,10 @@ var Viewport = function (_PIXI$Container) { return this._worldWidth * this.scale.x; } - /** - * world height in screen coordinates - * @type {number} - * @readonly + /** + * world height in screen coordinates + * @type {number} + * @readonly */ }, { @@ -82634,9 +82738,9 @@ var Viewport = function (_PIXI$Container) { return this._worldHeight * this.scale.y; } - /** - * get center of screen in world coordinates - * @type {PIXI.PointLike} + /** + * get center of screen in world coordinates + * @type {PIXI.PointLike} */ }, { @@ -82665,9 +82769,9 @@ var Viewport = function (_PIXI$Container) { this._reset(); } - /** - * world coordinates of the left edge of the screen - * @type {number} + /** + * world coordinates of the left edge of the screen + * @type {number} */ }, { @@ -82680,9 +82784,9 @@ var Viewport = function (_PIXI$Container) { this._reset(); } - /** - * world coordinates of the top edge of the screen - * @type {number} + /** + * world coordinates of the top edge of the screen + * @type {number} */ }, { @@ -82695,9 +82799,9 @@ var Viewport = function (_PIXI$Container) { this._reset(); } - /** - * world coordinates of the bottom edge of the screen - * @type {number} + /** + * world coordinates of the bottom edge of the screen + * @type {number} */ }, { @@ -82709,9 +82813,9 @@ var Viewport = function (_PIXI$Container) { this.y = -value * this.scale.y + this.screenHeight; this._reset(); } - /** - * determines whether the viewport is dirty (i.e., needs to be renderered to the screen because of a change) - * @type {boolean} + /** + * determines whether the viewport is dirty (i.e., needs to be renderered to the screen because of a change) + * @type {boolean} */ }, { @@ -82723,10 +82827,10 @@ var Viewport = function (_PIXI$Container) { this._dirty = value; } - /** - * permanently changes the Viewport's hitArea - *
NOTE: normally the hitArea = PIXI.Rectangle(Viewport.left, Viewport.top, Viewport.worldScreenWidth, Viewport.worldScreenHeight)
- * @type {(PIXI.Rectangle|PIXI.Circle|PIXI.Ellipse|PIXI.Polygon|PIXI.RoundedRectangle)} + /** + * permanently changes the Viewport's hitArea + *NOTE: normally the hitArea = PIXI.Rectangle(Viewport.left, Viewport.top, Viewport.worldScreenWidth, Viewport.worldScreenHeight)
+ * @type {(PIXI.Rectangle|PIXI.Circle|PIXI.Ellipse|PIXI.Polygon|PIXI.RoundedRectangle)} */ }, { @@ -82760,136 +82864,136 @@ var Viewport = function (_PIXI$Container) { return Viewport; }(PIXI.Container); -/** - * fires after a mouse or touch click - * @event Viewport#clicked - * @type {object} - * @property {PIXI.PointLike} screen - * @property {PIXI.PointLike} world - * @property {Viewport} viewport +/** + * fires after a mouse or touch click + * @event Viewport#clicked + * @type {object} + * @property {PIXI.PointLike} screen + * @property {PIXI.PointLike} world + * @property {Viewport} viewport */ -/** - * fires when a drag starts - * @event Viewport#drag-start - * @type {object} - * @property {PIXI.PointLike} screen - * @property {PIXI.PointLike} world - * @property {Viewport} viewport +/** + * fires when a drag starts + * @event Viewport#drag-start + * @type {object} + * @property {PIXI.PointLike} screen + * @property {PIXI.PointLike} world + * @property {Viewport} viewport */ -/** - * fires when a drag ends - * @event Viewport#drag-end - * @type {object} - * @property {PIXI.PointLike} screen - * @property {PIXI.PointLike} world - * @property {Viewport} viewport +/** + * fires when a drag ends + * @event Viewport#drag-end + * @type {object} + * @property {PIXI.PointLike} screen + * @property {PIXI.PointLike} world + * @property {Viewport} viewport */ -/** - * fires when a pinch starts - * @event Viewport#pinch-start - * @type {Viewport} +/** + * fires when a pinch starts + * @event Viewport#pinch-start + * @type {Viewport} */ -/** - * fires when a pinch end - * @event Viewport#pinch-end - * @type {Viewport} +/** + * fires when a pinch end + * @event Viewport#pinch-end + * @type {Viewport} */ -/** - * fires when a snap starts - * @event Viewport#snap-start - * @type {Viewport} +/** + * fires when a snap starts + * @event Viewport#snap-start + * @type {Viewport} */ -/** - * fires when a snap ends - * @event Viewport#snap-end - * @type {Viewport} +/** + * fires when a snap ends + * @event Viewport#snap-end + * @type {Viewport} */ -/** - * fires when a snap-zoom starts - * @event Viewport#snap-zoom-start - * @type {Viewport} +/** + * fires when a snap-zoom starts + * @event Viewport#snap-zoom-start + * @type {Viewport} */ -/** - * fires when a snap-zoom ends - * @event Viewport#snap-zoom-end - * @type {Viewport} +/** + * fires when a snap-zoom ends + * @event Viewport#snap-zoom-end + * @type {Viewport} */ -/** - * fires when a bounce starts in the x direction - * @event Viewport#bounce-x-start - * @type {Viewport} +/** + * fires when a bounce starts in the x direction + * @event Viewport#bounce-x-start + * @type {Viewport} */ -/** - * fires when a bounce ends in the x direction - * @event Viewport#bounce-x-end - * @type {Viewport} +/** + * fires when a bounce ends in the x direction + * @event Viewport#bounce-x-end + * @type {Viewport} */ -/** - * fires when a bounce starts in the y direction - * @event Viewport#bounce-y-start - * @type {Viewport} +/** + * fires when a bounce starts in the y direction + * @event Viewport#bounce-y-start + * @type {Viewport} */ -/** - * fires when a bounce ends in the y direction - * @event Viewport#bounce-y-end - * @type {Viewport} +/** + * fires when a bounce ends in the y direction + * @event Viewport#bounce-y-end + * @type {Viewport} */ -/** - * fires when for a mouse wheel event - * @event Viewport#wheel - * @type {object} - * @property {object} wheel - * @property {number} wheel.dx - * @property {number} wheel.dy - * @property {number} wheel.dz - * @property {Viewport} viewport +/** + * fires when for a mouse wheel event + * @event Viewport#wheel + * @type {object} + * @property {object} wheel + * @property {number} wheel.dx + * @property {number} wheel.dy + * @property {number} wheel.dz + * @property {Viewport} viewport */ -/** - * fires when a wheel-scroll occurs - * @event Viewport#wheel-scroll - * @type {Viewport} +/** + * fires when a wheel-scroll occurs + * @event Viewport#wheel-scroll + * @type {Viewport} */ -/** - * fires when a mouse-edge starts to scroll - * @event Viewport#mouse-edge-start - * @type {Viewport} +/** + * fires when a mouse-edge starts to scroll + * @event Viewport#mouse-edge-start + * @type {Viewport} */ -/** - * fires when the mouse-edge scrolling ends - * @event Viewport#mouse-edge-end - * @type {Viewport} +/** + * fires when the mouse-edge scrolling ends + * @event Viewport#mouse-edge-end + * @type {Viewport} */ -/** - * fires when viewport moves through UI interaction, deceleration, or follow - * @event Viewport#moved - * @type {object} - * @property {Viewport} viewport - * @property {string} type (drag, snap, pinch, follow, bounce-x, bounce-y, clamp-x, clamp-y, decelerate, mouse-edges, wheel) +/** + * fires when viewport moves through UI interaction, deceleration, or follow + * @event Viewport#moved + * @type {object} + * @property {Viewport} viewport + * @property {string} type (drag, snap, pinch, follow, bounce-x, bounce-y, clamp-x, clamp-y, decelerate, mouse-edges, wheel) */ -/** - * fires when viewport moves through UI interaction, deceleration, or follow - * @event Viewport#zoomed - * @type {object} - * @property {Viewport} viewport - * @property {string} type (drag-zoom, pinch, wheel, clamp-zoom) +/** + * fires when viewport moves through UI interaction, deceleration, or follow + * @event Viewport#zoomed + * @type {object} + * @property {Viewport} viewport + * @property {string} type (drag-zoom, pinch, wheel, clamp-zoom) */ PIXI.extras.Viewport = Viewport; @@ -82912,15 +83016,15 @@ var Plugin = require('./plugin'); module.exports = function (_Plugin) { _inherits(Wheel, _Plugin); - /** - * @private - * @param {Viewport} parent - * @param {object} [options] - * @param {number} [options.percent=0.1] percent to scroll with each spin - * @param {boolean} [options.reverse] reverse the direction of the scroll - * @param {PIXI.Point} [options.center] place this point at center during zoom instead of current mouse position - * - * @event wheel({wheel: {dx, dy, dz}, event, viewport}) + /** + * @private + * @param {Viewport} parent + * @param {object} [options] + * @param {number} [options.percent=0.1] percent to scroll with each spin + * @param {boolean} [options.reverse] reverse the direction of the scroll + * @param {PIXI.Point} [options.center] place this point at center during zoom instead of current mouse position + * + * @event wheel({wheel: {dx, dy, dz}, event, viewport}) */ function Wheel(parent, options) { _classCallCheck(this, Wheel); diff --git a/dist/iwmlib.3rdparty.min.js b/dist/iwmlib.3rdparty.min.js index 8aba46c..b0a63c2 100644 --- a/dist/iwmlib.3rdparty.min.js +++ b/dist/iwmlib.3rdparty.min.js @@ -1 +1 @@ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.OptimalSelect=e():t.OptimalSelect=e()}(this,function(){return function(r){var i={};function n(t){if(i[t])return i[t].exports;var e=i[t]={i:t,l:!1,exports:{}};return r[t].call(e.exports,e,e.exports,n),e.l=!0,e.exports}return n.m=r,n.c=i,n.i=function(t){return t},n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:r})},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=6)}([function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.convertNodeList=function(t){for(var e=t.length,r=new Array(e),i=0;i