pixi5-dragonbones
Version:
PixiJS plugin for DragonBones
1,316 lines • 749 kB
JavaScript
"use strict";
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 __());
};
})();
/**
* The MIT License (MIT)
*
* Copyright (c) 2012-2018 DragonBones team and other contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
var dragonBones;
(function (dragonBones) {
/**
* @private
*/
var DragonBones = /** @class */ (function () {
function DragonBones(eventManager) {
this._clock = new dragonBones.WorldClock();
this._events = [];
this._objects = [];
this._eventManager = null;
this._eventManager = eventManager;
console.info("DragonBones: " + DragonBones.VERSION + "\nWebsite: http://dragonbones.com/\nSource and Demo: https://github.com/DragonBones/");
}
DragonBones.prototype.advanceTime = function (passedTime) {
if (this._objects.length > 0) {
for (var _i = 0, _a = this._objects; _i < _a.length; _i++) {
var object = _a[_i];
object.returnToPool();
}
this._objects.length = 0;
}
this._clock.advanceTime(passedTime);
if (this._events.length > 0) {
for (var i = 0; i < this._events.length; ++i) {
var eventObject = this._events[i];
var armature = eventObject.armature;
if (armature._armatureData !== null) { // May be armature disposed before advanceTime.
armature.eventDispatcher.dispatchDBEvent(eventObject.type, eventObject);
if (eventObject.type === dragonBones.EventObject.SOUND_EVENT) {
this._eventManager.dispatchDBEvent(eventObject.type, eventObject);
}
}
this.bufferObject(eventObject);
}
this._events.length = 0;
}
};
DragonBones.prototype.bufferEvent = function (value) {
if (this._events.indexOf(value) < 0) {
this._events.push(value);
}
};
DragonBones.prototype.bufferObject = function (object) {
if (this._objects.indexOf(object) < 0) {
this._objects.push(object);
}
};
Object.defineProperty(DragonBones.prototype, "clock", {
get: function () {
return this._clock;
},
enumerable: true,
configurable: true
});
Object.defineProperty(DragonBones.prototype, "eventManager", {
get: function () {
return this._eventManager;
},
enumerable: true,
configurable: true
});
DragonBones.VERSION = "5.7.000";
DragonBones.yDown = true;
DragonBones.debug = false;
DragonBones.debugDraw = false;
return DragonBones;
}());
dragonBones.DragonBones = DragonBones;
})(dragonBones || (dragonBones = {}));
//
if (!console.warn) {
console.warn = function () { };
}
if (!console.assert) {
console.assert = function () { };
}
//
if (!Date.now) {
Date.now = function now() {
return new Date().getTime();
};
}
// Weixin can not support typescript extends.
var __extends = function (t, e) {
function r() {
this.constructor = t;
}
for (var i in e) {
if (e.hasOwnProperty(i)) {
t[i] = e[i];
}
}
r.prototype = e.prototype, t.prototype = new r();
};
//
if (typeof global === "undefined" && typeof window !== "undefined") {
var global = window;
}
if (typeof exports === "object" && typeof module === "object") {
module.exports = dragonBones;
}
else if (typeof define === "function" && define["amd"]) {
define(["dragonBones"], function () { return dragonBones; });
}
else if (typeof exports === "object") {
exports = dragonBones;
}
else if (typeof global !== "undefined") {
global.dragonBones = dragonBones;
}
/**
* The MIT License (MIT)
*
* Copyright (c) 2012-2018 DragonBones team and other contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
var dragonBones;
(function (dragonBones) {
/**
* - The BaseObject is the base class for all objects in the DragonBones framework.
* All BaseObject instances are cached to the object pool to reduce the performance consumption of frequent requests for memory or memory recovery.
* @version DragonBones 4.5
* @language en_US
*/
/**
* - 基础对象,通常 DragonBones 的对象都继承自该类。
* 所有基础对象的实例都会缓存到对象池,以减少频繁申请内存或内存回收的性能消耗。
* @version DragonBones 4.5
* @language zh_CN
*/
var BaseObject = /** @class */ (function () {
function BaseObject() {
/**
* - A unique identification number assigned to the object.
* @version DragonBones 4.5
* @language en_US
*/
/**
* - 分配给此实例的唯一标识号。
* @version DragonBones 4.5
* @language zh_CN
*/
this.hashCode = BaseObject._hashCode++;
this._isInPool = false;
}
BaseObject._returnObject = function (object) {
var classType = String(object.constructor);
var maxCount = classType in BaseObject._maxCountMap ? BaseObject._maxCountMap[classType] : BaseObject._defaultMaxCount;
var pool = BaseObject._poolsMap[classType] = BaseObject._poolsMap[classType] || [];
if (pool.length < maxCount) {
if (!object._isInPool) {
object._isInPool = true;
pool.push(object);
}
else {
console.warn("The object is already in the pool.");
}
}
else {
}
};
BaseObject.toString = function () {
throw new Error();
};
/**
* - Set the maximum cache count of the specify object pool.
* @param objectConstructor - The specify class. (Set all object pools max cache count if not set)
* @param maxCount - Max count.
* @version DragonBones 4.5
* @language en_US
*/
/**
* - 设置特定对象池的最大缓存数量。
* @param objectConstructor - 特定的类。 (不设置则设置所有对象池的最大缓存数量)
* @param maxCount - 最大缓存数量。
* @version DragonBones 4.5
* @language zh_CN
*/
BaseObject.setMaxCount = function (objectConstructor, maxCount) {
if (maxCount < 0 || maxCount !== maxCount) { // isNaN
maxCount = 0;
}
if (objectConstructor !== null) {
var classType = String(objectConstructor);
var pool = classType in BaseObject._poolsMap ? BaseObject._poolsMap[classType] : null;
if (pool !== null && pool.length > maxCount) {
pool.length = maxCount;
}
BaseObject._maxCountMap[classType] = maxCount;
}
else {
BaseObject._defaultMaxCount = maxCount;
for (var classType in BaseObject._poolsMap) {
var pool = BaseObject._poolsMap[classType];
if (pool.length > maxCount) {
pool.length = maxCount;
}
if (classType in BaseObject._maxCountMap) {
BaseObject._maxCountMap[classType] = maxCount;
}
}
}
};
/**
* - Clear the cached instances of a specify object pool.
* @param objectConstructor - Specify class. (Clear all cached instances if not set)
* @version DragonBones 4.5
* @language en_US
*/
/**
* - 清除特定对象池的缓存实例。
* @param objectConstructor - 特定的类。 (不设置则清除所有缓存的实例)
* @version DragonBones 4.5
* @language zh_CN
*/
BaseObject.clearPool = function (objectConstructor) {
if (objectConstructor === void 0) { objectConstructor = null; }
if (objectConstructor !== null) {
var classType = String(objectConstructor);
var pool = classType in BaseObject._poolsMap ? BaseObject._poolsMap[classType] : null;
if (pool !== null && pool.length > 0) {
pool.length = 0;
}
}
else {
for (var k in BaseObject._poolsMap) {
var pool = BaseObject._poolsMap[k];
pool.length = 0;
}
}
};
/**
* - Get an instance of the specify class from object pool.
* @param objectConstructor - The specify class.
* @version DragonBones 4.5
* @language en_US
*/
/**
* - 从对象池中获取特定类的实例。
* @param objectConstructor - 特定的类。
* @version DragonBones 4.5
* @language zh_CN
*/
BaseObject.borrowObject = function (objectConstructor) {
var classType = String(objectConstructor);
var pool = classType in BaseObject._poolsMap ? BaseObject._poolsMap[classType] : null;
if (pool !== null && pool.length > 0) {
var object_1 = pool.pop();
object_1._isInPool = false;
return object_1;
}
var object = new objectConstructor();
object._onClear();
return object;
};
/**
* - Clear the object and return it back to object pool。
* @version DragonBones 4.5
* @language en_US
*/
/**
* - 清除该实例的所有数据并将其返还对象池。
* @version DragonBones 4.5
* @language zh_CN
*/
BaseObject.prototype.returnToPool = function () {
this._onClear();
BaseObject._returnObject(this);
};
BaseObject._hashCode = 0;
BaseObject._defaultMaxCount = 3000;
BaseObject._maxCountMap = {};
BaseObject._poolsMap = {};
return BaseObject;
}());
dragonBones.BaseObject = BaseObject;
})(dragonBones || (dragonBones = {}));
/**
* The MIT License (MIT)
*
* Copyright (c) 2012-2018 DragonBones team and other contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
var dragonBones;
(function (dragonBones) {
/**
* - 2D Transform matrix.
* @version DragonBones 3.0
* @language en_US
*/
/**
* - 2D 转换矩阵。
* @version DragonBones 3.0
* @language zh_CN
*/
var Matrix = /** @class */ (function () {
/**
* @private
*/
function Matrix(a, b, c, d, tx, ty) {
if (a === void 0) { a = 1.0; }
if (b === void 0) { b = 0.0; }
if (c === void 0) { c = 0.0; }
if (d === void 0) { d = 1.0; }
if (tx === void 0) { tx = 0.0; }
if (ty === void 0) { ty = 0.0; }
this.a = a;
this.b = b;
this.c = c;
this.d = d;
this.tx = tx;
this.ty = ty;
}
Matrix.prototype.toString = function () {
return "[object dragonBones.Matrix] a:" + this.a + " b:" + this.b + " c:" + this.c + " d:" + this.d + " tx:" + this.tx + " ty:" + this.ty;
};
/**
* @private
*/
Matrix.prototype.copyFrom = function (value) {
this.a = value.a;
this.b = value.b;
this.c = value.c;
this.d = value.d;
this.tx = value.tx;
this.ty = value.ty;
return this;
};
/**
* @private
*/
Matrix.prototype.copyFromArray = function (value, offset) {
if (offset === void 0) { offset = 0; }
this.a = value[offset];
this.b = value[offset + 1];
this.c = value[offset + 2];
this.d = value[offset + 3];
this.tx = value[offset + 4];
this.ty = value[offset + 5];
return this;
};
/**
* - Convert to unit matrix.
* The resulting matrix has the following properties: a=1, b=0, c=0, d=1, tx=0, ty=0.
* @version DragonBones 3.0
* @language en_US
*/
/**
* - 转换为单位矩阵。
* 该矩阵具有以下属性:a=1、b=0、c=0、d=1、tx=0、ty=0。
* @version DragonBones 3.0
* @language zh_CN
*/
Matrix.prototype.identity = function () {
this.a = this.d = 1.0;
this.b = this.c = 0.0;
this.tx = this.ty = 0.0;
return this;
};
/**
* - Multiplies the current matrix with another matrix.
* @param value - The matrix that needs to be multiplied.
* @version DragonBones 3.0
* @language en_US
*/
/**
* - 将当前矩阵与另一个矩阵相乘。
* @param value - 需要相乘的矩阵。
* @version DragonBones 3.0
* @language zh_CN
*/
Matrix.prototype.concat = function (value) {
var aA = this.a * value.a;
var bA = 0.0;
var cA = 0.0;
var dA = this.d * value.d;
var txA = this.tx * value.a + value.tx;
var tyA = this.ty * value.d + value.ty;
if (this.b !== 0.0 || this.c !== 0.0) {
aA += this.b * value.c;
bA += this.b * value.d;
cA += this.c * value.a;
dA += this.c * value.b;
}
if (value.b !== 0.0 || value.c !== 0.0) {
bA += this.a * value.b;
cA += this.d * value.c;
txA += this.ty * value.c;
tyA += this.tx * value.b;
}
this.a = aA;
this.b = bA;
this.c = cA;
this.d = dA;
this.tx = txA;
this.ty = tyA;
return this;
};
/**
* - Convert to inverse matrix.
* @version DragonBones 3.0
* @language en_US
*/
/**
* - 转换为逆矩阵。
* @version DragonBones 3.0
* @language zh_CN
*/
Matrix.prototype.invert = function () {
var aA = this.a;
var bA = this.b;
var cA = this.c;
var dA = this.d;
var txA = this.tx;
var tyA = this.ty;
if (bA === 0.0 && cA === 0.0) {
this.b = this.c = 0.0;
if (aA === 0.0 || dA === 0.0) {
this.a = this.b = this.tx = this.ty = 0.0;
}
else {
aA = this.a = 1.0 / aA;
dA = this.d = 1.0 / dA;
this.tx = -aA * txA;
this.ty = -dA * tyA;
}
return this;
}
var determinant = aA * dA - bA * cA;
if (determinant === 0.0) {
this.a = this.d = 1.0;
this.b = this.c = 0.0;
this.tx = this.ty = 0.0;
return this;
}
determinant = 1.0 / determinant;
var k = this.a = dA * determinant;
bA = this.b = -bA * determinant;
cA = this.c = -cA * determinant;
dA = this.d = aA * determinant;
this.tx = -(k * txA + cA * tyA);
this.ty = -(bA * txA + dA * tyA);
return this;
};
/**
* - Apply a matrix transformation to a specific point.
* @param x - X coordinate.
* @param y - Y coordinate.
* @param result - The point after the transformation is applied.
* @param delta - Whether to ignore tx, ty's conversion to point.
* @version DragonBones 3.0
* @language en_US
*/
/**
* - 将矩阵转换应用于特定点。
* @param x - 横坐标。
* @param y - 纵坐标。
* @param result - 应用转换之后的点。
* @param delta - 是否忽略 tx,ty 对点的转换。
* @version DragonBones 3.0
* @language zh_CN
*/
Matrix.prototype.transformPoint = function (x, y, result, delta) {
if (delta === void 0) { delta = false; }
result.x = this.a * x + this.c * y;
result.y = this.b * x + this.d * y;
if (!delta) {
result.x += this.tx;
result.y += this.ty;
}
};
/**
* @private
*/
Matrix.prototype.transformRectangle = function (rectangle, delta) {
if (delta === void 0) { delta = false; }
var a = this.a;
var b = this.b;
var c = this.c;
var d = this.d;
var tx = delta ? 0.0 : this.tx;
var ty = delta ? 0.0 : this.ty;
var x = rectangle.x;
var y = rectangle.y;
var xMax = x + rectangle.width;
var yMax = y + rectangle.height;
var x0 = a * x + c * y + tx;
var y0 = b * x + d * y + ty;
var x1 = a * xMax + c * y + tx;
var y1 = b * xMax + d * y + ty;
var x2 = a * xMax + c * yMax + tx;
var y2 = b * xMax + d * yMax + ty;
var x3 = a * x + c * yMax + tx;
var y3 = b * x + d * yMax + ty;
var tmp = 0.0;
if (x0 > x1) {
tmp = x0;
x0 = x1;
x1 = tmp;
}
if (x2 > x3) {
tmp = x2;
x2 = x3;
x3 = tmp;
}
rectangle.x = Math.floor(x0 < x2 ? x0 : x2);
rectangle.width = Math.ceil((x1 > x3 ? x1 : x3) - rectangle.x);
if (y0 > y1) {
tmp = y0;
y0 = y1;
y1 = tmp;
}
if (y2 > y3) {
tmp = y2;
y2 = y3;
y3 = tmp;
}
rectangle.y = Math.floor(y0 < y2 ? y0 : y2);
rectangle.height = Math.ceil((y1 > y3 ? y1 : y3) - rectangle.y);
};
return Matrix;
}());
dragonBones.Matrix = Matrix;
})(dragonBones || (dragonBones = {}));
/**
* The MIT License (MIT)
*
* Copyright (c) 2012-2018 DragonBones team and other contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
var dragonBones;
(function (dragonBones) {
/**
* - 2D Transform.
* @version DragonBones 3.0
* @language en_US
*/
/**
* - 2D 变换。
* @version DragonBones 3.0
* @language zh_CN
*/
var Transform = /** @class */ (function () {
/**
* @private
*/
function Transform(x, y, skew, rotation, scaleX, scaleY) {
if (x === void 0) { x = 0.0; }
if (y === void 0) { y = 0.0; }
if (skew === void 0) { skew = 0.0; }
if (rotation === void 0) { rotation = 0.0; }
if (scaleX === void 0) { scaleX = 1.0; }
if (scaleY === void 0) { scaleY = 1.0; }
this.x = x;
this.y = y;
this.skew = skew;
this.rotation = rotation;
this.scaleX = scaleX;
this.scaleY = scaleY;
}
/**
* @private
*/
Transform.normalizeRadian = function (value) {
value = (value + Math.PI) % (Math.PI * 2.0);
value += value > 0.0 ? -Math.PI : Math.PI;
return value;
};
Transform.prototype.toString = function () {
return "[object dragonBones.Transform] x:" + this.x + " y:" + this.y + " skewX:" + this.skew * 180.0 / Math.PI + " skewY:" + this.rotation * 180.0 / Math.PI + " scaleX:" + this.scaleX + " scaleY:" + this.scaleY;
};
/**
* @private
*/
Transform.prototype.copyFrom = function (value) {
this.x = value.x;
this.y = value.y;
this.skew = value.skew;
this.rotation = value.rotation;
this.scaleX = value.scaleX;
this.scaleY = value.scaleY;
return this;
};
/**
* @private
*/
Transform.prototype.identity = function () {
this.x = this.y = 0.0;
this.skew = this.rotation = 0.0;
this.scaleX = this.scaleY = 1.0;
return this;
};
/**
* @private
*/
Transform.prototype.add = function (value) {
this.x += value.x;
this.y += value.y;
this.skew += value.skew;
this.rotation += value.rotation;
this.scaleX *= value.scaleX;
this.scaleY *= value.scaleY;
return this;
};
/**
* @private
*/
Transform.prototype.minus = function (value) {
this.x -= value.x;
this.y -= value.y;
this.skew -= value.skew;
this.rotation -= value.rotation;
this.scaleX /= value.scaleX;
this.scaleY /= value.scaleY;
return this;
};
/**
* @private
*/
Transform.prototype.fromMatrix = function (matrix) {
var backupScaleX = this.scaleX, backupScaleY = this.scaleY;
var PI_Q = Transform.PI_Q;
this.x = matrix.tx;
this.y = matrix.ty;
this.rotation = Math.atan(matrix.b / matrix.a);
var skewX = Math.atan(-matrix.c / matrix.d);
this.scaleX = (this.rotation > -PI_Q && this.rotation < PI_Q) ? matrix.a / Math.cos(this.rotation) : matrix.b / Math.sin(this.rotation);
this.scaleY = (skewX > -PI_Q && skewX < PI_Q) ? matrix.d / Math.cos(skewX) : -matrix.c / Math.sin(skewX);
if (backupScaleX >= 0.0 && this.scaleX < 0.0) {
this.scaleX = -this.scaleX;
this.rotation = this.rotation - Math.PI;
}
if (backupScaleY >= 0.0 && this.scaleY < 0.0) {
this.scaleY = -this.scaleY;
skewX = skewX - Math.PI;
}
this.skew = skewX - this.rotation;
return this;
};
/**
* @private
*/
Transform.prototype.toMatrix = function (matrix) {
if (this.rotation === 0.0) {
matrix.a = 1.0;
matrix.b = 0.0;
}
else {
matrix.a = Math.cos(this.rotation);
matrix.b = Math.sin(this.rotation);
}
if (this.skew === 0.0) {
matrix.c = -matrix.b;
matrix.d = matrix.a;
}
else {
matrix.c = -Math.sin(this.skew + this.rotation);
matrix.d = Math.cos(this.skew + this.rotation);
}
if (this.scaleX !== 1.0) {
matrix.a *= this.scaleX;
matrix.b *= this.scaleX;
}
if (this.scaleY !== 1.0) {
matrix.c *= this.scaleY;
matrix.d *= this.scaleY;
}
matrix.tx = this.x;
matrix.ty = this.y;
return this;
};
/**
* @private
*/
Transform.PI = Math.PI;
/**
* @private
*/
Transform.PI_D = Math.PI * 2.0;
/**
* @private
*/
Transform.PI_H = Math.PI / 2.0;
/**
* @private
*/
Transform.PI_Q = Math.PI / 4.0;
/**
* @private
*/
Transform.RAD_DEG = 180.0 / Math.PI;
/**
* @private
*/
Transform.DEG_RAD = Math.PI / 180.0;
return Transform;
}());
dragonBones.Transform = Transform;
})(dragonBones || (dragonBones = {}));
/**
* The MIT License (MIT)
*
* Copyright (c) 2012-2018 DragonBones team and other contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
var dragonBones;
(function (dragonBones) {
/**
* @private
*/
var ColorTransform = /** @class */ (function () {
function ColorTransform(alphaMultiplier, redMultiplier, greenMultiplier, blueMultiplier, alphaOffset, redOffset, greenOffset, blueOffset) {
if (alphaMultiplier === void 0) { alphaMultiplier = 1.0; }
if (redMultiplier === void 0) { redMultiplier = 1.0; }
if (greenMultiplier === void 0) { greenMultiplier = 1.0; }
if (blueMultiplier === void 0) { blueMultiplier = 1.0; }
if (alphaOffset === void 0) { alphaOffset = 0; }
if (redOffset === void 0) { redOffset = 0; }
if (greenOffset === void 0) { greenOffset = 0; }
if (blueOffset === void 0) { blueOffset = 0; }
this.alphaMultiplier = alphaMultiplier;
this.redMultiplier = redMultiplier;
this.greenMultiplier = greenMultiplier;
this.blueMultiplier = blueMultiplier;
this.alphaOffset = alphaOffset;
this.redOffset = redOffset;
this.greenOffset = greenOffset;
this.blueOffset = blueOffset;
}
ColorTransform.prototype.copyFrom = function (value) {
this.alphaMultiplier = value.alphaMultiplier;
this.redMultiplier = value.redMultiplier;
this.greenMultiplier = value.greenMultiplier;
this.blueMultiplier = value.blueMultiplier;
this.alphaOffset = value.alphaOffset;
this.redOffset = value.redOffset;
this.greenOffset = value.greenOffset;
this.blueOffset = value.blueOffset;
};
ColorTransform.prototype.identity = function () {
this.alphaMultiplier = this.redMultiplier = this.greenMultiplier = this.blueMultiplier = 1.0;
this.alphaOffset = this.redOffset = this.greenOffset = this.blueOffset = 0;
};
return ColorTransform;
}());
dragonBones.ColorTransform = ColorTransform;
})(dragonBones || (dragonBones = {}));
/**
* The MIT License (MIT)
*
* Copyright (c) 2012-2018 DragonBones team and other contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
var dragonBones;
(function (dragonBones) {
/**
* - The Point object represents a location in a two-dimensional coordinate system.
* @version DragonBones 3.0
* @language en_US
*/
/**
* - Point 对象表示二维坐标系统中的某个位置。
* @version DragonBones 3.0
* @language zh_CN
*/
var Point = /** @class */ (function () {
/**
* - Creates a new point. If you pass no parameters to this method, a point is created at (0,0).
* @param x - The horizontal coordinate.
* @param y - The vertical coordinate.
* @version DragonBones 3.0
* @language en_US
*/
/**
* - 创建一个 egret.Point 对象.若不传入任何参数,将会创建一个位于(0,0)位置的点。
* @param x - 该对象的x属性值,默认为 0.0。
* @param y - 该对象的y属性值,默认为 0.0。
* @version DragonBones 3.0
* @language zh_CN
*/
function Point(x, y) {
if (x === void 0) { x = 0.0; }
if (y === void 0) { y = 0.0; }
this.x = x;
this.y = y;
}
/**
* @private
*/
Point.prototype.copyFrom = function (value) {
this.x = value.x;
this.y = value.y;
};
/**
* @private
*/
Point.prototype.clear = function () {
this.x = this.y = 0.0;
};
return Point;
}());
dragonBones.Point = Point;
})(dragonBones || (dragonBones = {}));
/**
* The MIT License (MIT)
*
* Copyright (c) 2012-2018 DragonBones team and other contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
var dragonBones;
(function (dragonBones) {
/**
* - A Rectangle object is an area defined by its position, as indicated by its top-left corner point (x, y) and by its
* width and its height.<br/>
* The x, y, width, and height properties of the Rectangle class are independent of each other; changing the value of
* one property has no effect on the others. However, the right and bottom properties are integrally related to those
* four properties. For example, if you change the value of the right property, the value of the width property changes;
* if you change the bottom property, the value of the height property changes.
* @version DragonBones 3.0
* @language en_US
*/
/**
* - Rectangle 对象是按其位置(由它左上角的点 (x, y) 确定)以及宽度和高度定义的区域。<br/>
* Rectangle 类的 x、y、width 和 height 属性相互独立;更改一个属性的值不会影响其他属性。
* 但是,right 和 bottom 属性与这四个属性是整体相关的。例如,如果更改 right 属性的值,则 width
* 属性的值将发生变化;如果更改 bottom 属性,则 height 属性的值将发生变化。
* @version DragonBones 3.0
* @language zh_CN
*/
var Rectangle = /** @class */ (function () {
/**
* @private
*/
function Rectangle(x, y, width, height) {
if (x === void 0) { x = 0.0; }
if (y === void 0) { y = 0.0; }
if (width === void 0) { width = 0.0; }
if (height === void 0) { height = 0.0; }
this.x = x;
this.y = y;
this.width = width;
this.height = height;
}
/**
* @private
*/
Rectangle.prototype.copyFrom = function (value) {
this.x = value.x;
this.y = value.y;
this.width = value.width;
this.height = value.height;
};
/**
* @private
*/
Rectangle.prototype.clear = function () {
this.x = this.y = 0.0;
this.width = this.height = 0.0;
};
return Rectangle;
}());
dragonBones.Rectangle = Rectangle;
})(dragonBones || (dragonBones = {}));
/**
* The MIT License (MIT)
*
* Copyright (c) 2012-2018 DragonBones team and other contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
var dragonBones;
(function (dragonBones) {
/**
* - The user custom data.
* @version DragonBones 5.0
* @language en_US
*/
/**
* - 用户自定义数据。
* @version DragonBones 5.0
* @language zh_CN
*/
var UserData = /** @class */ (function (_super) {
__extends(UserData, _super);
function UserData() {
var _this = _super !== null && _super.apply(this, arguments) || this;
/**
* - The custom int numbers.
* @version DragonBones 5.0
* @language en_US
*/
/**
* - 自定义整数。
* @version DragonBones 5.0
* @language zh_CN
*/
_this.ints = [];
/**
* - The custom float numbers.
* @version DragonBones 5.0
* @language en_US
*/
/**
* - 自定义浮点数。
* @version DragonBones 5.0
* @language zh_CN
*/
_this.floats = [];
/**
* - The custom strings.
* @version DragonBones 5.0
* @language en_US
*/
/**
* - 自定义字符串。
* @version DragonBones 5.0
* @language zh_CN
*/
_this.strings = [];
return _this;
}
UserData.toString = function () {
return "[class dragonBones.UserData]";
};
UserData.prototype._onClear = function () {
this.ints.length = 0;
this.floats.length = 0;
this.strings.length = 0;
};
/**
* @internal
*/
UserData.prototype.addInt = function (value) {
this.ints.push(value);
};
/**
* @internal
*/
UserData.prototype.addFloat = function (value) {
this.floats.push(value);
};
/**
* @internal
*/
UserData.prototype.addString = function (value) {
this.strings.push(value);
};
/**
* - Get the custom int number.
* @version DragonBones 5.0
* @language en_US
*/
/**
* - 获取自定义整数。
* @version DragonBones 5.0
* @language zh_CN
*/
UserData.prototype.getInt = function (index) {
if (index === void 0) { index = 0; }
return index >= 0 && index < this.ints.length ? this.ints[index] : 0;
};
/**
* - Get the custom float number.
* @version DragonBones 5.0
* @language en_US
*/
/**
* - 获取自定义浮点数。
* @version DragonBones 5.0
* @language zh_CN
*/
UserData.prototype.getFloat = function (index) {
if (index === void 0) { index = 0; }
return index >= 0 && index < this.floats.length ? this.floats[index] : 0.0;
};
/**
* - Get the custom string.
* @version DragonBones 5.0
* @language en_US
*/
/**
* - 获取自定义字符串。
* @version DragonBones 5.0
* @language zh_CN
*/
UserData.prototype.getString = function (index) {
if (index === void 0) { index = 0; }
return index >= 0 && index < this.strings.length ? this.strings[index] : "";
};
return UserData;
}(dragonBones.BaseObject));
dragonBones.UserData = UserData;
/**
* @private
*/
var ActionData = /** @class */ (function (_super) {
__extends(ActionData, _super);
function ActionData() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.data = null; //
return _this;
}
ActionData.toString = function () {
return "[class dragonBones.ActionData]";
};
ActionData.prototype._onClear = function () {
if (this.data !== null) {
this.data.returnToPool();
}
this.type = 0 /* Play */;
this.name = "";
this.bone = null;
this.slot = null;
this.data = null;
};
return ActionData;
}(dragonBones.BaseObject));
dragonBones.ActionData = ActionData;
})(dragonBones || (dragonBones = {}));
/**
* The MIT License (MIT)
*
* Copyright (c) 2012-2018 DragonBones team and other contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
var dragonBones;
(function (dragonBones) {
/**
* - The DragonBones data.
* A DragonBones data contains multiple armature data.
* @see dragonBones.ArmatureData
* @version DragonBones 3.0
* @language en_US
*/
/**
* - 龙骨数据。
* 一个龙骨数据包含多个骨架数据。
* @see dragonBones.ArmatureData
* @version DragonBones 3.0
* @language zh_CN
*/
var DragonBonesData = /** @class */ (function (_super) {
__extends(DragonBonesData, _super);
function DragonBonesData() {
var _this = _super !== null && _super.apply(this, arguments) || this;
/**
* @internal
*/
_this.frameIndices = [];
/**
* @internal
*/
_this.cachedFrames = [];
/**
* - All armature data names.
* @version DragonBones 3.0
* @language en_US
*/
/**
* - 所有的骨架数据名称。
* @version DragonBones 3.0
* @language zh_CN
*/
_this.armatureNames = [];
/**
* @private
*/
_this.armatures = {};
/**
* @private
*/
_this.userData = null; // Initial value.
return _this;
}
DragonBonesData.toString = function () {
return "[class dragonBones.DragonBonesData]";
};
DragonBonesData.prototype._onClear = function () {
for (var k in this.armatures) {
this.armatures[k].returnToPool();
delete this.armatures[k];
}
if (this.userData !== null) {
this.userData.returnToPool();
}
this.autoSearch = false;
this.frameRate = 0;
this.version = "";
this.name = "";
this.stage = null;
this.frameIndices.length = 0;
this.cachedFrames.length = 0;
this.armatureNames.length = 0;
//this.armatures.clear();
this.binary = null; //
this.intArray = null; //
this.floatArray = null; //
this.frameIntArray = null; //
this.frameFloatArray = null; //
this.frameArray = null; //
this.timelineArray = null; //
this.colorArray = null; //
this.userData = null;
};
/**
* @internal
*/
DragonBonesData.prototype.addArmature = function (value) {
if (value.name in this.armatures) {
console.warn("Same armature: " + value.name);
return;
}
value.parent = this;
this.armatures[value.name] = value;
this.armatureNames.push(value.name);
};
/**
* - Get a specific armature data.
* @param armatureName - The armature data name.
* @version DragonBones 3.0
* @language en_US
*/
/**
* - 获取特定的骨架数据。
* @param armatureName - 骨架数据名称。
* @version DragonBones 3.0
* @language zh_CN
*/
DragonBonesData.prototype.getArmature = function (armatureName) {
return armatureName in this.armatures ? this.armatures[armatureName] : null;
};
return DragonBonesData;
}(dragonBones.BaseObject));
dragonBones.DragonBonesData = DragonBonesData;
})(dragonBones || (dragonBones = {}));
/**
* The MIT License (MIT)
*
* Copyright (c) 2012-2018 DragonBones team and other contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED,